notification app, api for device registration and fcm token

This commit is contained in:
abutalib-kiwi
2023-07-18 14:06:04 +05:30
parent 04342133ef
commit ba4d5933de
15 changed files with 142 additions and 1 deletions

30
notifications/views.py Normal file
View File

@ -0,0 +1,30 @@
"""
notifications views file
"""
# django imports
from django.db.models import Q
from rest_framework import viewsets
from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from account.utils import custom_response
from base.messages import SUCCESS_CODE
from notifications.serializers import RegisterDevice
class NotificationViewSet(viewsets.GenericViewSet):
""" used to do the notification actions """
serializer_class = None
permission_classes = [IsAuthenticated, ]
@action(methods=['post'], detail=False, url_path='device', url_name='device', serializer_class=RegisterDevice)
def fcm_registration(self, request):
"""
used to save the fcm token
"""
serializer = self.get_serializer_class()(data=request.data,
context={'user_id': request.auth.payload['user_id']})
serializer.is_valid(raise_exception=True)
serializer.save()
return custom_response(SUCCESS_CODE["3000"])