mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-28 00:20:48 +00:00
only set app data if provided, as we don't want to wipe existing data when we request keys from the network
This commit is contained in:
parent
bc53516c64
commit
5d4f6bc084
1 changed files with 5 additions and 6 deletions
11
meshchat.py
11
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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue