add call to m.room.create, get room version and type

Make cmode +S denote a space
This commit is contained in:
emerson 2022-05-02 18:59:49 -04:00
parent da1c006e69
commit d410b70042
2 changed files with 20 additions and 2 deletions

View file

@ -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<string>
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"];

View file

@ -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',