diff options
author | Vitaly Takmazov | 2022-12-21 02:17:29 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2022-12-21 02:23:16 +0300 |
commit | 55293b4ac33e0f4fd2bfce3a0f5783b42812a65c (patch) | |
tree | cf5996d6036554dbc78aeb1eb19d2fe09fc998b0 /src/main/java/com/juick/www/api/webfinger | |
parent | e588a7ded6fae3b033e1a59a4c24d1e1a6799747 (diff) |
webfinger, app-site-associations: adopt records
Diffstat (limited to 'src/main/java/com/juick/www/api/webfinger')
3 files changed, 8 insertions, 59 deletions
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) { } |