grain.social is a photo sharing platform built on atproto.
at main 1.1 kB view raw
1import { BffContext, RouteHandler } from "@bigmoves/bff"; 2import { GalleryPage } from "../components/GalleryPage.tsx"; 3import { getGallery } from "../lib/gallery.ts"; 4import { moderateGallery, ModerationDecsion } from "../lib/moderation.ts"; 5import { getGalleryMeta, getPageMeta } from "../meta.ts"; 6import type { State } from "../state.ts"; 7import { galleryLink } from "../utils.ts"; 8 9export const handler: RouteHandler = async ( 10 _req, 11 params, 12 ctx: BffContext<State>, 13) => { 14 const did = ctx.currentUser?.did; 15 const handle = params.handle; 16 const rkey = params.rkey; 17 const gallery = getGallery(handle, rkey, ctx); 18 19 if (!gallery) return ctx.next(); 20 21 ctx.state.meta = [ 22 { title: `${gallery.title} — Grain` }, 23 ...getPageMeta(galleryLink(handle, rkey)), 24 ...getGalleryMeta(gallery), 25 ]; 26 27 let modDecision: ModerationDecsion | undefined = undefined; 28 if (gallery.labels?.length) { 29 modDecision = await moderateGallery(gallery.labels ?? [], ctx); 30 } 31 32 return ctx.render( 33 <GalleryPage 34 gallery={gallery} 35 currentUserDid={did} 36 modDecision={modDecision} 37 />, 38 ); 39};