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

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