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

Add a user directory #2252

Merged
merged 34 commits into from Jun 1, 2017

Conversation

Projects
None yet
2 participants
Owner

erikjohnston commented May 31, 2017

No description provided.

erikjohnston added some commits May 31, 2017

synapse/handlers/user_directory.py
+ None if the field in the events either both match `public_value` o
+ neither do, i.e. there has been no change.
+ True if it didnt match `public_value` but now does
+ Falsse if it did match `public_value` but now doesn't
@NegativeMjark

NegativeMjark May 31, 2017

Contributor

Falsse

synapse/handlers/user_directory.py
+ `shared` to `world_readable` (`public_value`).
+
+ Returns:
+ None if the field in the events either both match `public_value` o
synapse/handlers/user_directory.py
+ defer.returnValue(None)
+
+ prev_hist_vis = None
+ hist_vis = None
@NegativeMjark

NegativeMjark May 31, 2017

Contributor

hist_vis

synapse/handlers/user_directory.py
+ if change:
+ yield self._handle_new_user(room_id, user_id, profile)
+ else:
+ yield self._handle_remove_user(room_id, user_id)
@NegativeMjark

NegativeMjark May 31, 2017

Contributor

It looks like lines 204-221 are duplicates of 172-197. Maybe lift them into a function?

erikjohnston added some commits May 31, 2017

+ avatar_url TEXT
+);
+
+CREATE INDEX user_directory_room_idx ON user_directory(room_id);
@NegativeMjark

NegativeMjark May 31, 2017

Contributor

Maybe add a UNIQUE index.

@erikjohnston

erikjohnston May 31, 2017

Owner

Probably not on room_id, no.

But I've added one to user_id.

+ WHERE stream_id > ?
+ GROUP BY stream_id
+ ORDER BY stream_id ASC
+ LIMIT 100

erikjohnston added some commits May 31, 2017

synapse/handlers/user_directory.py
+
+ Returns:
+ None if the field in the events either both match `public_value`
+ neither do, i.e. there has been no change.
@NegativeMjark

NegativeMjark Jun 1, 2017

Contributor

Should this be "or if neither do" ?

Bug fixes and logging
- Check if room is public when a user joins before adding to user dir
- Fix typo of field name "content.join_rules" -> "content.join_rule"
+ elif value != public_value and prev_value == public_value:
+ defer.returnValue(False)
+ else:
+ defer.returnValue(None)
@NegativeMjark

NegativeMjark Jun 1, 2017

Contributor

You could write this as:

old_value_is_public = prev_value == public_value
new_value_is_public = value == public_value
if old_value_is_public == new_value_is_public:
   defer.returnValue(None)
else:
   defer.returnValue(new_value_is_public)

I'm not sure if it is clearer or not.

@erikjohnston

erikjohnston Jun 1, 2017

Owner

I don't find it any more readable tbh

synapse/handlers/user_directory.py
+ prev_value = prev_event.content.get(key_name, None)
+
+ if event:
+ value = event.content.get(key_name, None)
@NegativeMjark

NegativeMjark Jun 1, 2017

Contributor

The None is redundant.

erikjohnston added some commits Jun 1, 2017

Other than the possibly spurious test failures LGTM?

erikjohnston added some commits Jun 1, 2017

Still LGTM?

@erikjohnston erikjohnston merged commit 87e5e05 into develop Jun 1, 2017

8 checks passed

Sytest Dendron (Commit) Build #2241 origin/erikj/user_dir succeeded in 9 min 31 sec
Details
Sytest Dendron (Merged PR) Build finished.
Details
Sytest Postgres (Commit) Build #3076 origin/erikj/user_dir succeeded in 8 min 16 sec
Details
Sytest Postgres (Merged PR) Build finished.
Details
Sytest SQLite (Commit) Build #3148 origin/erikj/user_dir succeeded in 1 min 34 sec
Details
Sytest SQLite (Merged PR) Build finished.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@erikjohnston erikjohnston referenced this pull request in vector-im/riot-web Jun 1, 2017

Closed

Optional per-HS user/people directory. #2930

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