unoffical wafrn mirror wafrn.net
atproto social-network activitypub
1
fork

Configure Feed

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

Added bsky uri and cid to posts federated?

+59 -38
+57 -37
packages/backend/utils/activitypub/getPostThreadRecursive.ts
··· 35 35 import { bulkCreateNotifications } from "../pushNotifications.js"; 36 36 import { getDeletedUser } from "../cacheGetters/getDeletedUser.js"; 37 37 import { Privacy } from "../../models/post.js"; 38 - import { getAtProtoThread, getPostThreadSafe, processSinglePost } from "../../atproto/utils/getAtProtoThread.js"; 38 + import { 39 + getAtProtoThread, 40 + getPostThreadSafe, 41 + processSinglePost, 42 + } from "../../atproto/utils/getAtProtoThread.js"; 39 43 import * as cheerio from "cheerio"; 40 - import { PostView, ThreadViewPost } from "@atproto/api/dist/client/types/app/bsky/feed/defs.js"; 44 + import { 45 + PostView, 46 + ThreadViewPost, 47 + } from "@atproto/api/dist/client/types/app/bsky/feed/defs.js"; 41 48 42 49 const updateMediaDataQueue = new Queue("processRemoteMediaData", { 43 50 connection: completeEnvironment.bullmqConnection, ··· 193 200 194 201 const privacy = getApObjectPrivacy(postPetition, remoteUser); 195 202 196 - let postTextContent = `${postPetition.content ? postPetition.content : "" 197 - }`; // Fix for bridgy giving this as undefined 203 + let postTextContent = `${ 204 + postPetition.content ? postPetition.content : "" 205 + }`; // Fix for bridgy giving this as undefined 198 206 if (postPetition.type == "Video") { 199 207 // peertube federation. We just add a link to the video, federating this is HELL 200 208 postTextContent = ··· 225 233 userId: 226 234 remoteUserServerBaned || remoteUser.banned 227 235 ? ( 228 - await deletedUser 229 - )?.id 236 + await deletedUser 237 + )?.id 230 238 : remoteUser.id, 231 239 description: remoteFile.name, 232 240 ipUpload: "IMAGE_FROM_OTHER_FEDIVERSE_INSTANCE", ··· 263 271 createdAt = new Date(); 264 272 } 265 273 266 - let bskyUri: string | undefined, bskyCid: string | undefined 267 - let existingBskyPost: Post | undefined 274 + let bskyUri: string | undefined, bskyCid: string | undefined; 275 + let existingBskyPost: Post | undefined; 268 276 // check if it's a bridgy post or a post from a wafrn by checking a valid FEP-fffd 269 277 if (postPetition.url && Array.isArray(postPetition.url)) { 270 - const url = postPetition.url as Array<string | { type: string, href: string }> 271 - const firstFffd = url.find(x => typeof x !== 'string') 278 + const url = postPetition.url as Array< 279 + string | { type: string; href: string } 280 + >; 281 + const firstFffd = url.find((x) => typeof x !== "string"); 272 282 // check if it starts at at:// then its a bridged post, we do not touch it if it's not 273 - if (firstFffd && firstFffd.href.startsWith('at://')) { 283 + if (firstFffd && firstFffd.href.startsWith("at://")) { 274 284 // get it's bsky counterparts first, we need the cid 275 285 const thread = await getPostThreadSafe({ 276 - uri: firstFffd.href 277 - }) 286 + uri: firstFffd.href, 287 + }); 278 288 if (thread && thread.success) { 279 289 try { 280 - const threadView = (thread.data.thread as ThreadViewPost) 281 - bskyCid = threadView.post.cid 282 - bskyUri = threadView.post.uri 290 + const threadView = thread.data.thread as ThreadViewPost; 291 + bskyCid = threadView.post.cid; 292 + bskyUri = threadView.post.uri; 283 293 // check if it cames from wafrn 284 - if (!(threadView.post.record as { fediverseId: string | undefined }).fediverseId) { 294 + if ( 295 + !( 296 + threadView.post.record as { 297 + fediverseId: string | undefined; 298 + } 299 + ).fediverseId 300 + ) { 285 301 // this is a bridgy fed post, assume main post is on bsky, use bsky user 286 - const postId = await processSinglePost(threadView.post) 302 + const postId = await processSinglePost(threadView.post); 287 303 if (postId) { 288 - const post = await Post.findByPk(postId) 304 + const post = await Post.findByPk(postId); 289 305 if (post) { 290 - post.remotePostId = postPetition.id 291 - await post.save() 292 - return post 306 + post.remotePostId = postPetition.id; 307 + await post.save(); 308 + return post; 293 309 } 294 310 } 295 311 } else { ··· 302 318 }, 303 319 }); 304 320 if (existingPost) { 305 - existingBskyPost = existingPost 321 + existingBskyPost = existingPost; 306 322 // do not attempt to merge it right now, this will crash backend 307 - bskyCid = undefined 308 - bskyUri = undefined 323 + bskyCid = undefined; 324 + bskyUri = undefined; 309 325 } 310 326 } 311 - } catch { } 327 + } catch {} 312 328 } 313 329 } 314 330 } ··· 318 334 content_warning: postPetition.summary 319 335 ? postPetition.summary 320 336 : remoteUser.NSFW 321 - ? "User is marked as NSFW by this instance staff. Possible NSFW without tagging" 322 - : "", 337 + ? "User is marked as NSFW by this instance staff. Possible NSFW without tagging" 338 + : "", 323 339 createdAt: createdAt, 324 340 updatedAt: createdAt, 325 341 userId: ··· 328 344 : remoteUser.id, 329 345 remotePostId: postPetition.id, 330 346 privacy: privacy, 331 - ...(bskyCid && bskyUri ? { 332 - bskyCid, 333 - bskyUri 334 - } : {}) 347 + bskyUri: postPetition.blueskyUri, 348 + bskyCid: postPetition.blueskyCid, 349 + ...(bskyCid && bskyUri 350 + ? { 351 + bskyCid, 352 + bskyUri, 353 + } 354 + : {}), 335 355 }; 336 356 337 357 if (postPetition.name) { ··· 543 563 }, 544 564 } 545 565 ); 546 - } catch { } 566 + } catch {} 547 567 await QuestionPoll.update( 548 568 { 549 569 postId: newPost.id, ··· 654 674 ); 655 675 656 676 // now we delete the existing bsky post 657 - await existingBskyPost.destroy() 677 + await existingBskyPost.destroy(); 658 678 659 679 // THEN we merge it 660 - newPost.bskyCid = existingBskyPost.bskyCid 661 - newPost.bskyUri = existingBskyPost.bskyUri 662 - await newPost.save() 680 + newPost.bskyCid = existingBskyPost.bskyCid; 681 + newPost.bskyUri = existingBskyPost.bskyUri; 682 + await newPost.save(); 663 683 } 664 684 665 685 return newPost;
+2
packages/backend/utils/activitypub/postToJSONLD.ts
··· 280 280 cc: usersToSend.cc, 281 281 object: { 282 282 id: `${completeEnvironment.frontendUrl}/fediverse/post/${post.id}`, 283 + blueskyUri: post.bskyUri, 284 + blueskyCid: post.bskyCid, 283 285 actor: actorUrl, 284 286 type: "Note", 285 287 summary: post.content_warning ? post.content_warning : "",
-1
packages/backend/utils/queueProcessors/sendPostToInboxes.ts
··· 8 8 const localUser = job.data.petitionBy; 9 9 const objectToSend = job.data.objectToSend; 10 10 //at some point we should remove the array thing but at the same time yeah 11 - logger.debug({ message: "sendpostToInbox", inbox, localUser: localUser.url }); 12 11 const tmp = await promiseRace( 13 12 [postPetitionSigned(objectToSend, localUser, inbox)], 14 13 5000