a tool for shared writing and social publishing

fix type error and lint

+18 -8
+18 -8
actions/deleteLeaflet.ts
··· 23 23 // Check publication and document ownership in one query 24 24 let { data: tokenData } = await supabaseServerClient 25 25 .from("permission_tokens") 26 - .select(` 26 + .select( 27 + ` 27 28 id, 28 29 leaflets_in_publications(publication, publications!inner(identity_did)), 29 30 leaflets_to_documents(document, documents!inner(uri)) 30 - `) 31 + `, 32 + ) 31 33 .eq("id", permission_token.id) 32 34 .single(); 33 35 ··· 36 38 const leafletInPubs = tokenData.leaflets_in_publications || []; 37 39 if (leafletInPubs.length > 0) { 38 40 if (!identity) { 39 - throw new Error("Unauthorized: You must be logged in to delete a leaflet in a publication"); 41 + throw new Error( 42 + "Unauthorized: You must be logged in to delete a leaflet in a publication", 43 + ); 40 44 } 41 45 const isOwner = leafletInPubs.some( 42 - (pub: any) => pub.publications.identity_did === identity.atp_did 46 + (pub: any) => pub.publications.identity_did === identity.atp_did, 43 47 ); 44 48 if (!isOwner) { 45 - throw new Error("Unauthorized: You must own the publication to delete this leaflet"); 49 + throw new Error( 50 + "Unauthorized: You must own the publication to delete this leaflet", 51 + ); 46 52 } 47 53 } 48 54 ··· 50 56 const leafletDocs = tokenData.leaflets_to_documents || []; 51 57 if (leafletDocs.length > 0) { 52 58 if (!identity) { 53 - throw new Error("Unauthorized: You must be logged in to delete a published leaflet"); 59 + throw new Error( 60 + "Unauthorized: You must be logged in to delete a published leaflet", 61 + ); 54 62 } 55 63 for (let leafletDoc of leafletDocs) { 56 64 const docUri = leafletDoc.documents?.uri; 57 65 // Extract the DID from the document URI (format: at://did:plc:xxx/...) 58 - if (docUri && !docUri.includes(identity.atp_did)) { 59 - throw new Error("Unauthorized: You must own the published document to delete this leaflet"); 66 + if (docUri && identity.atp_did && !docUri.includes(identity.atp_did)) { 67 + throw new Error( 68 + "Unauthorized: You must own the published document to delete this leaflet", 69 + ); 60 70 } 61 71 } 62 72 }