mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-15 13:33:54 +01:00
Efficiency fix for lookups of a single protocol
This commit is contained in:
parent
3328428d05
commit
25eb769b26
2 changed files with 7 additions and 2 deletions
|
@ -176,13 +176,16 @@ class ApplicationServicesHandler(object):
|
||||||
defer.returnValue(ret)
|
defer.returnValue(ret)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def get_3pe_protocols(self):
|
def get_3pe_protocols(self, only_protocol=None):
|
||||||
services = yield self.store.get_app_services()
|
services = yield self.store.get_app_services()
|
||||||
protocols = {}
|
protocols = {}
|
||||||
|
|
||||||
# Collect up all the individual protocol responses out of the ASes
|
# Collect up all the individual protocol responses out of the ASes
|
||||||
for s in services:
|
for s in services:
|
||||||
for p in s.protocols:
|
for p in s.protocols:
|
||||||
|
if only_protocol is not None and p != only_protocol:
|
||||||
|
continue
|
||||||
|
|
||||||
info = yield self.appservice_api.get_3pe_protocol(s, p)
|
info = yield self.appservice_api.get_3pe_protocol(s, p)
|
||||||
|
|
||||||
# Ignore any result that doesn't contain an "instances" list
|
# Ignore any result that doesn't contain an "instances" list
|
||||||
|
|
|
@ -55,7 +55,9 @@ class ThirdPartyProtocolServlet(RestServlet):
|
||||||
def on_GET(self, request, protocol):
|
def on_GET(self, request, protocol):
|
||||||
yield self.auth.get_user_by_req(request)
|
yield self.auth.get_user_by_req(request)
|
||||||
|
|
||||||
protocols = yield self.appservice_handler.get_3pe_protocols()
|
protocols = yield self.appservice_handler.get_3pe_protocols(
|
||||||
|
only_protocol=protocol,
|
||||||
|
)
|
||||||
if protocol in protocols:
|
if protocol in protocols:
|
||||||
defer.returnValue((200, protocols[protocol]))
|
defer.returnValue((200, protocols[protocol]))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue