mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-18 16:34:18 -05:00
Actually query over AS API for 3PE lookup metadata
This commit is contained in:
parent
8e1ed09dff
commit
5474824975
@ -52,6 +52,13 @@ class ApplicationServiceApi(SimpleHttpClient):
|
||||
pushing.
|
||||
"""
|
||||
|
||||
PROTOCOL_META = {
|
||||
# TODO(paul): Declare kinds of metadata in here
|
||||
"gitter": {
|
||||
"user_fields": ["username"],
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, hs):
|
||||
super(ApplicationServiceApi, self).__init__(hs)
|
||||
self.clock = hs.get_clock()
|
||||
@ -131,6 +138,19 @@ class ApplicationServiceApi(SimpleHttpClient):
|
||||
logger.warning("query_3pe to %s threw exception %s", uri, ex)
|
||||
defer.returnValue([])
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def get_3pe_protocol(self, service, protocol):
|
||||
# TODO: cache
|
||||
uri = "%s/thirdparty/protocol/%s" % (service.url, urllib.quote(protocol))
|
||||
try:
|
||||
response = yield self.get_json(uri, {})
|
||||
defer.returnValue(response)
|
||||
except Exception as ex:
|
||||
logger.warning("query_3pe_protocol to %s threw exception %s",
|
||||
uri, ex
|
||||
)
|
||||
defer.returnValue({})
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def push_bulk(self, service, events, txn_id=None):
|
||||
events = self._serialize(events)
|
||||
|
@ -37,13 +37,6 @@ def log_failure(failure):
|
||||
|
||||
class ApplicationServicesHandler(object):
|
||||
|
||||
PROTOCOL_META = {
|
||||
# TODO(paul): Declare kinds of metadata in here
|
||||
"gitter": {
|
||||
"user_fields": ["username"],
|
||||
}
|
||||
}
|
||||
|
||||
def __init__(self, hs):
|
||||
self.store = hs.get_datastore()
|
||||
self.is_mine_id = hs.is_mine_id
|
||||
@ -195,12 +188,7 @@ class ApplicationServicesHandler(object):
|
||||
protocols = {}
|
||||
for s in services:
|
||||
for p in s.protocols:
|
||||
if p in self.PROTOCOL_META:
|
||||
protocols[p] = self.PROTOCOL_META[p]
|
||||
else:
|
||||
# We don't know any metadata for it, but we'd best at least
|
||||
# still declare that we know it exists
|
||||
protocols[p] = {}
|
||||
protocols[p] = yield self.appservice_api.get_3pe_protocol(s, p)
|
||||
|
||||
self.supported_protocols = protocols
|
||||
defer.returnValue(protocols)
|
||||
|
Loading…
Reference in New Issue
Block a user