Keep direct rooms orthogonal ()

Signed-off-by: ajbura <ajbura@gmail.com>
This commit is contained in:
ajbura 2022-02-05 19:25:59 +05:30
parent a9692f7db4
commit c8ae428df8
3 changed files with 31 additions and 11 deletions

View file

@ -72,7 +72,22 @@ function parseReply(rawBody) {
};
}
function hasDMWith(userId) {
const mx = initMatrix.matrixClient;
const directIds = [...initMatrix.roomList.directs];
return directIds.find((roomId) => {
const dRoom = mx.getRoom(roomId);
const roomMembers = dRoom.getMembers();
if (roomMembers.length <= 2 && dRoom.getMember(userId)) {
return true;
}
return false;
});
}
export {
getBaseUrl, getUsername, getUsernameOfRoomMember,
isRoomAliasAvailable, getPowerLabel, parseReply,
hasDMWith,
};