Skip to content
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/modmail-dev/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section.

# Unreleased

### Fixed
* Confirm thread creation (react to contact) no longer leaves a thread stuck in a "not ready" cache state when the recipient has DMs disabled. The bot now catches `discord.Forbidden` when sending the confirmation prompt, cancels the thread, and clears the cache entry immediately instead of requiring a bot restart. (#3442)

# v4.2.1

### Added
Expand Down
29 changes: 21 additions & 8 deletions core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -2635,14 +2635,27 @@ async def create(
self.bot.config["confirm_thread_creation_deny"],
)
)
confirm = await destination.send(
embed=discord.Embed(
title=self.bot.config["confirm_thread_creation_title"],
description=self.bot.config["confirm_thread_response"],
color=self.bot.main_color,
),
view=view,
)
try:
confirm = await destination.send(
embed=discord.Embed(
title=self.bot.config["confirm_thread_creation_title"],
description=self.bot.config["confirm_thread_response"],
color=self.bot.main_color,
),
view=view,
)
except discord.Forbidden:
# Recipient has DMs disabled (or otherwise unreachable). Without this,
# the thread would stay stuck in cache in a "not ready" state until a
# bot restart, since view.wait() below would never run.
logger.warning(
"Could not send confirm-thread-creation message to %s, DMs are likely disabled.",
recipient,
)
thread.cancelled = True
del self.cache[recipient.id]
return thread

await view.wait()
if view.value is None:
thread.cancelled = True
Expand Down
14 changes: 7 additions & 7 deletions plugins/registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
},
"claim": {
"repository": "fourjr/modmail-plugins",
"branch": "v4",
"description": "Allows supporters to claim thread by sending ?claim in the thread channel",
"bot_version": "4.0.0",
"repository": "martinbndr/kyb3r-modmail-plugins",
"branch": "master",
"description": "Adds claim functionality to your modmail bot.",
"bot_version": "4.2.1",
"title": "Claim Thread",
"icon_url": "https://i.imgur.com/Mo60CdK.png",
"thumbnail_url": "https://i.imgur.com/Mo60CdK.png"
"icon_url": "https://i.ibb.co/dsPjgKLj/87249157.png",
"thumbnail_url": "https://i.ibb.co/dsPjgKLj/87249157.png"
},
"emote-manager": {
"repository": "fourjr/modmail-plugins",
Expand Down Expand Up @@ -125,4 +125,4 @@
"icon_url": "https://i.imgur.com/A1auJ95.png",
"thumbnail_url": "https://i.imgur.com/A1auJ95.png"
}
}
}
Loading