tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
make publication optional on documents
awarm.space
4 months ago
def3f555
a9757f65
+24
-22
5 changed files
expand all
collapse all
unified
split
appview
index.ts
lexicons
api
lexicons.ts
types
pub
leaflet
document.ts
pub
leaflet
document.json
src
document.ts
+20
-17
appview/index.ts
···
104
104
data: record.value as Json,
105
105
});
106
106
if (docResult.error) console.log(docResult.error);
107
107
-
let publicationURI = new AtUri(record.value.publication);
107
107
+
if (record.value.publication) {
108
108
+
let publicationURI = new AtUri(record.value.publication);
109
109
+
110
110
+
if (publicationURI.host !== evt.uri.host) {
111
111
+
console.log("Unauthorized to create post!");
112
112
+
return;
113
113
+
}
114
114
+
let docInPublicationResult = await supabase
115
115
+
.from("documents_in_publications")
116
116
+
.upsert({
117
117
+
publication: record.value.publication,
118
118
+
document: evt.uri.toString(),
119
119
+
});
120
120
+
await supabase
121
121
+
.from("documents_in_publications")
122
122
+
.delete()
123
123
+
.neq("publication", record.value.publication)
124
124
+
.eq("document", evt.uri.toString());
108
125
109
109
-
if (publicationURI.host !== evt.uri.host) {
110
110
-
console.log("Unauthorized to create post!");
111
111
-
return;
126
126
+
if (docInPublicationResult.error)
127
127
+
console.log(docInPublicationResult.error);
112
128
}
113
113
-
let docInPublicationResult = await supabase
114
114
-
.from("documents_in_publications")
115
115
-
.upsert({
116
116
-
publication: record.value.publication,
117
117
-
document: evt.uri.toString(),
118
118
-
});
119
119
-
await supabase
120
120
-
.from("documents_in_publications")
121
121
-
.delete()
122
122
-
.neq("publication", record.value.publication)
123
123
-
.eq("document", evt.uri.toString());
124
124
-
if (docInPublicationResult.error)
125
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
1411
-
required: ['pages', 'author', 'title', 'publication'],
1411
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
22
-
publication: string
22
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
16
-
"title",
17
17
-
"publication"
16
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
17
-
required: ["pages", "author", "title", "publication"],
17
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" },