Enforce the 200 friend limit on both users and await request acceptance - #31
Open
tintinhamans wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Database.Social.CountFriendsquery.CS8602warning suppressions with real null checks on the caller's shared user data.The friends limit was effectively advisory.
AddFriendnotified the client that thelist was full but then carried on and created the request anyway, and
AcceptPendingRequesthad no limit check at all, so a user could sit at the cap andkeep accepting incoming requests.
The limit was also one-sided. Because a friendship writes to both users' lists,
accepting a request could push the other user past 200 even when the acting user
had room.
Separately,
HelperFunction_AcceptFriendRequestwas invoked withoutawait. Therequest could return, and the friends-list-dirty notifications could fire, before the
friendship row and cache updates had actually been written.
SocialControllerFriendsLimitconstant and aRejectIfFriendsListFullhelper that notifiesevery session of the user and returns
403 Forbidden.AcceptPendingRequestandAddFriend.HelperFunction_AcceptFriendRequestnow verifies the target has room before creatingthe friendship and returns a
boolso callers can respond with403and skip thefriends-list-dirty notifications when nothing was created.
GetSharedDataForUserlookups into the sign-in guards and reused theresult, removing the duplicate lookups and the pragma suppressions.
Database.SocialCountFriends, a compiled query for a user's friendship count.int.MaxValue, so an unreadable count blocks thefriendship rather than silently bypassing the limit.
POST Friends/Requests/{id}returns403when the accepting user is at the limit,and also emits
SOCIAL_CANT_ADD_FRIEND_LIST_FULLto their sessions.POST Friends/Requests/{id}andPUT Friends/Requests/{id}return403withoutthe websocket message when the other user is at the limit.
PUT Friends/Requests/{id}no longer creates a pending request once the requester isat the limit; previously it warned and continued.