Skip to content

Commit

Permalink
pkp#10630 Review Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
defstat committed Dec 16, 2024
1 parent e55af97 commit 558521a
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 9 deletions.
4 changes: 3 additions & 1 deletion api/v1/invitations/InvitationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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([
Expand Down
3 changes: 3 additions & 0 deletions locale/en/invitation.po
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit 558521a

Please sign in to comment.