tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
291
fork
atom
a tool for shared writing and social publishing
291
fork
atom
overview
issues
27
pulls
pipelines
exit early w/o parsing bsky record in appview
awarm.space
7 months ago
311a7b9d
b983842c
+16
-3
1 changed file
expand all
collapse all
unified
split
appview
index.ts
+16
-3
appview/index.ts
···
169
169
}
170
170
if (evt.collection === "app.bsky.feed.post") {
171
171
if (evt.event !== "create") return;
172
172
+
173
173
+
// Early exit if no embed
174
174
+
if (
175
175
+
!evt.record ||
176
176
+
typeof evt.record !== "object" ||
177
177
+
!("embed" in evt.record)
178
178
+
)
179
179
+
return;
180
180
+
181
181
+
// Quick check if embed might contain our quote param
182
182
+
const embedStr = JSON.stringify(evt.record.embed);
183
183
+
if (!embedStr.includes(QUOTE_PARAM)) return;
184
184
+
185
185
+
// Now validate the record since we know it might be relevant
172
186
let record = AppBskyFeedPost.validateRecord(evt.record);
173
187
if (!record.success) return;
174
188
···
177
191
record.value.embed.external.uri.includes(QUOTE_PARAM)
178
192
? record.value.embed.external.uri
179
193
: null;
180
180
-
let pubUrl = embed;
181
181
-
if (pubUrl) {
194
194
+
if (embed) {
182
195
inngest.send({
183
196
name: "appview/index-bsky-post-mention",
184
184
-
data: { post_uri: evt.uri.toString(), document_link: pubUrl },
197
197
+
data: { post_uri: evt.uri.toString(), document_link: embed },
185
198
});
186
199
}
187
200
}