aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/TwitterManager.java2
-rw-r--r--src/main/java/com/juick/model/ExternalToken.java37
-rw-r--r--src/main/java/com/juick/www/api/Notifications.java24
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java2
4 files changed, 15 insertions, 50 deletions
diff --git a/src/main/java/com/juick/TwitterManager.java b/src/main/java/com/juick/TwitterManager.java
index a6a53e6c..f4cab89b 100644
--- a/src/main/java/com/juick/TwitterManager.java
+++ b/src/main/java/com/juick/TwitterManager.java
@@ -55,7 +55,7 @@ public class TwitterManager implements NotificationListener {
status += " http://juick.com/" + jmsg.getMid();
var twitter = Twitter.newBuilder()
.oAuthConsumer(twitter_consumer_key, twitter_consumer_secret)
- .oAuthAccessToken(t.getToken(), t.getSecret()).build();
+ .oAuthAccessToken(t.token(), t.secret()).build();
try {
twitter.v1().tweets().updateStatus(status);
} catch (Exception e) {
diff --git a/src/main/java/com/juick/model/ExternalToken.java b/src/main/java/com/juick/model/ExternalToken.java
index 65a07e55..12f5388c 100644
--- a/src/main/java/com/juick/model/ExternalToken.java
+++ b/src/main/java/com/juick/model/ExternalToken.java
@@ -17,48 +17,13 @@
package com.juick.model;
-import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Created by vitalyster on 22.11.2016.
*/
-public class ExternalToken {
- private final String name;
- private final String type;
- private final String token;
- private final String secret;
-
- @JsonCreator
- public ExternalToken(@JsonProperty("name") String name,
+public record ExternalToken(@JsonProperty("name") String name,
@JsonProperty("type") String type,
@JsonProperty("token") String token,
@JsonProperty("secret") String secret) {
- this.name = name;
- this.type = type;
- this.token = token;
- this.secret = secret;
- if (this.type == null) {
- throw new IllegalStateException("Token must have type");
- }
- if (this.token == null) {
- throw new IllegalStateException("Token must have value");
- }
- }
-
- public String getType() {
- return type;
- }
-
- public String getToken() {
- return token;
- }
-
- public String getName() {
- return name;
- }
-
- public String getSecret() {
- return secret;
- }
}
diff --git a/src/main/java/com/juick/www/api/Notifications.java b/src/main/java/com/juick/www/api/Notifications.java
index 43465c1a..5f941ba5 100644
--- a/src/main/java/com/juick/www/api/Notifications.java
+++ b/src/main/java/com/juick/www/api/Notifications.java
@@ -133,15 +133,15 @@ public class Notifications {
throw new HttpForbiddenException();
}
list.forEach(t -> {
- switch (t.getType()) {
+ switch (t.type()) {
case "gcm":
- pushQueriesService.deleteGCMToken(t.getToken());
+ pushQueriesService.deleteGCMToken(t.token());
break;
case "apns":
- pushQueriesService.deleteAPNSToken(t.getToken());
+ pushQueriesService.deleteAPNSToken(t.token());
break;
case "mpns":
- pushQueriesService.deleteMPNSToken(t.getToken());
+ pushQueriesService.deleteMPNSToken(t.token());
break;
default:
throw new HttpBadRequestException();
@@ -159,15 +159,15 @@ public class Notifications {
throw new HttpForbiddenException();
}
list.forEach(t -> {
- switch (t.getType()) {
+ switch (t.type()) {
case "gcm":
- pushQueriesService.deleteGCMToken(t.getToken());
+ pushQueriesService.deleteGCMToken(t.token());
break;
case "apns":
- pushQueriesService.deleteAPNSToken(t.getToken());
+ pushQueriesService.deleteAPNSToken(t.token());
break;
case "mpns":
- pushQueriesService.deleteMPNSToken(t.getToken());
+ pushQueriesService.deleteMPNSToken(t.token());
break;
default:
throw new HttpBadRequestException();
@@ -183,15 +183,15 @@ public class Notifications {
@Visitor User visitor,
@RequestBody List<ExternalToken> list) {
list.forEach(t -> {
- switch (t.getType()) {
+ switch (t.type()) {
case "gcm":
- pushQueriesService.addGCMToken(visitor.getUid(), t.getToken());
+ pushQueriesService.addGCMToken(visitor.getUid(), t.token());
break;
case "apns":
- pushQueriesService.addAPNSToken(visitor.getUid(), t.getToken());
+ pushQueriesService.addAPNSToken(visitor.getUid(), t.token());
break;
case "mpns":
- pushQueriesService.addMPNSToken(visitor.getUid(), t.getToken());
+ pushQueriesService.addMPNSToken(visitor.getUid(), t.token());
break;
default:
throw new HttpBadRequestException();
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 76146dd9..236c113b 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -781,7 +781,7 @@ public class ServerTests {
});
assertThat(users.size(), is(1));
assertThat(users.get(0).getTokens().size(), is(1));
- assertThat(users.get(0).getTokens().get(0).getToken(), equalTo(token));
+ assertThat(users.get(0).getTokens().get(0).token(), equalTo(token));
}
@Test