|
|
@ -41,11 +41,20 @@ def send_messages():
|
|
|
|
# those messages will be picked up by the cron send later
|
|
|
|
# those messages will be picked up by the cron send later
|
|
|
|
# once we have decided to continue sending messages
|
|
|
|
# once we have decided to continue sending messages
|
|
|
|
@shared_task
|
|
|
|
@shared_task
|
|
|
|
def send_message(msgid):
|
|
|
|
def send_message(msgid, is_retry=False):
|
|
|
|
if not global_preferences["helper__send_sms"]:
|
|
|
|
if not global_preferences["helper__send_sms"]:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
with transaction.atomic():
|
|
|
|
with transaction.atomic():
|
|
|
|
msg = Message.objects.select_for_update().get(pk=msgid)
|
|
|
|
msgs = Message.objects.select_for_update().filter(pk=msgid)[:1]
|
|
|
|
|
|
|
|
if not msgs:
|
|
|
|
|
|
|
|
if not is_retry:
|
|
|
|
|
|
|
|
print("message not found, retrying")
|
|
|
|
|
|
|
|
send_message.apply_async((msgid, True), countdown=0.2)
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
|
|
|
print(f"message {msgid} not found in retry, giving up")
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
msg = msgs[0]
|
|
|
|
if msg.sent_at:
|
|
|
|
if msg.sent_at:
|
|
|
|
return
|
|
|
|
return
|
|
|
|
send(msg)
|
|
|
|
send(msg)
|
|
|
|