-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User specific channel #186
Comments
Hi @Wineartist , if DEBUG:
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'simple'
},
},
'loggers': {
'tornado.general': {
'handlers': ['console'],
'level': 'ERROR',
'propagate': True,
}
}
} |
@Wineartist Do you have swampdragon auth installed and HttpDataConnection set? We also use user specific push notifications in our projects. Here is an example for a router that pushes generic notifications to users defined as targets in the proper model class GenericNotificationsRouter(ModelRouter):
valid_verbs = ['subscribe']
route_name = 'generic-notifications'
model = GenericNotification
serializer_class = GenericNotificationSDSerializer
@login_required
def subscribe(self, **kwargs):
super().subscribe(**kwargs)
def get_subscription_contexts(self, **kwargs):
return {'receivers__id__exact': self.connection.user.pk}
route_handler.register(GenericNotificationsRouter) Hope that helps you to understand the basic principle. |
I assume that your GenericNotification has a field called receivers, right? Does this field contain a list of users or solely one? I'm currently working on a private messaging app, trying to figure out how to restrict the broadcast of new messages to only the author/recepient. |
This field does contain a list of users. |
@ZuSe |
Hi, I'm woking on a project (runs on django 1.8 ) in which I require user specific push notification. I have successfully created a channel and broadcast data to all user using publish_data(). At present we have 10 million users. So I need to send a user specific push notification. I have used the following example to setup the swampdragon user specific notification:
https://github.com/CptLemming/swampdragon_notification_example
Using the above example I tried setting up swampdragon in my project. When I execute my project I'm not getting any notification or error regarding it.
My models.py:
My swampdragon_serializer.py (I'm using this file because models.py is already imported in the serializers.py so I won't be able to import serializers.py to my models.py for swamp dragon)
My router.py and notification.js looks the same as the example in the url mentioned above.
When I execute my project I'm not getting any notification or error.
I'm getting values from http://localhost:9999/data/info
My app is also not able to subscribe the channel. Since its not showing the console.log() (mentioned in the subscribe() ) in the browser console.
The text was updated successfully, but these errors were encountered: