mirror of
https://github.com/directus/directus.git
synced 2026-04-03 03:00:39 -04:00
Updates 5 of many
This commit is contained in:
@@ -18,6 +18,7 @@ import type {
|
||||
HookConfig,
|
||||
HybridExtension,
|
||||
InitHandler,
|
||||
NestedExtensionType,
|
||||
OperationApiConfig,
|
||||
ScheduleHandler,
|
||||
} from '@directus/shared/types';
|
||||
@@ -182,24 +183,30 @@ class ExtensionManager {
|
||||
}
|
||||
|
||||
function mapInfo(extension: Extension): ExtensionInfo {
|
||||
const extensionInfo = {
|
||||
const extensionInfo: ExtensionInfo = {
|
||||
name: extension.name,
|
||||
type: extension.type,
|
||||
local: extension.local,
|
||||
host: extension.host,
|
||||
version: extension.version,
|
||||
entries: [],
|
||||
};
|
||||
|
||||
if (extension.host) extensionInfo.host = extension.host;
|
||||
if (extension.version) extensionInfo.version = extension.version;
|
||||
|
||||
if (extension.type === 'bundle') {
|
||||
return {
|
||||
...extensionInfo,
|
||||
const bundleExtensionInfo: Omit<BundleExtension, 'entrypoint' | 'path'> = {
|
||||
name: extensionInfo.name,
|
||||
type: 'bundle',
|
||||
local: extensionInfo.local,
|
||||
entries: extension.entries.map((entry) => ({
|
||||
name: entry.name,
|
||||
type: entry.type,
|
||||
})),
|
||||
})) as { name: ExtensionInfo['name']; type: NestedExtensionType }[],
|
||||
};
|
||||
|
||||
return bundleExtensionInfo;
|
||||
} else {
|
||||
return extensionInfo as ExtensionInfo;
|
||||
return extensionInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,14 @@ export const handler = async (req: Request, res: Response, next: NextFunction) =
|
||||
admin: false,
|
||||
app: false,
|
||||
ip: getIPFromReq(req),
|
||||
userAgent: req.get('user-agent'),
|
||||
origin: req.get('origin'),
|
||||
};
|
||||
|
||||
const userAgent = req.get('user-agent');
|
||||
if (userAgent) defaultAccountability.userAgent = userAgent;
|
||||
|
||||
const origin = req.get('origin');
|
||||
if (origin) defaultAccountability.origin = origin;
|
||||
|
||||
const database = getDatabase();
|
||||
|
||||
const customAccountability = await emitter.emitFilter(
|
||||
@@ -50,12 +54,13 @@ export const handler = async (req: Request, res: Response, next: NextFunction) =
|
||||
if (isDirectusJWT(req.token)) {
|
||||
const payload = verifyAccessJWT(req.token, env.SECRET);
|
||||
|
||||
req.accountability.share = payload.share;
|
||||
req.accountability.share_scope = payload.share_scope;
|
||||
req.accountability.user = payload.id;
|
||||
req.accountability.role = payload.role;
|
||||
req.accountability.admin = payload.admin_access === true || payload.admin_access == 1;
|
||||
req.accountability.app = payload.app_access === true || payload.app_access == 1;
|
||||
|
||||
if (payload.share) req.accountability.share = payload.share;
|
||||
if (payload.share_scope) req.accountability.share_scope = payload.share_scope;
|
||||
if (payload.id) req.accountability.user = payload.id;
|
||||
} else {
|
||||
// Try finding the user with the provided token
|
||||
const user = await database
|
||||
|
||||
@@ -48,7 +48,7 @@ export const respond: RequestHandler = asyncHandler(async (req, res) => {
|
||||
}
|
||||
|
||||
if (req.sanitizedQuery.export) {
|
||||
const exportService = new ExportService({ accountability: req.accountability, schema: req.schema });
|
||||
const exportService = new ExportService({ accountability: req.accountability ?? null, schema: req.schema });
|
||||
|
||||
let filename = '';
|
||||
|
||||
|
||||
@@ -23,8 +23,7 @@ afterEach(() => {
|
||||
|
||||
test('no headers configured', async () => {
|
||||
const body = 'body';
|
||||
const headers = undefined;
|
||||
await config.handler({ url, method, body, headers }, {} as any);
|
||||
await config.handler({ url, method, body }, {} as any);
|
||||
|
||||
expect(axiosDefault).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
|
||||
@@ -97,12 +97,12 @@ export class FilesService extends ItemsService {
|
||||
const stream = await storage.location(data.storage).read(payload.filename_disk);
|
||||
const { height, width, description, title, tags, metadata } = await this.getMetadata(stream);
|
||||
|
||||
payload.height ??= height;
|
||||
payload.width ??= width;
|
||||
payload.description ??= description;
|
||||
payload.title ??= title;
|
||||
payload.tags ??= tags;
|
||||
payload.metadata ??= metadata;
|
||||
payload.height = height ?? null;
|
||||
payload.width = width ?? null;
|
||||
payload.description = description ?? null;
|
||||
payload.title = title ?? null;
|
||||
payload.tags = tags ?? null;
|
||||
payload.metadata = metadata ?? null;
|
||||
}
|
||||
|
||||
// We do this in a service without accountability. Even if you don't have update permissions to the file,
|
||||
|
||||
Reference in New Issue
Block a user