a tool for shared writing and social publishing

exit early w/o parsing bsky record in appview

+16 -3
+16 -3
appview/index.ts
··· 169 169 } 170 170 if (evt.collection === "app.bsky.feed.post") { 171 171 if (evt.event !== "create") return; 172 + 173 + // Early exit if no embed 174 + if ( 175 + !evt.record || 176 + typeof evt.record !== "object" || 177 + !("embed" in evt.record) 178 + ) 179 + return; 180 + 181 + // Quick check if embed might contain our quote param 182 + const embedStr = JSON.stringify(evt.record.embed); 183 + if (!embedStr.includes(QUOTE_PARAM)) return; 184 + 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 - let pubUrl = embed; 181 - if (pubUrl) { 194 + if (embed) { 182 195 inngest.send({ 183 196 name: "appview/index-bsky-post-mention", 184 - data: { post_uri: evt.uri.toString(), document_link: pubUrl }, 197 + data: { post_uri: evt.uri.toString(), document_link: embed }, 185 198 }); 186 199 } 187 200 }