Skip to content

Commit

Permalink
bugfix: fixed friends accepting
Browse files Browse the repository at this point in the history
  • Loading branch information
SlashLight committed Dec 18, 2024
1 parent 9354cc8 commit 532f897
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/profile/repository/QueryConsts.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const (
UpdateProfileAvatar = "UPDATE profile SET avatar = $2, first_name = $3, last_name = $4, bio = $5 WHERE id = $1;"
DeleteProfile = "DELETE FROM profile WHERE id = $1;"
AddFriends = "INSERT INTO friend(sender, receiver, status) VALUES ($1, $2, 1);"
AcceptFriendReq = "UPDATE friend SET status = 0 WHERE sender = $1 AND receiver = $2;"
AcceptFriendReq = "UPDATE friend SET status = 0 WHERE (sender = $1 AND receiver = $2) OR (sender = $2 AND receiver = $1);"
RemoveFriendsReq = "UPDATE friend SET status = ( CASE WHEN sender = $1 THEN -1 ELSE 1 END) WHERE (receiver = $1 AND sender = $2) OR (sender = $1 AND receiver = $2);"
GetAllFriends = "WITH friends AS (SELECT sender AS friend FROM friend WHERE (receiver = $1 AND status = 0) UNION SELECT receiver AS friend FROM friend WHERE (sender = $1 AND status = 0)) SELECT profile.id, first_name, last_name, avatar FROM profile INNER JOIN friends ON friend = profile.id WHERE profile.id > $2 ORDER BY profile.id LIMIT $3;"
GetAllSubs = "WITH subs AS ( SELECT sender AS subscriber FROM friend WHERE (receiver = $1 AND status = 1) UNION SELECT receiver AS subscriber FROM friend WHERE (sender = $1 AND status = -1)) SELECT profile.id, first_name, last_name, avatar FROM profile INNER JOIN subs ON subscriber = profile.id WHERE profile.id > $2 ORDER BY profile.id LIMIT $3;"
Expand Down

0 comments on commit 532f897

Please sign in to comment.