Replace returnValue with return (#5736)

This commit is contained in:
Amber Brown 2019-07-23 23:00:55 +10:00 committed by GitHub
parent 18a466b84e
commit 4806651744
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
177 changed files with 1359 additions and 1513 deletions

1
changelog.d/5736.misc Normal file
View File

@ -0,0 +1 @@
Replace uses of returnValue with plain return, as returnValue is not needed on Python 3.

View File

@ -148,7 +148,7 @@ call any other functions.
d = more_stuff()
result = yield d # also fine, of course
defer.returnValue(result)
return result
def nonInlineCallbacksFun():
logger.debug("just a wrapper really")

View File

@ -128,7 +128,7 @@ class Auth(object):
)
self._check_joined_room(member, user_id, room_id)
defer.returnValue(member)
return member
@defer.inlineCallbacks
def check_user_was_in_room(self, room_id, user_id):
@ -156,13 +156,13 @@ class Auth(object):
if forgot:
raise AuthError(403, "User %s not in room %s" % (user_id, room_id))
defer.returnValue(member)
return member
@defer.inlineCallbacks
def check_host_in_room(self, room_id, host):
with Measure(self.clock, "check_host_in_room"):
latest_event_ids = yield self.store.is_host_joined(room_id, host)
defer.returnValue(latest_event_ids)
return latest_event_ids
def _check_joined_room(self, member, user_id, room_id):
if not member or member.membership != Membership.JOIN:
@ -219,9 +219,7 @@ class Auth(object):
device_id="dummy-device", # stubbed
)
defer.returnValue(
synapse.types.create_requester(user_id, app_service=app_service)
)
return synapse.types.create_requester(user_id, app_service=app_service)
user_info = yield self.get_user_by_access_token(access_token, rights)
user = user_info["user"]
@ -262,11 +260,9 @@ class Auth(object):
request.authenticated_entity = user.to_string()
defer.returnValue(
synapse.types.create_requester(
return synapse.types.create_requester(
user, token_id, is_guest, device_id, app_service=app_service
)
)
except KeyError:
raise MissingClientTokenError()
@ -276,25 +272,25 @@ class Auth(object):
self.get_access_token_from_request(request)
)
if app_service is None:
defer.returnValue((None, None))
return (None, None)
if app_service.ip_range_whitelist:
ip_address = IPAddress(self.hs.get_ip_from_request(request))
if ip_address not in app_service.ip_range_whitelist:
defer.returnValue((None, None))
return (None, None)
if b"user_id" not in request.args:
defer.returnValue((app_service.sender, app_service))
return (app_service.sender, app_service)
user_id = request.args[b"user_id"][0].decode("utf8")
if app_service.sender == user_id:
defer.returnValue((app_service.sender, app_service))
return (app_service.sender, app_service)
if not app_service.is_interested_in_user(user_id):
raise AuthError(403, "Application service cannot masquerade as this user.")
if not (yield self.store.get_user_by_id(user_id)):
raise AuthError(403, "Application service has not registered this user")
defer.returnValue((user_id, app_service))
return (user_id, app_service)
@defer.inlineCallbacks
def get_user_by_access_token(self, token, rights="access"):
@ -330,7 +326,7 @@ class Auth(object):
msg="Access token has expired", soft_logout=True
)
defer.returnValue(r)
return r
# otherwise it needs to be a valid macaroon
try:
@ -378,7 +374,7 @@ class Auth(object):
}
else:
raise RuntimeError("Unknown rights setting %s", rights)
defer.returnValue(ret)
return ret
except (
_InvalidMacaroonException,
pymacaroons.exceptions.MacaroonException,
@ -506,7 +502,7 @@ class Auth(object):
def _look_up_user_by_access_token(self, token):
ret = yield self.store.get_user_by_access_token(token)
if not ret:
defer.returnValue(None)
return None
# we use ret.get() below because *lots* of unit tests stub out
# get_user_by_access_token in a way where it only returns a couple of
@ -518,7 +514,7 @@ class Auth(object):
"device_id": ret.get("device_id"),
"valid_until_ms": ret.get("valid_until_ms"),
}
defer.returnValue(user_info)
return user_info
def get_appservice_by_req(self, request):
token = self.get_access_token_from_request(request)
@ -543,7 +539,7 @@ class Auth(object):
@defer.inlineCallbacks
def compute_auth_events(self, event, current_state_ids, for_verification=False):
if event.type == EventTypes.Create:
defer.returnValue([])
return []
auth_ids = []
@ -604,7 +600,7 @@ class Auth(object):
if member_event.content["membership"] == Membership.JOIN:
auth_ids.append(member_event.event_id)
defer.returnValue(auth_ids)
return auth_ids
@defer.inlineCallbacks
def check_can_change_room_list(self, room_id, user):
@ -618,7 +614,7 @@ class Auth(object):
is_admin = yield self.is_server_admin(user)
if is_admin:
defer.returnValue(True)
return True
user_id = user.to_string()
yield self.check_joined_room(room_id, user_id)
@ -712,7 +708,7 @@ class Auth(object):
# * The user is a guest user, and has joined the room
# else it will throw.
member_event = yield self.check_user_was_in_room(room_id, user_id)
defer.returnValue((member_event.membership, member_event.event_id))
return (member_event.membership, member_event.event_id)
except AuthError:
visibility = yield self.state.get_current_state(
room_id, EventTypes.RoomHistoryVisibility, ""
@ -721,7 +717,7 @@ class Auth(object):
visibility
and visibility.content["history_visibility"] == "world_readable"
):
defer.returnValue((Membership.JOIN, None))
return (Membership.JOIN, None)
return
raise AuthError(
403, "Guest access not allowed", errcode=Codes.GUEST_ACCESS_FORBIDDEN

View File

@ -132,7 +132,7 @@ class Filtering(object):
@defer.inlineCallbacks
def get_user_filter(self, user_localpart, filter_id):
result = yield self.store.get_user_filter(user_localpart, filter_id)
defer.returnValue(FilterCollection(result))
return FilterCollection(result)
def add_user_filter(self, user_localpart, user_filter):
self.check_valid_filter(user_filter)

View File

@ -70,12 +70,12 @@ class PresenceStatusStubServlet(RestServlet):
except HttpResponseException as e:
raise e.to_synapse_error()
defer.returnValue((200, result))
return (200, result)
@defer.inlineCallbacks
def on_PUT(self, request, user_id):
yield self.auth.get_user_by_req(request)
defer.returnValue((200, {}))
return (200, {})
class KeyUploadServlet(RestServlet):
@ -126,11 +126,11 @@ class KeyUploadServlet(RestServlet):
self.main_uri + request.uri.decode("ascii"), body, headers=headers
)
defer.returnValue((200, result))
return (200, result)
else:
# Just interested in counts.
result = yield self.store.count_e2e_one_time_keys(user_id, device_id)
defer.returnValue((200, {"one_time_key_counts": result}))
return (200, {"one_time_key_counts": result})
class FrontendProxySlavedStore(

2
synapse/app/homeserver.py Executable file → Normal file
View File

@ -406,7 +406,7 @@ def setup(config_options):
if provision:
yield acme.provision_certificate()
defer.returnValue(provision)
return provision
@defer.inlineCallbacks
def reprovision_acme():

View File

@ -175,21 +175,21 @@ class ApplicationService(object):
@defer.inlineCallbacks
def _matches_user(self, event, store):
if not event:
defer.returnValue(False)
return False
if self.is_interested_in_user(event.sender):
defer.returnValue(True)
return True
# also check m.room.member state key
if event.type == EventTypes.Member and self.is_interested_in_user(
event.state_key
):
defer.returnValue(True)
return True
if not store:
defer.returnValue(False)
return False
does_match = yield self._matches_user_in_member_list(event.room_id, store)
defer.returnValue(does_match)
return does_match
@cachedInlineCallbacks(num_args=1, cache_context=True)
def _matches_user_in_member_list(self, room_id, store, cache_context):
@ -200,8 +200,8 @@ class ApplicationService(object):
# check joined member events
for user_id in member_list:
if self.is_interested_in_user(user_id):
defer.returnValue(True)
defer.returnValue(False)
return True
return False
def _matches_room_id(self, event):
if hasattr(event, "room_id"):
@ -211,13 +211,13 @@ class ApplicationService(object):
@defer.inlineCallbacks
def _matches_aliases(self, event, store):
if not store or not event:
defer.returnValue(False)
return False
alias_list = yield store.get_aliases_for_room(event.room_id)
for alias in alias_list:
if self.is_interested_in_alias(alias):
defer.returnValue(True)
defer.returnValue(False)
return True
return False
@defer.inlineCallbacks
def is_interested(self, event, store=None):
@ -231,15 +231,15 @@ class ApplicationService(object):
"""
# Do cheap checks first
if self._matches_room_id(event):
defer.returnValue(True)
return True
if (yield self._matches_aliases(event, store)):
defer.returnValue(True)
return True
if (yield self._matches_user(event, store)):
defer.returnValue(True)
return True
defer.returnValue(False)
return False
def is_interested_in_user(self, user_id):
return (

View File

@ -97,40 +97,40 @@ class ApplicationServiceApi(SimpleHttpClient):
@defer.inlineCallbacks
def query_user(self, service, user_id):
if service.url is None:
defer.returnValue(False)
return False
uri = service.url + ("/users/%s" % urllib.parse.quote(user_id))
response = None
try:
response = yield self.get_json(uri, {"access_token": service.hs_token})
if response is not None: # just an empty json object
defer.returnValue(True)
return True
except CodeMessageException as e:
if e.code == 404:
defer.returnValue(False)
return False
return
logger.warning("query_user to %s received %s", uri, e.code)
except Exception as ex:
logger.warning("query_user to %s threw exception %s", uri, ex)
defer.returnValue(False)
return False
@defer.inlineCallbacks
def query_alias(self, service, alias):
if service.url is None:
defer.returnValue(False)
return False
uri = service.url + ("/rooms/%s" % urllib.parse.quote(alias))
response = None
try:
response = yield self.get_json(uri, {"access_token": service.hs_token})
if response is not None: # just an empty json object
defer.returnValue(True)
return True
except CodeMessageException as e:
logger.warning("query_alias to %s received %s", uri, e.code)
if e.code == 404:
defer.returnValue(False)
return False
return
except Exception as ex:
logger.warning("query_alias to %s threw exception %s", uri, ex)
defer.returnValue(False)
return False
@defer.inlineCallbacks
def query_3pe(self, service, kind, protocol, fields):
@ -141,7 +141,7 @@ class ApplicationServiceApi(SimpleHttpClient):
else:
raise ValueError("Unrecognised 'kind' argument %r to query_3pe()", kind)
if service.url is None:
defer.returnValue([])
return []
uri = "%s%s/thirdparty/%s/%s" % (
service.url,
@ -155,7 +155,7 @@ class ApplicationServiceApi(SimpleHttpClient):
logger.warning(
"query_3pe to %s returned an invalid response %r", uri, response
)
defer.returnValue([])
return []
ret = []
for r in response:
@ -166,14 +166,14 @@ class ApplicationServiceApi(SimpleHttpClient):
"query_3pe to %s returned an invalid result %r", uri, r
)
defer.returnValue(ret)
return ret
except Exception as ex:
logger.warning("query_3pe to %s threw exception %s", uri, ex)
defer.returnValue([])
return []
def get_3pe_protocol(self, service, protocol):
if service.url is None:
defer.returnValue({})
return {}
@defer.inlineCallbacks
def _get():
@ -189,7 +189,7 @@ class ApplicationServiceApi(SimpleHttpClient):
logger.warning(
"query_3pe_protocol to %s did not return a" " valid result", uri
)
defer.returnValue(None)
return None
for instance in info.get("instances", []):
network_id = instance.get("network_id", None)
@ -198,10 +198,10 @@ class ApplicationServiceApi(SimpleHttpClient):
service.id, network_id
).to_string()
defer.returnValue(info)
return info
except Exception as ex:
logger.warning("query_3pe_protocol to %s threw exception %s", uri, ex)
defer.returnValue(None)
return None
key = (service.id, protocol)
return self.protocol_meta_cache.wrap(key, _get)
@ -209,7 +209,7 @@ class ApplicationServiceApi(SimpleHttpClient):
@defer.inlineCallbacks
def push_bulk(self, service, events, txn_id=None):
if service.url is None:
defer.returnValue(True)
return True
events = self._serialize(events)
@ -229,14 +229,14 @@ class ApplicationServiceApi(SimpleHttpClient):
)
sent_transactions_counter.labels(service.id).inc()
sent_events_counter.labels(service.id).inc(len(events))
defer.returnValue(True)
return True
return
except CodeMessageException as e:
logger.warning("push_bulk to %s received %s", uri, e.code)
except Exception as ex:
logger.warning("push_bulk to %s threw exception %s", uri, ex)
failed_transactions_counter.labels(service.id).inc()
defer.returnValue(False)
return False
def _serialize(self, events):
time_now = self.clock.time_msec()

View File

@ -193,7 +193,7 @@ class _TransactionController(object):
@defer.inlineCallbacks
def _is_service_up(self, service):
state = yield self.store.get_appservice_state(service)
defer.returnValue(state == ApplicationServiceState.UP or state is None)
return state == ApplicationServiceState.UP or state is None
class _Recoverer(object):
@ -208,7 +208,7 @@ class _Recoverer(object):
r.service.id,
)
r.recover()
defer.returnValue(recoverers)
return recoverers
def __init__(self, clock, store, as_api, service, callback):
self.clock = clock

View File

@ -462,7 +462,7 @@ class StoreKeyFetcher(KeyFetcher):
keys = {}
for (server_name, key_id), key in res.items():
keys.setdefault(server_name, {})[key_id] = key
defer.returnValue(keys)
return keys
class BaseV2KeyFetcher(object):
@ -566,7 +566,7 @@ class BaseV2KeyFetcher(object):
).addErrback(unwrapFirstError)
)
defer.returnValue(verify_keys)
return verify_keys
class PerspectivesKeyFetcher(BaseV2KeyFetcher):
@ -588,7 +588,7 @@ class PerspectivesKeyFetcher(BaseV2KeyFetcher):
result = yield self.get_server_verify_key_v2_indirect(
keys_to_fetch, key_server
)
defer.returnValue(result)
return result
except KeyLookupError as e:
logger.warning(
"Key lookup failed from %r: %s", key_server.server_name, e
@ -601,7 +601,7 @@ class PerspectivesKeyFetcher(BaseV2KeyFetcher):
str(e),
)
defer.returnValue({})
return {}
results = yield make_deferred_yieldable(
defer.gatherResults(
@ -615,7 +615,7 @@ class PerspectivesKeyFetcher(BaseV2KeyFetcher):
for server_name, keys in result.items():
union_of_keys.setdefault(server_name, {}).update(keys)
defer.returnValue(union_of_keys)
return union_of_keys
@defer.inlineCallbacks
def get_server_verify_key_v2_indirect(self, keys_to_fetch, key_server):
@ -701,7 +701,7 @@ class PerspectivesKeyFetcher(BaseV2KeyFetcher):
perspective_name, time_now_ms, added_keys
)
defer.returnValue(keys)
return keys
def _validate_perspectives_response(self, key_server, response):
"""Optionally check the signature on the result of a /key/query request
@ -843,7 +843,7 @@ class ServerKeyFetcher(BaseV2KeyFetcher):
)
keys.update(response_keys)
defer.returnValue(keys)
return keys
@defer.inlineCallbacks

View File

@ -144,8 +144,7 @@ class EventBuilder(object):
if self._origin_server_ts is not None:
event_dict["origin_server_ts"] = self._origin_server_ts
defer.returnValue(
create_local_event_from_event_dict(
return create_local_event_from_event_dict(
clock=self._clock,
hostname=self._hostname,
signing_key=self._signing_key,
@ -153,7 +152,6 @@ class EventBuilder(object):
event_dict=event_dict,
internal_metadata_dict=self.internal_metadata.get_dict(),
)
)
class EventBuilderFactory(object):

View File

@ -133,8 +133,7 @@ class EventContext(object):
else:
prev_state_id = None
defer.returnValue(
{
return {
"prev_state_id": prev_state_id,
"event_type": event.type,
"event_state_key": event.state_key if event.is_state() else None,
@ -145,7 +144,6 @@ class EventContext(object):
"prev_state_events": self.prev_state_events,
"app_service_id": self.app_service.id if self.app_service else None,
}
)
@staticmethod
def deserialize(store, input):
@ -202,7 +200,7 @@ class EventContext(object):
yield make_deferred_yieldable(self._fetching_state_deferred)
defer.returnValue(self._current_state_ids)
return self._current_state_ids
@defer.inlineCallbacks
def get_prev_state_ids(self, store):
@ -222,7 +220,7 @@ class EventContext(object):
yield make_deferred_yieldable(self._fetching_state_deferred)
defer.returnValue(self._prev_state_ids)
return self._prev_state_ids
def get_cached_current_state_ids(self):
"""Gets the current state IDs if we have them already cached.

View File

@ -51,7 +51,7 @@ class ThirdPartyEventRules(object):
defer.Deferred[bool]: True if the event should be allowed, False if not.
"""
if self.third_party_rules is None:
defer.returnValue(True)
return True
prev_state_ids = yield context.get_prev_state_ids(self.store)
@ -61,7 +61,7 @@ class ThirdPartyEventRules(object):
state_events[key] = yield self.store.get_event(event_id, allow_none=True)
ret = yield self.third_party_rules.check_event_allowed(event, state_events)
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def on_create_room(self, requester, config, is_requester_admin):
@ -98,7 +98,7 @@ class ThirdPartyEventRules(object):
"""
if self.third_party_rules is None:
defer.returnValue(True)
return True
state_ids = yield self.store.get_filtered_current_state_ids(room_id)
room_state_events = yield self.store.get_events(state_ids.values())
@ -110,4 +110,4 @@ class ThirdPartyEventRules(object):
ret = yield self.third_party_rules.check_threepid_can_be_invited(
medium, address, state_events
)
defer.returnValue(ret)
return ret

View File

@ -360,7 +360,7 @@ class EventClientSerializer(object):
"""
# To handle the case of presence events and the like
if not isinstance(event, EventBase):
defer.returnValue(event)
return event
event_id = event.event_id
serialized_event = serialize_event(event, time_now, **kwargs)
@ -406,7 +406,7 @@ class EventClientSerializer(object):
"sender": edit.sender,
}
defer.returnValue(serialized_event)
return serialized_event
def serialize_events(self, events, time_now, **kwargs):
"""Serializes multiple events.

View File

@ -106,7 +106,7 @@ class FederationBase(object):
"Failed to find copy of %s with valid signature", pdu.event_id
)
defer.returnValue(res)
return res
handle = preserve_fn(handle_check_result)
deferreds2 = [handle(pdu, deferred) for pdu, deferred in zip(pdus, deferreds)]
@ -116,9 +116,9 @@ class FederationBase(object):
).addErrback(unwrapFirstError)
if include_none:
defer.returnValue(valid_pdus)
return valid_pdus
else:
defer.returnValue([p for p in valid_pdus if p])
return [p for p in valid_pdus if p]
def _check_sigs_and_hash(self, room_version, pdu):
return make_deferred_yieldable(

View File

@ -213,7 +213,7 @@ class FederationClient(FederationBase):
).addErrback(unwrapFirstError)
)
defer.returnValue(pdus)
return pdus
@defer.inlineCallbacks
@log_function
@ -245,7 +245,7 @@ class FederationClient(FederationBase):
ev = self._get_pdu_cache.get(event_id)
if ev:
defer.returnValue(ev)
return ev
pdu_attempts = self.pdu_destination_tried.setdefault(event_id, {})
@ -307,7 +307,7 @@ class FederationClient(FederationBase):
if signed_pdu:
self._get_pdu_cache[event_id] = signed_pdu
defer.returnValue(signed_pdu)
return signed_pdu
@defer.inlineCallbacks
@log_function
@ -355,7 +355,7 @@ class FederationClient(FederationBase):
auth_chain.sort(key=lambda e: e.depth)
defer.returnValue((pdus, auth_chain))
return (pdus, auth_chain)
except HttpResponseException as e:
if e.code == 400 or e.code == 404:
logger.info("Failed to use get_room_state_ids API, falling back")
@ -404,7 +404,7 @@ class FederationClient(FederationBase):
signed_auth.sort(key=lambda e: e.depth)
defer.returnValue((signed_pdus, signed_auth))
return (signed_pdus, signed_auth)
@defer.inlineCallbacks
def get_events_from_store_or_dest(self, destination, room_id, event_ids):
@ -429,7 +429,7 @@ class FederationClient(FederationBase):
missing_events.discard(k)
if not missing_events:
defer.returnValue((signed_events, failed_to_fetch))
return (signed_events, failed_to_fetch)
logger.debug(
"Fetching unknown state/auth events %s for room %s",
@ -465,7 +465,7 @@ class FederationClient(FederationBase):
# We removed all events we successfully fetched from `batch`
failed_to_fetch.update(batch)
defer.returnValue((signed_events, failed_to_fetch))
return (signed_events, failed_to_fetch)
@defer.inlineCallbacks
@log_function
@ -485,7 +485,7 @@ class FederationClient(FederationBase):
signed_auth.sort(key=lambda e: e.depth)
defer.returnValue(signed_auth)
return signed_auth
@defer.inlineCallbacks
def _try_destination_list(self, description, destinations, callback):
@ -521,7 +521,7 @@ class FederationClient(FederationBase):
try:
res = yield callback(destination)
defer.returnValue(res)
return res
except InvalidResponseError as e:
logger.warn("Failed to %s via %s: %s", description, destination, e)
except HttpResponseException as e:
@ -615,7 +615,7 @@ class FederationClient(FederationBase):
event_dict=pdu_dict,
)
defer.returnValue((destination, ev, event_format))
return (destination, ev, event_format)
return self._try_destination_list(
"make_" + membership, destinations, send_request
@ -728,13 +728,11 @@ class FederationClient(FederationBase):
check_authchain_validity(signed_auth)
defer.returnValue(
{
return {
"state": signed_state,
"auth_chain": signed_auth,
"origin": destination,
}
)
return self._try_destination_list("send_join", destinations, send_request)
@ -758,7 +756,7 @@ class FederationClient(FederationBase):
# FIXME: We should handle signature failures more gracefully.
defer.returnValue(pdu)
return pdu
@defer.inlineCallbacks
def _do_send_invite(self, destination, pdu, room_version):
@ -786,7 +784,7 @@ class FederationClient(FederationBase):
"invite_room_state": pdu.unsigned.get("invite_room_state", []),
},
)
defer.returnValue(content)
return content
except HttpResponseException as e:
if e.code in [400, 404]:
err = e.to_synapse_error()
@ -821,7 +819,7 @@ class FederationClient(FederationBase):
event_id=pdu.event_id,
content=pdu.get_pdu_json(time_now),
)
defer.returnValue(content)
return content
def send_leave(self, destinations, pdu):
"""Sends a leave event to one of a list of homeservers.
@ -856,7 +854,7 @@ class FederationClient(FederationBase):
)
logger.debug("Got content: %s", content)
defer.returnValue(None)
return None
return self._try_destination_list("send_leave", destinations, send_request)
@ -917,7 +915,7 @@ class FederationClient(FederationBase):
"missing": content.get("missing", []),
}
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def get_missing_events(
@ -974,7 +972,7 @@ class FederationClient(FederationBase):
# get_missing_events
signed_events = []
defer.returnValue(signed_events)
return signed_events
@defer.inlineCallbacks
def forward_third_party_invite(self, destinations, room_id, event_dict):
@ -986,7 +984,7 @@ class FederationClient(FederationBase):
yield self.transport_layer.exchange_third_party_invite(
destination=destination, room_id=room_id, event_dict=event_dict
)
defer.returnValue(None)
return None
except CodeMessageException:
raise
except Exception as e:

View File

@ -99,7 +99,7 @@ class FederationServer(FederationBase):
res = self._transaction_from_pdus(pdus).get_dict()
defer.returnValue((200, res))
return (200, res)
@defer.inlineCallbacks
@log_function
@ -126,7 +126,7 @@ class FederationServer(FederationBase):
origin, transaction, request_time
)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def _handle_incoming_transaction(self, origin, transaction, request_time):
@ -147,8 +147,7 @@ class FederationServer(FederationBase):
"[%s] We've already responded to this request",
transaction.transaction_id,
)
defer.returnValue(response)
return
return response
logger.debug("[%s] Transaction is new", transaction.transaction_id)
@ -163,7 +162,7 @@ class FederationServer(FederationBase):
yield self.transaction_actions.set_response(
origin, transaction, 400, response
)
defer.returnValue((400, response))
return (400, response)
received_pdus_counter.inc(len(transaction.pdus))
@ -265,7 +264,7 @@ class FederationServer(FederationBase):
logger.debug("Returning: %s", str(response))
yield self.transaction_actions.set_response(origin, transaction, 200, response)
defer.returnValue((200, response))
return (200, response)
@defer.inlineCallbacks
def received_edu(self, origin, edu_type, content):
@ -298,7 +297,7 @@ class FederationServer(FederationBase):
event_id,
)
defer.returnValue((200, resp))
return (200, resp)
@defer.inlineCallbacks
def on_state_ids_request(self, origin, room_id, event_id):
@ -315,9 +314,7 @@ class FederationServer(FederationBase):
state_ids = yield self.handler.get_state_ids_for_pdu(room_id, event_id)
auth_chain_ids = yield self.store.get_auth_chain_ids(state_ids)
defer.returnValue(
(200, {"pdu_ids": state_ids, "auth_chain_ids": auth_chain_ids})
)
return (200, {"pdu_ids": state_ids, "auth_chain_ids": auth_chain_ids})
@defer.inlineCallbacks
def _on_context_state_request_compute(self, room_id, event_id):
@ -336,12 +333,10 @@ class FederationServer(FederationBase):
)
)
defer.returnValue(
{
return {
"pdus": [pdu.get_pdu_json() for pdu in pdus],
"auth_chain": [pdu.get_pdu_json() for pdu in auth_chain],
}
)
@defer.inlineCallbacks
@log_function
@ -349,15 +344,15 @@ class FederationServer(FederationBase):
pdu = yield self.handler.get_persisted_pdu(origin, event_id)
if pdu:
defer.returnValue((200, self._transaction_from_pdus([pdu]).get_dict()))
return (200, self._transaction_from_pdus([pdu]).get_dict())
else:
defer.returnValue((404, ""))
return (404, "")
@defer.inlineCallbacks
def on_query_request(self, query_type, args):
received_queries_counter.labels(query_type).inc()
resp = yield self.registry.on_query(query_type, args)
defer.returnValue((200, resp))
return (200, resp)
@defer.inlineCallbacks
def on_make_join_request(self, origin, room_id, user_id, supported_versions):
@ -371,9 +366,7 @@ class FederationServer(FederationBase):
pdu = yield self.handler.on_make_join_request(room_id, user_id)
time_now = self._clock.time_msec()
defer.returnValue(
{"event": pdu.get_pdu_json(time_now), "room_version": room_version}
)
return {"event": pdu.get_pdu_json(time_now), "room_version": room_version}
@defer.inlineCallbacks
def on_invite_request(self, origin, content, room_version):
@ -391,7 +384,7 @@ class FederationServer(FederationBase):
yield self.check_server_matches_acl(origin_host, pdu.room_id)
ret_pdu = yield self.handler.on_invite_request(origin, pdu)
time_now = self._clock.time_msec()
defer.returnValue({"event": ret_pdu.get_pdu_json(time_now)})
return {"event": ret_pdu.get_pdu_json(time_now)}
@defer.inlineCallbacks
def on_send_join_request(self, origin, content, room_id):
@ -407,8 +400,7 @@ class FederationServer(FederationBase):
logger.debug("on_send_join_request: pdu sigs: %s", pdu.signatures)
res_pdus = yield self.handler.on_send_join_request(origin, pdu)
time_now = self._clock.time_msec()
defer.returnValue(
(
return (
200,
{
"state": [p.get_pdu_json(time_now) for p in res_pdus["state"]],
@ -417,7 +409,6 @@ class FederationServer(FederationBase):
],
},
)
)
@defer.inlineCallbacks
def on_make_leave_request(self, origin, room_id, user_id):
@ -428,9 +419,7 @@ class FederationServer(FederationBase):
room_version = yield self.store.get_room_version(room_id)
time_now = self._clock.time_msec()
defer.returnValue(
{"event": pdu.get_pdu_json(time_now), "room_version": room_version}
)
return {"event": pdu.get_pdu_json(time_now), "room_version": room_version}
@defer.inlineCallbacks
def on_send_leave_request(self, origin, content, room_id):
@ -445,7 +434,7 @@ class FederationServer(FederationBase):
logger.debug("on_send_leave_request: pdu sigs: %s", pdu.signatures)
yield self.handler.on_send_leave_request(origin, pdu)
defer.returnValue((200, {}))
return (200, {})
@defer.inlineCallbacks
def on_event_auth(self, origin, room_id, event_id):
@ -456,7 +445,7 @@ class FederationServer(FederationBase):
time_now = self._clock.time_msec()
auth_pdus = yield self.handler.on_event_auth(event_id)
res = {"auth_chain": [a.get_pdu_json(time_now) for a in auth_pdus]}
defer.returnValue((200, res))
return (200, res)
@defer.inlineCallbacks
def on_query_auth_request(self, origin, content, room_id, event_id):
@ -509,7 +498,7 @@ class FederationServer(FederationBase):
"missing": ret.get("missing", []),
}
defer.returnValue((200, send_content))
return (200, send_content)
@log_function
def on_query_client_keys(self, origin, content):
@ -548,7 +537,7 @@ class FederationServer(FederationBase):
),
)
defer.returnValue({"one_time_keys": json_result})
return {"one_time_keys": json_result}
@defer.inlineCallbacks
@log_function
@ -580,9 +569,7 @@ class FederationServer(FederationBase):
time_now = self._clock.time_msec()
defer.returnValue(
{"events": [ev.get_pdu_json(time_now) for ev in missing_events]}
)
return {"events": [ev.get_pdu_json(time_now) for ev in missing_events]}
@log_function
def on_openid_userinfo(self, token):
@ -676,14 +663,14 @@ class FederationServer(FederationBase):
ret = yield self.handler.exchange_third_party_invite(
sender_user_id, target_user_id, room_id, signed
)
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def on_exchange_third_party_invite_request(self, origin, room_id, event_dict):
ret = yield self.handler.on_exchange_third_party_invite_request(
origin, room_id, event_dict
)
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def check_server_matches_acl(self, server_name, room_id):

View File

@ -374,7 +374,7 @@ class PerDestinationQueue(object):
assert len(edus) <= limit, "get_devices_by_remote returned too many EDUs"
defer.returnValue((edus, now_stream_id))
return (edus, now_stream_id)
@defer.inlineCallbacks
def _get_to_device_message_edus(self, limit):
@ -393,4 +393,4 @@ class PerDestinationQueue(object):
for content in contents
]
defer.returnValue((edus, stream_id))
return (edus, stream_id)

View File

@ -133,4 +133,4 @@ class TransactionManager(object):
)
success = False
defer.returnValue(success)
return success

View File

@ -183,7 +183,7 @@ class TransportLayerClient(object):
try_trailing_slash_on_400=True,
)
defer.returnValue(response)
return response
@defer.inlineCallbacks
@log_function
@ -201,7 +201,7 @@ class TransportLayerClient(object):
ignore_backoff=ignore_backoff,
)
defer.returnValue(content)
return content
@defer.inlineCallbacks
@log_function
@ -259,7 +259,7 @@ class TransportLayerClient(object):
ignore_backoff=ignore_backoff,
)
defer.returnValue(content)
return content
@defer.inlineCallbacks
@log_function
@ -270,7 +270,7 @@ class TransportLayerClient(object):
destination=destination, path=path, data=content
)
defer.returnValue(response)
return response
@defer.inlineCallbacks
@log_function
@ -288,7 +288,7 @@ class TransportLayerClient(object):
ignore_backoff=True,
)
defer.returnValue(response)
return response
@defer.inlineCallbacks
@log_function
@ -299,7 +299,7 @@ class TransportLayerClient(object):
destination=destination, path=path, data=content, ignore_backoff=True
)
defer.returnValue(response)
return response
@defer.inlineCallbacks
@log_function
@ -310,7 +310,7 @@ class TransportLayerClient(object):
destination=destination, path=path, data=content, ignore_backoff=True
)
defer.returnValue(response)
return response
@defer.inlineCallbacks
@log_function
@ -339,7 +339,7 @@ class TransportLayerClient(object):
destination=remote_server, path=path, args=args, ignore_backoff=True
)
defer.returnValue(response)
return response
@defer.inlineCallbacks
@log_function
@ -350,7 +350,7 @@ class TransportLayerClient(object):
destination=destination, path=path, data=event_dict
)
defer.returnValue(response)
return response
@defer.inlineCallbacks
@log_function
@ -359,7 +359,7 @@ class TransportLayerClient(object):
content = yield self.client.get_json(destination=destination, path=path)
defer.returnValue(content)
return content
@defer.inlineCallbacks
@log_function
@ -370,7 +370,7 @@ class TransportLayerClient(object):
destination=destination, path=path, data=content
)
defer.returnValue(content)
return content
@defer.inlineCallbacks
@log_function
@ -402,7 +402,7 @@ class TransportLayerClient(object):
content = yield self.client.post_json(
destination=destination, path=path, data=query_content, timeout=timeout
)
defer.returnValue(content)
return content
@defer.inlineCallbacks
@log_function
@ -426,7 +426,7 @@ class TransportLayerClient(object):
content = yield self.client.get_json(
destination=destination, path=path, timeout=timeout
)
defer.returnValue(content)
return content
@defer.inlineCallbacks
@log_function
@ -460,7 +460,7 @@ class TransportLayerClient(object):
content = yield self.client.post_json(
destination=destination, path=path, data=query_content, timeout=timeout
)
defer.returnValue(content)
return content
@defer.inlineCallbacks
@log_function
@ -488,7 +488,7 @@ class TransportLayerClient(object):
timeout=timeout,
)
defer.returnValue(content)
return content
@log_function
def get_group_profile(self, destination, group_id, requester_user_id):

View File

@ -157,7 +157,7 @@ class GroupAttestionRenewer(object):
yield self.store.update_remote_attestion(group_id, user_id, attestation)
defer.returnValue({})
return {}
def _start_renew_attestations(self):
return run_as_background_process("renew_attestations", self._renew_attestations)

View File

@ -85,7 +85,7 @@ class GroupsServerHandler(object):
if not is_admin:
raise SynapseError(403, "User is not admin in group")
defer.returnValue(group)
return group
@defer.inlineCallbacks
def get_group_summary(self, group_id, requester_user_id):
@ -151,8 +151,7 @@ class GroupsServerHandler(object):
group_id, requester_user_id
)
defer.returnValue(
{
return {
"profile": profile,
"users_section": {
"users": users,
@ -166,7 +165,6 @@ class GroupsServerHandler(object):
},
"user": membership_info,
}
)
@defer.inlineCallbacks
def update_group_summary_room(
@ -192,7 +190,7 @@ class GroupsServerHandler(object):
is_public=is_public,
)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def delete_group_summary_room(
@ -208,7 +206,7 @@ class GroupsServerHandler(object):
group_id=group_id, room_id=room_id, category_id=category_id
)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def set_group_join_policy(self, group_id, requester_user_id, content):
@ -228,7 +226,7 @@ class GroupsServerHandler(object):
yield self.store.set_group_join_policy(group_id, join_policy=join_policy)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def get_group_categories(self, group_id, requester_user_id):
@ -237,7 +235,7 @@ class GroupsServerHandler(object):
yield self.check_group_is_ours(group_id, requester_user_id, and_exists=True)
categories = yield self.store.get_group_categories(group_id=group_id)
defer.returnValue({"categories": categories})
return {"categories": categories}
@defer.inlineCallbacks
def get_group_category(self, group_id, requester_user_id, category_id):
@ -249,7 +247,7 @@ class GroupsServerHandler(object):
group_id=group_id, category_id=category_id
)
defer.returnValue(res)
return res
@defer.inlineCallbacks
def update_group_category(self, group_id, requester_user_id, category_id, content):
@ -269,7 +267,7 @@ class GroupsServerHandler(object):
profile=profile,
)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def delete_group_category(self, group_id, requester_user_id, category_id):
@ -283,7 +281,7 @@ class GroupsServerHandler(object):
group_id=group_id, category_id=category_id
)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def get_group_roles(self, group_id, requester_user_id):
@ -292,7 +290,7 @@ class GroupsServerHandler(object):
yield self.check_group_is_ours(group_id, requester_user_id, and_exists=True)
roles = yield self.store.get_group_roles(group_id=group_id)
defer.returnValue({"roles": roles})
return {"roles": roles}
@defer.inlineCallbacks
def get_group_role(self, group_id, requester_user_id, role_id):
@ -301,7 +299,7 @@ class GroupsServerHandler(object):
yield self.check_group_is_ours(group_id, requester_user_id, and_exists=True)
res = yield self.store.get_group_role(group_id=group_id, role_id=role_id)
defer.returnValue(res)
return res
@defer.inlineCallbacks
def update_group_role(self, group_id, requester_user_id, role_id, content):
@ -319,7 +317,7 @@ class GroupsServerHandler(object):
group_id=group_id, role_id=role_id, is_public=is_public, profile=profile
)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def delete_group_role(self, group_id, requester_user_id, role_id):
@ -331,7 +329,7 @@ class GroupsServerHandler(object):
yield self.store.remove_group_role(group_id=group_id, role_id=role_id)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def update_group_summary_user(
@ -355,7 +353,7 @@ class GroupsServerHandler(object):
is_public=is_public,
)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def delete_group_summary_user(self, group_id, requester_user_id, user_id, role_id):
@ -369,7 +367,7 @@ class GroupsServerHandler(object):
group_id=group_id, user_id=user_id, role_id=role_id
)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def get_group_profile(self, group_id, requester_user_id):
@ -391,7 +389,7 @@ class GroupsServerHandler(object):
group_description = {key: group[key] for key in cols}
group_description["is_openly_joinable"] = group["join_policy"] == "open"
defer.returnValue(group_description)
return group_description
else:
raise SynapseError(404, "Unknown group")
@ -461,9 +459,7 @@ class GroupsServerHandler(object):
# TODO: If admin add lists of users whose attestations have timed out
defer.returnValue(
{"chunk": chunk, "total_user_count_estimate": len(user_results)}
)
return {"chunk": chunk, "total_user_count_estimate": len(user_results)}
@defer.inlineCallbacks
def get_invited_users_in_group(self, group_id, requester_user_id):
@ -494,9 +490,7 @@ class GroupsServerHandler(object):
logger.warn("Error getting profile for %s: %s", user_id, e)
user_profiles.append(user_profile)
defer.returnValue(
{"chunk": user_profiles, "total_user_count_estimate": len(invited_users)}
)
return {"chunk": user_profiles, "total_user_count_estimate": len(invited_users)}
@defer.inlineCallbacks
def get_rooms_in_group(self, group_id, requester_user_id):
@ -533,9 +527,7 @@ class GroupsServerHandler(object):
chunk.sort(key=lambda e: -e["num_joined_members"])
defer.returnValue(
{"chunk": chunk, "total_room_count_estimate": len(room_results)}
)
return {"chunk": chunk, "total_room_count_estimate": len(room_results)}
@defer.inlineCallbacks
def add_room_to_group(self, group_id, requester_user_id, room_id, content):
@ -551,7 +543,7 @@ class GroupsServerHandler(object):
yield self.store.add_room_to_group(group_id, room_id, is_public=is_public)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def update_room_in_group(
@ -574,7 +566,7 @@ class GroupsServerHandler(object):
else:
raise SynapseError(400, "Uknown config option")
defer.returnValue({})
return {}
@defer.inlineCallbacks
def remove_room_from_group(self, group_id, requester_user_id, room_id):
@ -586,7 +578,7 @@ class GroupsServerHandler(object):
yield self.store.remove_room_from_group(group_id, room_id)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def invite_to_group(self, group_id, user_id, requester_user_id, content):
@ -644,9 +636,9 @@ class GroupsServerHandler(object):
)
elif res["state"] == "invite":
yield self.store.add_group_invite(group_id, user_id)
defer.returnValue({"state": "invite"})
return {"state": "invite"}
elif res["state"] == "reject":
defer.returnValue({"state": "reject"})
return {"state": "reject"}
else:
raise SynapseError(502, "Unknown state returned by HS")
@ -679,7 +671,7 @@ class GroupsServerHandler(object):
remote_attestation=remote_attestation,
)
defer.returnValue(local_attestation)
return local_attestation
@defer.inlineCallbacks
def accept_invite(self, group_id, requester_user_id, content):
@ -699,7 +691,7 @@ class GroupsServerHandler(object):
local_attestation = yield self._add_user(group_id, requester_user_id, content)
defer.returnValue({"state": "join", "attestation": local_attestation})
return {"state": "join", "attestation": local_attestation}
@defer.inlineCallbacks
def join_group(self, group_id, requester_user_id, content):
@ -716,7 +708,7 @@ class GroupsServerHandler(object):
local_attestation = yield self._add_user(group_id, requester_user_id, content)
defer.returnValue({"state": "join", "attestation": local_attestation})
return {"state": "join", "attestation": local_attestation}
@defer.inlineCallbacks
def knock(self, group_id, requester_user_id, content):
@ -769,7 +761,7 @@ class GroupsServerHandler(object):
if not self.hs.is_mine_id(user_id):
yield self.store.maybe_delete_remote_profile_cache(user_id)
defer.returnValue({})
return {}
@defer.inlineCallbacks
def create_group(self, group_id, requester_user_id, content):
@ -845,7 +837,7 @@ class GroupsServerHandler(object):
avatar_url=user_profile.get("avatar_url"),
)
defer.returnValue({"group_id": group_id})
return {"group_id": group_id}
@defer.inlineCallbacks
def delete_group(self, group_id, requester_user_id):

View File

@ -51,8 +51,8 @@ class AccountDataEventSource(object):
{"type": account_data_type, "content": content, "room_id": room_id}
)
defer.returnValue((results, current_stream_id))
return (results, current_stream_id)
@defer.inlineCallbacks
def get_pagination_rows(self, user, config, key):
defer.returnValue(([], config.to_id))
return ([], config.to_id)

View File

@ -193,7 +193,7 @@ class AccountValidityHandler(object):
if threepid["medium"] == "email":
addresses.append(threepid["address"])
defer.returnValue(addresses)
return addresses
@defer.inlineCallbacks
def _get_renewal_token(self, user_id):
@ -214,7 +214,7 @@ class AccountValidityHandler(object):
try:
renewal_token = stringutils.random_string(32)
yield self.store.set_renewal_token_for_user(user_id, renewal_token)
defer.returnValue(renewal_token)
return renewal_token
except StoreError:
attempts += 1
raise StoreError(500, "Couldn't generate a unique string as refresh string.")
@ -254,4 +254,4 @@ class AccountValidityHandler(object):
user_id=user_id, expiration_ts=expiration_ts, email_sent=email_sent
)
defer.returnValue(expiration_ts)
return expiration_ts

View File

@ -100,4 +100,4 @@ class AcmeHandler(object):
logger.exception("Failed saving!")
raise
defer.returnValue(True)
return True

View File

@ -49,7 +49,7 @@ class AdminHandler(BaseHandler):
"devices": {"": {"sessions": [{"connections": connections}]}},
}
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def get_users(self):
@ -61,7 +61,7 @@ class AdminHandler(BaseHandler):
"""
ret = yield self.store.get_users()
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def get_users_paginate(self, order, start, limit):
@ -78,7 +78,7 @@ class AdminHandler(BaseHandler):
"""
ret = yield self.store.get_users_paginate(order, start, limit)
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def search_users(self, term):
@ -92,7 +92,7 @@ class AdminHandler(BaseHandler):
"""
ret = yield self.store.search_users(term)
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def export_user_data(self, user_id, writer):
@ -225,7 +225,7 @@ class AdminHandler(BaseHandler):
state = yield self.store.get_state_for_event(event_id)
writer.write_state(room_id, event_id, state)
defer.returnValue(writer.finished())
return writer.finished()
class ExfiltrationWriter(object):

View File

@ -167,8 +167,8 @@ class ApplicationServicesHandler(object):
for user_service in user_query_services:
is_known_user = yield self.appservice_api.query_user(user_service, user_id)
if is_known_user:
defer.returnValue(True)
defer.returnValue(False)
return True
return False
@defer.inlineCallbacks
def query_room_alias_exists(self, room_alias):
@ -192,7 +192,7 @@ class ApplicationServicesHandler(object):
if is_known_alias:
# the alias exists now so don't query more ASes.
result = yield self.store.get_association_from_room_alias(room_alias)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def query_3pe(self, kind, protocol, fields):
@ -215,7 +215,7 @@ class ApplicationServicesHandler(object):
if success:
ret.extend(result)
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def get_3pe_protocols(self, only_protocol=None):
@ -254,7 +254,7 @@ class ApplicationServicesHandler(object):
for p in protocols.keys():
protocols[p] = _merge_instances(protocols[p])
defer.returnValue(protocols)
return protocols
@defer.inlineCallbacks
def _get_services_for_event(self, event):
@ -276,7 +276,7 @@ class ApplicationServicesHandler(object):
if (yield s.is_interested(event, self.store)):
interested_list.append(s)
defer.returnValue(interested_list)
return interested_list
def _get_services_for_user(self, user_id):
services = self.store.get_app_services()
@ -293,23 +293,23 @@ class ApplicationServicesHandler(object):
if not self.is_mine_id(user_id):
# we don't know if they are unknown or not since it isn't one of our
# users. We can't poke ASes.
defer.returnValue(False)
return False
return
user_info = yield self.store.get_user_by_id(user_id)
if user_info:
defer.returnValue(False)
return False
return
# user not found; could be the AS though, so check.
services = self.store.get_app_services()
service_list = [s for s in services if s.sender == user_id]
defer.returnValue(len(service_list) == 0)
return len(service_list) == 0
@defer.inlineCallbacks
def _check_user_exists(self, user_id):
unknown_user = yield self._is_unknown_user(user_id)
if unknown_user:
exists = yield self.query_user_exists(user_id)
defer.returnValue(exists)
defer.returnValue(True)
return exists
return True

View File

@ -155,7 +155,7 @@ class AuthHandler(BaseHandler):
if user_id != requester.user.to_string():
raise AuthError(403, "Invalid auth")
defer.returnValue(params)
return params
@defer.inlineCallbacks
def check_auth(self, flows, clientdict, clientip, password_servlet=False):
@ -280,7 +280,7 @@ class AuthHandler(BaseHandler):
creds,
list(clientdict),
)
defer.returnValue((creds, clientdict, session["id"]))
return (creds, clientdict, session["id"])
ret = self._auth_dict_for_flows(flows, session)
ret["completed"] = list(creds)
@ -307,8 +307,8 @@ class AuthHandler(BaseHandler):
if result:
creds[stagetype] = result
self._save_session(sess)
defer.returnValue(True)
defer.returnValue(False)
return True
return False
def get_session_id(self, clientdict):
"""
@ -379,7 +379,7 @@ class AuthHandler(BaseHandler):
res = yield checker(
authdict, clientip=clientip, password_servlet=password_servlet
)
defer.returnValue(res)
return res
# build a v1-login-style dict out of the authdict and fall back to the
# v1 code
@ -389,7 +389,7 @@ class AuthHandler(BaseHandler):
raise SynapseError(400, "", Codes.MISSING_PARAM)
(canonical_id, callback) = yield self.validate_login(user_id, authdict)
defer.returnValue(canonical_id)
return canonical_id
@defer.inlineCallbacks
def _check_recaptcha(self, authdict, clientip, **kwargs):
@ -433,7 +433,7 @@ class AuthHandler(BaseHandler):
resp_body.get("hostname"),
)
if resp_body["success"]:
defer.returnValue(True)
return True
raise LoginError(401, "", errcode=Codes.UNAUTHORIZED)
def _check_email_identity(self, authdict, **kwargs):
@ -502,7 +502,7 @@ class AuthHandler(BaseHandler):
threepid["threepid_creds"] = authdict["threepid_creds"]
defer.returnValue(threepid)
return threepid
def _get_params_recaptcha(self):
return {"public_key": self.hs.config.recaptcha_public_key}
@ -606,7 +606,7 @@ class AuthHandler(BaseHandler):
yield self.store.delete_access_token(access_token)
raise StoreError(400, "Login raced against device deletion")
defer.returnValue(access_token)
return access_token
@defer.inlineCallbacks
def check_user_exists(self, user_id):
@ -629,8 +629,8 @@ class AuthHandler(BaseHandler):
self.ratelimit_login_per_account(user_id)
res = yield self._find_user_id_and_pwd_hash(user_id)
if res is not None:
defer.returnValue(res[0])
defer.returnValue(None)
return res[0]
return None
@defer.inlineCallbacks
def _find_user_id_and_pwd_hash(self, user_id):
@ -661,7 +661,7 @@ class AuthHandler(BaseHandler):
user_id,
user_infos.keys(),
)
defer.returnValue(result)
return result
def get_supported_login_types(self):
"""Get a the login types supported for the /login API
@ -722,7 +722,7 @@ class AuthHandler(BaseHandler):
known_login_type = True
is_valid = yield provider.check_password(qualified_user_id, password)
if is_valid:
defer.returnValue((qualified_user_id, None))
return (qualified_user_id, None)
if not hasattr(provider, "get_supported_login_types") or not hasattr(
provider, "check_auth"
@ -756,7 +756,7 @@ class AuthHandler(BaseHandler):
if result:
if isinstance(result, str):
result = (result, None)
defer.returnValue(result)
return result
if login_type == LoginType.PASSWORD and self.hs.config.password_localdb_enabled:
known_login_type = True
@ -766,7 +766,7 @@ class AuthHandler(BaseHandler):
)
if canonical_user_id:
defer.returnValue((canonical_user_id, None))
return (canonical_user_id, None)
if not known_login_type:
raise SynapseError(400, "Unknown login type %s" % login_type)
@ -814,9 +814,9 @@ class AuthHandler(BaseHandler):
if isinstance(result, str):
# If it's a str, set callback function to None
result = (result, None)
defer.returnValue(result)
return result
defer.returnValue((None, None))
return (None, None)
@defer.inlineCallbacks
def _check_local_password(self, user_id, password):
@ -838,7 +838,7 @@ class AuthHandler(BaseHandler):
"""
lookupres = yield self._find_user_id_and_pwd_hash(user_id)
if not lookupres:
defer.returnValue(None)
return None
(user_id, password_hash) = lookupres
# If the password hash is None, the account has likely been deactivated
@ -850,8 +850,8 @@ class AuthHandler(BaseHandler):
result = yield self.validate_hash(password, password_hash)
if not result:
logger.warn("Failed password login for user %s", user_id)
defer.returnValue(None)
defer.returnValue(user_id)
return None
return user_id
@defer.inlineCallbacks
def validate_short_term_login_token_and_get_user_id(self, login_token):
@ -865,7 +865,7 @@ class AuthHandler(BaseHandler):
raise AuthError(403, "Invalid token", errcode=Codes.FORBIDDEN)
self.ratelimit_login_per_account(user_id)
yield self.auth.check_auth_blocking(user_id)
defer.returnValue(user_id)
return user_id
@defer.inlineCallbacks
def delete_access_token(self, access_token):
@ -976,7 +976,7 @@ class AuthHandler(BaseHandler):
)
yield self.store.user_delete_threepid(user_id, medium, address)
defer.returnValue(result)
return result
def _save_session(self, session):
# TODO: Persistent storage

View File

@ -125,7 +125,7 @@ class DeactivateAccountHandler(BaseHandler):
# Mark the user as deactivated.
yield self.store.set_user_deactivated_status(user_id, True)
defer.returnValue(identity_server_supports_unbinding)
return identity_server_supports_unbinding
def _start_user_parting(self):
"""

View File

@ -64,7 +64,7 @@ class DeviceWorkerHandler(BaseHandler):
for device in devices:
_update_device_from_client_ips(device, ips)
defer.returnValue(devices)
return devices
@defer.inlineCallbacks
def get_device(self, user_id, device_id):
@ -85,7 +85,7 @@ class DeviceWorkerHandler(BaseHandler):
raise errors.NotFoundError
ips = yield self.store.get_last_client_ip_by_device(user_id, device_id)
_update_device_from_client_ips(device, ips)
defer.returnValue(device)
return device
@measure_func("device.get_user_ids_changed")
@defer.inlineCallbacks
@ -200,9 +200,7 @@ class DeviceWorkerHandler(BaseHandler):
possibly_joined = []
possibly_left = []
defer.returnValue(
{"changed": list(possibly_joined), "left": list(possibly_left)}
)
return {"changed": list(possibly_joined), "left": list(possibly_left)}
class DeviceHandler(DeviceWorkerHandler):
@ -250,7 +248,7 @@ class DeviceHandler(DeviceWorkerHandler):
)
if new_device:
yield self.notify_device_update(user_id, [device_id])
defer.returnValue(device_id)
return device_id
# if the device id is not specified, we'll autogen one, but loop a few
# times in case of a clash.
@ -264,7 +262,7 @@ class DeviceHandler(DeviceWorkerHandler):
)
if new_device:
yield self.notify_device_update(user_id, [device_id])
defer.returnValue(device_id)
return device_id
attempts += 1
raise errors.StoreError(500, "Couldn't generate a device ID.")
@ -411,9 +409,7 @@ class DeviceHandler(DeviceWorkerHandler):
@defer.inlineCallbacks
def on_federation_query_user_devices(self, user_id):
stream_id, devices = yield self.store.get_devices_with_keys_by_user(user_id)
defer.returnValue(
{"user_id": user_id, "stream_id": stream_id, "devices": devices}
)
return {"user_id": user_id, "stream_id": stream_id, "devices": devices}
@defer.inlineCallbacks
def user_left_room(self, user, room_id):
@ -623,7 +619,7 @@ class DeviceListEduUpdater(object):
for _, stream_id, prev_ids, _ in updates:
if not prev_ids:
# We always do a resync if there are no previous IDs
defer.returnValue(True)
return True
for prev_id in prev_ids:
if prev_id == extremity:
@ -633,8 +629,8 @@ class DeviceListEduUpdater(object):
elif prev_id in stream_id_in_updates:
continue
else:
defer.returnValue(True)
return True
stream_id_in_updates.add(stream_id)
defer.returnValue(False)
return False

View File

@ -210,7 +210,7 @@ class DirectoryHandler(BaseHandler):
except AuthError as e:
logger.info("Failed to update alias events: %s", e)
defer.returnValue(room_id)
return room_id
@defer.inlineCallbacks
def delete_appservice_association(self, service, room_alias):
@ -229,7 +229,7 @@ class DirectoryHandler(BaseHandler):
room_id = yield self.store.delete_room_alias(room_alias)
defer.returnValue(room_id)
return room_id
@defer.inlineCallbacks
def get_association(self, room_alias):
@ -277,7 +277,7 @@ class DirectoryHandler(BaseHandler):
else:
servers = list(servers)
defer.returnValue({"room_id": room_id, "servers": servers})
return {"room_id": room_id, "servers": servers}
return
@defer.inlineCallbacks
@ -289,7 +289,7 @@ class DirectoryHandler(BaseHandler):
result = yield self.get_association_from_room_alias(room_alias)
if result is not None:
defer.returnValue({"room_id": result.room_id, "servers": result.servers})
return {"room_id": result.room_id, "servers": result.servers}
else:
raise SynapseError(
404,
@ -342,7 +342,7 @@ class DirectoryHandler(BaseHandler):
# Query AS to see if it exists
as_handler = self.appservice_handler
result = yield as_handler.query_room_alias_exists(room_alias)
defer.returnValue(result)
return result
def can_modify_alias(self, alias, user_id=None):
# Any application service "interested" in an alias they are regexing on
@ -369,10 +369,10 @@ class DirectoryHandler(BaseHandler):
creator = yield self.store.get_room_alias_creator(alias.to_string())
if creator is not None and creator == user_id:
defer.returnValue(True)
return True
is_admin = yield self.auth.is_server_admin(UserID.from_string(user_id))
defer.returnValue(is_admin)
return is_admin
@defer.inlineCallbacks
def edit_published_room_list(self, requester, room_id, visibility):

View File

@ -144,7 +144,7 @@ class E2eKeysHandler(object):
)
)
defer.returnValue({"device_keys": results, "failures": failures})
return {"device_keys": results, "failures": failures}
@defer.inlineCallbacks
def query_local_devices(self, query):
@ -189,7 +189,7 @@ class E2eKeysHandler(object):
r["unsigned"]["device_display_name"] = display_name
result_dict[user_id][device_id] = r
defer.returnValue(result_dict)
return result_dict
@defer.inlineCallbacks
def on_federation_query_client_keys(self, query_body):
@ -197,7 +197,7 @@ class E2eKeysHandler(object):
"""
device_keys_query = query_body.get("device_keys", {})
res = yield self.query_local_devices(device_keys_query)
defer.returnValue({"device_keys": res})
return {"device_keys": res}
@defer.inlineCallbacks
def claim_one_time_keys(self, query, timeout):
@ -259,7 +259,7 @@ class E2eKeysHandler(object):
),
)
defer.returnValue({"one_time_keys": json_result, "failures": failures})
return {"one_time_keys": json_result, "failures": failures}
@defer.inlineCallbacks
def upload_keys_for_user(self, user_id, device_id, keys):
@ -297,7 +297,7 @@ class E2eKeysHandler(object):
result = yield self.store.count_e2e_one_time_keys(user_id, device_id)
defer.returnValue({"one_time_key_counts": result})
return {"one_time_key_counts": result}
@defer.inlineCallbacks
def _upload_one_time_keys_for_user(

View File

@ -84,7 +84,7 @@ class E2eRoomKeysHandler(object):
user_id, version, room_id, session_id
)
defer.returnValue(results)
return results
@defer.inlineCallbacks
def delete_room_keys(self, user_id, version, room_id=None, session_id=None):
@ -262,7 +262,7 @@ class E2eRoomKeysHandler(object):
new_version = yield self.store.create_e2e_room_keys_version(
user_id, version_info
)
defer.returnValue(new_version)
return new_version
@defer.inlineCallbacks
def get_version_info(self, user_id, version=None):
@ -292,7 +292,7 @@ class E2eRoomKeysHandler(object):
raise NotFoundError("Unknown backup version")
else:
raise
defer.returnValue(res)
return res
@defer.inlineCallbacks
def delete_version(self, user_id, version=None):
@ -350,4 +350,4 @@ class E2eRoomKeysHandler(object):
user_id, version, version_info
)
defer.returnValue({})
return {}

View File

@ -143,7 +143,7 @@ class EventStreamHandler(BaseHandler):
"end": tokens[1].to_string(),
}
defer.returnValue(chunk)
return chunk
class EventHandler(BaseHandler):
@ -166,7 +166,7 @@ class EventHandler(BaseHandler):
event = yield self.store.get_event(event_id, check_room_id=room_id)
if not event:
defer.returnValue(None)
return None
return
users = yield self.store.get_users_in_room(event.room_id)
@ -179,4 +179,4 @@ class EventHandler(BaseHandler):
if not filtered:
raise AuthError(403, "You don't have permission to access that event.")
defer.returnValue(event)
return event

View File

@ -210,7 +210,7 @@ class FederationHandler(BaseHandler):
event_id,
origin,
)
defer.returnValue(None)
return None
state = None
auth_chain = []
@ -676,7 +676,7 @@ class FederationHandler(BaseHandler):
events = [e for e in events if e.event_id not in seen_events]
if not events:
defer.returnValue([])
return []
event_map = {e.event_id: e for e in events}
@ -838,7 +838,7 @@ class FederationHandler(BaseHandler):
# TODO: We can probably do something more clever here.
yield self._handle_new_event(dest, event, backfilled=True)
defer.returnValue(events)
return events
@defer.inlineCallbacks
def maybe_backfill(self, room_id, current_depth):
@ -894,7 +894,7 @@ class FederationHandler(BaseHandler):
)
if not filtered_extremities:
defer.returnValue(False)
return False
# Check if we reached a point where we should start backfilling.
sorted_extremeties_tuple = sorted(extremities.items(), key=lambda e: -int(e[1]))
@ -965,7 +965,7 @@ class FederationHandler(BaseHandler):
# If this succeeded then we probably already have the
# appropriate stuff.
# TODO: We can probably do something more intelligent here.
defer.returnValue(True)
return True
except SynapseError as e:
logger.info("Failed to backfill from %s because %s", dom, e)
continue
@ -985,11 +985,11 @@ class FederationHandler(BaseHandler):
logger.exception("Failed to backfill from %s because %s", dom, e)
continue
defer.returnValue(False)
return False
success = yield try_backfill(likely_domains)
if success:
defer.returnValue(True)
return True
# Huh, well *those* domains didn't work out. Lets try some domains
# from the time.
@ -1031,11 +1031,11 @@ class FederationHandler(BaseHandler):
[dom for dom, _ in likely_domains if dom not in tried_domains]
)
if success:
defer.returnValue(True)
return True
tried_domains.update(dom for dom, _ in likely_domains)
defer.returnValue(False)
return False
def _sanity_check_event(self, ev):
"""
@ -1082,7 +1082,7 @@ class FederationHandler(BaseHandler):
pdu=event,
)
defer.returnValue(pdu)
return pdu
@defer.inlineCallbacks
def on_event_auth(self, event_id):
@ -1090,7 +1090,7 @@ class FederationHandler(BaseHandler):
auth = yield self.store.get_auth_chain(
[auth_id for auth_id in event.auth_event_ids()], include_given=True
)
defer.returnValue([e for e in auth])
return [e for e in auth]
@log_function
@defer.inlineCallbacks
@ -1177,7 +1177,7 @@ class FederationHandler(BaseHandler):
run_in_background(self._handle_queued_pdus, room_queue)
defer.returnValue(True)
return True
@defer.inlineCallbacks
def _handle_queued_pdus(self, room_queue):
@ -1247,7 +1247,7 @@ class FederationHandler(BaseHandler):
room_version, event, context, do_sig_check=False
)
defer.returnValue(event)
return event
@defer.inlineCallbacks
@log_function
@ -1308,7 +1308,7 @@ class FederationHandler(BaseHandler):
state = yield self.store.get_events(list(prev_state_ids.values()))
defer.returnValue({"state": list(state.values()), "auth_chain": auth_chain})
return {"state": list(state.values()), "auth_chain": auth_chain}
@defer.inlineCallbacks
def on_invite_request(self, origin, pdu):
@ -1364,7 +1364,7 @@ class FederationHandler(BaseHandler):
context = yield self.state_handler.compute_event_context(event)
yield self.persist_events_and_notify([(event, context)])
defer.returnValue(event)
return event
@defer.inlineCallbacks
def do_remotely_reject_invite(self, target_hosts, room_id, user_id):
@ -1389,7 +1389,7 @@ class FederationHandler(BaseHandler):
context = yield self.state_handler.compute_event_context(event)
yield self.persist_events_and_notify([(event, context)])
defer.returnValue(event)
return event
@defer.inlineCallbacks
def _make_and_verify_event(
@ -1407,7 +1407,7 @@ class FederationHandler(BaseHandler):
assert event.user_id == user_id
assert event.state_key == user_id
assert event.room_id == room_id
defer.returnValue((origin, event, format_ver))
return (origin, event, format_ver)
@defer.inlineCallbacks
@log_function
@ -1451,7 +1451,7 @@ class FederationHandler(BaseHandler):
logger.warn("Failed to create new leave %r because %s", event, e)
raise e
defer.returnValue(event)
return event
@defer.inlineCallbacks
@log_function
@ -1484,7 +1484,7 @@ class FederationHandler(BaseHandler):
event.signatures,
)
defer.returnValue(None)
return None
@defer.inlineCallbacks
def get_state_for_pdu(self, room_id, event_id):
@ -1512,9 +1512,9 @@ class FederationHandler(BaseHandler):
del results[(event.type, event.state_key)]
res = list(results.values())
defer.returnValue(res)
return res
else:
defer.returnValue([])
return []
@defer.inlineCallbacks
def get_state_ids_for_pdu(self, room_id, event_id):
@ -1539,9 +1539,9 @@ class FederationHandler(BaseHandler):
else:
results.pop((event.type, event.state_key), None)
defer.returnValue(list(results.values()))
return list(results.values())
else:
defer.returnValue([])
return []
@defer.inlineCallbacks
@log_function
@ -1554,7 +1554,7 @@ class FederationHandler(BaseHandler):
events = yield filter_events_for_server(self.store, origin, events)
defer.returnValue(events)
return events
@defer.inlineCallbacks
@log_function
@ -1584,9 +1584,9 @@ class FederationHandler(BaseHandler):
events = yield filter_events_for_server(self.store, origin, [event])
event = events[0]
defer.returnValue(event)
return event
else:
defer.returnValue(None)
return None
def get_min_depth_for_context(self, context):
return self.store.get_min_depth(context)
@ -1618,7 +1618,7 @@ class FederationHandler(BaseHandler):
self.store.remove_push_actions_from_staging, event.event_id
)
defer.returnValue(context)
return context
@defer.inlineCallbacks
def _handle_new_events(self, origin, event_infos, backfilled=False):
@ -1641,7 +1641,7 @@ class FederationHandler(BaseHandler):
auth_events=ev_info.get("auth_events"),
backfilled=backfilled,
)
defer.returnValue(res)
return res
contexts = yield make_deferred_yieldable(
defer.gatherResults(
@ -1800,7 +1800,7 @@ class FederationHandler(BaseHandler):
if event.type == EventTypes.GuestAccess and not context.rejected:
yield self.maybe_kick_guest_users(event)
defer.returnValue(context)
return context
@defer.inlineCallbacks
def _check_for_soft_fail(self, event, state, backfilled):
@ -1919,7 +1919,7 @@ class FederationHandler(BaseHandler):
logger.debug("on_query_auth returning: %s", ret)
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def on_get_missing_events(
@ -1942,7 +1942,7 @@ class FederationHandler(BaseHandler):
self.store, origin, missing_events
)
defer.returnValue(missing_events)
return missing_events
@defer.inlineCallbacks
@log_function
@ -2418,8 +2418,7 @@ class FederationHandler(BaseHandler):
logger.debug("construct_auth_difference returning")
defer.returnValue(
{
return {
"auth_chain": local_auth,
"rejects": {
e.event_id: {"reason": reason_map[e.event_id], "proof": None}
@ -2427,7 +2426,6 @@ class FederationHandler(BaseHandler):
},
"missing": [e.event_id for e in missing_locals],
}
)
@defer.inlineCallbacks
@log_function
@ -2575,7 +2573,7 @@ class FederationHandler(BaseHandler):
builder=builder
)
EventValidator().validate_new(event)
defer.returnValue((event, context))
return (event, context)
@defer.inlineCallbacks
def _check_signature(self, event, context):

View File

@ -162,7 +162,7 @@ class GroupsLocalHandler(object):
res.setdefault("user", {})["is_publicised"] = is_publicised
defer.returnValue(res)
return res
@defer.inlineCallbacks
def create_group(self, group_id, user_id, content):
@ -207,7 +207,7 @@ class GroupsLocalHandler(object):
)
self.notifier.on_new_event("groups_key", token, users=[user_id])
defer.returnValue(res)
return res
@defer.inlineCallbacks
def get_users_in_group(self, group_id, requester_user_id):
@ -217,7 +217,7 @@ class GroupsLocalHandler(object):
res = yield self.groups_server_handler.get_users_in_group(
group_id, requester_user_id
)
defer.returnValue(res)
return res
group_server_name = get_domain_from_id(group_id)
@ -244,7 +244,7 @@ class GroupsLocalHandler(object):
res["chunk"] = valid_entries
defer.returnValue(res)
return res
@defer.inlineCallbacks
def join_group(self, group_id, user_id, content):
@ -285,7 +285,7 @@ class GroupsLocalHandler(object):
)
self.notifier.on_new_event("groups_key", token, users=[user_id])
defer.returnValue({})
return {}
@defer.inlineCallbacks
def accept_invite(self, group_id, user_id, content):
@ -326,7 +326,7 @@ class GroupsLocalHandler(object):
)
self.notifier.on_new_event("groups_key", token, users=[user_id])
defer.returnValue({})
return {}
@defer.inlineCallbacks
def invite(self, group_id, user_id, requester_user_id, config):
@ -346,7 +346,7 @@ class GroupsLocalHandler(object):
content,
)
defer.returnValue(res)
return res
@defer.inlineCallbacks
def on_invite(self, group_id, user_id, content):
@ -377,7 +377,7 @@ class GroupsLocalHandler(object):
logger.warn("No profile for user %s: %s", user_id, e)
user_profile = {}
defer.returnValue({"state": "invite", "user_profile": user_profile})
return {"state": "invite", "user_profile": user_profile}
@defer.inlineCallbacks
def remove_user_from_group(self, group_id, user_id, requester_user_id, content):
@ -406,7 +406,7 @@ class GroupsLocalHandler(object):
content,
)
defer.returnValue(res)
return res
@defer.inlineCallbacks
def user_removed_from_group(self, group_id, user_id, content):
@ -421,7 +421,7 @@ class GroupsLocalHandler(object):
@defer.inlineCallbacks
def get_joined_groups(self, user_id):
group_ids = yield self.store.get_joined_groups(user_id)
defer.returnValue({"groups": group_ids})
return {"groups": group_ids}
@defer.inlineCallbacks
def get_publicised_groups_for_user(self, user_id):
@ -433,14 +433,14 @@ class GroupsLocalHandler(object):
for app_service in self.store.get_app_services():
result.extend(app_service.get_groups_for_user(user_id))
defer.returnValue({"groups": result})
return {"groups": result}
else:
bulk_result = yield self.transport_client.bulk_get_publicised_groups(
get_domain_from_id(user_id), [user_id]
)
result = bulk_result.get("users", {}).get(user_id)
# TODO: Verify attestations
defer.returnValue({"groups": result})
return {"groups": result}
@defer.inlineCallbacks
def bulk_get_publicised_groups(self, user_ids, proxy=True):
@ -475,4 +475,4 @@ class GroupsLocalHandler(object):
for app_service in self.store.get_app_services():
results[uid].extend(app_service.get_groups_for_user(uid))
defer.returnValue({"users": results})
return {"users": results}

View File

@ -82,7 +82,7 @@ class IdentityHandler(BaseHandler):
"%s is not a trusted ID server: rejecting 3pid " + "credentials",
id_server,
)
defer.returnValue(None)
return None
try:
data = yield self.http_client.get_json(
@ -95,8 +95,8 @@ class IdentityHandler(BaseHandler):
raise e.to_synapse_error()
if "medium" in data:
defer.returnValue(data)
defer.returnValue(None)
return data
return None
@defer.inlineCallbacks
def bind_threepid(self, creds, mxid):
@ -133,7 +133,7 @@ class IdentityHandler(BaseHandler):
)
except CodeMessageException as e:
data = json.loads(e.msg) # XXX WAT?
defer.returnValue(data)
return data
@defer.inlineCallbacks
def try_unbind_threepid(self, mxid, threepid):
@ -161,7 +161,7 @@ class IdentityHandler(BaseHandler):
# We don't know where to unbind, so we don't have a choice but to return
if not id_servers:
defer.returnValue(False)
return False
changed = True
for id_server in id_servers:
@ -169,7 +169,7 @@ class IdentityHandler(BaseHandler):
mxid, threepid, id_server
)
defer.returnValue(changed)
return changed
@defer.inlineCallbacks
def try_unbind_threepid_with_id_server(self, mxid, threepid, id_server):
@ -224,7 +224,7 @@ class IdentityHandler(BaseHandler):
id_server=id_server,
)
defer.returnValue(changed)
return changed
@defer.inlineCallbacks
def requestEmailToken(
@ -250,7 +250,7 @@ class IdentityHandler(BaseHandler):
% (id_server, "/_matrix/identity/api/v1/validate/email/requestToken"),
params,
)
defer.returnValue(data)
return data
except HttpResponseException as e:
logger.info("Proxied requestToken failed: %r", e)
raise e.to_synapse_error()
@ -278,7 +278,7 @@ class IdentityHandler(BaseHandler):
% (id_server, "/_matrix/identity/api/v1/validate/msisdn/requestToken"),
params,
)
defer.returnValue(data)
return data
except HttpResponseException as e:
logger.info("Proxied requestToken failed: %r", e)
raise e.to_synapse_error()

View File

@ -250,7 +250,7 @@ class InitialSyncHandler(BaseHandler):
"end": now_token.to_string(),
}
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def room_initial_sync(self, requester, room_id, pagin_config=None):
@ -301,7 +301,7 @@ class InitialSyncHandler(BaseHandler):
result["account_data"] = account_data_events
defer.returnValue(result)
return result
@defer.inlineCallbacks
def _room_initial_sync_parted(
@ -330,15 +330,12 @@ class InitialSyncHandler(BaseHandler):
time_now = self.clock.time_msec()
defer.returnValue(
{
return {
"membership": membership,
"room_id": room_id,
"messages": {
"chunk": (
yield self._event_serializer.serialize_events(
messages, time_now
)
yield self._event_serializer.serialize_events(messages, time_now)
),
"start": start_token.to_string(),
"end": end_token.to_string(),
@ -351,7 +348,6 @@ class InitialSyncHandler(BaseHandler):
"presence": [],
"receipts": [],
}
)
@defer.inlineCallbacks
def _room_initial_sync_joined(
@ -384,13 +380,13 @@ class InitialSyncHandler(BaseHandler):
def get_presence():
# If presence is disabled, return an empty list
if not self.hs.config.use_presence:
defer.returnValue([])
return []
states = yield presence_handler.get_states(
[m.user_id for m in room_members], as_event=True
)
defer.returnValue(states)
return states
@defer.inlineCallbacks
def get_receipts():
@ -399,7 +395,7 @@ class InitialSyncHandler(BaseHandler):
)
if not receipts:
receipts = []
defer.returnValue(receipts)
return receipts
presence, receipts, (messages, token) = yield make_deferred_yieldable(
defer.gatherResults(
@ -442,7 +438,7 @@ class InitialSyncHandler(BaseHandler):
if not is_peeking:
ret["membership"] = membership
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def _check_in_room_or_world_readable(self, room_id, user_id):
@ -453,7 +449,7 @@ class InitialSyncHandler(BaseHandler):
# * The user is a guest user, and has joined the room
# else it will throw.
member_event = yield self.auth.check_user_was_in_room(room_id, user_id)
defer.returnValue((member_event.membership, member_event.event_id))
return (member_event.membership, member_event.event_id)
return
except AuthError:
visibility = yield self.state_handler.get_current_state(
@ -463,7 +459,7 @@ class InitialSyncHandler(BaseHandler):
visibility
and visibility.content["history_visibility"] == "world_readable"
):
defer.returnValue((Membership.JOIN, None))
return (Membership.JOIN, None)
return
raise AuthError(
403, "Guest access not allowed", errcode=Codes.GUEST_ACCESS_FORBIDDEN

View File

@ -87,7 +87,7 @@ class MessageHandler(object):
)
data = room_state[membership_event_id].get(key)
defer.returnValue(data)
return data
@defer.inlineCallbacks
def get_state_events(
@ -174,7 +174,7 @@ class MessageHandler(object):
# events, as clients won't use them.
bundle_aggregations=False,
)
defer.returnValue(events)
return events
@defer.inlineCallbacks
def get_joined_members(self, requester, room_id):
@ -213,15 +213,13 @@ class MessageHandler(object):
# Loop fell through, AS has no interested users in room
raise AuthError(403, "Appservice not in room")
defer.returnValue(
{
return {
user_id: {
"avatar_url": profile.avatar_url,
"display_name": profile.display_name,
}
for user_id, profile in iteritems(users_with_profile)
}
)
class EventCreationHandler(object):
@ -398,7 +396,7 @@ class EventCreationHandler(object):
self.validator.validate_new(event)
defer.returnValue((event, context))
return (event, context)
def _is_exempt_from_privacy_policy(self, builder, requester):
""""Determine if an event to be sent is exempt from having to consent
@ -425,9 +423,9 @@ class EventCreationHandler(object):
@defer.inlineCallbacks
def _is_server_notices_room(self, room_id):
if self.config.server_notices_mxid is None:
defer.returnValue(False)
return False
user_ids = yield self.store.get_users_in_room(room_id)
defer.returnValue(self.config.server_notices_mxid in user_ids)
return self.config.server_notices_mxid in user_ids
@defer.inlineCallbacks
def assert_accepted_privacy_policy(self, requester):
@ -507,7 +505,7 @@ class EventCreationHandler(object):
event.event_id,
prev_state.event_id,
)
defer.returnValue(prev_state)
return prev_state
yield self.handle_new_client_event(
requester=requester, event=event, context=context, ratelimit=ratelimit
@ -531,7 +529,7 @@ class EventCreationHandler(object):
prev_content = encode_canonical_json(prev_event.content)
next_content = encode_canonical_json(event.content)
if prev_content == next_content:
defer.returnValue(prev_event)
return prev_event
return
@defer.inlineCallbacks
@ -563,7 +561,7 @@ class EventCreationHandler(object):
yield self.send_nonmember_event(
requester, event, context, ratelimit=ratelimit
)
defer.returnValue(event)
return event
@measure_func("create_new_client_event")
@defer.inlineCallbacks
@ -626,7 +624,7 @@ class EventCreationHandler(object):
logger.debug("Created event %s", event.event_id)
defer.returnValue((event, context))
return (event, context)
@measure_func("handle_new_client_event")
@defer.inlineCallbacks

View File

@ -242,13 +242,11 @@ class PaginationHandler(object):
)
if not events:
defer.returnValue(
{
return {
"chunk": [],
"start": pagin_config.from_token.to_string(),
"end": next_token.to_string(),
}
)
state = None
if event_filter and event_filter.lazy_load_members() and len(events) > 0:
@ -286,4 +284,4 @@ class PaginationHandler(object):
)
)
defer.returnValue(chunk)
return chunk

View File

@ -461,7 +461,7 @@ class PresenceHandler(object):
if affect_presence:
run_in_background(_end)
defer.returnValue(_user_syncing())
return _user_syncing()
def get_currently_syncing_users(self):
"""Get the set of user ids that are currently syncing on this HS.
@ -556,7 +556,7 @@ class PresenceHandler(object):
"""Get the current presence state for a user.
"""
res = yield self.current_state_for_users([user_id])
defer.returnValue(res[user_id])
return res[user_id]
@defer.inlineCallbacks
def current_state_for_users(self, user_ids):
@ -585,7 +585,7 @@ class PresenceHandler(object):
states.update(new)
self.user_to_current_state.update(new)
defer.returnValue(states)
return states
@defer.inlineCallbacks
def _persist_and_notify(self, states):
@ -681,7 +681,7 @@ class PresenceHandler(object):
def get_state(self, target_user, as_event=False):
results = yield self.get_states([target_user.to_string()], as_event=as_event)
defer.returnValue(results[0])
return results[0]
@defer.inlineCallbacks
def get_states(self, target_user_ids, as_event=False):
@ -703,17 +703,15 @@ class PresenceHandler(object):
now = self.clock.time_msec()
if as_event:
defer.returnValue(
[
return [
{
"type": "m.presence",
"content": format_user_presence_state(state, now),
}
for state in updates
]
)
else:
defer.returnValue(updates)
return updates
@defer.inlineCallbacks
def set_state(self, target_user, state, ignore_status_msg=False):
@ -757,9 +755,9 @@ class PresenceHandler(object):
)
if observer_room_ids & observed_room_ids:
defer.returnValue(True)
return True
defer.returnValue(False)
return False
@defer.inlineCallbacks
def get_all_presence_updates(self, last_id, current_id):
@ -778,7 +776,7 @@ class PresenceHandler(object):
# TODO(markjh): replicate the unpersisted changes.
# This could use the in-memory stores for recent changes.
rows = yield self.store.get_all_presence_updates(last_id, current_id)
defer.returnValue(rows)
return rows
def notify_new_event(self):
"""Called when new events have happened. Handles users and servers
@ -1034,7 +1032,7 @@ class PresenceEventSource(object):
#
# Hence this guard where we just return nothing so that the sync
# doesn't return. C.f. #5503.
defer.returnValue(([], max_token))
return ([], max_token)
presence = self.get_presence_handler()
stream_change_cache = self.store.presence_stream_cache
@ -1068,18 +1066,12 @@ class PresenceEventSource(object):
updates = yield presence.current_state_for_users(user_ids_changed)
if include_offline:
defer.returnValue((list(updates.values()), max_token))
return (list(updates.values()), max_token)
else:
defer.returnValue(
(
[
s
for s in itervalues(updates)
if s.state != PresenceState.OFFLINE
],
return (
[s for s in itervalues(updates) if s.state != PresenceState.OFFLINE],
max_token,
)
)
def get_current_key(self):
return self.store.get_current_presence_token()
@ -1107,7 +1099,7 @@ class PresenceEventSource(object):
)
users_interested_in.update(user_ids)
defer.returnValue(users_interested_in)
return users_interested_in
def handle_timeouts(user_states, is_mine_fn, syncing_user_ids, now):
@ -1287,7 +1279,7 @@ def get_interested_parties(store, states):
# Always notify self
users_to_states.setdefault(state.user_id, []).append(state)
defer.returnValue((room_ids_to_states, users_to_states))
return (room_ids_to_states, users_to_states)
@defer.inlineCallbacks
@ -1321,4 +1313,4 @@ def get_interested_remotes(store, states, state_handler):
host = get_domain_from_id(user_id)
hosts_and_states.append(([host], states))
defer.returnValue(hosts_and_states)
return hosts_and_states

View File

@ -73,7 +73,7 @@ class BaseProfileHandler(BaseHandler):
raise SynapseError(404, "Profile was not found", Codes.NOT_FOUND)
raise
defer.returnValue({"displayname": displayname, "avatar_url": avatar_url})
return {"displayname": displayname, "avatar_url": avatar_url}
else:
try:
result = yield self.federation.make_query(
@ -82,7 +82,7 @@ class BaseProfileHandler(BaseHandler):
args={"user_id": user_id},
ignore_backoff=True,
)
defer.returnValue(result)
return result
except RequestSendFailed as e:
raise_from(SynapseError(502, "Failed to fetch profile"), e)
except HttpResponseException as e:
@ -108,10 +108,10 @@ class BaseProfileHandler(BaseHandler):
raise SynapseError(404, "Profile was not found", Codes.NOT_FOUND)
raise
defer.returnValue({"displayname": displayname, "avatar_url": avatar_url})
return {"displayname": displayname, "avatar_url": avatar_url}
else:
profile = yield self.store.get_from_remote_profile_cache(user_id)
defer.returnValue(profile or {})
return profile or {}
@defer.inlineCallbacks
def get_displayname(self, target_user):
@ -125,7 +125,7 @@ class BaseProfileHandler(BaseHandler):
raise SynapseError(404, "Profile was not found", Codes.NOT_FOUND)
raise
defer.returnValue(displayname)
return displayname
else:
try:
result = yield self.federation.make_query(
@ -139,7 +139,7 @@ class BaseProfileHandler(BaseHandler):
except HttpResponseException as e:
raise e.to_synapse_error()
defer.returnValue(result["displayname"])
return result["displayname"]
@defer.inlineCallbacks
def set_displayname(self, target_user, requester, new_displayname, by_admin=False):
@ -186,7 +186,7 @@ class BaseProfileHandler(BaseHandler):
if e.code == 404:
raise SynapseError(404, "Profile was not found", Codes.NOT_FOUND)
raise
defer.returnValue(avatar_url)
return avatar_url
else:
try:
result = yield self.federation.make_query(
@ -200,7 +200,7 @@ class BaseProfileHandler(BaseHandler):
except HttpResponseException as e:
raise e.to_synapse_error()
defer.returnValue(result["avatar_url"])
return result["avatar_url"]
@defer.inlineCallbacks
def set_avatar_url(self, target_user, requester, new_avatar_url, by_admin=False):
@ -251,7 +251,7 @@ class BaseProfileHandler(BaseHandler):
raise SynapseError(404, "Profile was not found", Codes.NOT_FOUND)
raise
defer.returnValue(response)
return response
@defer.inlineCallbacks
def _update_join_states(self, requester, target_user):

View File

@ -84,7 +84,7 @@ class ReceiptsHandler(BaseHandler):
if min_batch_id is None:
# no new receipts
defer.returnValue(False)
return False
affected_room_ids = list(set([r.room_id for r in receipts]))
@ -94,7 +94,7 @@ class ReceiptsHandler(BaseHandler):
min_batch_id, max_batch_id, affected_room_ids
)
defer.returnValue(True)
return True
@defer.inlineCallbacks
def received_client_receipt(self, room_id, receipt_type, user_id, event_id):
@ -124,9 +124,9 @@ class ReceiptsHandler(BaseHandler):
)
if not result:
defer.returnValue([])
return []
defer.returnValue(result)
return result
class ReceiptEventSource(object):
@ -139,13 +139,13 @@ class ReceiptEventSource(object):
to_key = yield self.get_current_key()
if from_key == to_key:
defer.returnValue(([], to_key))
return ([], to_key)
events = yield self.store.get_linearized_receipts_for_rooms(
room_ids, from_key=from_key, to_key=to_key
)
defer.returnValue((events, to_key))
return (events, to_key)
def get_current_key(self, direction="f"):
return self.store.get_max_receipt_stream_id()
@ -164,4 +164,4 @@ class ReceiptEventSource(object):
room_ids, from_key=from_key, to_key=to_key
)
defer.returnValue((events, to_key))
return (events, to_key)

View File

@ -265,7 +265,7 @@ class RegistrationHandler(BaseHandler):
# Bind email to new account
yield self._register_email_threepid(user_id, threepid_dict, None, False)
defer.returnValue(user_id)
return user_id
@defer.inlineCallbacks
def _auto_join_rooms(self, user_id):
@ -360,7 +360,7 @@ class RegistrationHandler(BaseHandler):
appservice_id=service_id,
create_profile_with_displayname=user.localpart,
)
defer.returnValue(user_id)
return user_id
@defer.inlineCallbacks
def check_recaptcha(self, ip, private_key, challenge, response):
@ -461,7 +461,7 @@ class RegistrationHandler(BaseHandler):
id = self._next_generated_user_id
self._next_generated_user_id += 1
defer.returnValue(str(id))
return str(id)
@defer.inlineCallbacks
def _validate_captcha(self, ip_addr, private_key, challenge, response):
@ -481,7 +481,7 @@ class RegistrationHandler(BaseHandler):
"error_url": "http://www.recaptcha.net/recaptcha/api/challenge?"
+ "error=%s" % lines[1],
}
defer.returnValue(json)
return json
@defer.inlineCallbacks
def _submit_captcha(self, ip_addr, private_key, challenge, response):
@ -497,7 +497,7 @@ class RegistrationHandler(BaseHandler):
"response": response,
},
)
defer.returnValue(data)
return data
@defer.inlineCallbacks
def _join_user_to_room(self, requester, room_identifier):
@ -622,7 +622,7 @@ class RegistrationHandler(BaseHandler):
initial_display_name=initial_display_name,
is_guest=is_guest,
)
defer.returnValue((r["device_id"], r["access_token"]))
return (r["device_id"], r["access_token"])
valid_until_ms = None
if self.session_lifetime is not None:
@ -645,7 +645,7 @@ class RegistrationHandler(BaseHandler):
user_id, device_id=device_id, valid_until_ms=valid_until_ms
)
defer.returnValue((device_id, access_token))
return (device_id, access_token)
@defer.inlineCallbacks
def post_registration_actions(
@ -798,7 +798,7 @@ class RegistrationHandler(BaseHandler):
if ex.errcode == Codes.MISSING_PARAM:
# This will only happen if the ID server returns a malformed response
logger.info("Can't add incomplete 3pid")
defer.returnValue(None)
return None
raise
yield self._auth_handler.add_threepid(

View File

@ -128,7 +128,7 @@ class RoomCreationHandler(BaseHandler):
old_room_id,
new_version, # args for _upgrade_room
)
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def _upgrade_room(self, requester, old_room_id, new_version):
@ -193,7 +193,7 @@ class RoomCreationHandler(BaseHandler):
requester, old_room_id, new_room_id, old_room_state
)
defer.returnValue(new_room_id)
return new_room_id
@defer.inlineCallbacks
def _update_upgraded_room_pls(
@ -671,7 +671,7 @@ class RoomCreationHandler(BaseHandler):
result["room_alias"] = room_alias.to_string()
yield directory_handler.send_room_alias_update_event(requester, room_id)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def _send_events_for_new_room(
@ -796,7 +796,7 @@ class RoomCreationHandler(BaseHandler):
room_creator_user_id=creator_id,
is_public=is_public,
)
defer.returnValue(gen_room_id)
return gen_room_id
except StoreError:
attempts += 1
raise StoreError(500, "Couldn't generate a room ID.")
@ -839,7 +839,7 @@ class RoomContextHandler(object):
event_id, get_prev_content=True, allow_none=True
)
if not event:
defer.returnValue(None)
return None
return
filtered = yield (filter_evts([event]))
@ -890,7 +890,7 @@ class RoomContextHandler(object):
results["end"] = token.copy_and_replace("room_key", results["end"]).to_string()
defer.returnValue(results)
return results
class RoomEventSource(object):
@ -941,7 +941,7 @@ class RoomEventSource(object):
else:
end_key = to_key
defer.returnValue((events, end_key))
return (events, end_key)
def get_current_key(self):
return self.store.get_room_events_max_id()
@ -959,4 +959,4 @@ class RoomEventSource(object):
limit=config.limit,
)
defer.returnValue((events, next_key))
return (events, next_key)

View File

@ -325,7 +325,7 @@ class RoomListHandler(BaseHandler):
current_limit=since_token.current_limit - 1,
).to_token()
defer.returnValue(results)
return results
@defer.inlineCallbacks
def _append_room_entry_to_chunk(
@ -420,7 +420,7 @@ class RoomListHandler(BaseHandler):
if join_rules_event:
join_rule = join_rules_event.content.get("join_rule", None)
if not allow_private and join_rule and join_rule != JoinRules.PUBLIC:
defer.returnValue(None)
return None
# Return whether this room is open to federation users or not
create_event = current_state.get((EventTypes.Create, ""))
@ -469,7 +469,7 @@ class RoomListHandler(BaseHandler):
if avatar_url:
result["avatar_url"] = avatar_url
defer.returnValue(result)
return result
@defer.inlineCallbacks
def get_remote_public_room_list(
@ -482,7 +482,7 @@ class RoomListHandler(BaseHandler):
third_party_instance_id=None,
):
if not self.enable_room_list_search:
defer.returnValue({"chunk": [], "total_room_count_estimate": 0})
return {"chunk": [], "total_room_count_estimate": 0}
if search_filter:
# We currently don't support searching across federation, so we have
@ -507,7 +507,7 @@ class RoomListHandler(BaseHandler):
]
}
defer.returnValue(res)
return res
def _get_remote_list_cached(
self,

View File

@ -191,7 +191,7 @@ class RoomMemberHandler(object):
)
if duplicate is not None:
# Discard the new event since this membership change is a no-op.
defer.returnValue(duplicate)
return duplicate
yield self.event_creation_handler.handle_new_client_event(
requester, event, context, extra_users=[target], ratelimit=ratelimit
@ -233,7 +233,7 @@ class RoomMemberHandler(object):
if prev_member_event.membership == Membership.JOIN:
yield self._user_left_room(target, room_id)
defer.returnValue(event)
return event
@defer.inlineCallbacks
def copy_room_tags_and_direct_to_room(self, old_room_id, new_room_id, user_id):
@ -303,7 +303,7 @@ class RoomMemberHandler(object):
require_consent=require_consent,
)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def _update_membership(
@ -423,7 +423,7 @@ class RoomMemberHandler(object):
same_membership = old_membership == effective_membership_state
same_sender = requester.user.to_string() == old_state.sender
if same_sender and same_membership and same_content:
defer.returnValue(old_state)
return old_state
if old_membership in ["ban", "leave"] and action == "kick":
raise AuthError(403, "The target user is not in the room")
@ -473,7 +473,7 @@ class RoomMemberHandler(object):
ret = yield self._remote_join(
requester, remote_room_hosts, room_id, target, content
)
defer.returnValue(ret)
return ret
elif effective_membership_state == Membership.LEAVE:
if not is_host_in_room:
@ -495,7 +495,7 @@ class RoomMemberHandler(object):
res = yield self._remote_reject_invite(
requester, remote_room_hosts, room_id, target
)
defer.returnValue(res)
return res
res = yield self._local_membership_update(
requester=requester,
@ -508,7 +508,7 @@ class RoomMemberHandler(object):
content=content,
require_consent=require_consent,
)
defer.returnValue(res)
return res
@defer.inlineCallbacks
def send_membership_event(
@ -596,11 +596,11 @@ class RoomMemberHandler(object):
"""
guest_access_id = current_state_ids.get((EventTypes.GuestAccess, ""), None)
if not guest_access_id:
defer.returnValue(False)
return False
guest_access = yield self.store.get_event(guest_access_id)
defer.returnValue(
return (
guest_access
and guest_access.content
and "guest_access" in guest_access.content
@ -635,7 +635,7 @@ class RoomMemberHandler(object):
servers.remove(room_alias.domain)
servers.insert(0, room_alias.domain)
defer.returnValue((RoomID.from_string(room_id), servers))
return (RoomID.from_string(room_id), servers)
@defer.inlineCallbacks
def _get_inviter(self, user_id, room_id):
@ -643,7 +643,7 @@ class RoomMemberHandler(object):
user_id=user_id, room_id=room_id
)
if invite:
defer.returnValue(UserID.from_string(invite.sender))
return UserID.from_string(invite.sender)
@defer.inlineCallbacks
def do_3pid_invite(
@ -708,11 +708,11 @@ class RoomMemberHandler(object):
if "signatures" not in data:
raise AuthError(401, "No signatures on 3pid binding")
yield self._verify_any_signature(data, id_server)
defer.returnValue(data["mxid"])
return data["mxid"]
except IOError as e:
logger.warn("Error from identity server lookup: %s" % (e,))
defer.returnValue(None)
return None
@defer.inlineCallbacks
def _verify_any_signature(self, data, server_hostname):
@ -904,7 +904,7 @@ class RoomMemberHandler(object):
if not public_keys:
public_keys.append(fallback_public_key)
display_name = data["display_name"]
defer.returnValue((token, public_keys, fallback_public_key, display_name))
return (token, public_keys, fallback_public_key, display_name)
@defer.inlineCallbacks
def _is_host_in_room(self, current_state_ids):
@ -913,7 +913,7 @@ class RoomMemberHandler(object):
create_event_id = current_state_ids.get(("m.room.create", ""))
if len(current_state_ids) == 1 and create_event_id:
# We can only get here if we're in the process of creating the room
defer.returnValue(True)
return True
for etype, state_key in current_state_ids:
if etype != EventTypes.Member or not self.hs.is_mine_id(state_key):
@ -925,16 +925,16 @@ class RoomMemberHandler(object):
continue
if event.membership == Membership.JOIN:
defer.returnValue(True)
return True
defer.returnValue(False)
return False
@defer.inlineCallbacks
def _is_server_notice_room(self, room_id):
if self._server_notices_mxid is None:
defer.returnValue(False)
return False
user_ids = yield self.store.get_users_in_room(room_id)
defer.returnValue(self._server_notices_mxid in user_ids)
return self._server_notices_mxid in user_ids
class RoomMemberMasterHandler(RoomMemberHandler):
@ -978,7 +978,7 @@ class RoomMemberMasterHandler(RoomMemberHandler):
ret = yield fed_handler.do_remotely_reject_invite(
remote_room_hosts, room_id, target.to_string()
)
defer.returnValue(ret)
return ret
except Exception as e:
# if we were unable to reject the exception, just mark
# it as rejected on our end and plough ahead.
@ -989,7 +989,7 @@ class RoomMemberMasterHandler(RoomMemberHandler):
logger.warn("Failed to reject invite: %s", e)
yield self.store.locally_reject_invite(target.to_string(), room_id)
defer.returnValue({})
return {}
def _user_joined_room(self, target, room_id):
"""Implements RoomMemberHandler._user_joined_room

View File

@ -53,7 +53,7 @@ class RoomMemberWorkerHandler(RoomMemberHandler):
yield self._user_joined_room(user, room_id)
defer.returnValue(ret)
return ret
def _remote_reject_invite(self, requester, remote_room_hosts, room_id, target):
"""Implements RoomMemberHandler._remote_reject_invite

View File

@ -69,7 +69,7 @@ class SearchHandler(BaseHandler):
# Scan through the old room for further predecessors
room_id = predecessor["room_id"]
defer.returnValue(historical_room_ids)
return historical_room_ids
@defer.inlineCallbacks
def search(self, user, content, batch=None):
@ -186,13 +186,11 @@ class SearchHandler(BaseHandler):
room_ids.intersection_update({batch_group_key})
if not room_ids:
defer.returnValue(
{
return {
"search_categories": {
"room_events": {"results": [], "count": 0, "highlights": []}
}
}
)
rank_map = {} # event_id -> rank of event
allowed_events = []
@ -455,4 +453,4 @@ class SearchHandler(BaseHandler):
if global_next_batch:
rooms_cat_res["next_batch"] = global_next_batch
defer.returnValue({"search_categories": {"room_events": rooms_cat_res}})
return {"search_categories": {"room_events": rooms_cat_res}}

View File

@ -48,7 +48,7 @@ class StateDeltasHandler(object):
if not event and not prev_event:
logger.debug("Neither event exists: %r %r", prev_event_id, event_id)
defer.returnValue(None)
return None
prev_value = None
value = None
@ -62,8 +62,8 @@ class StateDeltasHandler(object):
logger.debug("prev_value: %r -> value: %r", prev_value, value)
if value == public_value and prev_value != public_value:
defer.returnValue(True)
return True
elif value != public_value and prev_value == public_value:
defer.returnValue(False)
return False
else:
defer.returnValue(None)
return None

View File

@ -86,7 +86,7 @@ class StatsHandler(StateDeltasHandler):
# If still None then the initial background update hasn't happened yet
if self.pos is None:
defer.returnValue(None)
return None
# Loop round handling deltas until we're up to date
while True:
@ -328,6 +328,6 @@ class StatsHandler(StateDeltasHandler):
== "world_readable"
)
):
defer.returnValue(True)
return True
else:
defer.returnValue(False)
return False

View File

@ -263,7 +263,7 @@ class SyncHandler(object):
timeout,
full_state,
)
defer.returnValue(res)
return res
@defer.inlineCallbacks
def _wait_for_sync_for_user(self, sync_config, since_token, timeout, full_state):
@ -303,7 +303,7 @@ class SyncHandler(object):
lazy_loaded = "false"
non_empty_sync_counter.labels(sync_type, lazy_loaded).inc()
defer.returnValue(result)
return result
def current_sync_for_user(self, sync_config, since_token=None, full_state=False):
"""Get the sync for client needed to match what the server has now.
@ -317,7 +317,7 @@ class SyncHandler(object):
user_id = user.to_string()
rules = yield self.store.get_push_rules_for_user(user_id)
rules = format_push_rules_for_user(user, rules)
defer.returnValue(rules)
return rules
@defer.inlineCallbacks
def ephemeral_by_room(self, sync_result_builder, now_token, since_token=None):
@ -378,7 +378,7 @@ class SyncHandler(object):
event_copy = {k: v for (k, v) in iteritems(event) if k != "room_id"}
ephemeral_by_room.setdefault(room_id, []).append(event_copy)
defer.returnValue((now_token, ephemeral_by_room))
return (now_token, ephemeral_by_room)
@defer.inlineCallbacks
def _load_filtered_recents(
@ -426,8 +426,8 @@ class SyncHandler(object):
recents = []
if not limited or block_all_timeline:
defer.returnValue(
TimelineBatch(events=recents, prev_batch=now_token, limited=False)
return TimelineBatch(
events=recents, prev_batch=now_token, limited=False
)
filtering_factor = 2
@ -490,13 +490,11 @@ class SyncHandler(object):
prev_batch_token = now_token.copy_and_replace("room_key", room_key)
defer.returnValue(
TimelineBatch(
return TimelineBatch(
events=recents,
prev_batch=prev_batch_token,
limited=limited or newly_joined_room,
)
)
@defer.inlineCallbacks
def get_state_after_event(self, event, state_filter=StateFilter.all()):
@ -517,7 +515,7 @@ class SyncHandler(object):
if event.is_state():
state_ids = state_ids.copy()
state_ids[(event.type, event.state_key)] = event.event_id
defer.returnValue(state_ids)
return state_ids
@defer.inlineCallbacks
def get_state_at(self, room_id, stream_position, state_filter=StateFilter.all()):
@ -549,7 +547,7 @@ class SyncHandler(object):
else:
# no events in this room - so presumably no state
state = {}
defer.returnValue(state)
return state
@defer.inlineCallbacks
def compute_summary(self, room_id, sync_config, batch, state, now_token):
@ -579,7 +577,7 @@ class SyncHandler(object):
)
if not last_events:
defer.returnValue(None)
return None
return
last_event = last_events[-1]
@ -611,14 +609,14 @@ class SyncHandler(object):
if name_id:
name = yield self.store.get_event(name_id, allow_none=True)
if name and name.content.get("name"):
defer.returnValue(summary)
return summary
if canonical_alias_id:
canonical_alias = yield self.store.get_event(
canonical_alias_id, allow_none=True
)
if canonical_alias and canonical_alias.content.get("alias"):
defer.returnValue(summary)
return summary
me = sync_config.user.to_string()
@ -652,7 +650,7 @@ class SyncHandler(object):
summary["m.heroes"] = sorted([user_id for user_id in gone_user_ids])[0:5]
if not sync_config.filter_collection.lazy_load_members():
defer.returnValue(summary)
return summary
# ensure we send membership events for heroes if needed
cache_key = (sync_config.user.to_string(), sync_config.device_id)
@ -686,7 +684,7 @@ class SyncHandler(object):
cache.set(s.state_key, s.event_id)
state[(EventTypes.Member, s.state_key)] = s
defer.returnValue(summary)
return summary
def get_lazy_loaded_members_cache(self, cache_key):
cache = self.lazy_loaded_members_cache.get(cache_key)
@ -871,14 +869,12 @@ class SyncHandler(object):
if state_ids:
state = yield self.store.get_events(list(state_ids.values()))
defer.returnValue(
{
return {
(e.type, e.state_key): e
for e in sync_config.filter_collection.filter_room_state(
list(state.values())
)
}
)
@defer.inlineCallbacks
def unread_notifs_for_room_id(self, room_id, sync_config):
@ -894,11 +890,11 @@ class SyncHandler(object):
notifs = yield self.store.get_unread_event_push_actions_by_room_for_user(
room_id, sync_config.user.to_string(), last_unread_event_id
)
defer.returnValue(notifs)
return notifs
# There is no new information in this period, so your notification
# count is whatever it was last time.
defer.returnValue(None)
return None
@defer.inlineCallbacks
def generate_sync_result(self, sync_config, since_token=None, full_state=False):
@ -989,8 +985,7 @@ class SyncHandler(object):
"Sync result for newly joined room %s: %r", room_id, joined_room
)
defer.returnValue(
SyncResult(
return SyncResult(
presence=sync_result_builder.presence,
account_data=sync_result_builder.account_data,
joined=sync_result_builder.joined,
@ -1002,7 +997,6 @@ class SyncHandler(object):
device_one_time_keys_count=one_time_key_counts,
next_batch=sync_result_builder.now_token,
)
)
@measure_func("_generate_sync_entry_for_groups")
@defer.inlineCallbacks
@ -1124,11 +1118,9 @@ class SyncHandler(object):
# Remove any users that we still share a room with.
newly_left_users -= users_who_share_room
defer.returnValue(
DeviceLists(changed=users_that_have_changed, left=newly_left_users)
)
return DeviceLists(changed=users_that_have_changed, left=newly_left_users)
else:
defer.returnValue(DeviceLists(changed=[], left=[]))
return DeviceLists(changed=[], left=[])
@defer.inlineCallbacks
def _generate_sync_entry_for_to_device(self, sync_result_builder):
@ -1225,7 +1217,7 @@ class SyncHandler(object):
sync_result_builder.account_data = account_data_for_user
defer.returnValue(account_data_by_room)
return account_data_by_room
@defer.inlineCallbacks
def _generate_sync_entry_for_presence(
@ -1325,7 +1317,7 @@ class SyncHandler(object):
)
if not tags_by_room:
logger.debug("no-oping sync")
defer.returnValue(([], [], [], []))
return ([], [], [], [])
ignored_account_data = yield self.store.get_global_account_data_by_type_for_user(
"m.ignored_user_list", user_id=user_id
@ -1388,14 +1380,12 @@ class SyncHandler(object):
newly_left_users -= newly_joined_or_invited_users
defer.returnValue(
(
return (
newly_joined_rooms,
newly_joined_or_invited_users,
newly_left_rooms,
newly_left_users,
)
)
@defer.inlineCallbacks
def _have_rooms_changed(self, sync_result_builder):
@ -1414,13 +1404,13 @@ class SyncHandler(object):
)
if rooms_changed:
defer.returnValue(True)
return True
stream_id = RoomStreamToken.parse_stream_token(since_token.room_key).stream
for room_id in sync_result_builder.joined_room_ids:
if self.store.has_room_changed_since(room_id, stream_id):
defer.returnValue(True)
defer.returnValue(False)
return True
return False
@defer.inlineCallbacks
def _get_rooms_changed(self, sync_result_builder, ignored_users):
@ -1637,7 +1627,7 @@ class SyncHandler(object):
)
room_entries.append(entry)
defer.returnValue((room_entries, invited, newly_joined_rooms, newly_left_rooms))
return (room_entries, invited, newly_joined_rooms, newly_left_rooms)
@defer.inlineCallbacks
def _get_all_rooms(self, sync_result_builder, ignored_users):
@ -1711,7 +1701,7 @@ class SyncHandler(object):
)
)
defer.returnValue((room_entries, invited, []))
return (room_entries, invited, [])
@defer.inlineCallbacks
def _generate_room_entry(
@ -1912,7 +1902,7 @@ class SyncHandler(object):
joined_room_ids.add(room_id)
joined_room_ids = frozenset(joined_room_ids)
defer.returnValue(joined_room_ids)
return joined_room_ids
def _action_has_highlight(actions):

View File

@ -140,7 +140,7 @@ class TypingHandler(object):
if was_present:
# No point sending another notification
defer.returnValue(None)
return None
self._push_update(member=member, typing=True)
@ -173,7 +173,7 @@ class TypingHandler(object):
def _stopped_typing(self, member):
if member.user_id not in self._room_typing.get(member.room_id, set()):
# No point
defer.returnValue(None)
return None
self._member_typing_until.pop(member, None)
self._member_last_federation_poke.pop(member, None)

View File

@ -133,7 +133,7 @@ class UserDirectoryHandler(StateDeltasHandler):
# If still None then the initial background update hasn't happened yet
if self.pos is None:
defer.returnValue(None)
return None
# Loop round handling deltas until we're up to date
while True:

View File

@ -294,7 +294,7 @@ class SimpleHttpClient(object):
logger.info(
"Received response to %s %s: %s", method, redact_uri(uri), response.code
)
defer.returnValue(response)
return response
except Exception as e:
incoming_responses_counter.labels(method, "ERR").inc()
logger.info(
@ -345,7 +345,7 @@ class SimpleHttpClient(object):
body = yield make_deferred_yieldable(readBody(response))
if 200 <= response.code < 300:
defer.returnValue(json.loads(body))
return json.loads(body)
else:
raise HttpResponseException(response.code, response.phrase, body)
@ -385,7 +385,7 @@ class SimpleHttpClient(object):
body = yield make_deferred_yieldable(readBody(response))
if 200 <= response.code < 300:
defer.returnValue(json.loads(body))
return json.loads(body)
else:
raise HttpResponseException(response.code, response.phrase, body)
@ -410,7 +410,7 @@ class SimpleHttpClient(object):
ValueError: if the response was not JSON
"""
body = yield self.get_raw(uri, args, headers=headers)
defer.returnValue(json.loads(body))
return json.loads(body)
@defer.inlineCallbacks
def put_json(self, uri, json_body, args={}, headers=None):
@ -453,7 +453,7 @@ class SimpleHttpClient(object):
body = yield make_deferred_yieldable(readBody(response))
if 200 <= response.code < 300:
defer.returnValue(json.loads(body))
return json.loads(body)
else:
raise HttpResponseException(response.code, response.phrase, body)
@ -488,7 +488,7 @@ class SimpleHttpClient(object):
body = yield make_deferred_yieldable(readBody(response))
if 200 <= response.code < 300:
defer.returnValue(body)
return body
else:
raise HttpResponseException(response.code, response.phrase, body)
@ -545,14 +545,12 @@ class SimpleHttpClient(object):
except Exception as e:
raise_from(SynapseError(502, ("Failed to download remote body: %s" % e)), e)
defer.returnValue(
(
return (
length,
resp_headers,
response.request.absoluteURI.decode("ascii"),
response.code,
)
)
# XXX: FIXME: This is horribly copy-pasted from matrixfederationclient.
@ -627,10 +625,10 @@ class CaptchaServerHttpClient(SimpleHttpClient):
try:
body = yield make_deferred_yieldable(readBody(response))
defer.returnValue(body)
return body
except PartialDownloadError as e:
# twisted dislikes google's response, no content length.
defer.returnValue(e.response)
return e.response
def encode_urlencode_args(args):

View File

@ -177,7 +177,7 @@ class MatrixFederationAgent(object):
res = yield make_deferred_yieldable(
agent.request(method, uri, headers, bodyProducer)
)
defer.returnValue(res)
return res
@defer.inlineCallbacks
def _route_matrix_uri(self, parsed_uri, lookup_well_known=True):
@ -205,25 +205,21 @@ class MatrixFederationAgent(object):
port = parsed_uri.port
if port == -1:
port = 8448
defer.returnValue(
_RoutingResult(
return _RoutingResult(
host_header=parsed_uri.netloc,
tls_server_name=parsed_uri.host,
target_host=parsed_uri.host,
target_port=port,
)
)
if parsed_uri.port != -1:
# there is an explicit port
defer.returnValue(
_RoutingResult(
return _RoutingResult(
host_header=parsed_uri.netloc,
tls_server_name=parsed_uri.host,
target_host=parsed_uri.host,
target_port=parsed_uri.port,
)
)
if lookup_well_known:
# try a .well-known lookup
@ -259,7 +255,7 @@ class MatrixFederationAgent(object):
)
res = yield self._route_matrix_uri(new_uri, lookup_well_known=False)
defer.returnValue(res)
return res
# try a SRV lookup
service_name = b"_matrix._tcp.%s" % (parsed_uri.host,)
@ -283,14 +279,12 @@ class MatrixFederationAgent(object):
parsed_uri.host.decode("ascii"),
)
defer.returnValue(
_RoutingResult(
return _RoutingResult(
host_header=parsed_uri.netloc,
tls_server_name=parsed_uri.host,
target_host=target_host,
target_port=port,
)
)
@defer.inlineCallbacks
def _get_well_known(self, server_name):
@ -314,7 +308,7 @@ class MatrixFederationAgent(object):
if cache_period > 0:
self._well_known_cache.set(server_name, result, cache_period)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def _do_get_well_known(self, server_name):
@ -354,7 +348,7 @@ class MatrixFederationAgent(object):
# after startup
cache_period = WELL_KNOWN_INVALID_CACHE_PERIOD
cache_period += random.uniform(0, WELL_KNOWN_DEFAULT_CACHE_PERIOD_JITTER)
defer.returnValue((None, cache_period))
return (None, cache_period)
result = parsed_body["m.server"].encode("ascii")
@ -369,7 +363,7 @@ class MatrixFederationAgent(object):
else:
cache_period = min(cache_period, WELL_KNOWN_MAX_CACHE_PERIOD)
defer.returnValue((result, cache_period))
return (result, cache_period)
@implementer(IStreamClientEndpoint)

View File

@ -120,7 +120,7 @@ class SrvResolver(object):
if cache_entry:
if all(s.expires > now for s in cache_entry):
servers = list(cache_entry)
defer.returnValue(servers)
return servers
try:
answers, _, _ = yield make_deferred_yieldable(
@ -129,7 +129,7 @@ class SrvResolver(object):
except DNSNameError:
# TODO: cache this. We can get the SOA out of the exception, and use
# the negative-TTL value.
defer.returnValue([])
return []
except DomainError as e:
# We failed to resolve the name (other than a NameError)
# Try something in the cache, else rereaise
@ -138,7 +138,7 @@ class SrvResolver(object):
logger.warn(
"Failed to resolve %r, falling back to cache. %r", service_name, e
)
defer.returnValue(list(cache_entry))
return list(cache_entry)
else:
raise e
@ -169,4 +169,4 @@ class SrvResolver(object):
)
self._cache[service_name] = list(servers)
defer.returnValue(servers)
return servers

View File

@ -158,7 +158,7 @@ def _handle_json_response(reactor, timeout_sec, request, response):
response.code,
response.phrase.decode("ascii", errors="replace"),
)
defer.returnValue(body)
return body
class MatrixFederationHttpClient(object):
@ -256,7 +256,7 @@ class MatrixFederationHttpClient(object):
response = yield self._send_request(request, **send_request_args)
defer.returnValue(response)
return response
@defer.inlineCallbacks
def _send_request(
@ -520,7 +520,7 @@ class MatrixFederationHttpClient(object):
_flatten_response_never_received(e),
)
raise
defer.returnValue(response)
return response
def build_auth_headers(
self, destination, method, url_bytes, content=None, destination_is=None
@ -644,7 +644,7 @@ class MatrixFederationHttpClient(object):
self.reactor, self.default_timeout, request, response
)
defer.returnValue(body)
return body
@defer.inlineCallbacks
def post_json(
@ -713,7 +713,7 @@ class MatrixFederationHttpClient(object):
body = yield _handle_json_response(
self.reactor, _sec_timeout, request, response
)
defer.returnValue(body)
return body
@defer.inlineCallbacks
def get_json(
@ -778,7 +778,7 @@ class MatrixFederationHttpClient(object):
self.reactor, self.default_timeout, request, response
)
defer.returnValue(body)
return body
@defer.inlineCallbacks
def delete_json(
@ -836,7 +836,7 @@ class MatrixFederationHttpClient(object):
body = yield _handle_json_response(
self.reactor, self.default_timeout, request, response
)
defer.returnValue(body)
return body
@defer.inlineCallbacks
def get_file(
@ -902,7 +902,7 @@ class MatrixFederationHttpClient(object):
response.phrase.decode("ascii", errors="replace"),
length,
)
defer.returnValue((length, headers))
return (length, headers)
class _ReadBodyToFileProtocol(protocol.Protocol):

View File

@ -89,7 +89,7 @@ the function becomes the operation name for the span.
# We start
yield we_wait
# we finish
defer.returnValue(something_usual_and_useful)
return something_usual_and_useful
Operation names can be explicitly set for functions by using
``trace_using_operation_name`` and
@ -113,7 +113,7 @@ Operation names can be explicitly set for functions by using
# We start
yield we_wait
# we finish
defer.returnValue(something_usual_and_useful)
return something_usual_and_useful
Contexts and carriers
---------------------
@ -694,7 +694,7 @@ def trace_servlet(servlet_name, func):
},
):
result = yield defer.maybeDeferred(func, request, *args, **kwargs)
defer.returnValue(result)
return result
return _trace_servlet_inner

View File

@ -101,7 +101,7 @@ class ModuleApi(object):
)
user_id = yield self.register_user(localpart, displayname, emails)
_, access_token = yield self.register_device(user_id)
defer.returnValue((user_id, access_token))
return (user_id, access_token)
def register_user(self, localpart, displayname=None, emails=[]):
"""Registers a new user with given localpart and optional displayname, emails.

View File

@ -365,7 +365,7 @@ class Notifier(object):
current_token = user_stream.current_token
result = yield callback(prev_token, current_token)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def get_events_for(
@ -400,7 +400,7 @@ class Notifier(object):
@defer.inlineCallbacks
def check_for_updates(before_token, after_token):
if not after_token.is_after(before_token):
defer.returnValue(EventStreamResult([], (from_token, from_token)))
return EventStreamResult([], (from_token, from_token))
events = []
end_token = from_token
@ -440,7 +440,7 @@ class Notifier(object):
events.extend(new_events)
end_token = end_token.copy_and_replace(keyname, new_key)
defer.returnValue(EventStreamResult(events, (from_token, end_token)))
return EventStreamResult(events, (from_token, end_token))
user_id_for_stream = user.to_string()
if is_peeking:
@ -465,18 +465,18 @@ class Notifier(object):
from_token=from_token,
)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def _get_room_ids(self, user, explicit_room_id):
joined_room_ids = yield self.store.get_rooms_for_user(user.to_string())
if explicit_room_id:
if explicit_room_id in joined_room_ids:
defer.returnValue(([explicit_room_id], True))
return ([explicit_room_id], True)
if (yield self._is_world_readable(explicit_room_id)):
defer.returnValue(([explicit_room_id], False))
return ([explicit_room_id], False)
raise AuthError(403, "Non-joined access not allowed")
defer.returnValue((joined_room_ids, True))
return (joined_room_ids, True)
@defer.inlineCallbacks
def _is_world_readable(self, room_id):
@ -484,9 +484,9 @@ class Notifier(object):
room_id, EventTypes.RoomHistoryVisibility, ""
)
if state and "history_visibility" in state.content:
defer.returnValue(state.content["history_visibility"] == "world_readable")
return state.content["history_visibility"] == "world_readable"
else:
defer.returnValue(False)
return False
@log_function
def remove_expired_streams(self):

View File

@ -95,7 +95,7 @@ class BulkPushRuleEvaluator(object):
invited
)
defer.returnValue(rules_by_user)
return rules_by_user
@cached()
def _get_rules_for_room(self, room_id):
@ -134,7 +134,7 @@ class BulkPushRuleEvaluator(object):
pl_event = auth_events.get(POWER_KEY)
defer.returnValue((pl_event.content if pl_event else {}, sender_level))
return (pl_event.content if pl_event else {}, sender_level)
@defer.inlineCallbacks
def action_for_event_by_user(self, event, context):
@ -283,13 +283,13 @@ class RulesForRoom(object):
if state_group and self.state_group == state_group:
logger.debug("Using cached rules for %r", self.room_id)
self.room_push_rule_cache_metrics.inc_hits()
defer.returnValue(self.rules_by_user)
return self.rules_by_user
with (yield self.linearizer.queue(())):
if state_group and self.state_group == state_group:
logger.debug("Using cached rules for %r", self.room_id)
self.room_push_rule_cache_metrics.inc_hits()
defer.returnValue(self.rules_by_user)
return self.rules_by_user
self.room_push_rule_cache_metrics.inc_misses()
@ -366,7 +366,7 @@ class RulesForRoom(object):
logger.debug(
"Returning push rules for %r %r", self.room_id, ret_rules_by_user.keys()
)
defer.returnValue(ret_rules_by_user)
return ret_rules_by_user
@defer.inlineCallbacks
def _update_rules_with_member_event_ids(

View File

@ -258,17 +258,17 @@ class HttpPusher(object):
@defer.inlineCallbacks
def _process_one(self, push_action):
if "notify" not in push_action["actions"]:
defer.returnValue(True)
return True
tweaks = push_rule_evaluator.tweaks_for_actions(push_action["actions"])
badge = yield push_tools.get_badge_count(self.hs.get_datastore(), self.user_id)
event = yield self.store.get_event(push_action["event_id"], allow_none=True)
if event is None:
defer.returnValue(True) # It's been redacted
return True # It's been redacted
rejected = yield self.dispatch_push(event, tweaks, badge)
if rejected is False:
defer.returnValue(False)
return False
if isinstance(rejected, list) or isinstance(rejected, tuple):
for pk in rejected:
@ -282,7 +282,7 @@ class HttpPusher(object):
else:
logger.info("Pushkey %s was rejected: removing", pk)
yield self.hs.remove_pusher(self.app_id, pk, self.user_id)
defer.returnValue(True)
return True
@defer.inlineCallbacks
def _build_notification_dict(self, event, tweaks, badge):
@ -302,7 +302,7 @@ class HttpPusher(object):
],
}
}
defer.returnValue(d)
return d
ctx = yield push_tools.get_context_for_event(
self.store, self.state_handler, event, self.user_id
@ -345,13 +345,13 @@ class HttpPusher(object):
if "name" in ctx and len(ctx["name"]) > 0:
d["notification"]["room_name"] = ctx["name"]
defer.returnValue(d)
return d
@defer.inlineCallbacks
def dispatch_push(self, event, tweaks, badge):
notification_dict = yield self._build_notification_dict(event, tweaks, badge)
if not notification_dict:
defer.returnValue([])
return []
try:
resp = yield self.http_client.post_json_get_json(
self.url, notification_dict
@ -364,11 +364,11 @@ class HttpPusher(object):
type(e),
e,
)
defer.returnValue(False)
return False
rejected = []
if "rejected" in resp:
rejected = resp["rejected"]
defer.returnValue(rejected)
return rejected
@defer.inlineCallbacks
def _send_badge(self, badge):

View File

@ -316,7 +316,7 @@ class Mailer(object):
if not merge:
room_vars["notifs"].append(notifvars)
defer.returnValue(room_vars)
return room_vars
@defer.inlineCallbacks
def get_notif_vars(self, notif, user_id, notif_event, room_state_ids):
@ -343,7 +343,7 @@ class Mailer(object):
if messagevars is not None:
ret["messages"].append(messagevars)
defer.returnValue(ret)
return ret
@defer.inlineCallbacks
def get_message_vars(self, notif, event, room_state_ids):
@ -379,7 +379,7 @@ class Mailer(object):
if "body" in event.content:
ret["body_text_plain"] = event.content["body"]
defer.returnValue(ret)
return ret
def add_text_message_vars(self, messagevars, event):
msgformat = event.content.get("format")
@ -428,19 +428,16 @@ class Mailer(object):
inviter_name = name_from_member_event(inviter_member_event)
if room_name is None:
defer.returnValue(
INVITE_FROM_PERSON
% {"person": inviter_name, "app": self.app_name}
)
return INVITE_FROM_PERSON % {
"person": inviter_name,
"app": self.app_name,
}
else:
defer.returnValue(
INVITE_FROM_PERSON_TO_ROOM
% {
return INVITE_FROM_PERSON_TO_ROOM % {
"person": inviter_name,
"room": room_name,
"app": self.app_name,
}
)
sender_name = None
if len(notifs_by_room[room_id]) == 1:
@ -454,26 +451,21 @@ class Mailer(object):
sender_name = name_from_member_event(state_event)
if sender_name is not None and room_name is not None:
defer.returnValue(
MESSAGE_FROM_PERSON_IN_ROOM
% {
return MESSAGE_FROM_PERSON_IN_ROOM % {
"person": sender_name,
"room": room_name,
"app": self.app_name,
}
)
elif sender_name is not None:
defer.returnValue(
MESSAGE_FROM_PERSON
% {"person": sender_name, "app": self.app_name}
)
return MESSAGE_FROM_PERSON % {
"person": sender_name,
"app": self.app_name,
}
else:
# There's more than one notification for this room, so just
# say there are several
if room_name is not None:
defer.returnValue(
MESSAGES_IN_ROOM % {"room": room_name, "app": self.app_name}
)
return MESSAGES_IN_ROOM % {"room": room_name, "app": self.app_name}
else:
# If the room doesn't have a name, say who the messages
# are from explicitly to avoid, "messages in the Bob room"
@ -493,24 +485,19 @@ class Mailer(object):
]
)
defer.returnValue(
MESSAGES_FROM_PERSON
% {
"person": descriptor_from_member_events(
member_events.values()
),
return MESSAGES_FROM_PERSON % {
"person": descriptor_from_member_events(member_events.values()),
"app": self.app_name,
}
)
else:
# Stuff's happened in multiple different rooms
# ...but we still refer to the 'reason' room which triggered the mail
if reason["room_name"] is not None:
defer.returnValue(
MESSAGES_IN_ROOM_AND_OTHERS
% {"room": reason["room_name"], "app": self.app_name}
)
return MESSAGES_IN_ROOM_AND_OTHERS % {
"room": reason["room_name"],
"app": self.app_name,
}
else:
# If the reason room doesn't have a name, say who the messages
# are from explicitly to avoid, "messages in the Bob room"
@ -527,13 +514,10 @@ class Mailer(object):
[room_state_ids[room_id][("m.room.member", s)] for s in sender_ids]
)
defer.returnValue(
MESSAGES_FROM_PERSON_AND_OTHERS
% {
return MESSAGES_FROM_PERSON_AND_OTHERS % {
"person": descriptor_from_member_events(member_events.values()),
"app": self.app_name,
}
)
def make_room_link(self, room_id):
if self.hs.config.email_riot_base_url:

View File

@ -55,7 +55,7 @@ def calculate_room_name(
room_state_ids[("m.room.name", "")], allow_none=True
)
if m_room_name and m_room_name.content and m_room_name.content["name"]:
defer.returnValue(m_room_name.content["name"])
return m_room_name.content["name"]
# does it have a canonical alias?
if ("m.room.canonical_alias", "") in room_state_ids:
@ -68,7 +68,7 @@ def calculate_room_name(
and canon_alias.content["alias"]
and _looks_like_an_alias(canon_alias.content["alias"])
):
defer.returnValue(canon_alias.content["alias"])
return canon_alias.content["alias"]
# at this point we're going to need to search the state by all state keys
# for an event type, so rearrange the data structure
@ -82,10 +82,10 @@ def calculate_room_name(
if alias_event and alias_event.content.get("aliases"):
the_aliases = alias_event.content["aliases"]
if len(the_aliases) > 0 and _looks_like_an_alias(the_aliases[0]):
defer.returnValue(the_aliases[0])
return the_aliases[0]
if not fallback_to_members:
defer.returnValue(None)
return None
my_member_event = None
if ("m.room.member", user_id) in room_state_ids:
@ -104,14 +104,13 @@ def calculate_room_name(
)
if inviter_member_event:
if fallback_to_single_member:
defer.returnValue(
"Invite from %s"
% (name_from_member_event(inviter_member_event),)
return "Invite from %s" % (
name_from_member_event(inviter_member_event),
)
else:
return
else:
defer.returnValue("Room Invite")
return "Room Invite"
# we're going to have to generate a name based on who's in the room,
# so find out who is in the room that isn't the user.
@ -154,17 +153,17 @@ def calculate_room_name(
# return "Inviting %s" % (
# descriptor_from_member_events(third_party_invites)
# )
defer.returnValue("Inviting email address")
return "Inviting email address"
else:
defer.returnValue(ALL_ALONE)
return ALL_ALONE
else:
defer.returnValue(name_from_member_event(all_members[0]))
return name_from_member_event(all_members[0])
else:
defer.returnValue(ALL_ALONE)
return ALL_ALONE
elif len(other_members) == 1 and not fallback_to_single_member:
return
else:
defer.returnValue(descriptor_from_member_events(other_members))
return descriptor_from_member_events(other_members)
def descriptor_from_member_events(member_events):

View File

@ -39,7 +39,7 @@ def get_badge_count(store, user_id):
# return one badge count per conversation, as count per
# message is so noisy as to be almost useless
badge += 1 if notifs["notify_count"] else 0
defer.returnValue(badge)
return badge
@defer.inlineCallbacks
@ -61,4 +61,4 @@ def get_context_for_event(store, state_handler, ev, user_id):
sender_state_event = yield store.get_event(sender_state_event_id)
ctx["sender_display_name"] = name_from_member_event(sender_state_event)
defer.returnValue(ctx)
return ctx

View File

@ -123,7 +123,7 @@ class PusherPool:
)
pusher = yield self.start_pusher_by_id(app_id, pushkey, user_id)
defer.returnValue(pusher)
return pusher
@defer.inlineCallbacks
def remove_pushers_by_app_id_and_pushkey_not_user(
@ -224,7 +224,7 @@ class PusherPool:
if pusher_dict:
pusher = yield self._start_pusher(pusher_dict)
defer.returnValue(pusher)
return pusher
@defer.inlineCallbacks
def _start_pushers(self):
@ -293,7 +293,7 @@ class PusherPool:
p.on_started(have_notifs)
defer.returnValue(p)
return p
@defer.inlineCallbacks
def remove_pusher(self, app_id, pushkey, user_id):

View File

@ -185,7 +185,7 @@ class ReplicationEndpoint(object):
except RequestSendFailed as e:
raise_from(SynapseError(502, "Failed to talk to master"), e)
defer.returnValue(result)
return result
return send_request

View File

@ -80,7 +80,7 @@ class ReplicationFederationSendEventsRestServlet(ReplicationEndpoint):
payload = {"events": event_payloads, "backfilled": backfilled}
defer.returnValue(payload)
return payload
@defer.inlineCallbacks
def _handle_request(self, request):
@ -113,7 +113,7 @@ class ReplicationFederationSendEventsRestServlet(ReplicationEndpoint):
event_and_contexts, backfilled
)
defer.returnValue((200, {}))
return (200, {})
class ReplicationFederationSendEduRestServlet(ReplicationEndpoint):
@ -156,7 +156,7 @@ class ReplicationFederationSendEduRestServlet(ReplicationEndpoint):
result = yield self.registry.on_edu(edu_type, origin, edu_content)
defer.returnValue((200, result))
return (200, result)
class ReplicationGetQueryRestServlet(ReplicationEndpoint):
@ -204,7 +204,7 @@ class ReplicationGetQueryRestServlet(ReplicationEndpoint):
result = yield self.registry.on_query(query_type, args)
defer.returnValue((200, result))
return (200, result)
class ReplicationCleanRoomRestServlet(ReplicationEndpoint):
@ -238,7 +238,7 @@ class ReplicationCleanRoomRestServlet(ReplicationEndpoint):
def _handle_request(self, request, room_id):
yield self.store.clean_room_for_join(room_id)
defer.returnValue((200, {}))
return (200, {})
def register_servlets(hs, http_server):

View File

@ -64,7 +64,7 @@ class RegisterDeviceReplicationServlet(ReplicationEndpoint):
user_id, device_id, initial_display_name, is_guest
)
defer.returnValue((200, {"device_id": device_id, "access_token": access_token}))
return (200, {"device_id": device_id, "access_token": access_token})
def register_servlets(hs, http_server):

View File

@ -83,7 +83,7 @@ class ReplicationRemoteJoinRestServlet(ReplicationEndpoint):
remote_room_hosts, room_id, user_id, event_content
)
defer.returnValue((200, {}))
return (200, {})
class ReplicationRemoteRejectInviteRestServlet(ReplicationEndpoint):
@ -153,7 +153,7 @@ class ReplicationRemoteRejectInviteRestServlet(ReplicationEndpoint):
yield self.store.locally_reject_invite(user_id, room_id)
ret = {}
defer.returnValue((200, ret))
return (200, ret)
class ReplicationUserJoinedLeftRoomRestServlet(ReplicationEndpoint):

View File

@ -90,7 +90,7 @@ class ReplicationRegisterServlet(ReplicationEndpoint):
address=content["address"],
)
defer.returnValue((200, {}))
return (200, {})
class ReplicationPostRegisterActionsServlet(ReplicationEndpoint):
@ -143,7 +143,7 @@ class ReplicationPostRegisterActionsServlet(ReplicationEndpoint):
bind_msisdn=bind_msisdn,
)
defer.returnValue((200, {}))
return (200, {})
def register_servlets(hs, http_server):

View File

@ -85,7 +85,7 @@ class ReplicationSendEventRestServlet(ReplicationEndpoint):
"extra_users": [u.to_string() for u in extra_users],
}
defer.returnValue(payload)
return payload
@defer.inlineCallbacks
def _handle_request(self, request, event_id):
@ -117,7 +117,7 @@ class ReplicationSendEventRestServlet(ReplicationEndpoint):
requester, event, context, ratelimit=ratelimit, extra_users=extra_users
)
defer.returnValue((200, {}))
return (200, {})
def register_servlets(hs, http_server):

View File

@ -158,7 +158,7 @@ class Stream(object):
updates, current_token = yield self.get_updates_since(self.last_token)
self.last_token = current_token
defer.returnValue((updates, current_token))
return (updates, current_token)
@defer.inlineCallbacks
def get_updates_since(self, from_token):
@ -172,14 +172,14 @@ class Stream(object):
sent over the replication steam.
"""
if from_token in ("NOW", "now"):
defer.returnValue(([], self.upto_token))
return ([], self.upto_token)
current_token = self.upto_token
from_token = int(from_token)
if from_token == current_token:
defer.returnValue(([], current_token))
return ([], current_token)
if self._LIMITED:
rows = yield self.update_function(
@ -198,7 +198,7 @@ class Stream(object):
if self._LIMITED and len(updates) >= MAX_EVENTS_BEHIND:
raise Exception("stream %s has fallen behind" % (self.NAME))
defer.returnValue((updates, current_token))
return (updates, current_token)
def current_token(self):
"""Gets the current token of the underlying streams. Should be provided
@ -297,7 +297,7 @@ class PushRulesStream(Stream):
@defer.inlineCallbacks
def update_function(self, from_token, to_token, limit):
rows = yield self.store.get_all_push_rule_updates(from_token, to_token, limit)
defer.returnValue([(row[0], row[2]) for row in rows])
return [(row[0], row[2]) for row in rows]
class PushersStream(Stream):
@ -424,7 +424,7 @@ class AccountDataStream(Stream):
for stream_id, user_id, account_data_type, content in global_results
)
defer.returnValue(results)
return results
class GroupServerStream(Stream):

View File

@ -134,7 +134,7 @@ class EventsStream(Stream):
all_updates = heapq.merge(event_updates, state_updates)
defer.returnValue(all_updates)
return all_updates
@classmethod
def parse_row(cls, row):

View File

@ -84,7 +84,7 @@ class UsersRestServlet(RestServlet):
ret = yield self.handlers.admin_handler.get_users()
defer.returnValue((200, ret))
return (200, ret)
class VersionServlet(RestServlet):
@ -227,7 +227,7 @@ class UserRegisterServlet(RestServlet):
)
result = yield register._create_registration_details(user_id, body)
defer.returnValue((200, result))
return (200, result)
class WhoisRestServlet(RestServlet):
@ -252,7 +252,7 @@ class WhoisRestServlet(RestServlet):
ret = yield self.handlers.admin_handler.get_whois(target_user)
defer.returnValue((200, ret))
return (200, ret)
class PurgeMediaCacheRestServlet(RestServlet):
@ -271,7 +271,7 @@ class PurgeMediaCacheRestServlet(RestServlet):
ret = yield self.media_repository.delete_old_remote_media(before_ts)
defer.returnValue((200, ret))
return (200, ret)
class PurgeHistoryRestServlet(RestServlet):
@ -356,7 +356,7 @@ class PurgeHistoryRestServlet(RestServlet):
room_id, token, delete_local_events=delete_local_events
)
defer.returnValue((200, {"purge_id": purge_id}))
return (200, {"purge_id": purge_id})
class PurgeHistoryStatusRestServlet(RestServlet):
@ -381,7 +381,7 @@ class PurgeHistoryStatusRestServlet(RestServlet):
if purge_status is None:
raise NotFoundError("purge id '%s' not found" % purge_id)
defer.returnValue((200, purge_status.asdict()))
return (200, purge_status.asdict())
class DeactivateAccountRestServlet(RestServlet):
@ -413,7 +413,7 @@ class DeactivateAccountRestServlet(RestServlet):
else:
id_server_unbind_result = "no-support"
defer.returnValue((200, {"id_server_unbind_result": id_server_unbind_result}))
return (200, {"id_server_unbind_result": id_server_unbind_result})
class ShutdownRoomRestServlet(RestServlet):
@ -531,8 +531,7 @@ class ShutdownRoomRestServlet(RestServlet):
room_id, new_room_id, requester_user_id
)
defer.returnValue(
(
return (
200,
{
"kicked_users": kicked_users,
@ -541,7 +540,6 @@ class ShutdownRoomRestServlet(RestServlet):
"new_room_id": new_room_id,
},
)
)
class QuarantineMediaInRoom(RestServlet):
@ -564,7 +562,7 @@ class QuarantineMediaInRoom(RestServlet):
room_id, requester.user.to_string()
)
defer.returnValue((200, {"num_quarantined": num_quarantined}))
return (200, {"num_quarantined": num_quarantined})
class ListMediaInRoom(RestServlet):
@ -585,7 +583,7 @@ class ListMediaInRoom(RestServlet):
local_mxcs, remote_mxcs = yield self.store.get_media_mxcs_in_room(room_id)
defer.returnValue((200, {"local": local_mxcs, "remote": remote_mxcs}))
return (200, {"local": local_mxcs, "remote": remote_mxcs})
class ResetPasswordRestServlet(RestServlet):
@ -629,7 +627,7 @@ class ResetPasswordRestServlet(RestServlet):
yield self._set_password_handler.set_password(
target_user_id, new_password, requester
)
defer.returnValue((200, {}))
return (200, {})
class GetUsersPaginatedRestServlet(RestServlet):
@ -671,7 +669,7 @@ class GetUsersPaginatedRestServlet(RestServlet):
logger.info("limit: %s, start: %s", limit, start)
ret = yield self.handlers.admin_handler.get_users_paginate(order, start, limit)
defer.returnValue((200, ret))
return (200, ret)
@defer.inlineCallbacks
def on_POST(self, request, target_user_id):
@ -699,7 +697,7 @@ class GetUsersPaginatedRestServlet(RestServlet):
logger.info("limit: %s, start: %s", limit, start)
ret = yield self.handlers.admin_handler.get_users_paginate(order, start, limit)
defer.returnValue((200, ret))
return (200, ret)
class SearchUsersRestServlet(RestServlet):
@ -742,7 +740,7 @@ class SearchUsersRestServlet(RestServlet):
logger.info("term: %s ", term)
ret = yield self.handlers.admin_handler.search_users(term)
defer.returnValue((200, ret))
return (200, ret)
class DeleteGroupAdminRestServlet(RestServlet):
@ -765,7 +763,7 @@ class DeleteGroupAdminRestServlet(RestServlet):
raise SynapseError(400, "Can only delete local groups")
yield self.group_server.delete_group(group_id, requester.user.to_string())
defer.returnValue((200, {}))
return (200, {})
class AccountValidityRenewServlet(RestServlet):
@ -796,7 +794,7 @@ class AccountValidityRenewServlet(RestServlet):
)
res = {"expiration_ts": expiration_ts}
defer.returnValue((200, res))
return (200, res)
########################################################################################

View File

@ -87,7 +87,7 @@ class SendServerNoticeServlet(RestServlet):
event_content=body["content"],
)
defer.returnValue((200, {"event_id": event.event_id}))
return (200, {"event_id": event.event_id})
def on_PUT(self, request, txn_id):
return self.txns.fetch_or_execute_request(

View File

@ -54,7 +54,7 @@ class ClientDirectoryServer(RestServlet):
dir_handler = self.handlers.directory_handler
res = yield dir_handler.get_association(room_alias)
defer.returnValue((200, res))
return (200, res)
@defer.inlineCallbacks
def on_PUT(self, request, room_alias):
@ -87,7 +87,7 @@ class ClientDirectoryServer(RestServlet):
requester, room_alias, room_id, servers
)
defer.returnValue((200, {}))
return (200, {})
@defer.inlineCallbacks
def on_DELETE(self, request, room_alias):
@ -102,7 +102,7 @@ class ClientDirectoryServer(RestServlet):
service.url,
room_alias.to_string(),
)
defer.returnValue((200, {}))
return (200, {})
except InvalidClientCredentialsError:
# fallback to default user behaviour if they aren't an AS
pass
@ -118,7 +118,7 @@ class ClientDirectoryServer(RestServlet):
"User %s deleted alias %s", user.to_string(), room_alias.to_string()
)
defer.returnValue((200, {}))
return (200, {})
class ClientDirectoryListServer(RestServlet):
@ -136,9 +136,7 @@ class ClientDirectoryListServer(RestServlet):
if room is None:
raise NotFoundError("Unknown room")
defer.returnValue(
(200, {"visibility": "public" if room["is_public"] else "private"})
)
return (200, {"visibility": "public" if room["is_public"] else "private"})
@defer.inlineCallbacks
def on_PUT(self, request, room_id):
@ -151,7 +149,7 @@ class ClientDirectoryListServer(RestServlet):
requester, room_id, visibility
)
defer.returnValue((200, {}))
return (200, {})
@defer.inlineCallbacks
def on_DELETE(self, request, room_id):
@ -161,7 +159,7 @@ class ClientDirectoryListServer(RestServlet):
requester, room_id, "private"
)
defer.returnValue((200, {}))
return (200, {})
class ClientAppserviceDirectoryListServer(RestServlet):
@ -195,4 +193,4 @@ class ClientAppserviceDirectoryListServer(RestServlet):
requester.app_service.id, network_id, room_id, visibility
)
defer.returnValue((200, {}))
return (200, {})

View File

@ -67,7 +67,7 @@ class EventStreamRestServlet(RestServlet):
is_guest=is_guest,
)
defer.returnValue((200, chunk))
return (200, chunk)
def on_OPTIONS(self, request):
return (200, {})
@ -91,9 +91,9 @@ class EventRestServlet(RestServlet):
time_now = self.clock.time_msec()
if event:
event = yield self._event_serializer.serialize_event(event, time_now)
defer.returnValue((200, event))
return (200, event)
else:
defer.returnValue((404, "Event not found."))
return (404, "Event not found.")
def register_servlets(hs, http_server):

View File

@ -42,7 +42,7 @@ class InitialSyncRestServlet(RestServlet):
include_archived=include_archived,
)
defer.returnValue((200, content))
return (200, content)
def register_servlets(hs, http_server):

View File

@ -152,7 +152,7 @@ class LoginRestServlet(RestServlet):
well_known_data = self._well_known_builder.get_well_known()
if well_known_data:
result["well_known"] = well_known_data
defer.returnValue((200, result))
return (200, result)
@defer.inlineCallbacks
def _do_other_login(self, login_submission):
@ -212,7 +212,7 @@ class LoginRestServlet(RestServlet):
result = yield self._register_device_with_callback(
canonical_user_id, login_submission, callback_3pid
)
defer.returnValue(result)
return result
# No password providers were able to handle this 3pid
# Check local store
@ -241,7 +241,7 @@ class LoginRestServlet(RestServlet):
result = yield self._register_device_with_callback(
canonical_user_id, login_submission, callback
)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def _register_device_with_callback(self, user_id, login_submission, callback=None):
@ -273,7 +273,7 @@ class LoginRestServlet(RestServlet):
if callback is not None:
yield callback(result)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def do_token_login(self, login_submission):
@ -284,7 +284,7 @@ class LoginRestServlet(RestServlet):
)
result = yield self._register_device_with_callback(user_id, login_submission)
defer.returnValue(result)
return result
@defer.inlineCallbacks
def do_jwt_login(self, login_submission):
@ -321,7 +321,7 @@ class LoginRestServlet(RestServlet):
result = yield self._register_device_with_callback(
registered_user_id, login_submission
)
defer.returnValue(result)
return result
class BaseSSORedirectServlet(RestServlet):
@ -395,7 +395,7 @@ class CasTicketServlet(RestServlet):
# even if that's being used old-http style to signal end-of-data
body = pde.response
result = yield self.handle_cas_response(request, body, client_redirect_url)
defer.returnValue(result)
return result
def handle_cas_response(self, request, cas_response_body, client_redirect_url):
user, attributes = self.parse_cas_response(cas_response_body)

View File

@ -49,7 +49,7 @@ class LogoutRestServlet(RestServlet):
requester.user.to_string(), requester.device_id
)
defer.returnValue((200, {}))
return (200, {})
class LogoutAllRestServlet(RestServlet):
@ -75,7 +75,7 @@ class LogoutAllRestServlet(RestServlet):
# .. and then delete any access tokens which weren't associated with
# devices.
yield self._auth_handler.delete_access_tokens_for_user(user_id)
defer.returnValue((200, {}))
return (200, {})
def register_servlets(hs, http_server):

View File

@ -56,7 +56,7 @@ class PresenceStatusRestServlet(RestServlet):
state = yield self.presence_handler.get_state(target_user=user)
state = format_user_presence_state(state, self.clock.time_msec())
defer.returnValue((200, state))
return (200, state)
@defer.inlineCallbacks
def on_PUT(self, request, user_id):
@ -88,7 +88,7 @@ class PresenceStatusRestServlet(RestServlet):
if self.hs.config.use_presence:
yield self.presence_handler.set_state(user, state)
defer.returnValue((200, {}))
return (200, {})
def on_OPTIONS(self, request):
return (200, {})

View File

@ -48,7 +48,7 @@ class ProfileDisplaynameRestServlet(RestServlet):
if displayname is not None:
ret["displayname"] = displayname
defer.returnValue((200, ret))
return (200, ret)
@defer.inlineCallbacks
def on_PUT(self, request, user_id):
@ -61,11 +61,11 @@ class ProfileDisplaynameRestServlet(RestServlet):
try:
new_name = content["displayname"]
except Exception:
defer.returnValue((400, "Unable to parse name"))
return (400, "Unable to parse name")
yield self.profile_handler.set_displayname(user, requester, new_name, is_admin)
defer.returnValue((200, {}))
return (200, {})
def on_OPTIONS(self, request, user_id):
return (200, {})
@ -98,7 +98,7 @@ class ProfileAvatarURLRestServlet(RestServlet):
if avatar_url is not None:
ret["avatar_url"] = avatar_url
defer.returnValue((200, ret))
return (200, ret)
@defer.inlineCallbacks
def on_PUT(self, request, user_id):
@ -110,11 +110,11 @@ class ProfileAvatarURLRestServlet(RestServlet):
try:
new_name = content["avatar_url"]
except Exception:
defer.returnValue((400, "Unable to parse name"))
return (400, "Unable to parse name")
yield self.profile_handler.set_avatar_url(user, requester, new_name, is_admin)
defer.returnValue((200, {}))
return (200, {})
def on_OPTIONS(self, request, user_id):
return (200, {})
@ -150,7 +150,7 @@ class ProfileRestServlet(RestServlet):
if avatar_url is not None:
ret["avatar_url"] = avatar_url
defer.returnValue((200, ret))
return (200, ret)
def register_servlets(hs, http_server):

View File

@ -69,7 +69,7 @@ class PushRuleRestServlet(RestServlet):
if "attr" in spec:
yield self.set_rule_attr(user_id, spec, content)
self.notify_user(user_id)
defer.returnValue((200, {}))
return (200, {})
if spec["rule_id"].startswith("."):
# Rule ids starting with '.' are reserved for server default rules.
@ -106,7 +106,7 @@ class PushRuleRestServlet(RestServlet):
except RuleNotFoundException as e:
raise SynapseError(400, str(e))
defer.returnValue((200, {}))
return (200, {})
@defer.inlineCallbacks
def on_DELETE(self, request, path):
@ -123,7 +123,7 @@ class PushRuleRestServlet(RestServlet):
try:
yield self.store.delete_push_rule(user_id, namespaced_rule_id)
self.notify_user(user_id)
defer.returnValue((200, {}))
return (200, {})
except StoreError as e:
if e.code == 404:
raise NotFoundError()
@ -151,10 +151,10 @@ class PushRuleRestServlet(RestServlet):
)
if path[0] == "":
defer.returnValue((200, rules))
return (200, rules)
elif path[0] == "global":
result = _filter_ruleset_with_path(rules["global"], path[1:])
defer.returnValue((200, result))
return (200, result)
else:
raise UnrecognizedRequestError()

View File

@ -62,7 +62,7 @@ class PushersRestServlet(RestServlet):
if k not in allowed_keys:
del p[k]
defer.returnValue((200, {"pushers": pushers}))
return (200, {"pushers": pushers})
def on_OPTIONS(self, _):
return 200, {}
@ -94,7 +94,7 @@ class PushersSetRestServlet(RestServlet):
yield self.pusher_pool.remove_pusher(
content["app_id"], content["pushkey"], user_id=user.to_string()
)
defer.returnValue((200, {}))
return (200, {})
assert_params_in_dict(
content,
@ -143,7 +143,7 @@ class PushersSetRestServlet(RestServlet):
self.notifier.on_new_replication_data()
defer.returnValue((200, {}))
return (200, {})
def on_OPTIONS(self, _):
return 200, {}
@ -190,7 +190,7 @@ class PushersRemoveRestServlet(RestServlet):
)
request.write(PushersRemoveRestServlet.SUCCESS_HTML)
finish_request(request)
defer.returnValue(None)
return None
def on_OPTIONS(self, _):
return 200, {}

View File

@ -85,7 +85,7 @@ class RoomCreateRestServlet(TransactionRestServlet):
requester, self.get_room_config(request)
)
defer.returnValue((200, info))
return (200, info)
def get_room_config(self, request):
user_supplied_config = parse_json_object_from_request(request)
@ -155,9 +155,9 @@ class RoomStateEventRestServlet(TransactionRestServlet):
if format == "event":
event = format_event_for_client_v2(data.get_dict())
defer.returnValue((200, event))
return (200, event)
elif format == "content":
defer.returnValue((200, data.get_dict()["content"]))
return (200, data.get_dict()["content"])
@defer.inlineCallbacks
def on_PUT(self, request, room_id, event_type, state_key, txn_id=None):
@ -192,7 +192,7 @@ class RoomStateEventRestServlet(TransactionRestServlet):
ret = {}
if event:
ret = {"event_id": event.event_id}
defer.returnValue((200, ret))
return (200, ret)
# TODO: Needs unit testing for generic events + feedback
@ -226,7 +226,7 @@ class RoomSendEventRestServlet(TransactionRestServlet):
requester, event_dict, txn_id=txn_id
)
defer.returnValue((200, {"event_id": event.event_id}))
return (200, {"event_id": event.event_id})
def on_GET(self, request, room_id, event_type, txn_id):
return (200, "Not implemented")
@ -289,7 +289,7 @@ class JoinRoomAliasServlet(TransactionRestServlet):
third_party_signed=content.get("third_party_signed", None),
)
defer.returnValue((200, {"room_id": room_id}))
return (200, {"room_id": room_id})
def on_PUT(self, request, room_identifier, txn_id):
return self.txns.fetch_or_execute_request(
@ -342,7 +342,7 @@ class PublicRoomListRestServlet(TransactionRestServlet):
limit=limit, since_token=since_token
)
defer.returnValue((200, data))
return (200, data)
@defer.inlineCallbacks
def on_POST(self, request):
@ -387,7 +387,7 @@ class PublicRoomListRestServlet(TransactionRestServlet):
network_tuple=network_tuple,
)
defer.returnValue((200, data))
return (200, data)
# TODO: Needs unit testing
@ -438,7 +438,7 @@ class RoomMemberListRestServlet(RestServlet):
continue
chunk.append(event)
defer.returnValue((200, {"chunk": chunk}))
return (200, {"chunk": chunk})
# deprecated in favour of /members?membership=join?
@ -459,7 +459,7 @@ class JoinedRoomMemberListRestServlet(RestServlet):
requester, room_id
)
defer.returnValue((200, {"joined": users_with_profile}))
return (200, {"joined": users_with_profile})
# TODO: Needs better unit testing
@ -492,7 +492,7 @@ class RoomMessageListRestServlet(RestServlet):
event_filter=event_filter,
)
defer.returnValue((200, msgs))
return (200, msgs)
# TODO: Needs unit testing
@ -513,7 +513,7 @@ class RoomStateRestServlet(RestServlet):
user_id=requester.user.to_string(),
is_guest=requester.is_guest,
)
defer.returnValue((200, events))
return (200, events)
# TODO: Needs unit testing
@ -532,7 +532,7 @@ class RoomInitialSyncRestServlet(RestServlet):
content = yield self.initial_sync_handler.room_initial_sync(
room_id=room_id, requester=requester, pagin_config=pagination_config
)
defer.returnValue((200, content))
return (200, content)
class RoomEventServlet(RestServlet):
@ -555,9 +555,9 @@ class RoomEventServlet(RestServlet):
time_now = self.clock.time_msec()
if event:
event = yield self._event_serializer.serialize_event(event, time_now)
defer.returnValue((200, event))
return (200, event)
else:
defer.returnValue((404, "Event not found."))
return (404, "Event not found.")
class RoomEventContextServlet(RestServlet):
@ -607,7 +607,7 @@ class RoomEventContextServlet(RestServlet):
results["state"], time_now
)
defer.returnValue((200, results))
return (200, results)
class RoomForgetRestServlet(TransactionRestServlet):
@ -626,7 +626,7 @@ class RoomForgetRestServlet(TransactionRestServlet):
yield self.room_member_handler.forget(user=requester.user, room_id=room_id)
defer.returnValue((200, {}))
return (200, {})
def on_PUT(self, request, room_id, txn_id):
return self.txns.fetch_or_execute_request(
@ -676,7 +676,7 @@ class RoomMembershipRestServlet(TransactionRestServlet):
requester,
txn_id,
)
defer.returnValue((200, {}))
return (200, {})
return
target = requester.user
@ -703,7 +703,7 @@ class RoomMembershipRestServlet(TransactionRestServlet):
if membership_action == "join":
return_value["room_id"] = room_id
defer.returnValue((200, return_value))
return (200, return_value)
def _has_3pid_invite_keys(self, content):
for key in {"id_server", "medium", "address"}:
@ -745,7 +745,7 @@ class RoomRedactEventRestServlet(TransactionRestServlet):
txn_id=txn_id,
)
defer.returnValue((200, {"event_id": event.event_id}))
return (200, {"event_id": event.event_id})
def on_PUT(self, request, room_id, event_id, txn_id):
return self.txns.fetch_or_execute_request(
@ -790,7 +790,7 @@ class RoomTypingRestServlet(RestServlet):
target_user=target_user, auth_user=requester.user, room_id=room_id
)
defer.returnValue((200, {}))
return (200, {})
class SearchRestServlet(RestServlet):
@ -812,7 +812,7 @@ class SearchRestServlet(RestServlet):
requester.user, content, batch
)
defer.returnValue((200, results))
return (200, results)
class JoinedRoomsRestServlet(RestServlet):
@ -828,7 +828,7 @@ class JoinedRoomsRestServlet(RestServlet):
requester = yield self.auth.get_user_by_req(request, allow_guest=True)
room_ids = yield self.store.get_rooms_for_user(requester.user.to_string())
defer.returnValue((200, {"joined_rooms": list(room_ids)}))
return (200, {"joined_rooms": list(room_ids)})
def register_txn_path(servlet, regex_string, http_server, with_get=False):

View File

@ -60,10 +60,9 @@ class VoipRestServlet(RestServlet):
password = turnPassword
else:
defer.returnValue((200, {}))
return (200, {})
defer.returnValue(
(
return (
200,
{
"username": username,
@ -72,7 +71,6 @@ class VoipRestServlet(RestServlet):
"uris": turnUris,
},
)
)
def on_OPTIONS(self, request):
return (200, {})

View File

@ -117,7 +117,7 @@ class EmailPasswordRequestTokenRestServlet(RestServlet):
# Wrap the session id in a JSON object
ret = {"sid": sid}
defer.returnValue((200, ret))
return (200, ret)
@defer.inlineCallbacks
def send_password_reset(self, email, client_secret, send_attempt, next_link=None):
@ -149,7 +149,7 @@ class EmailPasswordRequestTokenRestServlet(RestServlet):
# Check that the send_attempt is higher than previous attempts
if send_attempt <= last_send_attempt:
# If not, just return a success without sending an email
defer.returnValue(session_id)
return session_id
else:
# An non-validated session does not exist yet.
# Generate a session id
@ -185,7 +185,7 @@ class EmailPasswordRequestTokenRestServlet(RestServlet):
token_expires,
)
defer.returnValue(session_id)
return session_id
class MsisdnPasswordRequestTokenRestServlet(RestServlet):
@ -221,7 +221,7 @@ class MsisdnPasswordRequestTokenRestServlet(RestServlet):
raise SynapseError(400, "MSISDN not found", Codes.THREEPID_NOT_FOUND)
ret = yield self.identity_handler.requestMsisdnToken(**body)
defer.returnValue((200, ret))
return (200, ret)
class PasswordResetSubmitTokenServlet(RestServlet):
@ -279,7 +279,7 @@ class PasswordResetSubmitTokenServlet(RestServlet):
request.setResponseCode(302)
request.setHeader("Location", next_link)
finish_request(request)
defer.returnValue(None)
return None
# Otherwise show the success template
html = self.config.email_password_reset_success_html_content
@ -295,7 +295,7 @@ class PasswordResetSubmitTokenServlet(RestServlet):
request.write(html.encode("utf-8"))
finish_request(request)
defer.returnValue(None)
return None
def load_jinja2_template(self, template_dir, template_filename, template_vars):
"""Loads a jinja2 template with variables to insert
@ -330,7 +330,7 @@ class PasswordResetSubmitTokenServlet(RestServlet):
)
response_code = 200 if valid else 400
defer.returnValue((response_code, {"success": valid}))
return (response_code, {"success": valid})
class PasswordRestServlet(RestServlet):
@ -399,7 +399,7 @@ class PasswordRestServlet(RestServlet):
yield self._set_password_handler.set_password(user_id, new_password, requester)
defer.returnValue((200, {}))
return (200, {})
def on_OPTIONS(self, _):
return 200, {}
@ -434,7 +434,7 @@ class DeactivateAccountRestServlet(RestServlet):
yield self._deactivate_account_handler.deactivate_account(
requester.user.to_string(), erase
)
defer.returnValue((200, {}))
return (200, {})
yield self.auth_handler.validate_user_via_ui_auth(
requester, body, self.hs.get_ip_from_request(request)
@ -447,7 +447,7 @@ class DeactivateAccountRestServlet(RestServlet):
else:
id_server_unbind_result = "no-support"
defer.returnValue((200, {"id_server_unbind_result": id_server_unbind_result}))
return (200, {"id_server_unbind_result": id_server_unbind_result})
class EmailThreepidRequestTokenRestServlet(RestServlet):
@ -481,7 +481,7 @@ class EmailThreepidRequestTokenRestServlet(RestServlet):
raise SynapseError(400, "Email is already in use", Codes.THREEPID_IN_USE)
ret = yield self.identity_handler.requestEmailToken(**body)
defer.returnValue((200, ret))
return (200, ret)
class MsisdnThreepidRequestTokenRestServlet(RestServlet):
@ -516,7 +516,7 @@ class MsisdnThreepidRequestTokenRestServlet(RestServlet):
raise SynapseError(400, "MSISDN is already in use", Codes.THREEPID_IN_USE)
ret = yield self.identity_handler.requestMsisdnToken(**body)
defer.returnValue((200, ret))
return (200, ret)
class ThreepidRestServlet(RestServlet):
@ -536,7 +536,7 @@ class ThreepidRestServlet(RestServlet):
threepids = yield self.datastore.user_get_threepids(requester.user.to_string())
defer.returnValue((200, {"threepids": threepids}))
return (200, {"threepids": threepids})
@defer.inlineCallbacks
def on_POST(self, request):
@ -568,7 +568,7 @@ class ThreepidRestServlet(RestServlet):
logger.debug("Binding threepid %s to %s", threepid, user_id)
yield self.identity_handler.bind_threepid(threePidCreds, user_id)
defer.returnValue((200, {}))
return (200, {})
class ThreepidDeleteRestServlet(RestServlet):
@ -603,7 +603,7 @@ class ThreepidDeleteRestServlet(RestServlet):
else:
id_server_unbind_result = "no-support"
defer.returnValue((200, {"id_server_unbind_result": id_server_unbind_result}))
return (200, {"id_server_unbind_result": id_server_unbind_result})
class WhoamiRestServlet(RestServlet):
@ -617,7 +617,7 @@ class WhoamiRestServlet(RestServlet):
def on_GET(self, request):
requester = yield self.auth.get_user_by_req(request)
defer.returnValue((200, {"user_id": requester.user.to_string()}))
return (200, {"user_id": requester.user.to_string()})
def register_servlets(hs, http_server):

View File

@ -55,7 +55,7 @@ class AccountDataServlet(RestServlet):
self.notifier.on_new_event("account_data_key", max_id, users=[user_id])
defer.returnValue((200, {}))
return (200, {})
@defer.inlineCallbacks
def on_GET(self, request, user_id, account_data_type):
@ -70,7 +70,7 @@ class AccountDataServlet(RestServlet):
if event is None:
raise NotFoundError("Account data not found")
defer.returnValue((200, event))
return (200, event)
class RoomAccountDataServlet(RestServlet):
@ -112,7 +112,7 @@ class RoomAccountDataServlet(RestServlet):
self.notifier.on_new_event("account_data_key", max_id, users=[user_id])
defer.returnValue((200, {}))
return (200, {})
@defer.inlineCallbacks
def on_GET(self, request, user_id, room_id, account_data_type):
@ -127,7 +127,7 @@ class RoomAccountDataServlet(RestServlet):
if event is None:
raise NotFoundError("Room account data not found")
defer.returnValue((200, event))
return (200, event)
def register_servlets(hs, http_server):

View File

@ -58,7 +58,7 @@ class AccountValidityRenewServlet(RestServlet):
)
request.write(AccountValidityRenewServlet.SUCCESS_HTML)
finish_request(request)
defer.returnValue(None)
return None
class AccountValiditySendMailServlet(RestServlet):
@ -87,7 +87,7 @@ class AccountValiditySendMailServlet(RestServlet):
user_id = requester.user.to_string()
yield self.account_activity_handler.send_renewal_email_to_user(user_id)
defer.returnValue((200, {}))
return (200, {})
def register_servlets(hs, http_server):

View File

@ -207,7 +207,7 @@ class AuthRestServlet(RestServlet):
request.write(html_bytes)
finish_request(request)
defer.returnValue(None)
return None
elif stagetype == LoginType.TERMS:
if ("session" not in request.args or len(request.args["session"])) == 0:
raise SynapseError(400, "No session supplied")
@ -239,7 +239,7 @@ class AuthRestServlet(RestServlet):
request.write(html_bytes)
finish_request(request)
defer.returnValue(None)
return None
else:
raise SynapseError(404, "Unknown auth stage type")

View File

@ -58,7 +58,7 @@ class CapabilitiesRestServlet(RestServlet):
"m.change_password": {"enabled": change_password},
}
}
defer.returnValue((200, response))
return (200, response)
def register_servlets(hs, http_server):

View File

@ -48,7 +48,7 @@ class DevicesRestServlet(RestServlet):
devices = yield self.device_handler.get_devices_by_user(
requester.user.to_string()
)
defer.returnValue((200, {"devices": devices}))
return (200, {"devices": devices})
class DeleteDevicesRestServlet(RestServlet):
@ -91,7 +91,7 @@ class DeleteDevicesRestServlet(RestServlet):
yield self.device_handler.delete_devices(
requester.user.to_string(), body["devices"]
)
defer.returnValue((200, {}))
return (200, {})
class DeviceRestServlet(RestServlet):
@ -114,7 +114,7 @@ class DeviceRestServlet(RestServlet):
device = yield self.device_handler.get_device(
requester.user.to_string(), device_id
)
defer.returnValue((200, device))
return (200, device)
@interactive_auth_handler
@defer.inlineCallbacks
@ -137,7 +137,7 @@ class DeviceRestServlet(RestServlet):
)
yield self.device_handler.delete_device(requester.user.to_string(), device_id)
defer.returnValue((200, {}))
return (200, {})
@defer.inlineCallbacks
def on_PUT(self, request, device_id):
@ -147,7 +147,7 @@ class DeviceRestServlet(RestServlet):
yield self.device_handler.update_device(
requester.user.to_string(), device_id, body
)
defer.returnValue((200, {}))
return (200, {})
def register_servlets(hs, http_server):

View File

@ -56,7 +56,7 @@ class GetFilterRestServlet(RestServlet):
user_localpart=target_user.localpart, filter_id=filter_id
)
defer.returnValue((200, filter.get_filter_json()))
return (200, filter.get_filter_json())
except (KeyError, StoreError):
raise SynapseError(400, "No such filter", errcode=Codes.NOT_FOUND)
@ -89,7 +89,7 @@ class CreateFilterRestServlet(RestServlet):
user_localpart=target_user.localpart, user_filter=content
)
defer.returnValue((200, {"filter_id": str(filter_id)}))
return (200, {"filter_id": str(filter_id)})
def register_servlets(hs, http_server):

View File

@ -47,7 +47,7 @@ class GroupServlet(RestServlet):
group_id, requester_user_id
)
defer.returnValue((200, group_description))
return (200, group_description)
@defer.inlineCallbacks
def on_POST(self, request, group_id):
@ -59,7 +59,7 @@ class GroupServlet(RestServlet):
group_id, requester_user_id, content
)
defer.returnValue((200, {}))
return (200, {})
class GroupSummaryServlet(RestServlet):
@ -83,7 +83,7 @@ class GroupSummaryServlet(RestServlet):
group_id, requester_user_id
)
defer.returnValue((200, get_group_summary))
return (200, get_group_summary)
class GroupSummaryRoomsCatServlet(RestServlet):
@ -120,7 +120,7 @@ class GroupSummaryRoomsCatServlet(RestServlet):
content=content,
)
defer.returnValue((200, resp))
return (200, resp)
@defer.inlineCallbacks
def on_DELETE(self, request, group_id, category_id, room_id):
@ -131,7 +131,7 @@ class GroupSummaryRoomsCatServlet(RestServlet):
group_id, requester_user_id, room_id=room_id, category_id=category_id
)
defer.returnValue((200, resp))
return (200, resp)
class GroupCategoryServlet(RestServlet):
@ -157,7 +157,7 @@ class GroupCategoryServlet(RestServlet):
group_id, requester_user_id, category_id=category_id
)
defer.returnValue((200, category))
return (200, category)
@defer.inlineCallbacks
def on_PUT(self, request, group_id, category_id):
@ -169,7 +169,7 @@ class GroupCategoryServlet(RestServlet):
group_id, requester_user_id, category_id=category_id, content=content
)
defer.returnValue((200, resp))
return (200, resp)
@defer.inlineCallbacks
def on_DELETE(self, request, group_id, category_id):
@ -180,7 +180,7 @@ class GroupCategoryServlet(RestServlet):
group_id, requester_user_id, category_id=category_id
)
defer.returnValue((200, resp))
return (200, resp)
class GroupCategoriesServlet(RestServlet):
@ -204,7 +204,7 @@ class GroupCategoriesServlet(RestServlet):
group_id, requester_user_id
)
defer.returnValue((200, category))
return (200, category)
class GroupRoleServlet(RestServlet):
@ -228,7 +228,7 @@ class GroupRoleServlet(RestServlet):
group_id, requester_user_id, role_id=role_id
)
defer.returnValue((200, category))
return (200, category)
@defer.inlineCallbacks
def on_PUT(self, request, group_id, role_id):
@ -240,7 +240,7 @@ class GroupRoleServlet(RestServlet):
group_id, requester_user_id, role_id=role_id, content=content
)
defer.returnValue((200, resp))
return (200, resp)
@defer.inlineCallbacks
def on_DELETE(self, request, group_id, role_id):
@ -251,7 +251,7 @@ class GroupRoleServlet(RestServlet):
group_id, requester_user_id, role_id=role_id
)
defer.returnValue((200, resp))
return (200, resp)
class GroupRolesServlet(RestServlet):
@ -275,7 +275,7 @@ class GroupRolesServlet(RestServlet):
group_id, requester_user_id
)
defer.returnValue((200, category))
return (200, category)
class GroupSummaryUsersRoleServlet(RestServlet):
@ -312,7 +312,7 @@ class GroupSummaryUsersRoleServlet(RestServlet):
content=content,
)
defer.returnValue((200, resp))
return (200, resp)
@defer.inlineCallbacks
def on_DELETE(self, request, group_id, role_id, user_id):
@ -323,7 +323,7 @@ class GroupSummaryUsersRoleServlet(RestServlet):
group_id, requester_user_id, user_id=user_id, role_id=role_id
)
defer.returnValue((200, resp))
return (200, resp)
class GroupRoomServlet(RestServlet):
@ -347,7 +347,7 @@ class GroupRoomServlet(RestServlet):
group_id, requester_user_id
)
defer.returnValue((200, result))
return (200, result)
class GroupUsersServlet(RestServlet):
@ -371,7 +371,7 @@ class GroupUsersServlet(RestServlet):
group_id, requester_user_id
)
defer.returnValue((200, result))
return (200, result)
class GroupInvitedUsersServlet(RestServlet):
@ -395,7 +395,7 @@ class GroupInvitedUsersServlet(RestServlet):
group_id, requester_user_id
)
defer.returnValue((200, result))
return (200, result)
class GroupSettingJoinPolicyServlet(RestServlet):
@ -420,7 +420,7 @@ class GroupSettingJoinPolicyServlet(RestServlet):
group_id, requester_user_id, content
)
defer.returnValue((200, result))
return (200, result)
class GroupCreateServlet(RestServlet):
@ -450,7 +450,7 @@ class GroupCreateServlet(RestServlet):
group_id, requester_user_id, content
)
defer.returnValue((200, result))
return (200, result)
class GroupAdminRoomsServlet(RestServlet):
@ -477,7 +477,7 @@ class GroupAdminRoomsServlet(RestServlet):
group_id, requester_user_id, room_id, content
)
defer.returnValue((200, result))
return (200, result)
@defer.inlineCallbacks
def on_DELETE(self, request, group_id, room_id):
@ -488,7 +488,7 @@ class GroupAdminRoomsServlet(RestServlet):
group_id, requester_user_id, room_id
)
defer.returnValue((200, result))
return (200, result)
class GroupAdminRoomsConfigServlet(RestServlet):
@ -516,7 +516,7 @@ class GroupAdminRoomsConfigServlet(RestServlet):
group_id, requester_user_id, room_id, config_key, content
)
defer.returnValue((200, result))
return (200, result)
class GroupAdminUsersInviteServlet(RestServlet):
@ -546,7 +546,7 @@ class GroupAdminUsersInviteServlet(RestServlet):
group_id, user_id, requester_user_id, config
)
defer.returnValue((200, result))
return (200, result)
class GroupAdminUsersKickServlet(RestServlet):
@ -573,7 +573,7 @@ class GroupAdminUsersKickServlet(RestServlet):
group_id, user_id, requester_user_id, content
)
defer.returnValue((200, result))
return (200, result)
class GroupSelfLeaveServlet(RestServlet):
@ -598,7 +598,7 @@ class GroupSelfLeaveServlet(RestServlet):
group_id, requester_user_id, requester_user_id, content
)
defer.returnValue((200, result))
return (200, result)
class GroupSelfJoinServlet(RestServlet):
@ -623,7 +623,7 @@ class GroupSelfJoinServlet(RestServlet):
group_id, requester_user_id, content
)
defer.returnValue((200, result))
return (200, result)
class GroupSelfAcceptInviteServlet(RestServlet):
@ -648,7 +648,7 @@ class GroupSelfAcceptInviteServlet(RestServlet):
group_id, requester_user_id, content
)
defer.returnValue((200, result))
return (200, result)
class GroupSelfUpdatePublicityServlet(RestServlet):
@ -672,7 +672,7 @@ class GroupSelfUpdatePublicityServlet(RestServlet):
publicise = content["publicise"]
yield self.store.update_group_publicity(group_id, requester_user_id, publicise)
defer.returnValue((200, {}))
return (200, {})
class PublicisedGroupsForUserServlet(RestServlet):
@ -694,7 +694,7 @@ class PublicisedGroupsForUserServlet(RestServlet):
result = yield self.groups_handler.get_publicised_groups_for_user(user_id)
defer.returnValue((200, result))
return (200, result)
class PublicisedGroupsForUsersServlet(RestServlet):
@ -719,7 +719,7 @@ class PublicisedGroupsForUsersServlet(RestServlet):
result = yield self.groups_handler.bulk_get_publicised_groups(user_ids)
defer.returnValue((200, result))
return (200, result)
class GroupsForUserServlet(RestServlet):
@ -741,7 +741,7 @@ class GroupsForUserServlet(RestServlet):
result = yield self.groups_handler.get_joined_groups(requester_user_id)
defer.returnValue((200, result))
return (200, result)
def register_servlets(hs, http_server):

View File

@ -95,7 +95,7 @@ class KeyUploadServlet(RestServlet):
result = yield self.e2e_keys_handler.upload_keys_for_user(
user_id, device_id, body
)
defer.returnValue((200, result))
return (200, result)
class KeyQueryServlet(RestServlet):
@ -149,7 +149,7 @@ class KeyQueryServlet(RestServlet):
timeout = parse_integer(request, "timeout", 10 * 1000)
body = parse_json_object_from_request(request)
result = yield self.e2e_keys_handler.query_devices(body, timeout)
defer.returnValue((200, result))
return (200, result)
class KeyChangesServlet(RestServlet):
@ -189,7 +189,7 @@ class KeyChangesServlet(RestServlet):
results = yield self.device_handler.get_user_ids_changed(user_id, from_token)
defer.returnValue((200, results))
return (200, results)
class OneTimeKeyServlet(RestServlet):
@ -224,7 +224,7 @@ class OneTimeKeyServlet(RestServlet):
timeout = parse_integer(request, "timeout", 10 * 1000)
body = parse_json_object_from_request(request)
result = yield self.e2e_keys_handler.claim_one_time_keys(body, timeout)
defer.returnValue((200, result))
return (200, result)
def register_servlets(hs, http_server):

View File

@ -88,9 +88,7 @@ class NotificationsServlet(RestServlet):
returned_push_actions.append(returned_pa)
next_token = str(pa["stream_ordering"])
defer.returnValue(
(200, {"notifications": returned_push_actions, "next_token": next_token})
)
return (200, {"notifications": returned_push_actions, "next_token": next_token})
def register_servlets(hs, http_server):

View File

@ -83,8 +83,7 @@ class IdTokenServlet(RestServlet):
yield self.store.insert_open_id_token(token, ts_valid_until_ms, user_id)
defer.returnValue(
(
return (
200,
{
"access_token": token,
@ -93,7 +92,6 @@ class IdTokenServlet(RestServlet):
"expires_in": self.EXPIRES_MS / 1000,
},
)
)
def register_servlets(hs, http_server):

View File

@ -59,7 +59,7 @@ class ReadMarkerRestServlet(RestServlet):
event_id=read_marker_event_id,
)
defer.returnValue((200, {}))
return (200, {})
def register_servlets(hs, http_server):

Some files were not shown because too many files have changed in this diff Show More