Add listSubscriptions and listAddressbook to api
listSubscriptions returns label, address and enabled for each address in the subscription list. listAddressbook return label and address for each address in the addressbook.
This commit is contained in:
parent
7772484da9
commit
3a4ef1e81f
|
@ -164,6 +164,34 @@ class MySimpleXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
|
|||
streamNumber, 'enabled': shared.config.getboolean(addressInKeysFile, 'enabled')}, indent=4, separators=(',', ': '))
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'listSubscriptions':
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put('''SELECT label, address, enabled from subscriptions''')
|
||||
shared.sqlSubmitQueue.put('')
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlLock.release()
|
||||
data = '{"subscriptions":['
|
||||
for row in queryreturn:
|
||||
label, address, enabled = row
|
||||
if len(data) > 20:
|
||||
data += ','
|
||||
data += json.dumps({'label': label, 'address': address, 'enabled': enabled})
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'listAddressbook':
|
||||
shared.sqlLock.acquire()
|
||||
shared.sqlSubmitQueue.put('''SELECT label, address from addressbook''')
|
||||
shared.sqlSubmitQueue.put('')
|
||||
queryreturn = shared.sqlReturnQueue.get()
|
||||
shared.sqlLock.release()
|
||||
data = '{"addresses":['
|
||||
for row in queryreturn:
|
||||
label, address = row
|
||||
if len(data) > 20:
|
||||
data += ','
|
||||
data += json.dumps({'label': label, 'address': address})
|
||||
data += ']}'
|
||||
return data
|
||||
elif method == 'createRandomAddress':
|
||||
if len(params) == 0:
|
||||
return 'API Error 0000: I need parameters!'
|
||||
|
|
Reference in New Issue
Block a user