mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-07-07 12:16:30 +00:00
fix(tasks): include creation time in SMS notification for expired topups 🐛
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m21s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 4m21s
This commit is contained in:
@ -5,6 +5,7 @@ from django.utils import timezone
|
|||||||
from procrastinate.contrib.django import app
|
from procrastinate.contrib.django import app
|
||||||
from api.notifications import send_sms
|
from api.notifications import send_sms
|
||||||
from billing.models import Topup
|
from billing.models import Topup
|
||||||
|
from django.utils.timezone import localtime
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -28,6 +29,7 @@ def update_expired_topups(timestamp: int):
|
|||||||
mobile=topup.user.mobile,
|
mobile=topup.user.mobile,
|
||||||
amount=topup.amount,
|
amount=topup.amount,
|
||||||
topup_id=str(topup.id),
|
topup_id=str(topup.id),
|
||||||
|
created_at=localtime(topup.created_at).isoformat(),
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
# Mark as notified even if we can't send SMS (no mobile number)
|
# Mark as notified even if we can't send SMS (no mobile number)
|
||||||
@ -41,9 +43,9 @@ def update_expired_topups(timestamp: int):
|
|||||||
|
|
||||||
# Assuming you have a separate task for sending SMS if you go that route
|
# Assuming you have a separate task for sending SMS if you go that route
|
||||||
@app.task
|
@app.task
|
||||||
def send_sms_task(mobile: str, amount: float, topup_id: str):
|
def send_sms_task(mobile: str, amount: float, topup_id: str, created_at: str):
|
||||||
message = (
|
message = (
|
||||||
f"Dear {mobile}, \n\nYour topup of {amount} MVR has expired. "
|
f"Dear {mobile}, \n\nYour topup of {amount} MVR [created at {created_at}] has expired. "
|
||||||
"Please make a new topup to update your wallet. \n\n- SAR Link"
|
"Please make a new topup to update your wallet. \n\n- SAR Link"
|
||||||
)
|
)
|
||||||
send_sms(mobile, message)
|
send_sms(mobile, message)
|
||||||
|
Reference in New Issue
Block a user