|
1 | 1 | import type { IMessage, IRoom, IUser } from '@rocket.chat/core-typings'; |
2 | 2 | import { isEditedMessage } from '@rocket.chat/core-typings'; |
3 | | -import { Messages, Rooms, Subscriptions, NotificationQueue } from '@rocket.chat/models'; |
4 | | -import { Meteor } from 'meteor/meteor'; |
| 3 | +import { Messages, Subscriptions, NotificationQueue } from '@rocket.chat/models'; |
5 | 4 |
|
6 | 5 | import { callbacks } from '../../../server/lib/callbacks'; |
7 | | -import { canAccessRoomAsync } from '../../authorization/server'; |
8 | 6 | import { |
9 | 7 | notifyOnSubscriptionChangedByRoomIdAndUserIds, |
10 | 8 | notifyOnSubscriptionChangedByRoomIdAndUserId, |
11 | 9 | } from '../../lib/server/lib/notifyListener'; |
12 | 10 | import { getMentions, getUserIdsFromHighlights } from '../../lib/server/lib/notifyUsersOnMessage'; |
13 | | -import { settings } from '../../settings/server'; |
14 | 11 |
|
15 | 12 | export async function reply({ tmid }: { tmid?: string }, message: IMessage, parentMessage: IMessage, followers: string[]) { |
16 | 13 | if (!tmid || isEditedMessage(message)) { |
@@ -101,32 +98,3 @@ export const readThread = async ({ user, room, tmid }: { user: IUser; room: IRoo |
101 | 98 |
|
102 | 99 | callbacks.runAsync('afterReadMessages', room, { uid: user._id, tmid }); |
103 | 100 | }; |
104 | | - |
105 | | -/** |
106 | | - * Marks a thread as read for a user, replicating the full behavior of the |
107 | | - * legacy `readThreads` DDP method: it validates that threads are enabled, that |
108 | | - * the thread and its room exist, that the user can access the room, and runs |
109 | | - * the `beforeReadMessages` callback before clearing the thread unread state. |
110 | | - */ |
111 | | -export const readThreadMethod = async ({ user, tmid }: { user: IUser; tmid: IMessage['_id'] }) => { |
112 | | - if (!settings.get('Threads_enabled')) { |
113 | | - throw new Meteor.Error('error-not-allowed', 'Threads Disabled', { method: 'readThreads' }); |
114 | | - } |
115 | | - |
116 | | - const thread = await Messages.findOneById(tmid); |
117 | | - if (!thread) { |
118 | | - return; |
119 | | - } |
120 | | - |
121 | | - const room = await Rooms.findOneById(thread.rid); |
122 | | - if (!room) { |
123 | | - throw new Meteor.Error('error-room-does-not-exist', 'This room does not exist', { method: 'readThreads' }); |
124 | | - } |
125 | | - |
126 | | - if (!(await canAccessRoomAsync(room, user))) { |
127 | | - throw new Meteor.Error('error-not-allowed', 'Not allowed', { method: 'readThreads' }); |
128 | | - } |
129 | | - |
130 | | - await callbacks.run('beforeReadMessages', thread.rid, user._id); |
131 | | - await readThread({ user, room, tmid }); |
132 | | -}; |
0 commit comments