mirror of
https://github.com/element-hq/synapse
synced 2024-08-20 02:40:22 +00:00
Merge branch 'develop' into markjh/synchrotron
Conflicts: synapse/handlers/sync.py
This commit is contained in:
commit
2bd948a30a
7 changed files with 654 additions and 553 deletions
|
@ -120,6 +120,24 @@ class Auth(object):
|
|||
return allowed
|
||||
|
||||
self.check_event_sender_in_room(event, auth_events)
|
||||
|
||||
# Special case to allow m.room.third_party_invite events wherever
|
||||
# a user is allowed to issue invites. Fixes
|
||||
# https://github.com/vector-im/vector-web/issues/1208 hopefully
|
||||
if event.type == EventTypes.ThirdPartyInvite:
|
||||
user_level = self._get_user_power_level(event.user_id, auth_events)
|
||||
invite_level = self._get_named_level(auth_events, "invite", 0)
|
||||
|
||||
if user_level < invite_level:
|
||||
raise AuthError(
|
||||
403, (
|
||||
"You cannot issue a third party invite for %s." %
|
||||
(event.content.display_name,)
|
||||
)
|
||||
)
|
||||
else:
|
||||
return True
|
||||
|
||||
self._can_send_event(event, auth_events)
|
||||
|
||||
if event.type == EventTypes.PowerLevels:
|
||||
|
|
|
@ -441,7 +441,7 @@ class RoomListHandler(BaseHandler):
|
|||
self.hs.config.secondary_directory_servers
|
||||
)
|
||||
self.remote_list_request_cache.set((), deferred)
|
||||
yield deferred
|
||||
self.remote_list_cache = yield deferred
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def get_aggregated_public_room_list(self):
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -72,7 +72,12 @@ class EmailPusher(object):
|
|||
self.processing = False
|
||||
|
||||
if self.hs.config.email_enable_notifs:
|
||||
self.mailer = Mailer(self.hs)
|
||||
if 'data' in pusherdict and 'brand' in pusherdict['data']:
|
||||
app_name = pusherdict['data']['brand']
|
||||
else:
|
||||
app_name = self.hs.config.email_app_name
|
||||
|
||||
self.mailer = Mailer(self.hs, app_name)
|
||||
else:
|
||||
self.mailer = None
|
||||
|
||||
|
|
|
@ -78,12 +78,12 @@ ALLOWED_ATTRS = {
|
|||
|
||||
|
||||
class Mailer(object):
|
||||
def __init__(self, hs):
|
||||
def __init__(self, hs, app_name):
|
||||
self.hs = hs
|
||||
self.store = self.hs.get_datastore()
|
||||
self.state_handler = self.hs.get_state_handler()
|
||||
loader = jinja2.FileSystemLoader(self.hs.config.email_template_dir)
|
||||
self.app_name = self.hs.config.email_app_name
|
||||
self.app_name = app_name
|
||||
env = jinja2.Environment(loader=loader)
|
||||
env.filters["format_ts"] = format_ts_filter
|
||||
env.filters["mxc_to_http"] = self.mxc_to_http_filter
|
||||
|
@ -122,6 +122,8 @@ class Mailer(object):
|
|||
user_display_name = yield self.store.get_profile_displayname(
|
||||
UserID.from_string(user_id).localpart
|
||||
)
|
||||
if user_display_name is None:
|
||||
user_display_name = user_id
|
||||
except StoreError:
|
||||
user_display_name = user_id
|
||||
|
||||
|
|
|
@ -106,7 +106,8 @@ class PushRuleStore(SQLBaseStore):
|
|||
desc="bulk_get_push_rules_enabled",
|
||||
)
|
||||
for row in rows:
|
||||
results.setdefault(row['user_name'], {})[row['rule_id']] = row['enabled']
|
||||
enabled = bool(row['enabled'])
|
||||
results.setdefault(row['user_name'], {})[row['rule_id']] = enabled
|
||||
defer.returnValue(results)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
|
|
|
@ -19,17 +19,24 @@ from ._base import SQLBaseStore
|
|||
|
||||
from unpaddedbase64 import encode_base64
|
||||
from synapse.crypto.event_signing import compute_event_reference_hash
|
||||
from synapse.util.caches.descriptors import cached, cachedList
|
||||
|
||||
|
||||
class SignatureStore(SQLBaseStore):
|
||||
"""Persistence for event signatures and hashes"""
|
||||
|
||||
@cached(lru=True)
|
||||
def get_event_reference_hash(self, event_id):
|
||||
return self._get_event_reference_hashes_txn(event_id)
|
||||
|
||||
@cachedList(cached_method_name="get_event_reference_hash",
|
||||
list_name="event_ids", num_args=1)
|
||||
def get_event_reference_hashes(self, event_ids):
|
||||
def f(txn):
|
||||
return [
|
||||
self._get_event_reference_hashes_txn(txn, ev)
|
||||
for ev in event_ids
|
||||
]
|
||||
return {
|
||||
event_id: self._get_event_reference_hashes_txn(txn, event_id)
|
||||
for event_id in event_ids
|
||||
}
|
||||
|
||||
return self.runInteraction(
|
||||
"get_event_reference_hashes",
|
||||
|
@ -41,15 +48,15 @@ class SignatureStore(SQLBaseStore):
|
|||
hashes = yield self.get_event_reference_hashes(
|
||||
event_ids
|
||||
)
|
||||
hashes = [
|
||||
{
|
||||
hashes = {
|
||||
e_id: {
|
||||
k: encode_base64(v) for k, v in h.items()
|
||||
if k == "sha256"
|
||||
}
|
||||
for h in hashes
|
||||
]
|
||||
for e_id, h in hashes.items()
|
||||
}
|
||||
|
||||
defer.returnValue(zip(event_ids, hashes))
|
||||
defer.returnValue(hashes.items())
|
||||
|
||||
def _get_event_reference_hashes_txn(self, txn, event_id):
|
||||
"""Get all the hashes for a given PDU.
|
||||
|
|
Loading…
Reference in a new issue