Skip to content

Commit

Permalink
Updated chatire to conform to the new api of django-notifs
Browse files Browse the repository at this point in the history
  • Loading branch information
danidee10 committed Feb 7, 2018
1 parent 342e103 commit 741c02f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 4 deletions.
4 changes: 3 additions & 1 deletion chat/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ def post(self, request, *args, **kwargs):
'message': chat_session_message.to_json()
}
}
notify.send(sender=self.__class__, **notif_args)
notify.send(
sender=self.__class__,**notif_args, channels=['websocket']
)

return Response ({
'status': 'SUCCESS', 'uri': chat_session.uri, 'message': message,
Expand Down
7 changes: 7 additions & 0 deletions chatire/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""Initialize celery."""

from __future__ import absolute_import, unicode_literals

from .celery import app as celery_app

__all__ = ['celery_app']
15 changes: 15 additions & 0 deletions chatire/celery.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""Celery init."""

from __future__ import absolute_import, unicode_literals
import os

from celery import Celery


# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'chatire.settings')

app = Celery('chatire')
app.config_from_object('django.conf:settings', namespace='CELERY')

app.autodiscover_tasks()
6 changes: 5 additions & 1 deletion chatire/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,10 @@

CORS_ORIGIN_ALLOW_ALL = True

# Celery settings
CELERY_TASK_ALWAYS_EAGER = True

# notifications settings
NOTIFICATIONS_CHANNELS = ['chat.channels.BroadCastWebSocketChannel']
NOTIFICATIONS_CHANNELS = {
'websocket': 'chat.channels.BroadCastWebSocketChannel'
}
9 changes: 7 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
amqp==2.2.2
billiard==3.5.0.3
celery==4.1.0
Django==2.0.1
django-cors-headers==2.1.0
django-notifs==2.5.5
django-notifs==2.6.0
django-templated-mail==1.0.0
djangorestframework==3.7.7
djoser==1.1.5
gevent==1.2.2
greenlet==0.4.12
kombu==4.1.0
pika==0.11.2
pytz==2017.3
simplejson==3.13.2
six==1.11.0
uWSGI==2.0.15
uwsgitop==0.10
vine==1.1.4

0 comments on commit 741c02f

Please sign in to comment.