A tool for parsing traffic on the jetstream and applying a moderation workstream based on regexp based rules

feat: Handle embeds in posts

Changed files
+28 -10
src
+28 -10
src/main.ts
··· 88 88 "app.bsky.feed.post", 89 89 (event: CommitCreateEvent<"app.bsky.feed.post">) => { 90 90 const atURI = `at://${event.did}/app.bsky.feed.post/${event.commit.rkey}`; 91 + const hasEmbed = event.commit.record.hasOwnProperty("embed"); 91 92 const hasFacets = event.commit.record.hasOwnProperty("facets"); 92 93 const hasText = event.commit.record.hasOwnProperty("text"); 93 94 ··· 124 125 tasks.push(checkPosts(posts)); 125 126 }); 126 127 } 127 - } else if (hasText) { 128 + } 129 + 130 + if (hasText) { 128 131 const posts: Post[] = [ 129 132 { 130 133 did: event.did, ··· 137 140 ]; 138 141 tasks.push(checkPosts(posts)); 139 142 } 143 + 144 + if (hasEmbed) { 145 + const embed = event.commit.record.embed; 146 + if (embed && embed.$type === "app.bsky.embed.external") { 147 + const posts: Post[] = [ 148 + { 149 + did: event.did, 150 + time: event.time_us, 151 + rkey: event.commit.rkey, 152 + atURI: atURI, 153 + text: embed.external.uri, 154 + cid: event.commit.cid, 155 + }, 156 + ]; 157 + tasks.push(checkPosts(posts)); 158 + } 159 + } 140 160 }, 141 161 ); 142 162 ··· 192 212 event.commit.record.displayName as string, 193 213 event.commit.record.description as string, 194 214 ); 215 + } 195 216 196 - if (event.commit.record.joinedViaStarterPack) { 197 - checkStarterPack( 198 - event.did, 199 - event.time_us, 200 - event.commit.record.joinedViaStarterPack.uri, 201 - ); 202 - } 203 - } else { 204 - return; 217 + if (event.commit.record.joinedViaStarterPack) { 218 + checkStarterPack( 219 + event.did, 220 + event.time_us, 221 + event.commit.record.joinedViaStarterPack.uri, 222 + ); 205 223 } 206 224 } catch (error) { 207 225 logger.error(`Error checking profile: ${error}`);