mirror of
https://github.com/directus/directus.git
synced 2026-04-25 03:00:53 -04:00
Added "null/admin" accountability and emitEvents opts (#10268)
This commit is contained in:
@@ -26,7 +26,8 @@ export class FilesService extends ItemsService {
|
||||
async uploadOne(
|
||||
stream: NodeJS.ReadableStream,
|
||||
data: Partial<File> & { filename_download: string; storage: string },
|
||||
primaryKey?: PrimaryKey
|
||||
primaryKey?: PrimaryKey,
|
||||
opts?: MutationOptions
|
||||
): Promise<PrimaryKey> {
|
||||
const payload = clone(data);
|
||||
|
||||
@@ -124,19 +125,21 @@ export class FilesService extends ItemsService {
|
||||
await this.cache.clear();
|
||||
}
|
||||
|
||||
emitter.emitAction(
|
||||
'files.upload',
|
||||
{
|
||||
payload,
|
||||
key: primaryKey,
|
||||
collection: this.collection,
|
||||
},
|
||||
{
|
||||
database: this.knex,
|
||||
schema: this.schema,
|
||||
accountability: this.accountability,
|
||||
}
|
||||
);
|
||||
if (opts?.emitEvents !== false) {
|
||||
emitter.emitAction(
|
||||
'files.upload',
|
||||
{
|
||||
payload,
|
||||
key: primaryKey,
|
||||
collection: this.collection,
|
||||
},
|
||||
{
|
||||
database: this.knex,
|
||||
schema: this.schema,
|
||||
accountability: this.accountability,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return primaryKey;
|
||||
}
|
||||
@@ -149,7 +152,7 @@ export class FilesService extends ItemsService {
|
||||
(permission) => permission.collection === 'directus_files' && permission.action === 'create'
|
||||
);
|
||||
|
||||
if (this.accountability?.admin !== true && !fileCreatePermissions) {
|
||||
if (this.accountability && this.accountability?.admin !== true && !fileCreatePermissions) {
|
||||
throw new ForbiddenException();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user