Skip to content

Commit

Permalink
requests: better error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lnielsen committed Feb 19, 2024
1 parent c78649a commit 358bf33
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions invenio_requests/customizations/user_moderation/user_moderation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from invenio_i18n import lazy_gettext as _
from invenio_users_resources.proxies import current_users_service
from marshmallow import ValidationError

from invenio_requests.customizations import RequestType, actions

Expand All @@ -18,7 +19,11 @@ class DeclineUserAction(actions.DeclineAction):
def execute(self, identity, uow):
"""Executes block action."""
user = self.request.topic.resolve()
current_users_service.block(identity, user.id, uow=uow)
try:
current_users_service.block(identity, user.id, uow=uow)
except ValidationError:
# User already blocked so just ignore
pass
super().execute(identity, uow)


Expand All @@ -28,7 +33,11 @@ class AcceptUserAction(actions.AcceptAction):
def execute(self, identity, uow):
"""Executes approve action."""
user = self.request.topic.resolve()
current_users_service.approve(identity, user.id, uow=uow)
try:
current_users_service.approve(identity, user.id, uow=uow)
except ValidationError:
# User already approved so just ignore
pass
super().execute(identity, uow)


Expand Down

0 comments on commit 358bf33

Please sign in to comment.