[READ ONLY MIRROR] Spark Social AppView Server github.com/sprksocial/server
atproto deno hono lexicon
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

bump

+33 -22
+33 -22
services/appview/src/middleware/takedown-filter.ts
··· 15 15 return 16 16 } 17 17 18 - // Call the next middleware/route handler first 19 18 await next() 20 19 21 - // Skip filtering if not a JSON response 22 20 const contentType = c.res.headers.get('Content-Type') 23 21 if (!contentType || !contentType.includes('application/json')) { 24 22 return ··· 30 28 31 29 const body = await c.res.json() 32 30 33 - const targetDid = body.did || body.user?.did || body.actor?.did || body.profile?.did || body.subject?.did 31 + const targetDid = 32 + body.did || 33 + body.user?.did || 34 + body.actor?.did || 35 + body.profile?.did || 36 + body.subject?.did 34 37 if (targetDid) { 35 38 const isRepoTakenDown = await takedownService.isRepoTakenDown(targetDid) 36 39 if (isRepoTakenDown) { ··· 51 54 return 52 55 } else { 53 56 // For other single-user responses, null out or minimize the content 54 - c.res = new Response(JSON.stringify({ 55 - error: 'Content unavailable - repository has been taken down', 56 - code: 404 57 - }), { 58 - status: 404, 59 - headers: c.res.headers, 60 - }) 57 + c.res = new Response( 58 + JSON.stringify({ 59 + error: 'Content unavailable - repository has been taken down', 60 + code: 404, 61 + }), 62 + { 63 + status: 404, 64 + headers: c.res.headers, 65 + }, 66 + ) 61 67 return 62 68 } 63 69 } ··· 82 88 const isThreadTakenDown = await takedownService.isTakenDown( 83 89 body.thread.post.uri, 84 90 ) 85 - 91 + 86 92 // Also check if the thread author repo is taken down 87 93 let isAuthorTakenDown = false 88 94 if (body.thread.post.author?.did) { 89 95 isAuthorTakenDown = await takedownService.isRepoTakenDown( 90 - body.thread.post.author.did 96 + body.thread.post.author.did, 91 97 ) 92 98 } 93 - 99 + 94 100 if (isThreadTakenDown || isAuthorTakenDown) { 95 101 body.thread = null 96 102 } else if (body.thread.replies) { ··· 207 213 // Check if author's repo is taken down 208 214 let isAuthorTakenDown = false 209 215 // Look for author DID in common locations 210 - const authorDid = get(item, 'author.did') || 211 - get(item, 'post.author.did') || 212 - get(item, 'user.did') || 213 - get(item, 'actor.did') 214 - 216 + const authorDid = 217 + get(item, 'author.did') || 218 + get(item, 'post.author.did') || 219 + get(item, 'user.did') || 220 + get(item, 'actor.did') 221 + 215 222 if (authorDid) { 216 223 isAuthorTakenDown = await takedownService.isRepoTakenDown(authorDid) 217 224 } ··· 220 227 if (!isTakenDown && !isAuthorTakenDown) { 221 228 // Also check for any embedded items like quotes or replies 222 229 if (item.embed && item.embed.record && item.embed.record.author?.did) { 223 - const embedAuthorTakenDown = await takedownService.isRepoTakenDown(item.embed.record.author.did) 230 + const embedAuthorTakenDown = await takedownService.isRepoTakenDown( 231 + item.embed.record.author.did, 232 + ) 224 233 if (embedAuthorTakenDown) { 225 234 // Null out the embed if from a taken-down repo 226 235 item.embed = { 227 236 $type: item.embed.$type, 228 - takenDown: true 237 + takenDown: true, 229 238 } 230 239 } else if (item.embed.record.uri) { 231 240 // Check if the specific embedded content is taken down 232 - const embedContentTakenDown = await takedownService.isTakenDown(item.embed.record.uri) 241 + const embedContentTakenDown = await takedownService.isTakenDown( 242 + item.embed.record.uri, 243 + ) 233 244 if (embedContentTakenDown) { 234 245 item.embed = { 235 246 $type: item.embed.$type, 236 - takenDown: true 247 + takenDown: true, 237 248 } 238 249 } 239 250 }