合并到远程
This commit is contained in:
15
src/common/utils/utils_message.py
Normal file
15
src/common/utils/utils_message.py
Normal file
@@ -0,0 +1,15 @@
|
||||
import msgpack
|
||||
|
||||
from src.common.data_models.message_component_model import MessageSequence
|
||||
|
||||
|
||||
class MessageUtils:
|
||||
@staticmethod
|
||||
def from_db_record_msg_to_MaiSeq(raw_content: bytes) -> MessageSequence:
|
||||
unpacked_data = msgpack.unpackb(raw_content)
|
||||
return MessageSequence.from_dict(unpacked_data)
|
||||
|
||||
@staticmethod
|
||||
async def from_MaiSeq_to_db_record_msg(msg: MessageSequence) -> bytes:
|
||||
dict_representation = msg.to_dict()
|
||||
return msgpack.packb(dict_representation) # type: ignore
|
||||
Reference in New Issue
Block a user