aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/server/api/webfinger
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-11-08 21:38:27 +0300
committerGravatar Vitaly Takmazov2018-11-08 21:38:27 +0300
commit7aaa3f9a29c280f01c677c918932620be45cdbd7 (patch)
tree39947b2c889afd08f9c73ba54fab91159d2af258 /juick-server/src/main/java/com/juick/server/api/webfinger
parent3ea9770d0d43fbe45449ac4531ec4b0a374d98ea (diff)
Merge everything into single Spring Boot application
Diffstat (limited to 'juick-server/src/main/java/com/juick/server/api/webfinger')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/webfinger/Resource.java51
-rw-r--r--juick-server/src/main/java/com/juick/server/api/webfinger/model/Account.java24
-rw-r--r--juick-server/src/main/java/com/juick/server/api/webfinger/model/Link.java31
3 files changed, 0 insertions, 106 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/webfinger/Resource.java b/juick-server/src/main/java/com/juick/server/api/webfinger/Resource.java
deleted file mode 100644
index 71a0ca31..00000000
--- a/juick-server/src/main/java/com/juick/server/api/webfinger/Resource.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.juick.server.api.webfinger;
-
-import com.juick.User;
-import com.juick.server.api.webfinger.model.Account;
-import com.juick.server.api.webfinger.model.Link;
-import com.juick.server.util.HttpNotFoundException;
-import com.juick.service.UserService;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.util.UriComponentsBuilder;
-import rocks.xmpp.addr.Jid;
-
-import javax.inject.Inject;
-import java.util.Collections;
-
-import static com.juick.server.api.activity.model.Context.ACTIVITY_MEDIA_TYPE;
-
-@RestController
-public class Resource {
- @Inject
- private UserService userService;
- @Value("${web_domain:localhost}")
- private String domain;
- @Value("${ap_base_uri:http://localhost:8080/}")
- private String baseUri;
-
- @GetMapping("/.well-known/webfinger")
- public Account getWebResource(@RequestParam String resource) {
- if (resource.startsWith("acct:")) {
- Jid account = Jid.of(resource.substring(5));
- if (account.getDomain().equals(domain)) {
- User user = userService.getUserByName(account.getLocal());
- 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;
- }
- }
- }
- throw new HttpNotFoundException();
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/api/webfinger/model/Account.java b/juick-server/src/main/java/com/juick/server/api/webfinger/model/Account.java
deleted file mode 100644
index 892fa303..00000000
--- a/juick-server/src/main/java/com/juick/server/api/webfinger/model/Account.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.juick.server.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;
- }
-}
diff --git a/juick-server/src/main/java/com/juick/server/api/webfinger/model/Link.java b/juick-server/src/main/java/com/juick/server/api/webfinger/model/Link.java
deleted file mode 100644
index 48e7ab67..00000000
--- a/juick-server/src/main/java/com/juick/server/api/webfinger/model/Link.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.juick.server.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;
- }
-}