delete lxmf messages by hash as ui might not have an id yet

This commit is contained in:
liamcottle 2024-07-08 23:10:21 +12:00
parent 827b453055
commit daffc19f92
2 changed files with 8 additions and 8 deletions

View file

@ -2291,7 +2291,7 @@
} }
// delete lxmf message from server // delete lxmf message from server
await window.axios.delete(`/api/v1/lxmf-messages/${chatItem.lxmf_message.id}`); await window.axios.delete(`/api/v1/lxmf-messages/${chatItem.lxmf_message.hash}`);
// remove lxmf message from chat items using hash, as other pending items might not have an id yet // remove lxmf message from chat items using hash, as other pending items might not have an id yet
this.chatItems = this.chatItems.filter((item) => { this.chatItems = this.chatItems.filter((item) => {

14
web.py
View file

@ -797,20 +797,20 @@ class ReticulumMeshChat:
}) })
# delete lxmf message # delete lxmf message
@routes.delete("/api/v1/lxmf-messages/{id}") @routes.delete("/api/v1/lxmf-messages/{hash}")
async def index(request): async def index(request):
# get path params # get path params
id = request.match_info.get("id", None) hash = request.match_info.get("hash", None)
# source_hash is required # hash is required
if id is None: if hash is None:
return web.json_response({ return web.json_response({
"message": "id is required", "message": "hash is required",
}, status=422) }, status=422)
# delete lxmf messages from db where id matches # delete lxmf messages from db where hash matches
database.LxmfMessage.delete_by_id(id) database.LxmfMessage.delete().where((database.LxmfMessage.hash == hash)).execute()
return web.json_response({ return web.json_response({
"message": "ok", "message": "ok",