Root the 3PE lookup API within /_matrix/app/unstable instead of at toplevel
This commit is contained in:
parent
142983b4ea
commit
e7af8be5ae
|
@ -29,6 +29,9 @@ logger = logging.getLogger(__name__)
|
||||||
HOUR_IN_MS = 60 * 60 * 1000
|
HOUR_IN_MS = 60 * 60 * 1000
|
||||||
|
|
||||||
|
|
||||||
|
APP_SERVICE_PREFIX = "/_matrix/app/unstable"
|
||||||
|
|
||||||
|
|
||||||
def _is_valid_3pe_result(r, field):
|
def _is_valid_3pe_result(r, field):
|
||||||
if not isinstance(r, dict):
|
if not isinstance(r, dict):
|
||||||
return False
|
return False
|
||||||
|
@ -103,16 +106,22 @@ class ApplicationServiceApi(SimpleHttpClient):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def query_3pe(self, service, kind, protocol, fields):
|
def query_3pe(self, service, kind, protocol, fields):
|
||||||
if kind == ThirdPartyEntityKind.USER:
|
if kind == ThirdPartyEntityKind.USER:
|
||||||
uri = "%s/thirdparty/user/%s" % (service.url, urllib.quote(protocol))
|
fragment = "user"
|
||||||
required_field = "userid"
|
required_field = "userid"
|
||||||
elif kind == ThirdPartyEntityKind.LOCATION:
|
elif kind == ThirdPartyEntityKind.LOCATION:
|
||||||
uri = "%s/thirdparty/location/%s" % (service.url, urllib.quote(protocol))
|
fragment = "location"
|
||||||
required_field = "alias"
|
required_field = "alias"
|
||||||
else:
|
else:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
"Unrecognised 'kind' argument %r to query_3pe()", kind
|
"Unrecognised 'kind' argument %r to query_3pe()", kind
|
||||||
)
|
)
|
||||||
|
|
||||||
|
uri = "%s%s/thirdparty/%s/%s" % (
|
||||||
|
service.url,
|
||||||
|
APP_SERVICE_PREFIX,
|
||||||
|
fragment,
|
||||||
|
urllib.quote(protocol)
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
response = yield self.get_json(uri, fields)
|
response = yield self.get_json(uri, fields)
|
||||||
if not isinstance(response, list):
|
if not isinstance(response, list):
|
||||||
|
@ -140,7 +149,11 @@ class ApplicationServiceApi(SimpleHttpClient):
|
||||||
def get_3pe_protocol(self, service, protocol):
|
def get_3pe_protocol(self, service, protocol):
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _get():
|
def _get():
|
||||||
uri = "%s/thirdparty/protocol/%s" % (service.url, urllib.quote(protocol))
|
uri = "%s%s/thirdparty/protocol/%s" % (
|
||||||
|
service.url,
|
||||||
|
APP_SERVICE_PREFIX,
|
||||||
|
urllib.quote(protocol)
|
||||||
|
)
|
||||||
try:
|
try:
|
||||||
defer.returnValue((yield self.get_json(uri, {})))
|
defer.returnValue((yield self.get_json(uri, {})))
|
||||||
except Exception as ex:
|
except Exception as ex:
|
||||||
|
|
Loading…
Reference in New Issue