mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-07-15 10:05:21 +00:00
notification app, api for device registration and fcm token
This commit is contained in:
30
notifications/views.py
Normal file
30
notifications/views.py
Normal 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"])
|
Reference in New Issue
Block a user