forked from MirrorHub/synapse
Add glob asterisks when running rules.
Means that now you can't do exact matches even in override rules, but I think we can live with that. Advantage is that you'll now always get back what was put in to the API.
This commit is contained in:
parent
9bfc8bf752
commit
4ffac34a64
2 changed files with 6 additions and 4 deletions
|
@ -137,6 +137,11 @@ class Pusher(object):
|
|||
return False
|
||||
pat = condition['pattern']
|
||||
|
||||
if pat.strip("*?[]") == pat:
|
||||
# no special glob characters so we assume the user means
|
||||
# 'contains this string' rather than 'is this string'
|
||||
pat = "*%s*" % (pat,)
|
||||
|
||||
val = _value_for_dotted_key(condition['key'], ev)
|
||||
if val is None:
|
||||
return False
|
||||
|
|
|
@ -98,10 +98,7 @@ class PushRuleRestServlet(ClientV1RestServlet):
|
|||
if 'pattern' not in req_obj:
|
||||
raise InvalidRuleException("Content rule missing 'pattern'")
|
||||
pat = req_obj['pattern']
|
||||
if pat.strip("*?[]") == pat:
|
||||
# no special glob characters so we assume the user means
|
||||
# 'contains this string' rather than 'is this string'
|
||||
pat = "*%s*" % (pat,)
|
||||
|
||||
conditions = [{
|
||||
'kind': 'event_match',
|
||||
'key': 'content.body',
|
||||
|
|
Loading…
Reference in a new issue