mirror of
https://git.sr.ht/~emerson/reflectionircd
synced 2025-08-05 16:59:10 +00:00
makes cmodes static, add fields for privacy events
This commit is contained in:
parent
3d101f202a
commit
e83c782284
1 changed files with 34 additions and 22 deletions
|
@ -12,17 +12,20 @@ export class Channel {
|
|||
private ircUsers: Map<string, IRCUser>
|
||||
private powerLevels: Map<string, number>
|
||||
private topic: Map<string, string>;
|
||||
private modes: Map<string, string>
|
||||
private eventIDsSeen: Set<string>;
|
||||
private historyVisibility: string
|
||||
private guestAccess: string
|
||||
private joinRules: string
|
||||
constructor(public roomId: string, private server: Server) {
|
||||
this.name = roomId;
|
||||
this.matrixUsers = new Map();
|
||||
this.ircUsers = new Map();
|
||||
this.powerLevels = new Map();
|
||||
this.topic = new Map([['text', ''], ['timestamp', '0'], ['setter', 'matrix']]);
|
||||
this.modes = new Map();
|
||||
this.modes.set('n', '');
|
||||
this.eventIDsSeen = new Set();
|
||||
this.historyVisibility = "shared";
|
||||
this.guestAccess = "forbidden";
|
||||
this.joinRules = "public";
|
||||
}
|
||||
|
||||
getNickPowerLevelMapping(nick: string): string {
|
||||
|
@ -82,11 +85,7 @@ export class Channel {
|
|||
sendMode(client: Client, passedTags: Map<string, string>) {
|
||||
if (!client.user)
|
||||
return;
|
||||
const chanModes = [];
|
||||
for (let m of this.modes.keys()) {
|
||||
chanModes.push(m);
|
||||
}
|
||||
client.sendMessage(client.server.name, "324", numerics["324"](client.user.nick, this.name, `+${chanModes.join("")}`), passedTags);
|
||||
client.sendMessage(client.server.name, "324", numerics["324"](client.user.nick, this.name, `+n`), passedTags);
|
||||
}
|
||||
|
||||
sendTopic(client: Client, passedTags: Map<string, string>) {
|
||||
|
@ -127,6 +126,12 @@ export class Channel {
|
|||
return;
|
||||
|
||||
switch (event["type"]) {
|
||||
case 'm.room.guest_access':
|
||||
this.handleMatrixGuestAccess(event);
|
||||
break;
|
||||
case 'm.room.history_visibility':
|
||||
this.handleMatrixHistoryVisibility(event);
|
||||
break;
|
||||
case 'm.room.join_rules':
|
||||
this.handleMatrixJoinRule(event);
|
||||
break;
|
||||
|
@ -161,6 +166,9 @@ export class Channel {
|
|||
case 'm.room.bot.options':
|
||||
case 'm.room.pinned_events':
|
||||
case 'm.room.tombstone':
|
||||
case 'm.room.canonical_alias':
|
||||
case 'm.room.server_acl':
|
||||
case 'org.matrix.room.preview_urls':
|
||||
break;
|
||||
default:
|
||||
console.log(event["type"]);
|
||||
|
@ -307,20 +315,24 @@ export class Channel {
|
|||
console.log(`Warning: join rule not found in ${event}`);
|
||||
return;
|
||||
}
|
||||
if (rule === "public") {
|
||||
if (this.modes.has('i')) {
|
||||
this.modes.delete('i');
|
||||
this.ircUsers.forEach((user) => {
|
||||
user.sendToAll(this.server.name, 'MODE', [this.name, '-i'], new Map());
|
||||
});
|
||||
}
|
||||
} else {
|
||||
if (!this.modes.has('i')) {
|
||||
this.modes.set('i', '');
|
||||
this.ircUsers.forEach((user) => {
|
||||
user.sendToAll(this.server.name, 'MODE', [this.name, '+i'], new Map());
|
||||
});
|
||||
}
|
||||
this.joinRules = rule;
|
||||
}
|
||||
|
||||
handleMatrixHistoryVisibility(event: any) {
|
||||
const rule = event["content"]?.["history_visibility"];
|
||||
if (!rule) {
|
||||
console.log(`Warning: history visibility not found in ${event}`);
|
||||
return;
|
||||
}
|
||||
this.historyVisibility = rule;
|
||||
}
|
||||
|
||||
handleMatrixGuestAccess(event: any) {
|
||||
const rule = event["content"]?.["guest_access"];
|
||||
if (!rule) {
|
||||
console.log(`Warning: Guest access not found in ${event}`);
|
||||
return;
|
||||
}
|
||||
this.guestAccess = rule;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue