Skip to content

Commit a70323a

Browse files
committed
refactor(chat): remove legacy chat.getThreadsList route
1 parent db76f3b commit a70323a

File tree

1 file changed

+0
-46
lines changed
  • apps/meteor/app/api/server/v1

1 file changed

+0
-46
lines changed

apps/meteor/app/api/server/v1/chat.ts

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -862,52 +862,6 @@ API.v1.addRoute(
862862
},
863863
);
864864

865-
API.v1.addRoute(
866-
'chat.getThreadsList',
867-
{ authRequired: true, validateParams: isChatGetThreadsListProps },
868-
{
869-
async get() {
870-
const { rid, type, text } = this.queryParams;
871-
872-
const { offset, count } = await getPaginationItems(this.queryParams);
873-
const { sort, fields, query } = await this.parseJsonQuery();
874-
875-
if (!settings.get<boolean>('Threads_enabled')) {
876-
throw new Meteor.Error('error-not-allowed', 'Threads Disabled');
877-
}
878-
const user = await Users.findOneById(this.userId, { projection: { _id: 1 } });
879-
const room = await Rooms.findOneById(rid, { projection: { ...roomAccessAttributes, t: 1, _id: 1 } });
880-
881-
if (!room || !user || !(await canAccessRoomAsync(room, user))) {
882-
throw new Meteor.Error('error-not-allowed', 'Not Allowed');
883-
}
884-
885-
const typeThread = {
886-
_hidden: { $ne: true },
887-
...(type === 'following' && { replies: { $in: [this.userId] } }),
888-
...(type === 'unread' && { _id: { $in: (await Subscriptions.findOneByRoomIdAndUserId(room._id, user._id))?.tunread || [] } }),
889-
msg: new RegExp(escapeRegExp(text || ''), 'i'),
890-
};
891-
892-
const threadQuery = { ...query, ...typeThread, rid: room._id, tcount: { $exists: true } };
893-
const { cursor, totalCount } = await Messages.findPaginated<IThreadMainMessage>(threadQuery, {
894-
sort: sort || { tlm: -1 },
895-
skip: offset,
896-
limit: count,
897-
projection: fields,
898-
});
899-
900-
const [threads, total] = await Promise.all([cursor.toArray(), totalCount]);
901-
902-
return API.v1.success({
903-
threads: await normalizeMessagesForUser(threads, this.userId),
904-
count: threads.length,
905-
offset,
906-
total,
907-
});
908-
},
909-
},
910-
);
911865

912866
API.v1.addRoute(
913867
'chat.syncThreadsList',

0 commit comments

Comments
 (0)