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

Commit f9029cd

Browse files
committed
Make the ACL update message less noisy
Fixes element-hq/element-web#14216 Copy is not reviewed as of writing.
1 parent 4425ae3 commit f9029cd

File tree

1 file changed

+6
-35
lines changed

1 file changed

+6
-35
lines changed

src/TextForEvent.js

Lines changed: 6 additions & 35 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 = `${senderDisplayName} set server ACLs for this room. `;
211211
} else {
212-
text = `${senderDisplayName} changed the server ACLs for this room: `;
212+
text = `${senderDisplayName} changed the server ACLs for this room. `;
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 */
218+
219+
// If we know for sure everyone is banned, mark the room as obliterated
219220
if (current.allow.length === 0) {
220221
return text + "🎉 All servers are banned from participating! This room can no longer be used.";
221222
}
222223

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-
}
235-
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}.`);
251-
}
252-
253-
return text + changes.join(" ");
224+
return text.trim();
254225
}
255226

256227
function textForMessageEvent(ev) {

0 commit comments

Comments
 (0)