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
API to subscribe to push notification does not seem to delete previous subscription? #30103
Comments
I've realise today that if I were to call My guess is that:
Of course, typically no one would call the subscribe endpoint in the same way that I accidentally did, though I think this makes for a point that something somewhere is broken. Also, I did not test this against if I only call |
the line in the docs came from this:
and mastodon/app/controllers/api/v1/push/subscriptions_controller.rb Lines 40 to 42 in 924af40
and mastodon/app/controllers/api/v1/push/subscriptions_controller.rb Lines 13 to 14 in 924af40
so maybe it's not finding the old web push subscription based on the access token id? |
What's odd is if thats the case, the behaviour with DELETE shouldn't be observed at all |
As @trwnh pointed out, there should only be one push subscription per access token, and creating an access token should remove the previous one.
At this point, I don't have an explanation for what you're observing. Since you are using |
I guess I could have explained it better. I am not trying to say that GET isn't generating a subscription (I well understand its not suppose to and isn't doing so), rather the current behaviour seems to show DELETE works (for deletion of a random subscription), but there are indeed more than one subscriptions, evident by what I am seeing from the DELETE, GET and returned ids. My account is |
We're seeing a total of 74 push subscriptions with your account, with 65 of them associated to your application… and among those, only 3 different access tokens… so something is indeed up, with multiple subscriptions being created for the same token, though I don't understand how this is possible… we even have a test for this behavior |
Oh, I missed the fact that they all seem to have been created approximately at the same time. So we're having a race condition where multiple calls created the subscription at the same time! |
Yeah, that is very likely the case here. By the way, can you check if in the db if there's records on any access token having only like 2/3 push subscriptions, rather than the extreme large amount of 65? I recall a while back seeing duplicated notifications of a smaller scale (2/3 duplicates, rather than the large number), and check if it created at around the same time? I may have revoked the token though, so unsure if it's still there. |
There was just a token with 63 registrations afaik. We'll fix this, in the meantime you should be able to just call |
Alright thanks @ClearlyClaire! |
Steps to reproduce the problem
/api/v1/push/subscription
many times. (Not sure if many times in a short time matters though, just stating based on what I (accidentally) did)Expected behaviour
1 notification with correct contents.
Actual behaviour
hundreds? of notifications.
Detailed description
Now, I am not entirely sure if the fault is on my end, but I am somewhat confident that it is the API's fault. Please advise if I'm doing something terribly wrong without noticing 😅
I am referring to the POST
/api/v1/push/subscription
endpoint.So the story here is that, new (unreleased) app here, where a bug occurred, which resulted in an endless loop, causing the app to accidentally send out many requests.
I realised this probably after like 2 seconds, shut the app down, fixed the issue, and relaunched the app.
I sent a post out using another account, tagging my app's logged in account, the rest is explained in the steps to reproduce section.
The documentation for that, states:
In this case, it didn't seem to be true? Eventually, I also tried calling DELETE
/api/v1/push/subscription
, but symptoms remains.My setup is for a watchOS app. Notifications are relayed using metatext-apns, which by the looks of it is just a simple relay so that shouldn't be the cause, right?
I am very new to this Mastodon/Web Push notifications stuff, so please let me know if you believe it's an issue from my end. Thank you!
Mastodon instance
mastodon.social
Mastodon version
v4.3.0-nightly.2024-04-18
Technical details
The text was updated successfully, but these errors were encountered: