From d410b700420a89985eac0a6cdcff1ad9ff19ce37 Mon Sep 17 00:00:00 2001 From: emerson Date: Mon, 2 May 2022 18:59:49 -0400 Subject: [PATCH] add call to m.room.create, get room version and type Make cmode +S denote a space --- src/Channel.ts | 18 ++++++++++++++++++ src/Client.ts | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Channel.ts b/src/Channel.ts index 9334199..205feff 100644 --- a/src/Channel.ts +++ b/src/Channel.ts @@ -13,6 +13,8 @@ export class Channel { public historyVisibility: string public guestAccess: string public joinRules: string + private roomVersion: number + private roomType: string private syncLocks: Set constructor(public roomId: string, private server: Server) { this.name = roomId; @@ -24,6 +26,8 @@ export class Channel { this.historyVisibility = ""; this.guestAccess = ""; this.joinRules = ""; + this.roomVersion = 0; + this.roomType = ""; this.syncLocks = new Set(); this.syncLocks.add('isDM'); this.doInitialSync(); @@ -52,6 +56,20 @@ export class Channel { } doInitialSync() { + this.addSyncLock("m.room.create"); + this.server.apiCall.get(`/rooms/${this.roomId}/state/m.room.create`).then(response => { + console.log(response.data); + this.roomType = response.data?.type || ""; + if (this.roomType === "m.space") + this.channelModes.set("S", ""); + this.roomVersion = response.data?.room_version || 0; + this.delSyncLock("m.room.create") + }).catch(e => { + const errcode = e.response?.data?.errcode; + if (errcode !== "M_NOT_FOUND") + console.log(e); + this.delSyncLock("m.room.create") + }) this.addSyncLock("m.room.canonical_alias"); this.server.apiCall.get(`/rooms/${this.roomId}/state/m.room.canonical_alias`).then(response => { const canonical_alias = response.data["alias"]; diff --git a/src/Client.ts b/src/Client.ts index 84d5ff7..27da1ea 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -598,10 +598,10 @@ export class Client { this.sendMessage(this.server.name, '001', [this.user.nick, `Welcome to the ${this.server.name} network, ${this.user.nick}`]) this.sendMessage(this.server.name, '002', [this.user.nick, `Your host is ${this.server.name}, running version 0.1.0`]); this.sendMessage(this.server.name, '003', [this.user.nick, `This server was created yesterday`]); - this.sendMessage(this.server.name, '004', [this.user.nick, this.server.name, '0.1.0', 'i', 'hnouv']); + this.sendMessage(this.server.name, '004', [this.user.nick, this.server.name, '0.1.0', 'i', 'Shnouv']); const iSupportArray = [ 'CASEMAPPING=ascii', - 'CHANMODES=,,,nu', + 'CHANMODES=,,,Snu', 'CHANTYPES=#&!', 'MAXTARGETS=1', 'MODES=1',