8000 Allow deleting moved messages by 00-kat · Pull Request #219 · ghostty-org/discord-bot · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow deleting moved messages #219

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Allow deleting moved messages #219

wants to merge 7 commits into from

Conversation

00-kat
Copy link
Collaborator
@00-kat 00-kat commented May 1, 2025

Closes half of section three of #155, and lays the groundwork for the other half.

It's not perfect, but I doubt the few edge cases would ever occur.

Copy link
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for deleting moved messages while refining the moved message processing workflow. Key changes include updates to message data handling (switching to a MessageData.scrape method and using files instead of attachments), the addition of test cases for snowflake extraction and moved message author detection, and the introduction of a context menu command for deleting moved messages.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/test_message_moving.py Adds comprehensive tests for snowflake extraction and moved message author logic.
app/utils/webhooks.py Updates moved message formatting, replaces attachment handling with files, and renames a parameter.
app/utils/message_data.py Switches to a MessageData subclass with asynchronous file scraping.
app/utils/init.py Updates imports to reflect changes in message data handling.
app/core.py Minor comment update for consistency.
app/components/zig_codeblocks.py Adjusts call to move_message_via_webhook with a flag to disable move markers.
app/components/move_message.py Introduces a context menu command to delete moved messages and updates permissions handling.
app/components/github_integration/mentions/resolution.py Updates comment capitalization for consistency.

@00-kat
Copy link
Collaborator Author
00-kat commented May 1, 2025

I'll deal with the CI failure tomorrow (I didn't catch it before because Ruff 0.9.10, which is what I use, handles it correctly, while Ruff 0.9.6, which is what the CI uses as it is what is in the lockfile, doesn't).

I would like a suggestion on what to do:

  • Bump Ruff.
  • Add a noqa.

@trag1c
Copy link
Member
trag1c commented May 1, 2025

Let's bump ruff to v0.11.78 :)

@00-kat 00-kat force-pushed the 0x7f branch 2 times, most recently from 12c005a to 858c6e2 Compare May 2, 2025 02:36
@00-kat 00-kat mentioned this pull request May 1, 2025
13 tasks
@00-kat 00-kat force-pushed the 0x7f branch 2 times, most recently from f46ba14 to 7a8789e Compare May 2, 2025 03:09
@00-kat 00-kat force-pushed the 0x7f branch 3 times, most recently from 5d27463 to f20a330 Compare May 2, 2025 03:25
@00-kat

This comment was marked as outdated.

@00-kat 00-kat force-pushed the 0x7f branch 2 times, most recently from ac73a22 to 878fa83 Compare May 2, 2025 10:51
@00-kat 00-kat marked this pull request as draft May 2, 2025 11:17
@00-kat 00-kat force-pushed the 0x7f branch 8 times, most recently from 14bb084 to 9a9b0a5 Compare May 4, 2025 11:56
@00-kat 00-kat mentioned this pull request May 4, 2025
@00-kat 00-kat force-pushed the 0x7f branch 2 times, most recently from 727fa5a to 44aa13b Compare May 5, 2025 06:38
@00-kat
Copy link
Collaborator Author

Note: there is currently a known issue, where moved moved messages cannot be deleted, but I don't want to fix it now since it's an exceptionally rare case and it requires parsing the subtext, which I started in another commit and am not in the mood to do the commit surgery to reorder into this one.

@00-kat 00-kat marked this pull request as ready for review May 5, 2025 12:55
@00-kat 00-kat force-pushed the 0x7f branch 9 times, most recently from c1bf257 to 4a51c7b Compare May 10, 2025 11:05
@00-kat 00-kat force-pushed the 0x7f branch 2 times, most recently from 249627a to 0d04362 Compare May 10, 2025 12:27
@00-kat 00-kat requested a review from trag1c May 10, 2025 12:28
@00-kat 00-kat force-pushed the 0x7f branch 2 times, most recently from 017819a to 13d287b Compare May 25, 2025 10:26
Copy link
Member
@trag1c trag1c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, I just have a couple of more high-level concerns.

Comment on lines +309 to +312
# WARNING: get_moved_message_author_id() makes a lot of assumptions about
# the structure of the subtext; be careful when editing this as
# invalidating the previous expected structure can break editing and
# deletion of messages moved before the change was merged or ALLOW THE
# WRONG PERSON TO EDIT OR DELETE A MOVED MESSAGE, *even if* that function
# is updated to match the new structure, as this subtext change won't
# retroactively apply to previously moved messages on Discord's servers.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering whether we could counteract this neatly, e.g. by versioning the format somehow and deciding which format to check based on message timestamp. Obviously the ALLOW THE WRONG PERSON TO EDIT OR DELETE A MOVED MESSAGE scenario isn't very likely to happen, but it's still something we can consider I think.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Message timestamp checks does sound like a good idea! It would definitely make the future changes for editing moved messages less fragile. An alternate I can think of is inserting zero-width spaces in the subtext, though that does sound hacky.

Copy link
Collaborator Author
@00-kat 00-kat Jun 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I just realised, one problem with timestamp checks is that the timestamp would need to be updated when the bot is redeployed rather than when the change is made, which would be annoying to do correctly…

So should I use timestamps or something else?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

which would be annoying to do correctly

I think it would be best if I pushed a change to update the timestamp right before deploying (maybe I could move it a minute or two forward to account for the redeploy time). Worst case scenario there would be a small X-minute window of wrong edits/deletions being allowed, but users don't even know when a redeploy happens I believe.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hard part is remembering 😛.

@00-kat 00-kat force-pushed the 0x7f branch 3 times, most recently from 425efa8 to 097709d Compare June 16, 2025 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0