mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-10-01 11:49:51 -04:00
Merge branch 'develop' of github.com:matrix-org/synapse into state-chache
This commit is contained in:
commit
eae0842bc1
@ -157,15 +157,19 @@ class TransactionQueue(object):
|
||||
else:
|
||||
logger.info("TX [%s] is ready for retry", destination)
|
||||
|
||||
logger.info("TX [%s] _attempt_new_transaction", destination)
|
||||
|
||||
if destination in self.pending_transactions:
|
||||
# XXX: pending_transactions can get stuck on by a never-ending
|
||||
# request at which point pending_pdus_by_dest just keeps growing.
|
||||
# we need application-layer timeouts of some flavour of these
|
||||
# requests
|
||||
logger.info(
|
||||
"TX [%s] Transaction already in progress",
|
||||
destination
|
||||
)
|
||||
return
|
||||
|
||||
logger.info("TX [%s] _attempt_new_transaction", destination)
|
||||
|
||||
# list of (pending_pdu, deferred, order)
|
||||
pending_pdus = self.pending_pdus_by_dest.pop(destination, [])
|
||||
pending_edus = self.pending_edus_by_dest.pop(destination, [])
|
||||
@ -176,6 +180,7 @@ class TransactionQueue(object):
|
||||
destination, len(pending_pdus))
|
||||
|
||||
if not pending_pdus and not pending_edus and not pending_failures:
|
||||
logger.info("TX [%s] Nothing to send", destination)
|
||||
return
|
||||
|
||||
logger.debug(
|
||||
|
@ -658,7 +658,9 @@ class PresenceHandler(BaseHandler):
|
||||
|
||||
observers = set(self._remote_recvmap.get(user, set()))
|
||||
if observers:
|
||||
logger.debug(" | %d interested local observers %r", len(observers), observers)
|
||||
logger.debug(
|
||||
" | %d interested local observers %r", len(observers), observers
|
||||
)
|
||||
|
||||
rm_handler = self.homeserver.get_handlers().room_member_handler
|
||||
room_ids = yield rm_handler.get_rooms_for_user(user)
|
||||
|
@ -105,14 +105,17 @@ class RegistrationHandler(BaseHandler):
|
||||
# do it here.
|
||||
try:
|
||||
auth_user = UserID.from_string(user_id)
|
||||
identicon_resource = self.hs.get_resource_for_media_repository().getChildWithDefault("identicon", None)
|
||||
upload_resource = self.hs.get_resource_for_media_repository().getChildWithDefault("upload", None)
|
||||
media_repository = self.hs.get_resource_for_media_repository()
|
||||
identicon_resource = media_repository.getChildWithDefault("identicon", None)
|
||||
upload_resource = media_repository.getChildWithDefault("upload", None)
|
||||
identicon_bytes = identicon_resource.generate_identicon(user_id, 320, 320)
|
||||
content_uri = yield upload_resource.create_content(
|
||||
"image/png", None, identicon_bytes, len(identicon_bytes), auth_user
|
||||
)
|
||||
profile_handler = self.hs.get_handlers().profile_handler
|
||||
profile_handler.set_avatar_url(auth_user, auth_user, ("%s#auto" % content_uri))
|
||||
profile_handler.set_avatar_url(
|
||||
auth_user, auth_user, ("%s#auto" % (content_uri,))
|
||||
)
|
||||
except NotImplementedError:
|
||||
pass # make tests pass without messing around creating default avatars
|
||||
|
||||
|
@ -170,8 +170,10 @@ class Pusher(object):
|
||||
return False
|
||||
if not display_name:
|
||||
return False
|
||||
return re.search("\b%s\b" % re.escape(display_name),
|
||||
ev['content']['body'], flags=re.IGNORECASE) is not None
|
||||
return re.search(
|
||||
"\b%s\b" % re.escape(display_name), ev['content']['body'],
|
||||
flags=re.IGNORECASE
|
||||
) is not None
|
||||
|
||||
elif condition['kind'] == 'room_member_count':
|
||||
if 'is' not in condition:
|
||||
|
@ -1,5 +1,6 @@
|
||||
from synapse.push.rulekinds import PRIORITY_CLASS_MAP, PRIORITY_CLASS_INVERSE_MAP
|
||||
|
||||
|
||||
def list_with_base_rules(rawrules, user_name):
|
||||
ruleslist = []
|
||||
|
||||
@ -10,8 +11,8 @@ def list_with_base_rules(rawrules, user_name):
|
||||
while r['priority_class'] < current_prio_class:
|
||||
ruleslist.extend(make_base_rules(
|
||||
user_name,
|
||||
PRIORITY_CLASS_INVERSE_MAP[current_prio_class])
|
||||
)
|
||||
PRIORITY_CLASS_INVERSE_MAP[current_prio_class]
|
||||
))
|
||||
current_prio_class -= 1
|
||||
|
||||
ruleslist.append(r)
|
||||
@ -19,8 +20,8 @@ def list_with_base_rules(rawrules, user_name):
|
||||
while current_prio_class > 0:
|
||||
ruleslist.extend(make_base_rules(
|
||||
user_name,
|
||||
PRIORITY_CLASS_INVERSE_MAP[current_prio_class])
|
||||
)
|
||||
PRIORITY_CLASS_INVERSE_MAP[current_prio_class]
|
||||
))
|
||||
current_prio_class -= 1
|
||||
|
||||
return ruleslist
|
||||
|
@ -4,5 +4,5 @@ PRIORITY_CLASS_MAP = {
|
||||
'room': 3,
|
||||
'content': 4,
|
||||
'override': 5,
|
||||
}
|
||||
}
|
||||
PRIORITY_CLASS_INVERSE_MAP = {v: k for k, v in PRIORITY_CLASS_MAP.items()}
|
||||
|
@ -19,10 +19,11 @@ REQUIREMENTS = {
|
||||
"pydenticon": ["pydenticon"],
|
||||
}
|
||||
|
||||
|
||||
def github_link(project, version, egg):
|
||||
return "https://github.com/%s/tarball/%s/#egg=%s" % (project, version, egg)
|
||||
|
||||
DEPENDENCY_LINKS=[
|
||||
DEPENDENCY_LINKS = [
|
||||
github_link(
|
||||
project="matrix-org/syutil",
|
||||
version="v0.0.2",
|
||||
@ -101,6 +102,7 @@ def check_requirements():
|
||||
% (dependency, file_path, version, required_version)
|
||||
)
|
||||
|
||||
|
||||
def list_requirements():
|
||||
result = []
|
||||
linked = []
|
||||
@ -111,7 +113,7 @@ def list_requirements():
|
||||
for requirement in REQUIREMENTS:
|
||||
is_linked = False
|
||||
for link in linked:
|
||||
if requirement.replace('-','_').startswith(link):
|
||||
if requirement.replace('-', '_').startswith(link):
|
||||
is_linked = True
|
||||
if not is_linked:
|
||||
result.append(requirement)
|
||||
|
@ -15,12 +15,17 @@
|
||||
|
||||
from twisted.internet import defer
|
||||
|
||||
from synapse.api.errors import SynapseError, Codes, UnrecognizedRequestError, NotFoundError, \
|
||||
StoreError
|
||||
from synapse.api.errors import (
|
||||
SynapseError, Codes, UnrecognizedRequestError, NotFoundError, StoreError
|
||||
)
|
||||
from .base import ClientV1RestServlet, client_path_pattern
|
||||
from synapse.storage.push_rule import InconsistentRuleException, RuleNotFoundException
|
||||
from synapse.storage.push_rule import (
|
||||
InconsistentRuleException, RuleNotFoundException
|
||||
)
|
||||
import synapse.push.baserules as baserules
|
||||
from synapse.push.rulekinds import PRIORITY_CLASS_MAP, PRIORITY_CLASS_INVERSE_MAP
|
||||
from synapse.push.rulekinds import (
|
||||
PRIORITY_CLASS_MAP, PRIORITY_CLASS_INVERSE_MAP
|
||||
)
|
||||
|
||||
import json
|
||||
|
||||
@ -105,7 +110,9 @@ class PushRuleRestServlet(ClientV1RestServlet):
|
||||
# we build up the full structure and then decide which bits of it
|
||||
# to send which means doing unnecessary work sometimes but is
|
||||
# is probably not going to make a whole lot of difference
|
||||
rawrules = yield self.hs.get_datastore().get_push_rules_for_user_name(user.to_string())
|
||||
rawrules = yield self.hs.get_datastore().get_push_rules_for_user_name(
|
||||
user.to_string()
|
||||
)
|
||||
|
||||
for r in rawrules:
|
||||
r["conditions"] = json.loads(r["conditions"])
|
||||
@ -383,6 +390,7 @@ def _namespaced_rule_id_from_spec(spec):
|
||||
def _rule_id_from_namespaced(in_rule_id):
|
||||
return in_rule_id.split('/')[-1]
|
||||
|
||||
|
||||
class InvalidRuleException(Exception):
|
||||
pass
|
||||
|
||||
|
@ -40,7 +40,8 @@ class UploadResource(BaseMediaResource):
|
||||
return NOT_DONE_YET
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def create_content(self, media_type, upload_name, content, content_length, auth_user):
|
||||
def create_content(self, media_type, upload_name, content, content_length,
|
||||
auth_user):
|
||||
media_id = random_string(24)
|
||||
|
||||
fname = self.filepaths.local_media_filepath(media_id)
|
||||
|
@ -84,7 +84,7 @@ class PerformanceCounters(object):
|
||||
|
||||
def update(self, key, start_time, end_time=None):
|
||||
if end_time is None:
|
||||
end_time = time.time() * 1000;
|
||||
end_time = time.time() * 1000
|
||||
duration = end_time - start_time
|
||||
count, cum_time = self.current_counters.get(key, (0, 0))
|
||||
count += 1
|
||||
@ -588,7 +588,7 @@ class SQLBaseStore(object):
|
||||
"LIMIT 1 "
|
||||
)
|
||||
|
||||
start_time = time.time() * 1000;
|
||||
start_time = time.time() * 1000
|
||||
|
||||
txn.execute(sql, (event_id,))
|
||||
|
||||
@ -613,7 +613,7 @@ class SQLBaseStore(object):
|
||||
def _get_event_from_row_txn(self, txn, internal_metadata, js, redacted,
|
||||
check_redacted=True, get_prev_content=False):
|
||||
|
||||
start_time = time.time() * 1000;
|
||||
start_time = time.time() * 1000
|
||||
update_counter = self._get_event_counters.update
|
||||
|
||||
d = json.loads(js)
|
||||
|
@ -91,7 +91,9 @@ class PushRuleStore(SQLBaseStore):
|
||||
txn.execute(sql, (user_name, relative_to_rule))
|
||||
res = txn.fetchall()
|
||||
if not res:
|
||||
raise RuleNotFoundException("before/after rule not found: %s" % (relative_to_rule))
|
||||
raise RuleNotFoundException(
|
||||
"before/after rule not found: %s" % (relative_to_rule,)
|
||||
)
|
||||
priority_class, base_rule_priority = res[0]
|
||||
|
||||
if 'priority_class' in kwargs and kwargs['priority_class'] != priority_class:
|
||||
|
Loading…
Reference in New Issue
Block a user