Add more server default rules so we have default rules for whether you get notifs for invites / random member events
This commit is contained in:
parent
657a0d2568
commit
c06b45129c
|
@ -72,10 +72,6 @@ class Pusher(object):
|
|||
# let's assume you probably know about messages you sent yourself
|
||||
defer.returnValue(['dont_notify'])
|
||||
|
||||
if ev['type'] == 'm.room.member':
|
||||
if ev['state_key'] != self.user_name:
|
||||
defer.returnValue(['dont_notify'])
|
||||
|
||||
rawrules = yield self.store.get_push_rules_for_user(self.user_name)
|
||||
|
||||
for r in rawrules:
|
||||
|
@ -121,6 +117,10 @@ class Pusher(object):
|
|||
ev, c, display_name=my_display_name,
|
||||
room_member_count=room_member_count
|
||||
)
|
||||
logger.debug(
|
||||
"Rule %s %s",
|
||||
r['rule_id'], "matches" if matches else "doesn't match"
|
||||
)
|
||||
# ignore rules with no actions (we have an explict 'dont_notify')
|
||||
if len(actions) == 0:
|
||||
logger.warn(
|
||||
|
|
|
@ -33,7 +33,7 @@ def make_base_rules(user, kind):
|
|||
if kind == 'override':
|
||||
rules = make_base_override_rules()
|
||||
elif kind == 'underride':
|
||||
rules = make_base_underride_rules()
|
||||
rules = make_base_underride_rules(user)
|
||||
elif kind == 'content':
|
||||
rules = make_base_content_rules(user)
|
||||
|
||||
|
@ -119,8 +119,78 @@ def make_base_override_rules():
|
|||
]
|
||||
|
||||
|
||||
def make_base_underride_rules():
|
||||
def make_base_underride_rules(user):
|
||||
return [
|
||||
{
|
||||
'rule_id': 'global/underride/.m.rule.invite_for_me',
|
||||
'conditions': [
|
||||
{
|
||||
'kind': 'event_match',
|
||||
'key': 'type',
|
||||
'pattern': 'm.room.member',
|
||||
},
|
||||
{
|
||||
'kind': 'event_match',
|
||||
'key': 'content.membership',
|
||||
'pattern': 'invite',
|
||||
},
|
||||
{
|
||||
'kind': 'event_match',
|
||||
'key': 'state_key',
|
||||
'pattern': user.to_string(),
|
||||
},
|
||||
],
|
||||
'actions': [
|
||||
'notify',
|
||||
{
|
||||
'set_tweak': 'sound',
|
||||
'value': 'default'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'rule_id': 'global/underride/.m.rule.member_event',
|
||||
'conditions': [
|
||||
{
|
||||
'kind': 'event_match',
|
||||
'key': 'type',
|
||||
'pattern': 'm.room.member',
|
||||
}
|
||||
],
|
||||
'actions': [
|
||||
'notify',
|
||||
]
|
||||
},
|
||||
{
|
||||
'rule_id': 'global/underride/.m.rule.message',
|
||||
'conditions': [
|
||||
{
|
||||
'kind': 'event_match',
|
||||
'key': 'type',
|
||||
'pattern': 'm.room.message',
|
||||
}
|
||||
],
|
||||
'actions': [
|
||||
'notify',
|
||||
]
|
||||
},
|
||||
{
|
||||
'rule_id': 'global/underride/.m.rule.call',
|
||||
'conditions': [
|
||||
{
|
||||
'kind': 'event_match',
|
||||
'key': 'type',
|
||||
'pattern': 'm.call.invite',
|
||||
}
|
||||
],
|
||||
'actions': [
|
||||
'notify',
|
||||
{
|
||||
'set_tweak': 'sound',
|
||||
'value': 'ring'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
'rule_id': 'global/underride/.m.rule.fallback',
|
||||
'conditions': [
|
||||
|
|
Loading…
Reference in New Issue