a tool for shared writing and social publishing
at update/reader 26 lines 860 B view raw
1"use server"; 2import { getIdentityData } from "actions/getIdentityData"; 3import { createNewLeaflet } from "./createNewLeaflet"; 4import { supabaseServerClient } from "supabase/serverClient"; 5 6export async function createPublicationDraft(publication_uri: string) { 7 let identity = await getIdentityData(); 8 if (!identity || !identity.atp_did) return null; 9 let newLeaflet = await createNewLeaflet({ 10 pageType: "doc", 11 redirectUser: false, 12 firstBlockType: "text", 13 }); 14 let { data: publication } = await supabaseServerClient 15 .from("publications") 16 .select("*") 17 .eq("uri", publication_uri) 18 .single(); 19 if (publication?.identity_did !== identity.atp_did) return; 20 21 await supabaseServerClient 22 .from("leaflets_in_publications") 23 .insert({ publication: publication_uri, leaflet: newLeaflet, doc: null }); 24 25 return newLeaflet; 26}