mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Remove compression from MessageP2P payload from/to methods.
This commit is contained in:
parent
7a9ee28bf7
commit
6928ab14cc
1 changed files with 2 additions and 6 deletions
|
@ -2,7 +2,6 @@ import datetime
|
||||||
import api_validations
|
import api_validations
|
||||||
import base64
|
import base64
|
||||||
import json
|
import json
|
||||||
import lzma
|
|
||||||
|
|
||||||
|
|
||||||
class MessageP2P:
|
class MessageP2P:
|
||||||
|
@ -37,8 +36,7 @@ class MessageP2P:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_payload(cls, payload):
|
def from_payload(cls, payload):
|
||||||
json_string = str(lzma.decompress(payload), 'utf-8')
|
payload_message = json.loads(payload)
|
||||||
payload_message = json.loads(json_string)
|
|
||||||
attachments = list(map(cls.__decode_attachment__, payload_message['attachments']))
|
attachments = list(map(cls.__decode_attachment__, payload_message['attachments']))
|
||||||
return cls(payload_message['origin'], payload_message['destination'],
|
return cls(payload_message['origin'], payload_message['destination'],
|
||||||
payload_message['body'], attachments)
|
payload_message['body'], attachments)
|
||||||
|
@ -70,6 +68,4 @@ class MessageP2P:
|
||||||
def to_payload(self):
|
def to_payload(self):
|
||||||
"""Make a byte array ready to be sent out of the message data"""
|
"""Make a byte array ready to be sent out of the message data"""
|
||||||
json_string = json.dumps(self.to_dict())
|
json_string = json.dumps(self.to_dict())
|
||||||
json_bytes = bytes(json_string, 'utf-8')
|
return json_string
|
||||||
final_payload = lzma.compress(json_bytes)
|
|
||||||
return final_payload
|
|
||||||
|
|
Loading…
Reference in a new issue