UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

1 lines 1.21 kB
{"version":3,"file":"assert-media-access.mjs","names":[],"sources":["../../../../src/services/media-share-links/helpers/assert-media-access.ts"],"sourcesContent":["import { MediaRepository } from \"../../../libs/repositories/index.js\";\nimport type { ServiceFn } from \"../../../utils/services/types.js\";\n\n/**\n * Ensures share-link operations only run for media visible in the current tenant scope.\n */\nconst assertMediaAccess: ServiceFn<\n\t[\n\t\t{\n\t\t\tmediaId: number;\n\t\t},\n\t],\n\tundefined\n> = async (context, props) => {\n\tconst Media = new MediaRepository(context.db.client, context.config.db);\n\n\tconst mediaRes = await Media.selectSingleById({\n\t\tid: props.mediaId,\n\t\ttenantKey: context.request.tenantKey,\n\t\tvalidation: {\n\t\t\tenabled: true,\n\t\t},\n\t});\n\tif (mediaRes.error) return mediaRes;\n\n\treturn {\n\t\terror: undefined,\n\t\tdata: undefined,\n\t};\n};\n\nexport default assertMediaAccess;\n"],"mappings":"oDAMA,MAAM,EAOF,MAAO,EAAS,IAAU,CAG7B,IAAM,EAAW,MAAM,IAFL,EAAgB,EAAQ,GAAG,OAAQ,EAAQ,OAAO,EAEzC,CAAC,CAAC,iBAAiB,CAC7C,GAAI,EAAM,QACV,UAAW,EAAQ,QAAQ,UAC3B,WAAY,CACX,QAAS,EACV,CACD,CAAC,EAGD,OAFI,EAAS,MAAc,EAEpB,CACN,MAAO,IAAA,GACP,KAAM,IAAA,EACP,CACD"}