Skip to content

Commit

Permalink
fix: prevent crash when trying to msg other workers
Browse files Browse the repository at this point in the history
  • Loading branch information
db0 committed Jan 28, 2025
1 parent 9ea3d23 commit 04be4e4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ SPDX-License-Identifier: AGPL-3.0-or-later

# Changelog

# 4.46.1

Fixes crash when trying to set messages to foreign workers

# 4.46.0

* Adds worker messages in `api/v2/workers/messages` endpoints. Worker messages can be set by horde moderators or by their own workers and will (soon) be returned to the workers every time they pop a request as a way to send them important messages since when we don't have any other method of communication with them.
Expand Down
4 changes: 2 additions & 2 deletions horde/apis/v2/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3298,8 +3298,8 @@ def post(self):
raise e.WorkerNotFound(self.args.worker_id)
if not user.moderator:
self.origin = str(user.id)
if worker and worker.user_id != self.user.id:
raise e.Forbidden("You can only send messages to your own workers.")
if worker and worker.user_id != user.id:
raise e.Forbidden("You can only send messages to your own workers.", rc="MessagesOnlyOwnWorkers")
self.expiry = self.args.expiry
# Max expiry is 30 days
if self.expiry and self.expiry > 30 * 24:
Expand Down
1 change: 1 addition & 0 deletions horde/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
"StyleGetMistmatch",
"TooManyStyleExamples",
"ExampleURLAlreadyInUse",
"MessagesOnlyOwnWorkers",
]


Expand Down

0 comments on commit 04be4e4

Please sign in to comment.