added notification type in push data

This commit is contained in:
abutalib-kiwi
2023-09-26 17:24:40 +05:30
parent ea02d7f5bb
commit 32c35f8649
2 changed files with 21 additions and 1 deletions

View File

@ -22,79 +22,93 @@ ARTICLE_REWARD_POINTS = 17
REMOVE_JUNIOR = 18 REMOVE_JUNIOR = 18
TEST_NOTIFICATION = 99 TEST_NOTIFICATION = 99
# notification dictionary # notification dictionary
NOTIFICATION_DICT = { NOTIFICATION_DICT = {
REGISTRATION: { REGISTRATION: {
"notification_type": REGISTRATION,
"title": "Successfully registered!", "title": "Successfully registered!",
"body": "You have registered successfully. Now login and complete your profile." "body": "You have registered successfully. Now login and complete your profile."
}, },
# user will receive notification as soon junior # user will receive notification as soon junior
# sign up application using their guardian code for association # sign up application using their guardian code for association
ASSOCIATE_REQUEST: { ASSOCIATE_REQUEST: {
"notification_type": ASSOCIATE_REQUEST,
"title": "Associate request!", "title": "Associate request!",
"body": "You have request from {from_user} to associate with you." "body": "You have request from {from_user} to associate with you."
}, },
# Juniors will receive notification when # Juniors will receive notification when
# custodians reject their request for associate # custodians reject their request for associate
ASSOCIATE_REJECTED: { ASSOCIATE_REJECTED: {
"notification_type": ASSOCIATE_REJECTED,
"title": "Associate request rejected!", "title": "Associate request rejected!",
"body": "Your request to associate has been rejected by {from_user}." "body": "Your request to associate has been rejected by {from_user}."
}, },
# Juniors will receive notification when # Juniors will receive notification when
# custodians approve their request for associate # custodians approve their request for associate
ASSOCIATE_APPROVED: { ASSOCIATE_APPROVED: {
"notification_type": ASSOCIATE_APPROVED,
"title": "Associate request approved!", "title": "Associate request approved!",
"body": "Your request to associate has been approved by {from_user}." "body": "Your request to associate has been approved by {from_user}."
}, },
# Juniors will receive Notifications # Juniors will receive Notifications
# for every Points earned by referrals # for every Points earned by referrals
REFERRAL_POINTS: { REFERRAL_POINTS: {
"notification_type": REFERRAL_POINTS,
"title": "Earn Referral points!", "title": "Earn Referral points!",
"body": "You earn 5 points for referral." "body": "You earn 5 points for referral."
}, },
# Juniors will receive notification # Juniors will receive notification
# once any custodians add them in their account # once any custodians add them in their account
ASSOCIATE_JUNIOR: { ASSOCIATE_JUNIOR: {
"notification_type": ASSOCIATE_JUNIOR,
"title": "Profile already setup!", "title": "Profile already setup!",
"body": "Your guardian has already setup your profile." "body": "Your guardian has already setup your profile."
}, },
ASSOCIATE_EXISTING_JUNIOR: { ASSOCIATE_EXISTING_JUNIOR: {
"notification_type": ASSOCIATE_EXISTING_JUNIOR,
"title": "Associated to guardian", "title": "Associated to guardian",
"body": "Your are associated to your guardian {from_user}." "body": "Your are associated to your guardian {from_user}."
}, },
# Juniors will receive Notification # Juniors will receive Notification
# for every Task Assign by Custodians # for every Task Assign by Custodians
TASK_ASSIGNED: { TASK_ASSIGNED: {
"notification_type": TASK_ASSIGNED,
"title": "New task assigned!", "title": "New task assigned!",
"body": "{from_user} has assigned you a new task." "body": "{from_user} has assigned you a new task."
}, },
# Guardian will receive notification as soon # Guardian will receive notification as soon
# as junior send task for approval # as junior send task for approval
TASK_ACTION: { TASK_ACTION: {
"notification_type": TASK_ACTION,
"title": "Task completion approval!", "title": "Task completion approval!",
"body": "{from_user} completed their task {task_name}." "body": "{from_user} completed their task {task_name}."
}, },
# Juniors will receive notification as soon # Juniors will receive notification as soon
# as their task is rejected by custodians # as their task is rejected by custodians
TASK_REJECTED: { TASK_REJECTED: {
"notification_type": TASK_REJECTED,
"title": "Task completion rejected!", "title": "Task completion rejected!",
"body": "Your task completion request has been rejected by {from_user}." "body": "Your task completion request has been rejected by {from_user}."
}, },
# Juniors will receive notification as soon as their task is approved by custodians # Juniors will receive notification as soon as their task is approved by custodians
# and for every Points earned by Task completion # and for every Points earned by Task completion
TASK_APPROVED: { TASK_APPROVED: {
"notification_type": TASK_APPROVED,
"title": "Task completion approved!", "title": "Task completion approved!",
"body": "Your task completion request has been approved by {from_user}. " "body": "Your task completion request has been approved by {from_user}. "
"Also you earned 5 points for successful completion." "Also you earned 5 points for successful completion."
}, },
# Juniors will receive notification when their task end date about to end # Juniors will receive notification when their task end date about to end
PENDING_TASK_EXPIRING: { PENDING_TASK_EXPIRING: {
"notification_type": PENDING_TASK_EXPIRING,
"title": "Task expiring soon!", "title": "Task expiring soon!",
"body": "Your task {task_name} is expiring soon. Please complete it." "body": "Your task {task_name} is expiring soon. Please complete it."
}, },
# User will receive notification when their assigned task is about to end # User will receive notification when their assigned task is about to end
# and juniors have not performed any action # and juniors have not performed any action
IN_PROGRESS_TASK_EXPIRING: { IN_PROGRESS_TASK_EXPIRING: {
"notification_type": IN_PROGRESS_TASK_EXPIRING,
"title": "Task expiring soon!", "title": "Task expiring soon!",
"body": "{from_user} didn't take any action on assigned task {task_name} and it's expiring soon. " "body": "{from_user} didn't take any action on assigned task {task_name} and it's expiring soon. "
"Please assist to complete it." "Please assist to complete it."
@ -102,27 +116,32 @@ NOTIFICATION_DICT = {
# Juniors will receive Notification # Juniors will receive Notification
# related to Leaderboard progress # related to Leaderboard progress
TOP_JUNIOR: { TOP_JUNIOR: {
"notification_type": TOP_JUNIOR,
"title": "Leaderboard topper!", "title": "Leaderboard topper!",
"body": "{from_user} is on top in leaderboard with {points} points." "body": "{from_user} is on top in leaderboard with {points} points."
}, },
# Juniors will receive notification # Juniors will receive notification
# when admin add any new financial learnings # when admin add any new financial learnings
NEW_ARTICLE_PUBLISHED: { NEW_ARTICLE_PUBLISHED: {
"notification_type": NEW_ARTICLE_PUBLISHED,
"title": "Time to read!", "title": "Time to read!",
"body": "A new article has been published." "body": "A new article has been published."
}, },
# Juniors will receive notification when they earn points by reading financial Learning # Juniors will receive notification when they earn points by reading financial Learning
ARTICLE_REWARD_POINTS: { ARTICLE_REWARD_POINTS: {
"notification_type": ARTICLE_REWARD_POINTS,
"title": "Article reward points!", "title": "Article reward points!",
"body": "You are rewarded with {points} points for reading article and answering questions. " "body": "You are rewarded with {points} points for reading article and answering questions. "
}, },
# Juniors will receive notification as soon as their custodians remove them from account # Juniors will receive notification as soon as their custodians remove them from account
REMOVE_JUNIOR: { REMOVE_JUNIOR: {
"notification_type": REMOVE_JUNIOR,
"title": "Disassociate by guardian!", "title": "Disassociate by guardian!",
"body": "Your guardian has disassociated you." "body": "Your guardian has disassociated you."
}, },
# Test notification # Test notification
TEST_NOTIFICATION: { TEST_NOTIFICATION: {
"notification_type": TEST_NOTIFICATION,
"title": "Test Notification", "title": "Test Notification",
"body": "This notification is for testing purpose from {from_user}." "body": "This notification is for testing purpose from {from_user}."
} }

View File

@ -58,7 +58,8 @@ class NotificationViewSet(viewsets.GenericViewSet):
""" """
notify_task_expiry() notify_task_expiry()
notify_top_junior() notify_top_junior()
send_notification(TEST_NOTIFICATION, None, None, request.auth.payload['user_id'], notification_type = request.query_params.get('type', TEST_NOTIFICATION)
send_notification(int(notification_type), None, None, request.auth.payload['user_id'],
{}) {})
return custom_response(SUCCESS_CODE["3000"]) return custom_response(SUCCESS_CODE["3000"])