a tool for shared writing and social publishing
at main 33 lines 941 B view raw
1"use server"; 2 3import { getIdentityData } from "actions/getIdentityData"; 4import { supabaseServerClient } from "supabase/serverClient"; 5 6export async function moveLeafletToPublication( 7 leaflet_id: string, 8 publication_uri: string, 9 metadata: { title: string; description: string }, 10 entitiesToDelete: string[], 11) { 12 let identity = await getIdentityData(); 13 if (!identity || !identity.atp_did) return null; 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.from("leaflets_in_publications").insert({ 22 publication: publication_uri, 23 leaflet: leaflet_id, 24 doc: null, 25 title: metadata.title, 26 description: metadata.description, 27 }); 28 29 await supabaseServerClient 30 .from("entities") 31 .delete() 32 .in("id", entitiesToDelete); 33}