a tool for shared writing and social publishing

make publication optional on documents

+24 -22
+20 -17
appview/index.ts
··· 104 104 data: record.value as Json, 105 105 }); 106 106 if (docResult.error) console.log(docResult.error); 107 - let publicationURI = new AtUri(record.value.publication); 107 + if (record.value.publication) { 108 + let publicationURI = new AtUri(record.value.publication); 109 + 110 + if (publicationURI.host !== evt.uri.host) { 111 + console.log("Unauthorized to create post!"); 112 + return; 113 + } 114 + let docInPublicationResult = await supabase 115 + .from("documents_in_publications") 116 + .upsert({ 117 + publication: record.value.publication, 118 + document: evt.uri.toString(), 119 + }); 120 + await supabase 121 + .from("documents_in_publications") 122 + .delete() 123 + .neq("publication", record.value.publication) 124 + .eq("document", evt.uri.toString()); 108 125 109 - if (publicationURI.host !== evt.uri.host) { 110 - console.log("Unauthorized to create post!"); 111 - return; 126 + if (docInPublicationResult.error) 127 + console.log(docInPublicationResult.error); 112 128 } 113 - let docInPublicationResult = await supabase 114 - .from("documents_in_publications") 115 - .upsert({ 116 - publication: record.value.publication, 117 - document: evt.uri.toString(), 118 - }); 119 - await supabase 120 - .from("documents_in_publications") 121 - .delete() 122 - .neq("publication", record.value.publication) 123 - .eq("document", evt.uri.toString()); 124 - if (docInPublicationResult.error) 125 - console.log(docInPublicationResult.error); 126 129 } 127 130 if (evt.event === "delete") { 128 131 await supabase.from("documents").delete().eq("uri", evt.uri.toString());
+1 -1
lexicons/api/lexicons.ts
··· 1408 1408 description: 'Record containing a document', 1409 1409 record: { 1410 1410 type: 'object', 1411 - required: ['pages', 'author', 'title', 'publication'], 1411 + required: ['pages', 'author', 'title'], 1412 1412 properties: { 1413 1413 title: { 1414 1414 type: 'string',
+1 -1
lexicons/api/types/pub/leaflet/document.ts
··· 19 19 postRef?: ComAtprotoRepoStrongRef.Main 20 20 description?: string 21 21 publishedAt?: string 22 - publication: string 22 + publication?: string 23 23 author: string 24 24 pages: ( 25 25 | $Typed<PubLeafletPagesLinearDocument.Main>
+1 -2
lexicons/pub/leaflet/document.json
··· 13 13 "required": [ 14 14 "pages", 15 15 "author", 16 - "title", 17 - "publication" 16 + "title" 18 17 ], 19 18 "properties": { 20 19 "title": {
+1 -1
lexicons/src/document.ts
··· 14 14 description: "Record containing a document", 15 15 record: { 16 16 type: "object", 17 - required: ["pages", "author", "title", "publication"], 17 + required: ["pages", "author", "title"], 18 18 properties: { 19 19 title: { type: "string", maxLength: 1280, maxGraphemes: 128 }, 20 20 postRef: { type: "ref", ref: "com.atproto.repo.strongRef" },