added optional user as name

This commit is contained in:
abutalib-kiwi
2023-08-24 13:33:34 +05:30
parent f541608656
commit cd3b385756
7 changed files with 51 additions and 19 deletions

View File

@ -9,6 +9,7 @@ from firebase_admin.messaging import Message, Notification as FirebaseNotificati
# django imports
from django.contrib.auth import get_user_model
# local imports
from account.models import UserNotification
from account.utils import get_user_full_name
from base.constants import GUARDIAN, JUNIOR
@ -17,8 +18,6 @@ from junior.models import Junior
from notifications.constants import NOTIFICATION_DICT
from notifications.models import Notification
# local imports
User = get_user_model()
@ -105,7 +104,7 @@ def send_notification(notification_type, from_user_id, from_user_type, to_user_i
notification_data.update({'badge': Notification.objects.filter(notification_to=to_user, is_read=False).count()})
Notification.objects.create(notification_type=notification_type, notification_from=from_user,
notification_to=to_user, data=notification_data)
if user_notification_type.push_notification:
if user_notification_type and user_notification_type.push_notification:
send_push(to_user, push_data)