The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/apps/meteor/client/lib/utils/getUidDirectMessage.ts

14 lines
484 B

import type { IRoom, IUser } from '@rocket.chat/core-typings';
import { Meteor } from 'meteor/meteor';
import { ChatRoom } from '../../../app/models/client';
export const getUidDirectMessage = (rid: IRoom['_id'], userId: IUser['_id'] | null = Meteor.userId()): string | undefined => {
const room = ChatRoom.findOne({ _id: rid }, { fields: { uids: 1 } });
if (!room?.uids || room.uids.length > 2) {
return undefined;
}
return room.uids.filter((uid) => uid !== userId)[0];
};