Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | import { Processor, Process } from '@nestjs/bull'; import { Job } from 'bull'; import { Logger } from '@nestjs/common'; import { NotificationService } from '../services/notification.service'; @Processor('social-processing') export class SocialProcessor { private readonly logger = new Logger(SocialProcessor.name); constructor(private readonly notificationService: NotificationService) {} @Process('notify-friends') async notifyFriends(job: Job<{ userId: string; activityId: string; type: string; }>) { try { const { userId, activityId, type } = job.data; this.logger.log(`Processing friend notification for user ${userId}, activity ${activityId}`); // This would notify all friends about the activity await this.notificationService.sendActivityNotification(userId, type, { activityId }); return { success: true }; } catch (error) { this.logger.error(`Error processing friend notification`, error); throw error; } } @Process('notify-reaction') async notifyReaction(job: Job<{ fromUserId: string; toUserId: string; activityId: string; reactionType: string; }>) { try { const { fromUserId, toUserId, activityId, reactionType } = job.data; this.logger.log(`Processing reaction notification from ${fromUserId} to ${toUserId}`); await this.notificationService.sendActivityNotification(toUserId, 'reaction', { fromUserId, activityId, reactionType, }); return { success: true }; } catch (error) { this.logger.error(`Error processing reaction notification`, error); throw error; } } @Process('notify-comment') async notifyComment(job: Job<{ fromUserId: string; toUserId: string; activityId: string; message: string; }>) { try { const { fromUserId, toUserId, activityId, message } = job.data; this.logger.log(`Processing comment notification from ${fromUserId} to ${toUserId}`); await this.notificationService.sendActivityNotification(toUserId, 'comment', { fromUserId, activityId, message, }); return { success: true }; } catch (error) { this.logger.error(`Error processing comment notification`, error); throw error; } } } |