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/client/lib/utils/getUidDirectMessage.ts

15 lines
539 B

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