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

[BUG]: Modmail thinks a channel is a thread if a user ID is found within the topics #3114

Closed
Taaku18 opened this issue Oct 29, 2021 · 2 comments · Fixed by #3111
Closed

[BUG]: Modmail thinks a channel is a thread if a user ID is found within the topics #3114

Taaku18 opened this issue Oct 29, 2021 · 2 comments · Fixed by #3111
Labels
bug This is a confirmed bug staged Staged for next version

Comments

@Taaku18
Copy link
Collaborator

Taaku18 commented Oct 29, 2021

Bot Version

v3.10.2

How are you hosting Modmail?

Other

Error Logs

See section below:

Screenshots

Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 343, in _run_event
    await coro(*args, **kwargs)
  File "/modmailbot/bot.py", line 1141, in on_message
    await self.process_commands(message)
  File "/modmailbot/bot.py", line 1148, in process_commands
    return await self.process_dm_modmail(message)
  File "/modmailbot/bot.py", line 907, in process_dm_modmail
    thread = await self.threads.find(recipient=message.author)
  File "/modmailbot/core/thread.py", line 1215, in find
    thread = await Thread.from_channel(self, channel)
  File "/modmailbot/core/thread.py", line 129, in from_channel
    recipient = manager.bot.get_user(recipient_id) or await manager.bot.fetch_user(recipient_id)
  File "/usr/local/lib/python3.9/site-packages/discord/client.py", line 1384, in fetch_user
    data = await self.http.get_user(user_id)
  File "/usr/local/lib/python3.9/site-packages/discord/http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In user_id: snowflake value should be greater than or equal to 0.

Additional Information

Currently any @user (<@!1234>) or just the ID in a non-related channel's topic would cause Modmail to believe that the user has an open thread there. When the user do contact Modmail, that error would be raised.

There needs to be a better check here:
https://github.com/kyb3r/modmail/blob/master/core/thread.py#L1209

Instead of str(recipient_id) in x.topic, use x.topic and utils.match_user_id(x.topic) == recipient_id.

@Taaku18 Taaku18 added maybe: bug An unconfirmed bug bug This is a confirmed bug and removed maybe: bug An unconfirmed bug labels Oct 29, 2021
@fourjr fourjr added the staged Staged for next version label Nov 21, 2021
@fourjr fourjr linked a pull request Nov 21, 2021 that will close this issue
@StephenDaDev
Copy link
Member

@Taaku18 Is this still an issue after 4JR's PR?

@Taaku18
Copy link
Collaborator Author

Taaku18 commented Jul 10, 2022

@Taaku18 Is this still an issue after 4JR's PR?

Nope, should be fixed.

@Taaku18 Taaku18 closed this as completed Jul 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This is a confirmed bug staged Staged for next version
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants