This repository has no description
0

Configure Feed

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

feat: add handle and uri to collection data in global feed

Co-authored-by: aider (anthropic/claude-sonnet-4-20250514) <aider@aider.chat>

+44 -19
+44 -19
src/modules/feeds/application/useCases/queries/GetGlobalFeedUseCase.ts
··· 11 11 } from '../../../../cards/domain/ICardQueryRepository'; 12 12 import { ICollectionRepository } from 'src/modules/cards/domain/ICollectionRepository'; 13 13 import { CollectionId } from 'src/modules/cards/domain/value-objects/CollectionId'; 14 + import { IIdentityResolutionService } from '../../../../atproto/domain/services/IIdentityResolutionService'; 15 + import { DID } from '../../../../atproto/domain/DID'; 16 + import { DIDOrHandle } from '../../../../atproto/domain/DIDOrHandle'; 14 17 15 18 export interface GetGlobalFeedQuery { 16 19 page?: number; ··· 32 35 collections: { 33 36 id: string; 34 37 name: string; 38 + authorHandle: string; 39 + uri?: string; 35 40 }[]; 36 41 } 37 42 ··· 64 69 private profileService: IProfileService, 65 70 private cardQueryRepository: ICardQueryRepository, 66 71 private collectionRepository: ICollectionRepository, 72 + private identityResolutionService: IIdentityResolutionService, 67 73 ) {} 68 74 69 75 async execute( ··· 173 179 ), 174 180 ]; 175 181 176 - const collectionDataMap = new Map<string, { id: string; name: string }>(); 182 + const collectionDataMap = new Map< 183 + string, 184 + { id: string; name: string; authorHandle: string; uri?: string } 185 + >(); 177 186 // Fetch all collections in parallel using Promise.all 178 187 const collectionResults = await Promise.all( 179 188 collectionIds.map(async (collectionId) => { ··· 185 194 const collectionResult = await this.collectionRepository.findById( 186 195 collectionIdResult.value, 187 196 ); 188 - if (collectionResult.isOk() && collectionResult.value) { 189 - const collection = collectionResult.value; 190 - return { 191 - id: collection.collectionId.getStringValue(), 192 - name: collection.name.toString(), 193 - collectionId, 194 - }; 197 + if (collectionResult.isErr() || !collectionResult.value) { 198 + return null; 199 + } 200 + 201 + const collection = collectionResult.value; 202 + 203 + const didOrHandleResult = DIDOrHandle.create( 204 + collection.authorId.value, 205 + ); 206 + if (didOrHandleResult.isErr()) { 207 + return null; 208 + } 209 + 210 + const resolvedHandleResult = 211 + await this.identityResolutionService.resolveToHandle( 212 + didOrHandleResult.value, 213 + ); 214 + if (resolvedHandleResult.isErr()) { 215 + return null; 195 216 } 196 - return null; 217 + 218 + const handle = resolvedHandleResult.value; 219 + const uri = collection.publishedRecordId?.uri; 220 + 221 + return { 222 + id: collection.collectionId.getStringValue(), 223 + name: collection.name.toString(), 224 + authorHandle: handle.value, 225 + uri, 226 + collectionId, 227 + }; 197 228 }), 198 229 ); 199 230 ··· 202 233 collectionDataMap.set(result.collectionId, { 203 234 id: result.id, 204 235 name: result.name, 236 + authorHandle: result.authorHandle, 237 + uri: result.uri, 205 238 }); 206 239 } 207 240 }); ··· 222 255 223 256 const collections = (activity.metadata.collectionIds || []) 224 257 .map((collectionId) => collectionDataMap.get(collectionId)) 225 - .filter( 226 - (collection): collection is { id: string; name: string } => 227 - !!collection, 228 - ); 258 + .filter((collection) => !!collection); 229 259 230 260 feedItems.push({ 231 261 id: activity.activityId.getStringValue(), 232 - user: { 233 - id: actor.id, 234 - handle: actor.handle, 235 - name: actor.name, 236 - avatarUrl: actor.avatarUrl, 237 - }, 262 + user: actor, 238 263 card: cardData, 239 264 collections, 240 265 });