Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 5c79f35

Browse files
authored
Merge pull request #5316 from matrix-org/travis/less-acl-noise
Make the ACL update message less noisy
2 parents 9234a58 + 161dc0b commit 5c79f35

File tree

2 files changed

+10
-36
lines changed

2 files changed

+10
-36
lines changed

src/TextForEvent.js

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -198,59 +198,30 @@ function textForRelatedGroupsEvent(ev) {
198198
function textForServerACLEvent(ev) {
199199
const senderDisplayName = ev.sender && ev.sender.name ? ev.sender.name : ev.getSender();
200200
const prevContent = ev.getPrevContent();
201-
const changes = [];
202201
const current = ev.getContent();
203202
const prev = {
204203
deny: Array.isArray(prevContent.deny) ? prevContent.deny : [],
205204
allow: Array.isArray(prevContent.allow) ? prevContent.allow : [],
206205
allow_ip_literals: !(prevContent.allow_ip_literals === false),
207206
};
207+
208208
let text = "";
209209
if (prev.deny.length === 0 && prev.allow.length === 0) {
210-
text = `${senderDisplayName} set server ACLs for this room: `;
210+
text = _t("%(senderDisplayName)s set the server ACLs for this room.", {senderDisplayName});
211211
} else {
212-
text = `${senderDisplayName} changed the server ACLs for this room: `;
212+
text = _t("%(senderDisplayName)s changed the server ACLs for this room.", {senderDisplayName});
213213
}
214214

215215
if (!Array.isArray(current.allow)) {
216216
current.allow = [];
217217
}
218-
/* If we know for sure everyone is banned, don't bother showing the diff view */
219-
if (current.allow.length === 0) {
220-
return text + "🎉 All servers are banned from participating! This room can no longer be used.";
221-
}
222-
223-
if (!Array.isArray(current.deny)) {
224-
current.deny = [];
225-
}
226-
227-
const bannedServers = current.deny.filter((srv) => typeof(srv) === 'string' && !prev.deny.includes(srv));
228-
const unbannedServers = prev.deny.filter((srv) => typeof(srv) === 'string' && !current.deny.includes(srv));
229-
const allowedServers = current.allow.filter((srv) => typeof(srv) === 'string' && !prev.allow.includes(srv));
230-
const unallowedServers = prev.allow.filter((srv) => typeof(srv) === 'string' && !current.allow.includes(srv));
231-
232-
if (bannedServers.length > 0) {
233-
changes.push(`Servers matching ${bannedServers.join(", ")} are now banned.`);
234-
}
235218

236-
if (unbannedServers.length > 0) {
237-
changes.push(`Servers matching ${unbannedServers.join(", ")} were removed from the ban list.`);
238-
}
239-
240-
if (allowedServers.length > 0) {
241-
changes.push(`Servers matching ${allowedServers.join(", ")} are now allowed.`);
242-
}
243-
244-
if (unallowedServers.length > 0) {
245-
changes.push(`Servers matching ${unallowedServers.join(", ")} were removed from the allowed list.`);
246-
}
247-
248-
if (prev.allow_ip_literals !== current.allow_ip_literals) {
249-
const allowban = current.allow_ip_literals ? "allowed" : "banned";
250-
changes.push(`Participating from a server using an IP literal hostname is now ${allowban}.`);
219+
// If we know for sure everyone is banned, mark the room as obliterated
220+
if (current.allow.length === 0) {
221+
return text + " " + _t("🎉 All servers are banned from participating! This room can no longer be used.");
251222
}
252223

253-
return text + changes.join(" ");
224+
return text;
254225
}
255226

256227
function textForMessageEvent(ev) {

src/i18n/strings/en_EN.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,9 @@
242242
"%(senderDisplayName)s enabled flair for %(groups)s in this room.": "%(senderDisplayName)s enabled flair for %(groups)s in this room.",
243243
"%(senderDisplayName)s disabled flair for %(groups)s in this room.": "%(senderDisplayName)s disabled flair for %(groups)s in this room.",
244244
"%(senderDisplayName)s enabled flair for %(newGroups)s and disabled flair for %(oldGroups)s in this room.": "%(senderDisplayName)s enabled flair for %(newGroups)s and disabled flair for %(oldGroups)s in this room.",
245+
"%(senderDisplayName)s set the server ACLs for this room.": "%(senderDisplayName)s set the server ACLs for this room.",
246+
"%(senderDisplayName)s changed the server ACLs for this room.": "%(senderDisplayName)s changed the server ACLs for this room.",
247+
"🎉 All servers are banned from participating! This room can no longer be used.": "🎉 All servers are banned from participating! This room can no longer be used.",
245248
"%(senderDisplayName)s sent an image.": "%(senderDisplayName)s sent an image.",
246249
"%(senderName)s set the main address for this room to %(address)s.": "%(senderName)s set the main address for this room to %(address)s.",
247250
"%(senderName)s removed the main address for this room.": "%(senderName)s removed the main address for this room.",

0 commit comments

Comments
 (0)