Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Adding support for removing old tokens #755

Merged

Conversation

secondsun
Copy link
Contributor

@matzew @danielpassos 馃憮 ?

@corinnekrych or someone else, can you confirm this doesn't cause any regressions with iOS?

@@ -137,6 +139,9 @@ public Response crossOriginForInstallations(@Context HttpHeaders headers) {
* @param entity {@link Installation} for Device registration
* @return registered {@link Installation}
*
* @requestheader x-ag-old-token the old push service dependant token (ie InstanceID in FCM).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunaltey, we also need a JavaDoc @param here, since the build is failing :/(

@@ -171,6 +177,11 @@ public Response registerInstallation(
// otherwise we register a new installation:
logger.trace("Mobile Application on device was launched");

//The token has changed, remove the old one
if (!oldToken.isEmpty() && !oldToken.equals(entity.getDeviceToken())) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why would a device send its current token as the old one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the device isn't making a similar check on its end.

@@ -171,6 +177,11 @@ public Response registerInstallation(
// otherwise we register a new installation:
logger.trace("Mobile Application on device was launched");

//The token has changed, remove the old one
if (!oldToken.isEmpty() && !oldToken.equals(entity.getDeviceToken())) {
clientInstallationService.removeInstallationForVariantByDeviceToken(variant.getVariantID(), oldToken);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's add a log here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Log!
Like this?

@matzew
Copy link
Contributor

matzew commented Sep 15, 2016

@secondsun you can easily test if it breaks, using CURL:

curl -u "variantID:secret" -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"deviceToken" : "iOS_token_copied_from_junit_tests_in_InstallationDAOTest"}' http://localhost:8080/ag-push/rest/registry/device

馃榿

@matzew matzew merged commit 0961fe1 into aerogear:master Sep 15, 2016
@matzew
Copy link
Contributor

matzew commented Sep 15, 2016

btw. tested with

curl -u "4af3513f-2346-4d3e-832c-5273f4f7e3fd:9a4d33e7-5549-45da-9a13-33eb2643ebaf" -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"deviceToken" : "1ce51dad49a77ca7b45924074bcc4f19aea20378f5feda202fbba3beed7073d7"}' http://localhost:8080/ag-push/rest/registry/device

@secondsun @corinnekrych workz!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants