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 ircUsers: Map<string, IRCUser>
|
||||||
private powerLevels: Map<string, number>
|
private powerLevels: Map<string, number>
|
||||||
private topic: Map<string, string>;
|
private topic: Map<string, string>;
|
||||||
private modes: Map<string, string>
|
|
||||||
private eventIDsSeen: Set<string>;
|
private eventIDsSeen: Set<string>;
|
||||||
|
private historyVisibility: string
|
||||||
|
private guestAccess: string
|
||||||
|
private joinRules: string
|
||||||
constructor(public roomId: string, private server: Server) {
|
constructor(public roomId: string, private server: Server) {
|
||||||
this.name = roomId;
|
this.name = roomId;
|
||||||
this.matrixUsers = new Map();
|
this.matrixUsers = new Map();
|
||||||
this.ircUsers = new Map();
|
this.ircUsers = new Map();
|
||||||
this.powerLevels = new Map();
|
this.powerLevels = new Map();
|
||||||
this.topic = new Map([['text', ''], ['timestamp', '0'], ['setter', 'matrix']]);
|
this.topic = new Map([['text', ''], ['timestamp', '0'], ['setter', 'matrix']]);
|
||||||
this.modes = new Map();
|
|
||||||
this.modes.set('n', '');
|
|
||||||
this.eventIDsSeen = new Set();
|
this.eventIDsSeen = new Set();
|
||||||
|
this.historyVisibility = "shared";
|
||||||
|
this.guestAccess = "forbidden";
|
||||||
|
this.joinRules = "public";
|
||||||
}
|
}
|
||||||
|
|
||||||
getNickPowerLevelMapping(nick: string): string {
|
getNickPowerLevelMapping(nick: string): string {
|
||||||
|
@ -82,11 +85,7 @@ export class Channel {
|
||||||
sendMode(client: Client, passedTags: Map<string, string>) {
|
sendMode(client: Client, passedTags: Map<string, string>) {
|
||||||
if (!client.user)
|
if (!client.user)
|
||||||
return;
|
return;
|
||||||
const chanModes = [];
|
client.sendMessage(client.server.name, "324", numerics["324"](client.user.nick, this.name, `+n`), passedTags);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sendTopic(client: Client, passedTags: Map<string, string>) {
|
sendTopic(client: Client, passedTags: Map<string, string>) {
|
||||||
|
@ -127,6 +126,12 @@ export class Channel {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch (event["type"]) {
|
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':
|
case 'm.room.join_rules':
|
||||||
this.handleMatrixJoinRule(event);
|
this.handleMatrixJoinRule(event);
|
||||||
break;
|
break;
|
||||||
|
@ -161,6 +166,9 @@ export class Channel {
|
||||||
case 'm.room.bot.options':
|
case 'm.room.bot.options':
|
||||||
case 'm.room.pinned_events':
|
case 'm.room.pinned_events':
|
||||||
case 'm.room.tombstone':
|
case 'm.room.tombstone':
|
||||||
|
case 'm.room.canonical_alias':
|
||||||
|
case 'm.room.server_acl':
|
||||||
|
case 'org.matrix.room.preview_urls':
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
console.log(event["type"]);
|
console.log(event["type"]);
|
||||||
|
@ -307,20 +315,24 @@ export class Channel {
|
||||||
console.log(`Warning: join rule not found in ${event}`);
|
console.log(`Warning: join rule not found in ${event}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (rule === "public") {
|
this.joinRules = rule;
|
||||||
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')) {
|
handleMatrixHistoryVisibility(event: any) {
|
||||||
this.modes.set('i', '');
|
const rule = event["content"]?.["history_visibility"];
|
||||||
this.ircUsers.forEach((user) => {
|
if (!rule) {
|
||||||
user.sendToAll(this.server.name, 'MODE', [this.name, '+i'], new Map());
|
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