danidee10/django-notifs

View on GitHub
notifications/channels/django_channels.py

Summary

Maintainability
A
0 mins
Test Coverage
B
87%
"""Notification channels for django-notifs."""

import json

from notifications import default_settings as settings
from notifications.channels import BaseNotificationChannel


class DjangoWebSocketChannel(BaseNotificationChannel):
    """django-channels websocket channel"""

    name = 'websocket'
    providers = ['django_channels']

    def build_payload(self, provider):
        return {
            'type': settings.NOTIFICATIONS_WEBSOCKET_EVENT_NAME,
            'message': json.dumps(self.context['message']),
        }