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
Support for channel notifications #2501
Conversation
dbkr
added some commits
Oct 5, 2017
| + { | ||
| + 'kind': 'event_match', | ||
| + 'key': 'content.body', | ||
| + 'pattern': '*@channel*', |
dbkr
added some commits
Oct 5, 2017
| + ) | ||
| + auth_events = yield self.store.get_events(auth_events_ids) | ||
| + auth_events = { | ||
| + (e.type, e.state_key): e for e in auth_events.values() |
erikjohnston
Oct 5, 2017
•
Owner
you want .itervalues() here (which returns an iterator rather than constructing a new list)
erikjohnston
Oct 5, 2017
Owner
I'd probably also move this in to the else, and explicitly do:
pl_event_key = (EventTypes.PowerLevels, "", )
pl_event_id = context.prev_state_ids.get((EventTypes.PowerLevels, "",))
if pl_event_id:
pl_event = yield self.store.get_event(pl_event_id)
auth_events = { pl_event_key: pl_event }
else:
...
defer.returnValue(get_user_power_level(event.sender, auth_events))to avoid some allocations
dbkr
Oct 10, 2017
Member
is it worth s/values/itervalues/ in the place I copied it from and all the other places that copied it from that too? :)
|
i'd avoid overcomplicating it with the layer of indirection to set a powerlevel for channel bing. if folks want that they can just surely add a custom push rule in the client (or in their particular server). conceptually this looks fine to me, but needs input from @erikjohnston on the state wrangling. |
| @@ -109,6 +111,23 @@ def _get_rules_for_room(self, room_id): | ||
| ) | ||
| @defer.inlineCallbacks | ||
| + def _get_sender_power_level(self, event, context): | ||
| + pl_event_key = (EventTypes.PowerLevels, "", ) | ||
| + if pl_event_key in context.prev_state_ids: |
erikjohnston
Oct 5, 2017
Owner
It's faster to do:
pl_event = context.prev_state_ids.get((EventTypes.PowerLevels, "",))
if pl_event:
...| @@ -1,5 +1,6 @@ | ||
| # -*- coding: utf-8 -*- | ||
| # Copyright 2015, 2016 OpenMarket Ltd | ||
| +# Copyright 2015 New Vector Ltd |
dbkr commentedOct 5, 2017
•
edited
Add condition type to check the sender's power level and add a base
rule using it for @channel notifications.
Thought: should we add a layer of indirection here so a channel can configure the minimum PL for sending a channel bing?