Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

500 when accepting follow requests #2651

Closed
HerrLevin opened this issue Jun 3, 2024 · 3 comments · Fixed by #2770
Closed

500 when accepting follow requests #2651

HerrLevin opened this issue Jun 3, 2024 · 3 comments · Fixed by #2770
Labels
bug Something isn't working verified The problem was verified by a Teammember

Comments

@HerrLevin
Copy link
Member

Describe the bug

In very rare cases it's possible to provoke an error 500 (AlreadyFollowingException) when accepting a follow request

Steps to reproduce

This cannot easily be reproduced without manipulating the database.

  1. Table follows
id|user_id|follow_id|created_at             |updated_at             |
--+-------+---------+-----------------------+-----------------------+
 1|      1|        2|2024-04-19 13:07:10.000|2024-04-19 13:07:10.000|
  1. Table follow_requests
id|user_id|follow_id|created_at             |updated_at             |
--+-------+---------+-----------------------+-----------------------+
 1|      1|        2|2024-04-19 12:00:01.000|2024-04-19 12:00:01.000|
  1. Accept follow-reqeust

Browser console logs

No response

Browser

No response

@HerrLevin HerrLevin added the bug Something isn't working label Jun 3, 2024
@HerrLevin
Copy link
Member Author

Idea: try/catch around the follow acceptance and just remove the follow request if THIS exception occurs

@HerrLevin HerrLevin added the verified The problem was verified by a Teammember label Jun 3, 2024
@MrKrisKrisu
Copy link
Member

I cannot find the cause of your problem. We have two endpoints APIv1 and legacy frontend. Both Endpoints catches the AlreadyFollowingException and don't return HTTP 500 then.

} catch (AlreadyFollowingException) {
return $this->sendError(['message' => __('controller.user.follow-error')], 409);

} catch (AlreadyFollowingException) {
return response()->json(['message' => __('controller.user.follow-request-already-exists')], 409);

@HerrLevin
Copy link
Member Author

No, it's in

public static function approveFollower(int $userId, int $approverId): bool {
$request = FollowRequest::where('user_id', $approverId)->where('follow_id', $userId)->firstOrFail();
$follow = UserController::createFollow($request->user, $request->requestedFollow, true);
if ($follow) {
$request->delete();
}
return $follow;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working verified The problem was verified by a Teammember
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants