mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-09-07 09:21:53 +00:00
Initial hack at the 3PN protocols metadata lookup API
This commit is contained in:
parent
63c19e1df9
commit
9899824b85
@ -88,6 +88,8 @@ class ApplicationService(object):
|
|||||||
self.sender = sender
|
self.sender = sender
|
||||||
self.namespaces = self._check_namespaces(namespaces)
|
self.namespaces = self._check_namespaces(namespaces)
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|
||||||
|
# .protocols is a publicly visible field
|
||||||
if protocols:
|
if protocols:
|
||||||
self.protocols = set(protocols)
|
self.protocols = set(protocols)
|
||||||
else:
|
else:
|
||||||
|
@ -175,6 +175,14 @@ class ApplicationServicesHandler(object):
|
|||||||
|
|
||||||
defer.returnValue(ret)
|
defer.returnValue(ret)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def get_3pe_protocols(self):
|
||||||
|
services = yield self.store.get_app_services()
|
||||||
|
protocols = set()
|
||||||
|
for s in services:
|
||||||
|
protocols.update(s.protocols)
|
||||||
|
defer.returnValue(protocols)
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _get_services_for_event(self, event):
|
def _get_services_for_event(self, event):
|
||||||
"""Retrieve a list of application services interested in this event.
|
"""Retrieve a list of application services interested in this event.
|
||||||
|
@ -25,6 +25,39 @@ from ._base import client_v2_patterns
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
class ThirdPartyProtocolsServlet(RestServlet):
|
||||||
|
PATTERNS = client_v2_patterns("/thirdparty/protocols", releases=())
|
||||||
|
|
||||||
|
META = {
|
||||||
|
# TODO(paul): Declare kinds of metadata in here
|
||||||
|
}
|
||||||
|
|
||||||
|
def __init__(self, hs):
|
||||||
|
super(ThirdPartyProtocolsServlet, self).__init__()
|
||||||
|
|
||||||
|
self.auth = hs.get_auth()
|
||||||
|
self.appservice_handler = hs.get_application_service_handler()
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def on_GET(self, request):
|
||||||
|
yield self.auth.get_user_by_req(request)
|
||||||
|
|
||||||
|
protocols = yield self.appservice_handler.get_3pe_protocols()
|
||||||
|
|
||||||
|
result = {}
|
||||||
|
# TODO(paul): Eventually this kind of metadata wants to come from the
|
||||||
|
# ASes themselves
|
||||||
|
for protocol in protocols:
|
||||||
|
if protocol in self.META:
|
||||||
|
result[protocol] = self.META[protocol]
|
||||||
|
else:
|
||||||
|
# We don't know any metadata for it, but we'd best at least
|
||||||
|
# still declare that we know it exists
|
||||||
|
result[protocol] = {}
|
||||||
|
|
||||||
|
defer.returnValue((200, result))
|
||||||
|
|
||||||
|
|
||||||
class ThirdPartyUserServlet(RestServlet):
|
class ThirdPartyUserServlet(RestServlet):
|
||||||
PATTERNS = client_v2_patterns("/thirdparty/user(/(?P<protocol>[^/]+))?$",
|
PATTERNS = client_v2_patterns("/thirdparty/user(/(?P<protocol>[^/]+))?$",
|
||||||
releases=())
|
releases=())
|
||||||
@ -74,5 +107,6 @@ class ThirdPartyLocationServlet(RestServlet):
|
|||||||
|
|
||||||
|
|
||||||
def register_servlets(hs, http_server):
|
def register_servlets(hs, http_server):
|
||||||
|
ThirdPartyProtocolsServlet(hs).register(http_server)
|
||||||
ThirdPartyUserServlet(hs).register(http_server)
|
ThirdPartyUserServlet(hs).register(http_server)
|
||||||
ThirdPartyLocationServlet(hs).register(http_server)
|
ThirdPartyLocationServlet(hs).register(http_server)
|
||||||
|
Loading…
Reference in New Issue
Block a user