Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape discord invites even if they don’t use https:// #57

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/helpers/discord.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ test("escapeDisruptiveContent", () => {
expect(escapeDisruptiveContent("https://example.com")).toBe(
"<https://example.com>",
);
expect(escapeDisruptiveContent("discord.gg/butts")).toBe(
"<discord.gg/butts>",
);
expect(
escapeDisruptiveContent("test stuff discord.gg/butts wrapped around"),
).toBe("test stuff <discord.gg/butts> wrapped around");
expect(
escapeDisruptiveContent(
"some dumb text https://example.com with a link and text",
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/discord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const describeAttachments = (attachments: Message["attachments"]) => {
.join("\n");
};

const urlRegex = /(https?:\/\/\S+)\b/g;
const urlRegex = /(https?:\/\/\S+|discord.gg\/\S+)\b/g;
/*
* Escape content that Discord would otherwise do undesireable things with.
* Sepecifically, suppresses @-mentions and link previews.
Expand Down
17 changes: 17 additions & 0 deletions todo
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

track audit logs in realtime
on delete/ban/kick/etc, check for an associated audit log
if no, wait 500ms and try again, up to 3x
add retry helper

async pairing essentially. unreliable delivery, dual queue of messages/audit logs
TTL cache for deleted messages/kicks/bans + audit logs
for each audit log, schedule a task for 1s later to seek an associated message and print log. Retry up to 3x





Surface actions taken by mods in a more intuitive way for members.
Concept of "oversight board" separate from moderators.
Message deletions, kicks, bans
Loading