Allow users to appear anonymously while spectating games #537
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.
Loads the value created in lichess-org/lila#14775 from MongoDB and modifies the table of spectators to store whether that user appears anonymously or not.
Then, when reporting the room status, will add users appearing anonymously to the anon count and remove them from the list of users specified.
User spectating a game anonymously using this setting:
The only thing I was not sure about was whether or not to look up the user's preference in MongoDB or have it be sent as part of the call to the websocket. I chose to do the lookup here to decouple the logic more but I can see the extra db call being something we would want to avoid. Another option would be to not care about the user's preference all all while connecting but to handle it when the room's status is requested, but I felt that would lead to an extremely large number of db calls.