@lucidcms/core
Version:
The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.
2 lines • 1.41 kB
JavaScript
import{copy as e}from"../../libs/i18n/copy.mjs";import t from"../../utils/helpers/get-base-url.mjs";import n from"../../libs/repositories/media-share-links.mjs";import r from"../../utils/media/create-share-stream-url.mjs";import i from"../../libs/formatters/media-share-links.mjs";import a from"../../libs/formatters/index.mjs";import{isPast as o}from"date-fns";const s=async(s,c)=>{let l=await new n(s.db.client,s.config.db).selectSingleWithMediaByToken({token:c.token});if(l.error)return{error:{type:`basic`,name:e(`server:core.share.links.not.found.title`),status:404,message:e(`server:core.share.links.not.found.message`)},data:void 0};if(l.data.expires_at&&o(l.data.expires_at))return{error:{type:`basic`,name:e(`server:core.share.links.expired.title`),status:410,message:e(`server:core.share.links.expired.message`)},data:void 0};if(a.formatBoolean(l.data.media_is_deleted))return{error:{type:`basic`,name:e(`server:core.share.links.media.deleted.title`),status:410,message:e(`server:core.share.links.media.deleted.message`)},data:void 0};let u=!!l.data.password&&!c.sessionCookie,d=t(s),f=r({token:l.data.token,host:d}),p=l.data.media_poster_key&&l.data.media_poster_type===`image`?r({token:l.data.token,host:d,poster:!0}):void 0;return{error:void 0,data:i.formatShareAccess({link:l.data,shareUrl:f,posterShareUrl:p,passwordRequired:u})}};export{s as default};
//# sourceMappingURL=get-share-access.mjs.map