mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-05 06:50:28 +03:00
Add ability to manage room addresses
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
6fdd9ed48b
commit
54635bf0d3
5 changed files with 447 additions and 10 deletions
|
|
@ -34,16 +34,11 @@ function getUsernameOfRoomMember(roomMember) {
|
|||
|
||||
async function isRoomAliasAvailable(alias) {
|
||||
try {
|
||||
const myUserId = initMatrix.matrixClient.getUserId();
|
||||
const myServer = myUserId.slice(myUserId.indexOf(':') + 1);
|
||||
const result = await initMatrix.matrixClient.resolveRoomAlias(alias);
|
||||
const aliasIsRegisteredOnMyServer = typeof result.servers.find((server) => server === myServer) === 'string';
|
||||
|
||||
if (aliasIsRegisteredOnMyServer) return false;
|
||||
return true;
|
||||
if (result.room_id) return false;
|
||||
return false;
|
||||
} catch (e) {
|
||||
if (e.errcode === 'M_NOT_FOUND') return true;
|
||||
if (e.errcode === 'M_INVALID_PARAM') throw new Error(e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue