@@ -86,6 +86,8 @@ export class NotificationsService implements OnModuleInit {
8686
8787 const enriched_payload = { ...payload } ;
8888
89+ let is_blocked = false ;
90+
8991 if (
9092 notification_data . type === NotificationType . REPLY ||
9193 notification_data . type === NotificationType . MENTION ||
@@ -163,6 +165,9 @@ export class NotificationsService implements OnModuleInit {
163165
164166 if ( actor ) {
165167 const enriched_user = this . enrichUserWithStatus ( actor ) ;
168+ if ( enriched_user . is_blocked ) {
169+ is_blocked = true ;
170+ }
166171 if ( notification_data . type === NotificationType . REPLY ) {
167172 enriched_payload . replier = enriched_user ;
168173 } else if ( notification_data . type === NotificationType . MENTION ) {
@@ -257,14 +262,14 @@ export class NotificationsService implements OnModuleInit {
257262
258263 const is_online = this . messagesGateway . isOnline ( user_id ) ;
259264
260- if ( is_online ) {
265+ if ( is_online && ! is_blocked ) {
261266 enriched_payload . created_at = new Date ( ) ;
262267 this . notificationsGateway . sendToUser ( notification_data . type , user_id , {
263268 ...enriched_payload ,
264269 id : notification_data . _id . toString ( ) ,
265270 action : 'add' ,
266271 } ) ;
267- } else {
272+ } else if ( ! is_blocked ) {
268273 await this . fcmService . sendNotificationToUserDevice (
269274 user_id ,
270275 notification_data . type ,
@@ -1393,8 +1398,19 @@ export class NotificationsService implements OnModuleInit {
13931398 const skip = ( page - 1 ) * page_size ;
13941399 const paginated_notifications = deduplicated_notifications . slice ( skip , skip + page_size ) ;
13951400
1401+ const filtered_paginated_notifications = paginated_notifications . filter ( ( notification ) => {
1402+ if ( notification . type === NotificationType . REPLY ) {
1403+ return ! ( notification as any ) . replier ?. is_blocked ;
1404+ } else if ( notification . type === NotificationType . MENTION ) {
1405+ return ! ( notification as any ) . mentioner ?. is_blocked ;
1406+ } else if ( notification . type === NotificationType . QUOTE ) {
1407+ return ! ( notification as any ) . quoter ?. is_blocked ;
1408+ }
1409+ return true ;
1410+ } ) ;
1411+
13961412 return {
1397- notifications : paginated_notifications ,
1413+ notifications : filtered_paginated_notifications ,
13981414 page,
13991415 page_size,
14001416 total,
@@ -1631,8 +1647,17 @@ export class NotificationsService implements OnModuleInit {
16311647 const skip = ( page - 1 ) * page_size ;
16321648 const paginated_notifications = response_notifications . slice ( skip , skip + page_size ) ;
16331649
1650+ const filtered_paginated_notifications = paginated_notifications . filter ( ( notification ) => {
1651+ if ( notification . type === NotificationType . REPLY ) {
1652+ return ! ( notification as any ) . replier ?. is_blocked ;
1653+ } else if ( notification . type === NotificationType . MENTION ) {
1654+ return ! ( notification as any ) . mentioner ?. is_blocked ;
1655+ }
1656+ return true ;
1657+ } ) ;
1658+
16341659 return {
1635- notifications : paginated_notifications ,
1660+ notifications : filtered_paginated_notifications ,
16361661 page,
16371662 page_size,
16381663 total,
0 commit comments