fix: legacy signal dispatcher with new confirm

This commit is contained in:
2024-02-18 17:32:10 +01:00
parent 1b3885850b
commit 00bb802327

View File

@@ -24,7 +24,7 @@ def report_dispatch_error(target, uid, error):
def confirm_dispatch(target, uid): def confirm_dispatch(target, uid):
'''Confirm to server that message has been dispatched and can be removed''' '''Confirm to server that message has been dispatched and can be removed'''
response = requests.post(target + "/confirm-dispatch", json=[{ "uid" : uid }], response = requests.post(target + "/confirm-dispatch", json=[{ "uuid" : uid }],
auth=(args.user, args.password)) auth=(args.user, args.password))
if response.status_code not in [200, 204]: if response.status_code not in [200, 204]:
@@ -64,6 +64,7 @@ if __name__ == "__main__":
# track dispatches that were confirmed to avoid duplicate confirmation # # track dispatches that were confirmed to avoid duplicate confirmation #
dispatch_confirmed = [] dispatch_confirmed = []
dispatch_failed = [] dispatch_failed = []
errors = {}
for entry in response.json(): for entry in response.json():
@@ -82,6 +83,9 @@ if __name__ == "__main__":
try: try:
signal_send(phone, message) signal_send(phone, message)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
for uid in uid_list:
errors.update({uid:str(e)})
print("Dispatch failed {}".format(e)) print("Dispatch failed {}".format(e))
continue continue
else: else:
@@ -94,7 +98,7 @@ if __name__ == "__main__":
if uid not in dispatch_confirmed: if uid not in dispatch_confirmed:
# confirm or report fail # # confirm or report fail #
if errors[uid]: if errors.get(uid):
report_dispatch_error(args.target, uid, errors[uid]) report_dispatch_error(args.target, uid, errors[uid])
else: else:
confirm_dispatch(args.target, uid) confirm_dispatch(args.target, uid)