-
Notifications
You must be signed in to change notification settings - Fork 109
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
Muliple subscriptions for same Device #135
Comments
@jeremyknoepfel Thanks. That is really interesting! I do not know how this happens, maybe chrome changed something? Can you check on Firefox as well? |
@safwanrahman Unfortunately i didn't have time to test it on Firefox. The problem still occurs with Chrome. Isn't it possible to make the combination of auth and browser unique to each user? |
Isn't there a mechanism to check whether the current browser is subscribed to push events, preventing this situation altogether? |
@safwanrahman from django.db.models import Count, Min
from webpush.models import SubscriptionInfo
# Step 1: Annotate each WebpushSubscriptionInfo with the minimum id for each group of auth and p256dh.
duplicates = (
SubscriptionInfo.objects
.values('auth', 'p256dh')
.annotate(min_id=Min('id'), count_id=Count('id'))
.filter(count_id__gt=1)
)
# Step 2: Collect the IDs of the entries with the lowest id in each group.
min_ids_to_delete = [entry['min_id'] for entry in duplicates]
# Step 3: Delete these entries.
SubscriptionInfo.objects.filter(id__in=min_ids_to_delete).delete() A long term solution for the django-webpush package would be to set the auth&p256dh as unique und update the existing entry instead of creating a new one when the client browser updates. |
hi @safwanrahman thank you for this contribution, Are there any plans to introduce a fix to the issue soon? |
When a user has subscribed for push it creates an entry in the subscription info. However if his browser gets updated to a newer version a new entry gets added.
This now has the effect, that the following user gets the same push message sent 5 times to his device when using the send_notification_to_user method.
The text was updated successfully, but these errors were encountered: