Skip to content
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

Mass removal of tokens in Meteor 1.7 #342

Open
artpolikarpov opened this issue Jul 20, 2018 · 6 comments
Open

Mass removal of tokens in Meteor 1.7 #342

artpolikarpov opened this issue Jul 20, 2018 · 6 comments
Projects

Comments

@artpolikarpov
Copy link

artpolikarpov commented Jul 20, 2018

This is urgent. Just found that this piece of raix:push-update method:

      // xxx: Hack
      // Clean up mech making sure tokens are uniq - android sometimes generate
      // new tokens resulting in duplicates
      var removed = Push.appCollection.remove({
        $and: [
          { _id: { $ne: doc._id } },
          { token: doc.token },     // Match token
          { appName: doc.appName }, // Match appName
          { token: { $exists: true } }  // Make sure token exists
        ]
      });

...is deleting all tokens from _raix_push_app_tokens collection some times!

@artpolikarpov
Copy link
Author

It happens when doc.token is undefined for some reason. I think we should change it to options.token.

@da314pc
Copy link
Collaborator

da314pc commented Aug 14, 2018

@artpolikarpov
I think this method may be correct. When the message was sent were all the apps installed?
If the app is not installed, I think the token is automatically removed on failed delivery, until the user opens the app and registers a new token.

@artpolikarpov
Copy link
Author

@da314pc If you carefully read the source, then you see that on failed delivery, tokens are nulled, not removed.

@da314pc
Copy link
Collaborator

da314pc commented Aug 14, 2018

I'll do some digging. were all your tokens removed?

@artpolikarpov
Copy link
Author

Not all but many. Thanks goodness I had a duplicate collection for them. In general, I warned.

@CyberCyclone
Copy link

CyberCyclone commented Sep 3, 2018

I can confirm that this is an issue. As @artpolikarpov stated, the tokens are being being cleared. When this function comes around, null isn't considered in the $and statement and therefore is considered the same as:
var removed = Push.appCollection.remove({ $and: [ { _id: { $ne: doc._id } }, { appName: doc.appName }, // Match appName { token: { $exists: true } } // Make sure token exists ] });

This therefore removes ALL tokens that are valid.

The workaround we have is:

if(doc.token){ var removed = Push.appCollection.remove({ $and: [ { _id: { $ne: doc._id } }, { token: doc.token }, // Match token { appName: doc.appName }, // Match appName { token: { $exists: true } } // Make sure token exists ] }); }

@da314pc da314pc added this to Needs triage in 3.0.2 Jan 9, 2019
@da314pc da314pc moved this from Needs triage to Low priority in 3.0.2 Jan 9, 2019
@da314pc da314pc moved this from Low priority to High priority in 3.0.2 Jan 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
3.0.2
  
High priority
Development

No branches or pull requests

3 participants