settings: Add two realm settings to restrict direct messages.

Fixes #24467.
This commit is contained in:
Vector73
2024-07-08 22:30:08 +05:30
committed by Tim Abbott
parent 318d3e3cca
commit 6098c2cebe
45 changed files with 975 additions and 209 deletions

View File

@@ -519,6 +519,25 @@ class InvitationError(JsonableError):
self.daily_limit_reached: bool = daily_limit_reached
class DirectMessageInitiationError(JsonableError):
def __init__(self) -> None:
pass
@staticmethod
@override
def msg_format() -> str:
return _("You do not have permission to initiate direct message conversations.")
class DirectMessagePermissionError(JsonableError):
def __init__(self, is_nobody_group: bool) -> None:
if is_nobody_group:
msg = _("Direct messages are disabled in this organization.")
else:
msg = _("You do not have permission to send direct messages to this recipient.")
super().__init__(msg)
class AccessDeniedError(JsonableError):
http_status_code = 403