notification set up and celery configuration

This commit is contained in:
abutalib-kiwi
2023-07-19 16:24:53 +05:30
parent 2e7d36485c
commit 3223a2b050
10 changed files with 200 additions and 5 deletions

View File

@ -8,9 +8,12 @@ from rest_framework.decorators import action
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
# local imports
from account.utils import custom_response
from base.messages import SUCCESS_CODE
from notifications.constants import TEST_NOTIFICATION
from notifications.serializers import RegisterDevice
from notifications.utils import send_notification
class NotificationViewSet(viewsets.GenericViewSet):
@ -28,3 +31,12 @@ class NotificationViewSet(viewsets.GenericViewSet):
serializer.is_valid(raise_exception=True)
serializer.save()
return custom_response(SUCCESS_CODE["3000"])
@action(methods=['get'], detail=False, url_path='test', url_name='test', serializer_class=None)
def send_test_notification(self, request):
"""
to send test notification
:return:
"""
send_notification.delay(TEST_NOTIFICATION, None, request.auth.payload['user_id'], {})
return custom_response(SUCCESS_CODE["3000"])