Skip to content

Commit

Permalink
fix: Wrong default value in recipients
Browse files Browse the repository at this point in the history
  • Loading branch information
siderai committed May 24, 2023
1 parent b86e8da commit 20e2b37
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion botx/bots/mixins/requests/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async def send_command_result(
silent_response=payload.options.silent_response,
),
),
recipients=payload.options.recipients,
recipients=payload.options.recipients or "all",
file=payload.file,
opts=ResultOptions(
stealth_mode=payload.options.stealth_mode,
Expand Down
2 changes: 1 addition & 1 deletion botx/bots/mixins/requests/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async def send_notification(
silent_response=payload.options.silent_response,
),
),
recipients=payload.options.recipients,
recipients=payload.options.recipients or "all",
file=payload.file,
opts=ResultOptions(
stealth_mode=payload.options.stealth_mode,
Expand Down
3 changes: 1 addition & 2 deletions botx/clients/methods/v3/notification/direct_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ class NotificationDirect(AuthorizedBotXMethod[UUID]):
event_sync_id: Optional[UUID] = None

#: HUIDs of users that should receive notifications.
recipients: AvailableRecipients = "all"

recipients: Optional[AvailableRecipients] = None
#: data for build message: body, markup, mentions.
result: ResultPayload = Field(..., alias="notification")

Expand Down
4 changes: 2 additions & 2 deletions botx/models/messages/sending/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ def add_recipient(self, recipient: UUID) -> None:
Arguments:
recipient: recipient for message.
"""
if self.payload.options.recipients == "all":
if not isinstance(self.payload.options.recipients, list):
self.payload.options.recipients = []

self.payload.options.recipients.append(recipient)
Expand All @@ -449,7 +449,7 @@ def add_recipients(self, recipients: List[UUID]) -> None:
Arguments:
recipients: recipients for message.
"""
if self.payload.options.recipients == "all":
if not isinstance(self.payload.options.recipients, list):
self.payload.options.recipients = []

self.payload.options.recipients.extend(recipients)
Expand Down
4 changes: 2 additions & 2 deletions botx/models/messages/sending/options.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Special options for message."""

from typing import List
from typing import List, Optional

from botx.models.base import BotXBaseModel
from botx.models.entities import Mention
Expand Down Expand Up @@ -28,7 +28,7 @@ class MessageOptions(BotXBaseModel):
"""Message options configuration."""

#: users that should receive message.
recipients: AvailableRecipients = "all"
recipients: Optional[AvailableRecipients] = None

#: attached to message mentions.
mentions: List[Mention] = []
Expand Down

0 comments on commit 20e2b37

Please sign in to comment.