mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 18:07:02 +00:00
28 lines
904 B
Python
28 lines
904 B
Python
"""
|
|
notifications utils file
|
|
"""
|
|
# third party imports
|
|
from fcm_django.models import FCMDevice
|
|
|
|
# local imports
|
|
|
|
|
|
def register_fcm_token(user_id, registration_id, device_id, device_type):
|
|
""" used to register the fcm device token"""
|
|
device, _ = FCMDevice.objects.update_or_create(device_id=device_id,
|
|
defaults={'user_id': user_id, 'type': device_type,
|
|
'active': True,
|
|
'registration_id': registration_id})
|
|
return device
|
|
|
|
|
|
def remove_fcm_token(user_id: int, access_token: str, registration_id) -> None:
|
|
"""
|
|
remove access_token and registration_token
|
|
"""
|
|
try:
|
|
# remove fcm token for this device
|
|
FCMDevice.objects.filter(user_id=user_id).delete()
|
|
except Exception as e:
|
|
print(e)
|