updates list for new rest result

- list is now a json object which contains
  "messages" which is a JSON Array list
This commit is contained in:
Raphael Maenle 2021-12-17 16:22:04 +01:00
parent be09c04987
commit 3d3633592a

17
main.py
View File

@ -7,6 +7,7 @@ import requests
import base64 import base64
import re import re
SENDER_LENGTH = 4 SENDER_LENGTH = 4
PASSWORD_LENGTH = 8 PASSWORD_LENGTH = 8
@ -109,6 +110,10 @@ class Bump:
password = self.get_password() password = self.get_password()
return password_decrypt(data, password).decode() return password_decrypt(data, password).decode()
def push_fake(self, data):
print(self.encrypt(data))
def push(self, data): def push(self, data):
url = self.URL + "push" url = self.URL + "push"
params = { params = {
@ -121,8 +126,8 @@ class Bump:
print(r.json()) print(r.json())
def peak(self): def peek(self):
return self.get_post("peak") return self.get_post("peek")
def pop(self): def pop(self):
return self.get_post("pop") return self.get_post("pop")
@ -148,10 +153,11 @@ class Bump:
messages = requests.post(url, params).json() messages = requests.post(url, params).json()
if messages == {} or messages == None or messages == []: if(messages == {} or messages == None or
"messages" in messages and messages["messages"] == []):
return [{}] return [{}]
elif type(messages) == list: elif "messages" in messages:
for message in messages: for message in messages.get("messages"):
message['data'] = self.decrypt(message.get('data')) message['data'] = self.decrypt(message.get('data'))
return messages return messages
@ -186,3 +192,4 @@ class Bump:
if __name__ == '__main__': if __name__ == '__main__':
b = Bump() b = Bump()
b.decrypt("M1dEAxKZ5HUHCJoRkgGOvAABhqCAAAAAAGG2eKTSlKXWLDQx5B_wssZsNwsanzQID2UyUm4KKuKYKgfwH5MG2N-qzt6K4mg3pfZmWPaiDB9PiqlX236k6zo9Yvvq")