mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-12-24 21:29:22 -05:00
Updater command line client to new IS API
This commit is contained in:
parent
3c349b408b
commit
47a4bff139
@ -233,56 +233,68 @@ class SynapseCmd(cmd.Cmd):
|
|||||||
defer.returnValue(False)
|
defer.returnValue(False)
|
||||||
defer.returnValue(True)
|
defer.returnValue(True)
|
||||||
|
|
||||||
def do_3pidrequest(self, line):
|
def do_emailrequest(self, line):
|
||||||
"""Requests the association of a third party identifier
|
"""Requests the association of a third party identifier
|
||||||
<medium> The medium of the identifer (currently only 'email')
|
<address> The email address)
|
||||||
<address> The address of the identifer (ie. the email address)
|
<clientSecret> A string of characters generated when requesting an email that you'll supply in subsequent calls to identify yourself
|
||||||
|
<sendAttempt> The number of times the user has requested an email. Leave this the same between requests to retry the request at the transport level. Increment it to request that the email be sent again.
|
||||||
"""
|
"""
|
||||||
args = self._parse(line, ['medium', 'address'])
|
args = self._parse(line, ['address', 'clientSecret', 'sendAttempt'])
|
||||||
|
|
||||||
if not args['medium'] == 'email':
|
postArgs = {'email': args['address'], 'clientSecret': args['clientSecret'], 'sendAttempt': args['sendAttempt']}
|
||||||
print "Only email is supported currently"
|
|
||||||
return
|
|
||||||
|
|
||||||
postArgs = {'email': args['address'], 'clientSecret': '____'}
|
reactor.callFromThread(self._do_emailrequest, postArgs)
|
||||||
|
|
||||||
reactor.callFromThread(self._do_3pidrequest, postArgs)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _do_3pidrequest(self, args):
|
def _do_emailrequest(self, args):
|
||||||
url = self._identityServerUrl()+"/matrix/identity/api/v1/validate/email/requestToken"
|
url = self._identityServerUrl()+"/matrix/identity/api/v1/validate/email/requestToken"
|
||||||
|
|
||||||
json_res = yield self.http_client.do_request("POST", url, data=urllib.urlencode(args), jsonreq=False,
|
json_res = yield self.http_client.do_request("POST", url, data=urllib.urlencode(args), jsonreq=False,
|
||||||
headers={'Content-Type': ['application/x-www-form-urlencoded']})
|
headers={'Content-Type': ['application/x-www-form-urlencoded']})
|
||||||
print json_res
|
print json_res
|
||||||
if 'tokenId' in json_res:
|
if 'sid' in json_res:
|
||||||
print "Token ID %s sent" % (json_res['tokenId'])
|
print "Token sent. Your session ID is %s" % (json_res['sid'])
|
||||||
|
|
||||||
def do_3pidvalidate(self, line):
|
def do_emailvalidate(self, line):
|
||||||
"""Validate and associate a third party ID
|
"""Validate and associate a third party ID
|
||||||
<medium> The medium of the identifer (currently only 'email')
|
<sid> The session ID (sid) given to you in the response to requestToken
|
||||||
<tokenId> The identifier iof the token given in 3pidrequest
|
|
||||||
<token> The token sent to your third party identifier address
|
<token> The token sent to your third party identifier address
|
||||||
|
<clientSecret> The same clientSecret you supplied in requestToken
|
||||||
"""
|
"""
|
||||||
args = self._parse(line, ['medium', 'tokenId', 'token'])
|
args = self._parse(line, ['sid', 'token', 'clientSecret'])
|
||||||
|
|
||||||
if not args['medium'] == 'email':
|
postArgs = { 'sid' : args['sid'], 'token' : args['token'], 'clientSecret': args['clientSecret'] }
|
||||||
print "Only email is supported currently"
|
|
||||||
return
|
|
||||||
|
|
||||||
postArgs = { 'tokenId' : args['tokenId'], 'token' : args['token'] }
|
reactor.callFromThread(self._do_emailvalidate, postArgs)
|
||||||
postArgs['mxId'] = self.config["user"]
|
|
||||||
|
|
||||||
reactor.callFromThread(self._do_3pidvalidate, postArgs)
|
|
||||||
|
|
||||||
@defer.inlineCallbacks
|
@defer.inlineCallbacks
|
||||||
def _do_3pidvalidate(self, args):
|
def _do_emailvalidate(self, args):
|
||||||
url = self._identityServerUrl()+"/matrix/identity/api/v1/validate/email/submitToken"
|
url = self._identityServerUrl()+"/matrix/identity/api/v1/validate/email/submitToken"
|
||||||
|
|
||||||
json_res = yield self.http_client.do_request("POST", url, data=urllib.urlencode(args), jsonreq=False,
|
json_res = yield self.http_client.do_request("POST", url, data=urllib.urlencode(args), jsonreq=False,
|
||||||
headers={'Content-Type': ['application/x-www-form-urlencoded']})
|
headers={'Content-Type': ['application/x-www-form-urlencoded']})
|
||||||
print json_res
|
print json_res
|
||||||
|
|
||||||
|
def do_3pidbind(self, line):
|
||||||
|
"""Validate and associate a third party ID
|
||||||
|
<sid> The session ID (sid) given to you in the response to requestToken
|
||||||
|
<clientSecret> The same clientSecret you supplied in requestToken
|
||||||
|
"""
|
||||||
|
args = self._parse(line, ['sid', 'clientSecret'])
|
||||||
|
|
||||||
|
postArgs = { 'sid' : args['sid'], 'clientSecret': args['clientSecret'] }
|
||||||
|
postArgs['mxid'] = self.config["user"]
|
||||||
|
|
||||||
|
reactor.callFromThread(self._do_3pidbind, postArgs)
|
||||||
|
|
||||||
|
@defer.inlineCallbacks
|
||||||
|
def _do_3pidbind(self, args):
|
||||||
|
url = self._identityServerUrl()+"/matrix/identity/api/v1/3pid/bind"
|
||||||
|
|
||||||
|
json_res = yield self.http_client.do_request("POST", url, data=urllib.urlencode(args), jsonreq=False,
|
||||||
|
headers={'Content-Type': ['application/x-www-form-urlencoded']})
|
||||||
|
print json_res
|
||||||
|
|
||||||
def do_join(self, line):
|
def do_join(self, line):
|
||||||
"""Joins a room: "join <roomid>" """
|
"""Joins a room: "join <roomid>" """
|
||||||
try:
|
try:
|
||||||
|
Loading…
Reference in New Issue
Block a user