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
465 B

import type { IRoom, IUser } from '@rocket.chat/core-typings';
import { Rooms } from '../../stores';
import { getUserId } from '../user';
export const getUidDirectMessage = (rid: IRoom['_id'], uid: IUser['_id'] | undefined = getUserId() ?? undefined): string | undefined => {
const room = Rooms.state.get(rid);
if (!room || room.t !== 'd' || !room.uids || room.uids.length > 2) {
return undefined;
}
return room.uids.filter((_uid) => _uid !== uid)[0];
};