Push service release version 4
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -17,7 +17,7 @@
|
||||
|
||||
<groupId>de.77zzcx7.push-service</groupId>
|
||||
<artifactId>push-service-parent</artifactId>
|
||||
<version>4-SNAPSHOT</version>
|
||||
<version>4</version>
|
||||
<packaging>pom</packaging>
|
||||
<description>A micro service to send push notifications</description>
|
||||
<name>push-service-parent</name>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<artifactId>push-service-parent</artifactId>
|
||||
<groupId>de.77zzcx7.push-service</groupId>
|
||||
<version>4-SNAPSHOT</version>
|
||||
<version>4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>push-service-client-lib</artifactId>
|
||||
@@ -42,11 +42,7 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<!--
|
||||
Setting the classifier of the spring-boot uber JAR to exec will keep the verbatim JAR file
|
||||
as actual distributed artifact required for users to include the beans
|
||||
-->
|
||||
<classifier>exec</classifier>
|
||||
<skip>true</skip>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package de.pushservice.client;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
|
||||
|
||||
/**
|
||||
* Not used but required by the spring boot maven plugin during repackage
|
||||
*/
|
||||
@SpringBootApplication
|
||||
public class PushServiceClientApplication extends SpringBootServletInitializer {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(PushServiceClientApplication.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
|
||||
return application.sources(PushServiceClientApplication.class);
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class PayloadDto {
|
||||
private String icon;
|
||||
private int[] vibration;
|
||||
private long timestamp;
|
||||
private String tag;
|
||||
|
||||
public PayloadDto(String title) {
|
||||
this.title = title;
|
||||
@@ -67,4 +68,12 @@ public class PayloadDto {
|
||||
public String toString() {
|
||||
return ReflectionToStringBuilder.toString(this);
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public void setTag(String tag) {
|
||||
this.tag = tag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,27 @@ self.addEventListener('push', function(event) {
|
||||
icon: payload.icon,
|
||||
vibrate: payload.vibration,
|
||||
timestamp: payload.timestamp,
|
||||
tag: payload.tag
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
self.addEventListener('notificationclick', function(event) {
|
||||
event.notification.close();
|
||||
|
||||
event.waitUntil(clients.matchAll({
|
||||
type: "window"
|
||||
}).then(function(clientList) {
|
||||
for (var i = 0; i < clientList.length; i++) {
|
||||
var client = clientList[i];
|
||||
|
||||
if (client.url.includes(new URL(self.registration.scope).pathname) && 'focus' in client) {
|
||||
return client.focus();
|
||||
}
|
||||
}
|
||||
|
||||
if (clients.openWindow) {
|
||||
return clients.openWindow(new URL(self.registration.scope).pathname);
|
||||
}
|
||||
}));
|
||||
});
|
||||
@@ -7,7 +7,7 @@
|
||||
<parent>
|
||||
<artifactId>push-service-parent</artifactId>
|
||||
<groupId>de.77zzcx7.push-service</groupId>
|
||||
<version>4-SNAPSHOT</version>
|
||||
<version>4</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>push-service-server</artifactId>
|
||||
|
||||
@@ -59,6 +59,13 @@ public class ExternalPushServiceResponseHandler {
|
||||
|
||||
updateSubscription(subscription);
|
||||
break;
|
||||
case 403: // Forbidden
|
||||
// also "SENDER_ID_MISMATCH" - may happen if the VAPID keys were changed -> subscription needs to be removed
|
||||
// AND CLIENT NEEDS TO RE-SUBSCRIBE (not sure how to control that from here, though)
|
||||
LOGGER.error(String.format("Received 403 for endpoint %s", subscription.getEndpoint()));
|
||||
|
||||
deleteSubscription(subscription);
|
||||
break;
|
||||
case 404: // Not found
|
||||
// Subscription expired or endpoint is wrong -> subscription needs to be removed
|
||||
LOGGER.info(String.format("Received 404 for endpoint %s", subscription.getEndpoint()));
|
||||
@@ -80,6 +87,8 @@ public class ExternalPushServiceResponseHandler {
|
||||
updateSubscription(subscription);
|
||||
break;
|
||||
default:
|
||||
LOGGER.error(String.format("Unhandled HTTP response code: %s for endpoint %s",
|
||||
response.getStatusLine().getStatusCode(), subscription.getEndpoint()));
|
||||
}
|
||||
} catch (InterruptedException ire) {
|
||||
LOGGER.error(String.format("Thread interrupted for endpoint %s", subscription.getEndpoint()));
|
||||
|
||||
Reference in New Issue
Block a user