From 5d4f6bc0842e9c4acff81af0aaac71458b542311 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Tue, 13 Aug 2024 23:25:39 +1200 Subject: [PATCH] only set app data if provided, as we don't want to wipe existing data when we request keys from the network --- meshchat.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/meshchat.py b/meshchat.py index c0fffde..8e63c87 100644 --- a/meshchat.py +++ b/meshchat.py @@ -1585,21 +1585,20 @@ class ReticulumMeshChat: # upserts the provided announce to the database def db_upsert_announce(self, identity: RNS.Identity, destination_hash: bytes, aspect: str, app_data: bytes): - # parse app data - parsed_app_data = None - if app_data is not None: - parsed_app_data = base64.b64encode(app_data).decode("utf-8") - # prepare data to insert or update data = { "destination_hash": destination_hash.hex(), "aspect": aspect, "identity_hash": identity.hash.hex(), "identity_public_key": base64.b64encode(identity.get_public_key()).decode("utf-8"), - "app_data": parsed_app_data, "updated_at": datetime.now(timezone.utc), } + # only set app data if provided, as we don't want to wipe existing data when we request keys from the network + if app_data is not None: + # parse app data as utf8 string + data["app_data"] = base64.b64encode(app_data).decode("utf-8") + # upsert to database query = database.Announce.insert(data) query = query.on_conflict(conflict_target=[database.Announce.destination_hash], update=data)