aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-21 02:17:29 +0300
committerGravatar Vitaly Takmazov2022-12-21 02:23:16 +0300
commit55293b4ac33e0f4fd2bfce3a0f5783b42812a65c (patch)
treecf5996d6036554dbc78aeb1eb19d2fe09fc998b0 /src/main/java/com/juick
parente588a7ded6fae3b033e1a59a4c24d1e1a6799747 (diff)
webfinger, app-site-associations: adopt records
Diffstat (limited to 'src/main/java/com/juick')
-rw-r--r--src/main/java/com/juick/SignatureManager.java6
-rw-r--r--src/main/java/com/juick/www/api/apple/AppSiteAssociation.java33
-rw-r--r--src/main/java/com/juick/www/api/webfinger/Resource.java14
-rw-r--r--src/main/java/com/juick/www/api/webfinger/model/Account.java22
-rw-r--r--src/main/java/com/juick/www/api/webfinger/model/Link.java31
5 files changed, 16 insertions, 90 deletions
diff --git a/src/main/java/com/juick/SignatureManager.java b/src/main/java/com/juick/SignatureManager.java
index 49c8c7dd..fad4e0da 100644
--- a/src/main/java/com/juick/SignatureManager.java
+++ b/src/main/java/com/juick/SignatureManager.java
@@ -187,9 +187,9 @@ public class SignatureManager {
if (response.getStatusCode().is2xxSuccessful()) {
Account acctData = response.getBody();
if (acctData != null) {
- for (Link l : acctData.getLinks()) {
- if (l.getRel().equals("self") && l.getType().equals(ACTIVITY_MEDIA_TYPE)) {
- return getContext(URI.create(l.getHref()));
+ for (Link l : acctData.links()) {
+ if (l.rel().equals("self") && l.type().equals(ACTIVITY_MEDIA_TYPE)) {
+ return getContext(URI.create(l.href()));
}
}
}
diff --git a/src/main/java/com/juick/www/api/apple/AppSiteAssociation.java b/src/main/java/com/juick/www/api/apple/AppSiteAssociation.java
index c0827003..19839254 100644
--- a/src/main/java/com/juick/www/api/apple/AppSiteAssociation.java
+++ b/src/main/java/com/juick/www/api/apple/AppSiteAssociation.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2020, Juick
+ * Copyright (C) 2008-2022, Juick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -35,36 +35,13 @@ public class AppSiteAssociation {
@GetMapping("/.well-known/apple-app-site-association")
@ResponseBody
public SiteAssociations appSiteAssociations() {
- WebCredentials webCredentials = new WebCredentials();
- webCredentials.setApps(Collections.singletonList(appId));
- SiteAssociations siteAssociations = new SiteAssociations();
- siteAssociations.setWebcredentials(webCredentials);
- return siteAssociations;
+ WebCredentials webCredentials = new WebCredentials(Collections.singletonList(appId));
+ return new SiteAssociations(webCredentials);
}
- private class SiteAssociations {
- private WebCredentials webcredentials;
-
- @JsonProperty
- public WebCredentials getWebcredentials() {
- return webcredentials;
- }
-
- public void setWebcredentials(WebCredentials webcredentials) {
- this.webcredentials = webcredentials;
- }
+ private record SiteAssociations(WebCredentials webcredentials) {
}
- private class WebCredentials {
- private List<String> apps;
-
- @JsonProperty
- public List<String> getApps() {
- return apps;
- }
-
- public void setApps(List<String> apps) {
- this.apps = apps;
- }
+ private record WebCredentials(List<String> apps) {
}
}
diff --git a/src/main/java/com/juick/www/api/webfinger/Resource.java b/src/main/java/com/juick/www/api/webfinger/Resource.java
index d3980511..570ceed3 100644
--- a/src/main/java/com/juick/www/api/webfinger/Resource.java
+++ b/src/main/java/com/juick/www/api/webfinger/Resource.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2020, Juick
+ * Copyright (C) 2008-2022, Juick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -30,7 +30,7 @@ import org.springframework.web.util.UriComponentsBuilder;
import rocks.xmpp.addr.Jid;
import javax.inject.Inject;
-import java.util.Collections;
+import java.util.List;
import static com.juick.www.api.activity.model.Context.ACTIVITY_MEDIA_TYPE;
@@ -52,14 +52,8 @@ public class Resource {
if (!user.isAnonymous()) {
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(baseUri);
builder.path(String.format("/u/%s", user.getName()));
- Link blog = new Link();
- blog.setRel("self");
- blog.setType(ACTIVITY_MEDIA_TYPE);
- blog.setHref(builder.toUriString());
- Account result = new Account();
- result.setSubject(resource);
- result.setLinks(Collections.singletonList(blog));
- return result;
+ Link blog = new Link("self", ACTIVITY_MEDIA_TYPE, builder.toUriString());
+ return new Account(resource, List.of(blog));
}
}
}
diff --git a/src/main/java/com/juick/www/api/webfinger/model/Account.java b/src/main/java/com/juick/www/api/webfinger/model/Account.java
index e0ca5fe9..6dafa7a4 100644
--- a/src/main/java/com/juick/www/api/webfinger/model/Account.java
+++ b/src/main/java/com/juick/www/api/webfinger/model/Account.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2020, Juick
+ * Copyright (C) 2008-2022, Juick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -19,23 +19,5 @@ package com.juick.www.api.webfinger.model;
import java.util.List;
-public class Account {
- private String subject;
- private List<Link> links;
-
- public String getSubject() {
- return subject;
- }
-
- public void setSubject(String subject) {
- this.subject = subject;
- }
-
- public List<Link> getLinks() {
- return links;
- }
-
- public void setLinks(List<Link> links) {
- this.links = links;
- }
+public record Account (String subject, List<Link> links) {
}
diff --git a/src/main/java/com/juick/www/api/webfinger/model/Link.java b/src/main/java/com/juick/www/api/webfinger/model/Link.java
index 1036d43c..696ccd6d 100644
--- a/src/main/java/com/juick/www/api/webfinger/model/Link.java
+++ b/src/main/java/com/juick/www/api/webfinger/model/Link.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2008-2020, Juick
+ * Copyright (C) 2008-2022, Juick
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
@@ -17,32 +17,5 @@
package com.juick.www.api.webfinger.model;
-public class Link {
- private String rel;
- private String type;
- private String href;
-
- public String getRel() {
- return rel;
- }
-
- public void setRel(String rel) {
- this.rel = rel;
- }
-
- public String getType() {
- return type;
- }
-
- public void setType(String type) {
- this.type = type;
- }
-
- public String getHref() {
- return href;
- }
-
- public void setHref(String href) {
- this.href = href;
- }
+public record Link(String rel, String type, String href) {
}