This repository has no description
0

Configure Feed

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

index url from connections

+81 -3
-1
src/modules/search/application/eventHandlers/CardAddedToLibraryEventHandler.ts
··· 40 40 // Index the URL for search 41 41 const indexResult = await this.indexUrlForSearchUseCase.execute({ 42 42 url: card.url.value, 43 - cardId: event.cardId.getStringValue(), 44 43 }); 45 44 46 45 if (indexResult.isErr()) {
+69
src/modules/search/application/eventHandlers/ConnectionCreatedEventHandler.ts
··· 1 + import { ConnectionCreatedEvent } from '../../../cards/domain/events/ConnectionCreatedEvent'; 2 + import { IEventHandler } from '../../../../shared/application/events/IEventSubscriber'; 3 + import { Result, ok } from '../../../../shared/core/Result'; 4 + import { IndexUrlForSearchUseCase } from '../useCases/commands/IndexUrlForSearchUseCase'; 5 + import { IConnectionRepository } from '../../../cards/domain/IConnectionRepository'; 6 + 7 + export class ConnectionCreatedEventHandler 8 + implements IEventHandler<ConnectionCreatedEvent> 9 + { 10 + constructor( 11 + private indexUrlForSearchUseCase: IndexUrlForSearchUseCase, 12 + private connectionRepository: IConnectionRepository, 13 + ) {} 14 + 15 + async handle(event: ConnectionCreatedEvent): Promise<Result<void>> { 16 + // Get connection details 17 + const connectionResult = await this.connectionRepository.findById( 18 + event.connectionId, 19 + ); 20 + if (connectionResult.isErr()) { 21 + console.error( 22 + 'Failed to find connection for search indexing:', 23 + connectionResult.error, 24 + ); 25 + return ok(undefined); // Don't fail the event processing 26 + } 27 + 28 + const connection = connectionResult.value; 29 + if (!connection) { 30 + console.warn( 31 + 'Connection not found for search indexing:', 32 + event.connectionId.getStringValue(), 33 + ); 34 + return ok(undefined); 35 + } 36 + 37 + // Index source URL if it exists 38 + if (connection.source.url) { 39 + const sourceIndexResult = await this.indexUrlForSearchUseCase.execute({ 40 + url: connection.source.url.value, 41 + }); 42 + 43 + if (sourceIndexResult.isErr()) { 44 + console.error( 45 + 'Failed to index source URL for search:', 46 + sourceIndexResult.error, 47 + ); 48 + // Don't fail the event processing - search indexing is not critical 49 + } 50 + } 51 + 52 + // Index target URL if it exists 53 + if (connection.target.url) { 54 + const targetIndexResult = await this.indexUrlForSearchUseCase.execute({ 55 + url: connection.target.url.value, 56 + }); 57 + 58 + if (targetIndexResult.isErr()) { 59 + console.error( 60 + 'Failed to index target URL for search:', 61 + targetIndexResult.error, 62 + ); 63 + // Don't fail the event processing - search indexing is not critical 64 + } 65 + } 66 + 67 + return ok(undefined); 68 + } 69 + }
-1
src/modules/search/application/useCases/commands/IndexUrlForSearchUseCase.ts
··· 7 7 8 8 export interface IndexUrlForSearchDTO { 9 9 url: string; 10 - cardId: string; 11 10 } 12 11 13 12 export interface IndexUrlForSearchResponseDTO {
+1 -1
src/shared/infrastructure/events/BullMQEventPublisher.ts
··· 94 94 case EventNames.USER_UNFOLLOWED_TARGET: 95 95 return [QueueNames.NOTIFICATIONS]; 96 96 case EventNames.CONNECTION_CREATED: 97 - return [QueueNames.FEEDS, QueueNames.NOTIFICATIONS]; 97 + return [QueueNames.FEEDS, QueueNames.NOTIFICATIONS, QueueNames.SEARCH]; 98 98 case EventNames.CONNECTION_REMOVED: 99 99 return [QueueNames.NOTIFICATIONS]; 100 100 default:
+11
src/shared/infrastructure/processes/SearchWorkerProcess.ts
··· 5 5 } from '../http/factories/ServiceFactory'; 6 6 import { UseCaseFactory } from '../http/factories/UseCaseFactory'; 7 7 import { CardAddedToLibraryEventHandler } from '../../../modules/search/application/eventHandlers/CardAddedToLibraryEventHandler'; 8 + import { ConnectionCreatedEventHandler } from '../../../modules/search/application/eventHandlers/ConnectionCreatedEventHandler'; 8 9 import { QueueNames } from '../events/QueueConfig'; 9 10 import { EventNames } from '../events/EventConfig'; 10 11 import { BaseWorkerProcess } from './BaseWorkerProcess'; ··· 50 51 await subscriber.subscribe( 51 52 EventNames.CARD_ADDED_TO_LIBRARY, 52 53 cardAddedToLibraryHandler, 54 + ); 55 + 56 + const connectionCreatedHandler = new ConnectionCreatedEventHandler( 57 + useCases.indexUrlForSearchUseCase, 58 + repositories.connectionRepository, 59 + ); 60 + 61 + await subscriber.subscribe( 62 + EventNames.CONNECTION_CREATED, 63 + connectionCreatedHandler, 53 64 ); 54 65 } 55 66 }