0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-17 15:31:19 +01:00

Merge branch 'develop' of github.com:matrix-org/synapse into erikj/setup

This commit is contained in:
Erik Johnston 2016-01-27 17:22:35 +00:00
commit a955cbfa49
4 changed files with 27 additions and 9 deletions

View file

@ -1186,7 +1186,13 @@ class FederationHandler(BaseHandler):
try: try:
self.auth.check(e, auth_events=auth_for_e) self.auth.check(e, auth_events=auth_for_e)
except AuthError as err: except SynapseError as err:
# we may get SynapseErrors here as well as AuthErrors. For
# instance, there are a couple of (ancient) events in some
# rooms whose senders do not have the correct sigil; these
# cause SynapseErrors in auth.check. We don't want to give up
# the attempt to federate altogether in such cases.
logger.warn( logger.warn(
"Rejecting %s because %s", "Rejecting %s because %s",
e.event_id, err.msg e.event_id, err.msg

View file

@ -173,6 +173,12 @@ BASE_APPEND_UNDERRIDE_RULES = [
'kind': 'room_member_count', 'kind': 'room_member_count',
'is': '2', 'is': '2',
'_id': 'member_count', '_id': 'member_count',
},
{
'kind': 'event_match',
'key': 'type',
'pattern': 'm.room.message',
'_id': '_message',
} }
], ],
'actions': [ 'actions': [

View file

@ -52,7 +52,7 @@ class PushRuleRestServlet(ClientV1RestServlet):
content = _parse_json(request) content = _parse_json(request)
if 'attr' in spec: if 'attr' in spec:
self.set_rule_attr(requester.user.to_string(), spec, content) yield self.set_rule_attr(requester.user.to_string(), spec, content)
defer.returnValue((200, {})) defer.returnValue((200, {}))
try: try:
@ -66,11 +66,12 @@ class PushRuleRestServlet(ClientV1RestServlet):
raise SynapseError(400, e.message) raise SynapseError(400, e.message)
before = request.args.get("before", None) before = request.args.get("before", None)
if before and len(before): if before:
before = before[0] before = _namespaced_rule_id(spec, before[0])
after = request.args.get("after", None) after = request.args.get("after", None)
if after and len(after): if after:
after = after[0] after = _namespaced_rule_id(spec, after[0])
try: try:
yield self.hs.get_datastore().add_push_rule( yield self.hs.get_datastore().add_push_rule(
@ -228,7 +229,7 @@ class PushRuleRestServlet(ClientV1RestServlet):
# bools directly, so let's not break them. # bools directly, so let's not break them.
raise SynapseError(400, "Value for 'enabled' must be boolean") raise SynapseError(400, "Value for 'enabled' must be boolean")
namespaced_rule_id = _namespaced_rule_id_from_spec(spec) namespaced_rule_id = _namespaced_rule_id_from_spec(spec)
self.hs.get_datastore().set_push_rule_enabled( return self.hs.get_datastore().set_push_rule_enabled(
user_id, namespaced_rule_id, val user_id, namespaced_rule_id, val
) )
else: else:
@ -452,11 +453,15 @@ def _strip_device_condition(rule):
def _namespaced_rule_id_from_spec(spec): def _namespaced_rule_id_from_spec(spec):
return _namespaced_rule_id(spec, spec['rule_id'])
def _namespaced_rule_id(spec, rule_id):
if spec['scope'] == 'global': if spec['scope'] == 'global':
scope = 'global' scope = 'global'
else: else:
scope = 'device/%s' % (spec['profile_tag']) scope = 'device/%s' % (spec['profile_tag'])
return "%s/%s/%s" % (scope, spec['template'], spec['rule_id']) return "%s/%s/%s" % (scope, spec['template'], rule_id)
def _rule_id_from_namespaced(in_rule_id): def _rule_id_from_namespaced(in_rule_id):

View file

@ -130,7 +130,8 @@ class PushRuleStore(SQLBaseStore):
def _add_push_rule_relative_txn(self, txn, user_id, **kwargs): def _add_push_rule_relative_txn(self, txn, user_id, **kwargs):
after = kwargs.pop("after", None) after = kwargs.pop("after", None)
relative_to_rule = kwargs.pop("before", after) before = kwargs.pop("before", None)
relative_to_rule = before or after
res = self._simple_select_one_txn( res = self._simple_select_one_txn(
txn, txn,