Example #1
0
 def post( self, request ):
     if request.json['identity'] in BitKey.objects.filter(user=request.json['_user']):
             return JsonResponse( { 'error' : 'You have already created an identity with that name'})
     identity = request.json['identity']
     import pdb; pdb.set_trace()
     newaddy = BMclient.call('createRandomAddress', BMclient._encode(identity) )
     bitty = BitKey.objects.create(name=request.json['identity'], key=newaddy['data'][0]['address'], user=request.json['_user'])
     return JsonResponse( { 'identity' : bitty.name } )
Example #2
0
 def post(self, request):
     to_address = request.json['to_address']
     from_add = request.json['from_address']
     subject = request.json['subject']
     message = request.json['message']
     sent = BMclient.call('sendMessage', to_address, from_add,
                          BMclient._encode(subject),
                          BMclient._encode(message))
     return JsonResponse({'message_status': sent})
Example #3
0
 def post( self, request ):
     client_response = BMclient.call('createChan', BMclient._encode(request.json['form']))
     if client_response['status'] == 24:
         pass
         # here we have to deal with multiple users trying to create a chan
         # with the same name
     elif client_response['status'] != 200:
         return JsonResponse( { 'error' : client_response['status'] } )
     else:
         address = client_response['data'][0]['address']
         return JsonResponse( { 'address' : address, 'label' : request.json['form'] } )
Example #4
0
 def post(self, request):
     client_response = BMclient.call(
         'joinChan', BMclient._encode(request.json['label']),
         request.json['address'])
     if client_response['status'] == 200 or client_response['status'] == 16:
         return JsonResponse({
             'label': request.json['label'],
             'address': request.json['address']
         })
     else:
         return JsonResponse({
             'status': client_response['status'],
             'error': client_response['data']
         })
Example #5
0
def get_messages(function_name, request, chans=False):
    bitkeys = BitKey.objects.filter(user=request.json['_user'])
    addresses = [bk.key for bk in bitkeys]
    if chans:
        addresses += chans
    data = [BMclient.call(function_name, address) for address in addresses]
    return JsonResponse({'messages': data, 'chans': chans})
Example #6
0
 def post(self, request):
     address = request.json['chan_remove_list']
     status = BMclient.call('leaveChan', address)
     return JsonResponse({'status': status})