widget parole 14
This commit is contained in:
parent
be935ffc75
commit
ec604cf76f
@ -129,14 +129,24 @@ export async function GET(request: Request) {
|
||||
}
|
||||
|
||||
// Filter subscriptions for the current user
|
||||
const userSubscriptions = subscriptionsData.update.filter((sub: any) =>
|
||||
sub.u?._id === currentUser._id ||
|
||||
(sub.userMentions > 0 && sub.alert)
|
||||
);
|
||||
const userSubscriptions = subscriptionsData.update.filter((sub: any) => {
|
||||
// For direct messages (t: 'd'), check if the room ID contains the user's ID
|
||||
if (sub.t === 'd') {
|
||||
return sub.rid.includes(currentUser._id);
|
||||
}
|
||||
// For channels (t: 'c'), include if user has unread messages or mentions
|
||||
return sub.t === 'c' && (sub.unread > 0 || sub.userMentions > 0 || sub.alert);
|
||||
});
|
||||
|
||||
console.log('Filtered subscriptions:', {
|
||||
total: userSubscriptions.length,
|
||||
roomTypes: userSubscriptions.map((sub: any) => sub.t)
|
||||
roomTypes: userSubscriptions.map((sub: any) => ({
|
||||
type: sub.t,
|
||||
name: sub.fname || sub.name,
|
||||
unread: sub.unread,
|
||||
mentions: sub.userMentions,
|
||||
alert: sub.alert
|
||||
}))
|
||||
});
|
||||
|
||||
const messages: any[] = [];
|
||||
|
||||
Loading…
Reference in New Issue
Block a user