From 952f2ea97ef11d9c5e75980560e50b0588e5864b Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sat, 4 May 2024 04:58:15 +1200 Subject: [PATCH] save incoming state in db --- database.py | 1 + web.py | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/database.py b/database.py index c7dbc9e..b2c159d 100644 --- a/database.py +++ b/database.py @@ -19,6 +19,7 @@ class LxmfMessage(BaseModel): destination_hash = CharField(index=True) state = CharField() # state is converted from internal int to a human friendly string progress = FloatField() # progress is converted from internal float 0.00-1.00 to float between 0.00/100 (2 decimal places) + is_incoming = BooleanField() # if true, we should ignore state, it's set to draft by default on incoming messages content = TextField() fields = TextField() # json string created_at = DateTimeField(default=datetime.now) diff --git a/web.py b/web.py index 9955b47..0875145 100644 --- a/web.py +++ b/web.py @@ -192,6 +192,7 @@ class ReticulumWebChat: "hash": db_lxmf_message.hash, "source_hash": db_lxmf_message.source_hash, "destination_hash": db_lxmf_message.destination_hash, + "is_incoming": db_lxmf_message.is_incoming, "state": db_lxmf_message.state, "progress": db_lxmf_message.progress, "content": db_lxmf_message.content, @@ -455,6 +456,7 @@ class ReticulumWebChat: "hash": lxmf_message.hash.hex(), "source_hash": lxmf_message.source_hash.hex(), "destination_hash": lxmf_message.destination_hash.hex(), + "is_incoming": lxmf_message.incoming, "state": self.convert_lxmf_state_to_string(lxmf_message), "progress": progress_percentage, "content": lxmf_message.content.decode('utf-8'), @@ -494,6 +496,7 @@ class ReticulumWebChat: hash=lxmf_message_dict["hash"], source_hash=lxmf_message_dict["source_hash"], destination_hash=lxmf_message_dict["destination_hash"], + is_incoming=lxmf_message_dict["is_incoming"], state=lxmf_message_dict["state"], progress=lxmf_message_dict["progress"], content=lxmf_message_dict["content"], @@ -539,6 +542,7 @@ class ReticulumWebChat: "hash": lxmf_message_dict["hash"], "source_hash": lxmf_message_dict["source_hash"], "destination_hash": lxmf_message_dict["destination_hash"], + "is_incoming": lxmf_message_dict["is_incoming"], "state": lxmf_message_dict["state"], "progress": lxmf_message_dict["progress"], "content": lxmf_message_dict["content"],