Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion apps/meteor/.mocharc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,5 @@ module.exports = {
'tests/unit/server/**/*.spec.ts',
'app/api/server/lib/**/*.spec.ts',
'app/file-upload/server/**/*.spec.ts',
'app/lib/server/functions/notifications/**/*.spec.ts',
],
};
231 changes: 0 additions & 231 deletions apps/meteor/app/lib/server/functions/notifications/desktop.spec.ts

This file was deleted.

9 changes: 2 additions & 7 deletions apps/meteor/app/lib/server/functions/notifications/desktop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type { IMessage, IRoom, IUser, AtLeast } from '@rocket.chat/core-typings'
import { roomCoordinator } from '../../../../../server/lib/rooms/roomCoordinator';
import { metrics } from '../../../../metrics/server';
import { settings } from '../../../../settings/server';
import type { SubscriptionAggregation } from '../../lib/sendNotificationsOnMessage';

/**
* Send notification to user
Expand All @@ -23,21 +22,17 @@ export async function notifyDesktopUser({
room,
duration,
notificationMessage,
receiver,
}: {
userId: string;
user: AtLeast<IUser, '_id' | 'name' | 'username'>;
message: IMessage | Pick<IMessage, 'u'>;
room: IRoom;
duration?: number;
notificationMessage: string;
receiver?: SubscriptionAggregation['receiver'][number];
}): Promise<void> {
const { title, text, name } = await roomCoordinator
.getRoomDirectives(room.t)
.getNotificationDetails(room, user, notificationMessage, userId, receiver?.language);

const showPushMessage = settings.get<boolean>('Push_show_message');
.getNotificationDetails(room, user, notificationMessage, userId);

const payload = {
title: title || '',
Expand All @@ -56,7 +51,7 @@ export async function notifyDesktopUser({
sender: message.u,
type: room.t,
message: {
msg: 'msg' in message && showPushMessage ? message.msg : '',
msg: 'msg' in message ? message.msg : '',
...('t' in message && {
t: message.t,
}),
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/app/lib/server/lib/sendNotificationsOnMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getEmailData, shouldNotifyEmail } from '../functions/notifications/emai
import { messageContainsHighlight } from '../functions/notifications/messageContainsHighlight';
import { getPushData, shouldNotifyMobile } from '../functions/notifications/mobile';

export type SubscriptionAggregation = {
type SubscriptionAggregation = {
receiver: [Pick<IUser, 'active' | 'emails' | 'language' | 'status' | 'statusConnection' | 'username' | 'settings'> | null];
} & Pick<
ISubscription,
Expand Down Expand Up @@ -134,7 +134,6 @@ export const sendNotification = async ({
user: sender,
message,
room,
receiver,
});
}

Expand Down
22 changes: 12 additions & 10 deletions apps/meteor/client/hooks/notification/useNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const useNotification = () => {
return;
}

const { rid, name, _id: msgId } = notification.payload;
const { rid } = notification.payload;
if (!rid) {
return;
}
Expand Down Expand Up @@ -63,54 +63,56 @@ export const useNotification = () => {
n.close();
window.focus();

const jump = msgId && { jump: msgId };
if (!notification.payload._id || !notification.payload.rid || !notification.payload.name) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You removed _id and name from the destructing but still being in use here.

Also, rid is already destructured and you're accessing it from the full path.

@abhinavkrin abhinavkrin Jul 24, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a revert of a previous PR. Since earlier case was also working fine I didnt change anything in the revert PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return;
}

switch (notification.payload?.type) {
case 'd':
router.navigate({
pattern: '/direct/:rid/:tab?/:context?',
params: {
rid,
rid: notification.payload.rid,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the destructured rid?

...(notification.payload.tmid && {
tab: 'thread',
context: notification.payload.tmid,
}),
},
search: { ...router.getSearchParameters(), ...jump },
search: { ...router.getSearchParameters(), jump: notification.payload._id },
});
break;
case 'c':
return router.navigate({
pattern: '/channel/:name/:tab?/:context?',
params: {
name: name || rid,
name: notification.payload.name,
...(notification.payload.tmid && {
tab: 'thread',
context: notification.payload.tmid,
}),
},
search: { ...router.getSearchParameters(), ...jump },
search: { ...router.getSearchParameters(), jump: notification.payload._id },
});
case 'p':
return router.navigate({
pattern: '/group/:name/:tab?/:context?',
params: {
name: name || rid,
name: notification.payload.name,
...(notification.payload.tmid && {
tab: 'thread',
context: notification.payload.tmid,
}),
},
search: { ...router.getSearchParameters(), ...jump },
search: { ...router.getSearchParameters(), jump: notification.payload._id },
});
case 'l':
return router.navigate({
pattern: '/live/:id/:tab?/:context?',
params: {
id: rid,
id: notification.payload.rid,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before

tab: 'room-info',
},
search: { ...router.getSearchParameters(), ...jump },
search: { ...router.getSearchParameters(), jump: notification.payload._id },
});
}
};
Expand Down
3 changes: 1 addition & 2 deletions apps/meteor/definition/IRoomTypeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ export interface IRoomTypeServerDirectives {
sender: AtLeast<IUser, '_id' | 'name' | 'username'>,
notificationMessage: string,
userId: string,
language?: string,
) => Promise<{ title?: string; text: string; name?: string }>;
) => Promise<{ title: string | undefined; text: string; name: string | undefined }>;
getMsgSender: (message: IMessage) => Promise<IUser | null>;
includeInRoomSearch: () => boolean;
getReadReceiptsExtraData: (message: IMessage) => Partial<ReadReceipt>;
Expand Down
Loading
Loading