referral notifications correction
This commit is contained in:
@@ -5,7 +5,11 @@ from datetime import timedelta
|
||||
from django.utils import timezone
|
||||
from onesignal_sdk.client import Client as OneSignalClient
|
||||
from accounts.models import IAmPrincipal, IAmPrincipalOtp, IAmPrincipalType
|
||||
from manage_notifications.models import IAmPrincipalNotificationSettings, InAppNotification, NotificationCategoryChoices
|
||||
from manage_notifications.models import (
|
||||
IAmPrincipalNotificationSettings,
|
||||
InAppNotification,
|
||||
NotificationCategoryChoices,
|
||||
)
|
||||
from manage_referrals.models import (
|
||||
GoodTimeCoins,
|
||||
ReferralRecord,
|
||||
@@ -60,24 +64,30 @@ class NotificationService:
|
||||
end_date = principal_subscription.end_date
|
||||
message = f"Your payment for {subscription} of ${amount} was successfully processed. Your subscription is valid till {end_date}"
|
||||
self.send_notification(title, message, principal.player_id)
|
||||
self.save_notification(principal, title, message, NotificationCategoryChoices.TRANSACTION)
|
||||
self.save_notification(
|
||||
principal, title, message, NotificationCategoryChoices.TRANSACTION
|
||||
)
|
||||
|
||||
def referral_received_notification(self, principal, amount, email):
|
||||
print("referral_received_notification: ", principal.player_id)
|
||||
title = "Congratulations! You got a referral G-Token."
|
||||
message = f"Your referral {email} has subscribed to GoodTimesApp. You have received {amount} (£)"
|
||||
self.save_notification(
|
||||
principal, title, message, NotificationCategoryChoices.REFERRAL
|
||||
)
|
||||
if not self.should_send_referral_notification(principal):
|
||||
print("Referral notifications are disabled for this user")
|
||||
return
|
||||
title = "Congratulations! You got a referral G-Token."
|
||||
message = f"Your referral {email} has subscribed to GoodTimesApp. You have received {amount} (£)"
|
||||
self.send_notification(title, message, principal.player_id)
|
||||
self.save_notification(principal, title, message, NotificationCategoryChoices.REFERRAL)
|
||||
|
||||
def payment_failed_notification(self, principal, subscription, amount):
|
||||
print("payment_failed_notification: ", principal.player_id)
|
||||
title = "Payment Failed!"
|
||||
message = f"Your payment for {subscription} of ${amount} was failed."
|
||||
self.send_notification(title, message, principal.player_id)
|
||||
self.save_notification(principal, title, message, NotificationCategoryChoices.TRANSACTION)
|
||||
self.save_notification(
|
||||
principal, title, message, NotificationCategoryChoices.TRANSACTION
|
||||
)
|
||||
|
||||
def should_send_referral_notification(self, principal):
|
||||
notification_settings = get_object_or_404(
|
||||
|
||||
Reference in New Issue
Block a user