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.

Fixes bsky connection issues

+16 -9
+3 -2
packages/backend/atproto/utils/getAtprotoUser.ts
··· 47 47 48 48 async function getAtprotoUser( 49 49 inputHandle: string, 50 + options?: {ignoreCache?: boolean} 50 51 ): Promise<User | undefined> { 51 52 // we check if we found the user 52 53 let avatarString = ``; ··· 79 80 if (userFound && userFound.email) { 80 81 return (await User.findByPk(userFound.id)) as User; 81 82 } 82 - const did = handle.startsWith('did:') ? handle : (await resolveHandle(handle)) as string 83 - const doc = await getDidDoc(did) 83 + const did = handle.startsWith('did:') ? handle : (await resolveHandle(handle, options?.ignoreCache == true)) as string 84 + const doc = await getDidDoc(did, options?.ignoreCache == true) 84 85 if (userFound) { 85 86 avatarString = userFound.avatar; 86 87
+5 -2
packages/backend/routes/users.ts
··· 1480 1480 } 1481 1481 const userId = req.jwtData?.userId as string 1482 1482 const user = await User.scope('full').findByPk(userId) 1483 - const bskyUrl = req.body.url 1483 + let bskyUrl = req.body.url 1484 + if(bskyUrl.startsWith('@')) { 1485 + bskyUrl = bskyUrl.substring(1) 1486 + } 1484 1487 const pasword = req.body.password 1485 1488 if (user && bskyUrl && pasword) { 1486 1489 const localIds = await getAllLocalUserIds() 1487 - const bskyUser = await getAtprotoUser(bskyUrl) 1490 + const bskyUser = await getAtprotoUser(bskyUrl, {ignoreCache: true}) 1488 1491 if (bskyUser && bskyUser.url === user.url) { 1489 1492 return res.send({ 1490 1493 success: true
+3 -1
packages/backend/utils/activitypub/searchRemoteUser.ts
··· 69 69 } 70 70 } 71 71 if(searchData && searchData.type === 'bluesky') { 72 - return getAtprotoUser(searchTerm) 72 + return getAtprotoUser(searchTerm, { 73 + ignoreCache: true 74 + }) 73 75 } 74 76 return users.find((elem) => !!elem); 75 77 }
+4 -2
packages/backend/utils/atproto/getDidDoc.ts
··· 1 1 import { DidDocument } from '@atcute/identity' 2 2 import { getServerFromDid } from './getServerFromDid.js' 3 3 import { redisCache } from '../redis.js' 4 - import { completeEnvironment } from '../backendOptions.js' 5 4 import getUserAgent from '../getUserAgent.js' 6 5 7 6 8 - export async function getDidDoc(inputDid: string): Promise<DidDocument | undefined> { 7 + export async function getDidDoc(inputDid: string, ignoreCache?: boolean): Promise<DidDocument | undefined> { 9 8 let did = inputDid 9 + if(ignoreCache) { 10 + await redisCache.del('didDoc:' + did) 11 + } 10 12 if (did.startsWith('at://')) { 11 13 did = did.replace(/^at:\/\//, '') 12 14 }
+1 -2
packages/backend/utils/atproto/resolveHandleToDid.ts
··· 1 1 2 2 import { AtprotoHandleResolverNode } from '@atproto-labs/handle-resolver-node' 3 - import e from 'express' 4 3 5 4 const resolver = new AtprotoHandleResolverNode() 6 5 7 6 8 - async function resolveHandle(handle: string) { 7 + async function resolveHandle(handle: string, ignoreCache: boolean) { 9 8 return resolver.resolve(handle) 10 9 } 11 10