From 558521a5cfcf29ea4a23ed89beb0868170eecc7e Mon Sep 17 00:00:00 2001 From: Dimitris Efstathiou Date: Mon, 16 Dec 2024 20:46:08 +0200 Subject: [PATCH] pkp/pkp-lib#10630 Review Fixes --- api/v1/invitations/InvitationController.php | 4 +++- .../core/InvitationActionRedirectController.php | 2 +- .../ChangeProfileEmailInviteRedirectController.php | 2 +- .../RegistrationAccessInviteRedirectController.php | 2 +- .../handlers/ReviewerAccessInviteRedirectController.php | 2 +- .../userRoleAssignment/UserRoleAssignmentInvite.php | 1 - .../UserRoleAssignmentInviteRedirectController.php | 2 +- .../handlers/api/UserRoleAssignmentCreateController.php | 8 ++++++-- locale/en/invitation.po | 3 +++ 9 files changed, 17 insertions(+), 9 deletions(-) diff --git a/api/v1/invitations/InvitationController.php b/api/v1/invitations/InvitationController.php index b5273908f6e..8ddb286115a 100644 --- a/api/v1/invitations/InvitationController.php +++ b/api/v1/invitations/InvitationController.php @@ -359,7 +359,9 @@ public function cancel(Request $illuminateRequest): JsonResponse try { return $this->selectedHandler->cancel(); } catch (\Exception $e) { - return response()->json([], Response::HTTP_INTERNAL_SERVER_ERROR); + return response()->json([ + 'error' => $e->getMessage() + ], Response::HTTP_INTERNAL_SERVER_ERROR); } } diff --git a/classes/invitation/core/InvitationActionRedirectController.php b/classes/invitation/core/InvitationActionRedirectController.php index 645304b30ba..c3975bffb10 100644 --- a/classes/invitation/core/InvitationActionRedirectController.php +++ b/classes/invitation/core/InvitationActionRedirectController.php @@ -27,7 +27,7 @@ public function __construct(Invitation $invitation) $this->invitation = $invitation; } - abstract public function preRedirectActions(InvitationAction $action); + abstract public function preRedirectActions(InvitationAction $action): void; abstract public function acceptHandle(Request $request): void; abstract public function declineHandle(Request $request): void; diff --git a/classes/invitation/invitations/changeProfileEmail/handlers/ChangeProfileEmailInviteRedirectController.php b/classes/invitation/invitations/changeProfileEmail/handlers/ChangeProfileEmailInviteRedirectController.php index c7ec84f3f54..b4c5183cc10 100644 --- a/classes/invitation/invitations/changeProfileEmail/handlers/ChangeProfileEmailInviteRedirectController.php +++ b/classes/invitation/invitations/changeProfileEmail/handlers/ChangeProfileEmailInviteRedirectController.php @@ -79,7 +79,7 @@ public function declineHandle(Request $request): void $request->redirectUrl($url); } - public function preRedirectActions(InvitationAction $action) + public function preRedirectActions(InvitationAction $action): void { if ($action == InvitationAction::ACCEPT) { $this->getInvitation()->finalize(); diff --git a/classes/invitation/invitations/registrationAccess/handlers/RegistrationAccessInviteRedirectController.php b/classes/invitation/invitations/registrationAccess/handlers/RegistrationAccessInviteRedirectController.php index 5b3a1c851cf..1beacbaf31a 100644 --- a/classes/invitation/invitations/registrationAccess/handlers/RegistrationAccessInviteRedirectController.php +++ b/classes/invitation/invitations/registrationAccess/handlers/RegistrationAccessInviteRedirectController.php @@ -107,7 +107,7 @@ public function declineHandle(Request $request): void $request->redirectUrl($url); } - public function preRedirectActions(InvitationAction $action) + public function preRedirectActions(InvitationAction $action): void { if ($action == InvitationAction::ACCEPT) { $this->getInvitation()->finalize(); diff --git a/classes/invitation/invitations/reviewerAccess/handlers/ReviewerAccessInviteRedirectController.php b/classes/invitation/invitations/reviewerAccess/handlers/ReviewerAccessInviteRedirectController.php index 08e9af29fcc..a53ea65fb39 100644 --- a/classes/invitation/invitations/reviewerAccess/handlers/ReviewerAccessInviteRedirectController.php +++ b/classes/invitation/invitations/reviewerAccess/handlers/ReviewerAccessInviteRedirectController.php @@ -85,7 +85,7 @@ public function declineHandle(Request $request): void $request->redirectUrl($url); } - public function preRedirectActions(InvitationAction $action) + public function preRedirectActions(InvitationAction $action): void { return; } diff --git a/classes/invitation/invitations/userRoleAssignment/UserRoleAssignmentInvite.php b/classes/invitation/invitations/userRoleAssignment/UserRoleAssignmentInvite.php index 91fc0ce9f0f..ce4791110a0 100644 --- a/classes/invitation/invitations/userRoleAssignment/UserRoleAssignmentInvite.php +++ b/classes/invitation/invitations/userRoleAssignment/UserRoleAssignmentInvite.php @@ -35,7 +35,6 @@ use PKP\invitation\invitations\userRoleAssignment\rules\UserMustExistRule; use PKP\mail\mailables\UserRoleAssignmentInvitationNotify; use PKP\security\Validation; -use PKP\user\User; class UserRoleAssignmentInvite extends Invitation implements IApiHandleable { diff --git a/classes/invitation/invitations/userRoleAssignment/handlers/UserRoleAssignmentInviteRedirectController.php b/classes/invitation/invitations/userRoleAssignment/handlers/UserRoleAssignmentInviteRedirectController.php index c0bc4ed4225..1cfa72210cd 100644 --- a/classes/invitation/invitations/userRoleAssignment/handlers/UserRoleAssignmentInviteRedirectController.php +++ b/classes/invitation/invitations/userRoleAssignment/handlers/UserRoleAssignmentInviteRedirectController.php @@ -93,7 +93,7 @@ public function declineHandle(Request $request): void $request->redirectUrl($url); } - public function preRedirectActions(InvitationAction $action) + public function preRedirectActions(InvitationAction $action): void { return; } diff --git a/classes/invitation/invitations/userRoleAssignment/handlers/api/UserRoleAssignmentCreateController.php b/classes/invitation/invitations/userRoleAssignment/handlers/api/UserRoleAssignmentCreateController.php index cf19d9b9cc5..dc3ea00db1a 100644 --- a/classes/invitation/invitations/userRoleAssignment/handlers/api/UserRoleAssignmentCreateController.php +++ b/classes/invitation/invitations/userRoleAssignment/handlers/api/UserRoleAssignmentCreateController.php @@ -162,7 +162,9 @@ public function cancel(): JsonResponse $result = $this->invitation->updateStatus(InvitationStatus::CANCELLED); if (!$result) { - return response()->json([], Response::HTTP_CONFLICT); + return response()->json([ + 'error' => __('invitation.api.error.operationFailed') + ], Response::HTTP_UNPROCESSABLE_ENTITY); } return response()->json([], Response::HTTP_OK); @@ -173,7 +175,9 @@ public function getMailable(): JsonResponse $mailable = $this->invitation->getMailable(); if (!isset($mailable)) { - return response()->json([], Response::HTTP_NOT_FOUND); + return response()->json([ + 'error' => __('invitation.api.error.invitationTypeNotHasMailable') + ], Response::HTTP_NOT_FOUND); } return response()->json([ diff --git a/locale/en/invitation.po b/locale/en/invitation.po index 4388feb8849..19fcb9d9417 100644 --- a/locale/en/invitation.po +++ b/locale/en/invitation.po @@ -70,6 +70,9 @@ msgstr "For added user groups, a masthead must be provided" msgid "invitation.api.error.invitationTypeNotHasMailable" msgstr "This invitation type does not have a mailable defined" +msgid "invitation.api.error.operationFailed" +msgstr "This invitation operation failed" + msgid "invitation.userRoleAssignment.validation.error.addUserRoles.userGroupNotExisting" msgstr "The provided user group ID {$userGroupId} does not exist"