Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
Format presence events on the edges instead of reformatting them multiple times #2013
Conversation
erikjohnston
assigned
NegativeMjark
Mar 15, 2017
| - # account_data has been allowed to have non-dict content, so check type first | ||
| - if isinstance(content, dict): | ||
| - sender = content.get("user_id") | ||
| + if isinstance(event, UserPresenceState): |
NegativeMjark
Mar 15, 2017
Contributor
Could you comment what's going on here? Just a quick comment to explain why both branches are necessary would be enough.
| @@ -979,14 +981,15 @@ def should_notify(old_state, new_state): | ||
| return False | ||
| -def format_user_presence_state(state, now): | ||
| +def format_user_presence_state(state, now, include_user_id=True): | ||
| """Convert UserPresenceState to a format that can be sent down to clients | ||
| and to other servers. |
NegativeMjark
Mar 15, 2017
Contributor
Maybe add a comment to explain why the "user_id" is optional? something like
The "user_id" is optional so that this function can be used to format presence
updates for client /sync responses and for federation /send requests.
| + sender = event.get("sender", None) | ||
| + if not sender: | ||
| + # Presence events have their 'sender' in content.user_id | ||
| + content = event.get("content") |
NegativeMjark
Mar 15, 2017
Contributor
Is this still needed? It looks like it is presence specific and presence should be handled as UserPresenceState tuples/
NegativeMjark
Mar 15, 2017
Contributor
I don't remember tbh. I think only presence has a content.user_id though.
erikjohnston
added some commits
Mar 15, 2017
|
Other than updating the comment for #2013 (diff) LGTM |
erikjohnston commentedMar 15, 2017
No description provided.