mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 11:26:09 -04:00
Port rest.client.v2
This commit is contained in:
parent
af5d0ebc72
commit
9c41ba4c5f
23 changed files with 361 additions and 505 deletions
|
@ -16,8 +16,6 @@
|
|||
|
||||
import logging
|
||||
|
||||
from twisted.internet import defer
|
||||
|
||||
from synapse.api.constants import ThirdPartyEntityKind
|
||||
from synapse.http.servlet import RestServlet
|
||||
|
||||
|
@ -35,11 +33,10 @@ class ThirdPartyProtocolsServlet(RestServlet):
|
|||
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, allow_guest=True)
|
||||
async def on_GET(self, request):
|
||||
await self.auth.get_user_by_req(request, allow_guest=True)
|
||||
|
||||
protocols = yield self.appservice_handler.get_3pe_protocols()
|
||||
protocols = await self.appservice_handler.get_3pe_protocols()
|
||||
return 200, protocols
|
||||
|
||||
|
||||
|
@ -52,11 +49,10 @@ class ThirdPartyProtocolServlet(RestServlet):
|
|||
self.auth = hs.get_auth()
|
||||
self.appservice_handler = hs.get_application_service_handler()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def on_GET(self, request, protocol):
|
||||
yield self.auth.get_user_by_req(request, allow_guest=True)
|
||||
async def on_GET(self, request, protocol):
|
||||
await self.auth.get_user_by_req(request, allow_guest=True)
|
||||
|
||||
protocols = yield self.appservice_handler.get_3pe_protocols(
|
||||
protocols = await self.appservice_handler.get_3pe_protocols(
|
||||
only_protocol=protocol
|
||||
)
|
||||
if protocol in protocols:
|
||||
|
@ -74,14 +70,13 @@ class ThirdPartyUserServlet(RestServlet):
|
|||
self.auth = hs.get_auth()
|
||||
self.appservice_handler = hs.get_application_service_handler()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def on_GET(self, request, protocol):
|
||||
yield self.auth.get_user_by_req(request, allow_guest=True)
|
||||
async def on_GET(self, request, protocol):
|
||||
await self.auth.get_user_by_req(request, allow_guest=True)
|
||||
|
||||
fields = request.args
|
||||
fields.pop(b"access_token", None)
|
||||
|
||||
results = yield self.appservice_handler.query_3pe(
|
||||
results = await self.appservice_handler.query_3pe(
|
||||
ThirdPartyEntityKind.USER, protocol, fields
|
||||
)
|
||||
|
||||
|
@ -97,14 +92,13 @@ class ThirdPartyLocationServlet(RestServlet):
|
|||
self.auth = hs.get_auth()
|
||||
self.appservice_handler = hs.get_application_service_handler()
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def on_GET(self, request, protocol):
|
||||
yield self.auth.get_user_by_req(request, allow_guest=True)
|
||||
async def on_GET(self, request, protocol):
|
||||
await self.auth.get_user_by_req(request, allow_guest=True)
|
||||
|
||||
fields = request.args
|
||||
fields.pop(b"access_token", None)
|
||||
|
||||
results = yield self.appservice_handler.query_3pe(
|
||||
results = await self.appservice_handler.query_3pe(
|
||||
ThirdPartyEntityKind.LOCATION, protocol, fields
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue