@@ -219,6 +219,25 @@ export class NotificationsService implements OnModuleInit {
219219 }
220220 }
221221 }
222+ } else if (
223+ notification_data . type === NotificationType . LIKE ||
224+ notification_data . type === NotificationType . REPOST
225+ ) {
226+ if ( notification_data . type === NotificationType . LIKE ) {
227+ if ( payload . tweet ) {
228+ enriched_payload . tweet = this . cleanTweet ( payload . tweet ) ;
229+ }
230+ if ( payload . liker ) {
231+ enriched_payload . liker = this . cleanUser ( payload . liker ) ;
232+ }
233+ } else if ( notification_data . type === NotificationType . REPOST ) {
234+ if ( payload . tweet ) {
235+ enriched_payload . tweet = this . cleanTweet ( payload . tweet ) ;
236+ }
237+ if ( payload . reposter ) {
238+ enriched_payload . reposter = this . cleanUser ( payload . reposter ) ;
239+ }
240+ }
222241 }
223242
224243 const is_online = this . messagesGateway . isOnline ( user_id ) ;
@@ -941,6 +960,7 @@ export class NotificationsService implements OnModuleInit {
941960 if ( reply_notification . replied_by ) {
942961 user_ids . add ( reply_notification . replied_by ) ;
943962 user_ids_needing_relationships . add ( reply_notification . replied_by ) ;
963+ user_ids_needing_relationships . add ( reply_notification . replied_by ) ;
944964 }
945965 if ( reply_notification . reply_tweet_id ) {
946966 tweet_ids . add ( reply_notification . reply_tweet_id ) ;
@@ -1334,20 +1354,20 @@ export class NotificationsService implements OnModuleInit {
13341354 const deduplicated_notifications = this . deduplicateNotifications ( response_notifications ) ;
13351355
13361356 // Clean notifications with missing tweets
1337- // if (missing_tweet_ids.size > 0) {
1338- // await this.clear_jobs_service.queueClearNotification({
1339- // user_id,
1340- // tweet_ids: Array.from(missing_tweet_ids),
1341- // });
1342- // }
1343-
1344- // // Clean up notifications with missing users
1345- // if (missing_user_ids.size > 0) {
1346- // await this.clear_jobs_service.queueClearNotificationByUsers(
1347- // user_id,
1348- // Array.from(missing_user_ids)
1349- // );
1350- // }
1357+ if ( missing_tweet_ids . size > 0 ) {
1358+ await this . clear_jobs_service . queueClearNotification ( {
1359+ user_id,
1360+ tweet_ids : Array . from ( missing_tweet_ids ) ,
1361+ } ) ;
1362+ }
1363+
1364+ // Clean up notifications with missing users
1365+ if ( missing_user_ids . size > 0 ) {
1366+ await this . clear_jobs_service . queueClearNotificationByUsers (
1367+ user_id ,
1368+ Array . from ( missing_user_ids )
1369+ ) ;
1370+ }
13511371
13521372 // Apply pagination
13531373 const total = deduplicated_notifications . length ;
@@ -2337,6 +2357,10 @@ export class NotificationsService implements OnModuleInit {
23372357 }
23382358
23392359 // Fetch all data in parallel
2360+ const should_fetch_tweet_user =
2361+ notification . type !== NotificationType . LIKE &&
2362+ notification . type !== NotificationType . REPOST ;
2363+
23402364 const [ users , tweets ] = await Promise . all ( [
23412365 user_ids . size > 0
23422366 ? this . user_repository . find ( {
@@ -2347,7 +2371,7 @@ export class NotificationsService implements OnModuleInit {
23472371 tweet_ids . size > 0
23482372 ? this . tweet_repository . find ( {
23492373 where : { tweet_id : In ( Array . from ( tweet_ids ) ) } ,
2350- relations : [ 'user' ] ,
2374+ relations : should_fetch_tweet_user ? [ 'user' ] : [ ] ,
23512375 } )
23522376 : [ ] ,
23532377 ] ) ;
@@ -2376,9 +2400,9 @@ export class NotificationsService implements OnModuleInit {
23762400 if ( ! user ) {
23772401 missing_user_ids . add ( id ) ;
23782402 }
2379- return user ;
2403+ return user ? this . cleanUser ( user ) : undefined ;
23802404 } )
2381- . filter ( ( user ) : user is User => user !== undefined ) ;
2405+ . filter ( ( user ) => user !== undefined ) ;
23822406
23832407 // Clean up missing user IDs if any
23842408 if ( missing_user_ids . size > 0 ) {
@@ -2407,9 +2431,9 @@ export class NotificationsService implements OnModuleInit {
24072431 if ( ! tweet ) {
24082432 missing_tweet_ids . add ( id ) ;
24092433 }
2410- return tweet ;
2434+ return tweet ? this . cleanTweet ( tweet ) : undefined ;
24112435 } )
2412- . filter ( ( tweet ) : tweet is Tweet => tweet !== undefined ) ;
2436+ . filter ( ( tweet ) => tweet !== undefined ) ;
24132437
24142438 const liked_by_ids = Array . isArray ( like_notification . liked_by )
24152439 ? like_notification . liked_by
@@ -2421,9 +2445,9 @@ export class NotificationsService implements OnModuleInit {
24212445 if ( ! user ) {
24222446 missing_user_ids . add ( id ) ;
24232447 }
2424- return user ;
2448+ return user ? this . cleanUser ( user ) : undefined ;
24252449 } )
2426- . filter ( ( user ) : user is User => user !== undefined ) ;
2450+ . filter ( ( user ) => user !== undefined ) ;
24272451
24282452 // Clean up missing tweet IDs if any
24292453 if ( missing_tweet_ids . size > 0 ) {
@@ -2461,9 +2485,9 @@ export class NotificationsService implements OnModuleInit {
24612485 if ( ! tweet ) {
24622486 missing_tweet_ids . add ( id ) ;
24632487 }
2464- return tweet ;
2488+ return tweet ? this . cleanTweet ( tweet ) : undefined ;
24652489 } )
2466- . filter ( ( tweet ) : tweet is Tweet => tweet !== undefined ) ;
2490+ . filter ( ( tweet ) => tweet !== undefined ) ;
24672491
24682492 const reposted_by_ids = Array . isArray ( repost_notification . reposted_by )
24692493 ? repost_notification . reposted_by
@@ -2475,9 +2499,9 @@ export class NotificationsService implements OnModuleInit {
24752499 if ( ! user ) {
24762500 missing_user_ids . add ( id ) ;
24772501 }
2478- return user ;
2502+ return user ? this . cleanUser ( user ) : undefined ;
24792503 } )
2480- . filter ( ( user ) : user is User => user !== undefined ) ;
2504+ . filter ( ( user ) => user !== undefined ) ;
24812505
24822506 // Clean up missing tweet IDs if any
24832507 if ( missing_tweet_ids . size > 0 ) {
0 commit comments