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

Merged
merged 5 commits into from Mar 15, 2017

Conversation

Projects
None yet
2 participants
Owner

erikjohnston commented Mar 15, 2017

No description provided.

synapse/api/filtering.py
- # 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

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

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.
synapse/api/filtering.py
+ sender = event.get("sender", None)
+ if not sender:
+ # Presence events have their 'sender' in content.user_id
+ content = event.get("content")
@NegativeMjark

NegativeMjark Mar 15, 2017

Contributor

Is this still needed? It looks like it is presence specific and presence should be handled as UserPresenceState tuples/

@erikjohnston

erikjohnston Mar 15, 2017

Owner

Does account data have a sender?

@NegativeMjark

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

Contributor

NegativeMjark commented Mar 15, 2017

Other than updating the comment for #2013 (diff) LGTM

@erikjohnston erikjohnston merged commit 9d52719 into develop Mar 15, 2017

0 of 5 checks passed

Sytest Dendron (Merged PR) Build triggered. sha1 is merged.
Details
Sytest Postgres (Merged PR) Build triggered. sha1 is merged.
Details
Sytest SQLite (Merged PR) Build started sha1 is merged.
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details

@erikjohnston erikjohnston deleted the erikj/presence_FASTER branch Oct 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment