aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/ActivityPubManager.java10
-rw-r--r--src/main/java/com/juick/CommandsManager.java2
-rw-r--r--src/main/java/com/juick/service/component/SystemEvent.java6
-rw-r--r--src/main/java/com/juick/www/WebApp.java2
-rw-r--r--src/main/java/com/juick/www/api/Notifications.java20
-rw-r--r--src/main/java/com/juick/www/api/SystemActivity.java18
-rw-r--r--src/main/java/com/juick/www/api/Users.java40
-rw-r--r--src/main/java/com/juick/www/api/activity/Profile.java2
-rw-r--r--src/main/java/com/juick/www/controllers/Settings.java52
9 files changed, 84 insertions, 68 deletions
diff --git a/src/main/java/com/juick/ActivityPubManager.java b/src/main/java/com/juick/ActivityPubManager.java
index 5df89527..621a89c2 100644
--- a/src/main/java/com/juick/ActivityPubManager.java
+++ b/src/main/java/com/juick/ActivityPubManager.java
@@ -249,7 +249,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
User user = msg.getUser();
String userUri = personUri(user);
Note note = makeNote(msg);
- Person me = (Person) signatureManager.getContext(URI.create(userUri)).get();
+ Actor me = (Actor) signatureManager.getContext(URI.create(userUri)).get();
Set<String> subscribers = new HashSet<>(socialService.getFollowers(user));
if (MessageUtils.isReply(msg) && msg.getTo().getUri().toASCIIString().length() > 0) {
String replier = msg.getTo().getUri().toASCIIString();
@@ -261,7 +261,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
subscribers.addAll(note.getCc());
subscribers.forEach(acct -> {
Optional<Context> context = signatureManager.getContext(URI.create(acct));
- if (context.isPresent() && context.get() instanceof Person) {
+ if (context.isPresent() && context.get() instanceof Actor) {
Actor follower = (Actor)context.get();
Create create = new Create();
create.setId(note.getId());
@@ -359,7 +359,7 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
Note activity = (Note) noteContext.get();
Optional<Context> personContext = signatureManager.getContext(URI.create(activity.getAttributedTo()));
if (personContext.isPresent()) {
- Person person = (Person) personContext.get();
+ Actor person = (Actor) personContext.get();
note.getTags().add(new Mention(person.getUrl(), person.getPreferredUsername()));
msg.getTo().setName(person.getPreferredUsername());
note.setInReplyTo(activity.getInReplyTo());
@@ -424,8 +424,8 @@ public class ActivityPubManager implements ActivityListener, NotificationListene
}, () -> logger.warn("Follower not found: {}", acct));
});
}
- public User personToUser(URI uri) throws HttpBadRequestException {
- Person person = (Person) signatureManager.getContext(uri).orElseThrow(HttpBadRequestException::new);
+ public User actorToUser(URI uri) throws HttpBadRequestException {
+ Actor person = (Actor) signatureManager.getContext(uri).orElseThrow(HttpBadRequestException::new);
User user = new User();
user.setUri(URI.create(person.getId()));
user.setName(person.getPreferredUsername());
diff --git a/src/main/java/com/juick/CommandsManager.java b/src/main/java/com/juick/CommandsManager.java
index 6d315a7d..6ad19bee 100644
--- a/src/main/java/com/juick/CommandsManager.java
+++ b/src/main/java/com/juick/CommandsManager.java
@@ -582,7 +582,7 @@ public class CommandsManager {
}
Message reply = messagesService.getReply(mid, newrid);
if (reply.getUser().isAnonymous()) {
- reply.setUser(activityPubManager.personToUser(reply.getUser().getUri()));
+ reply.setUser(activityPubManager.actorToUser(reply.getUser().getUri()));
} else {
reply.getUser().setAvatar(webApp.getAvatarUrl(reply.getUser()));
}
diff --git a/src/main/java/com/juick/service/component/SystemEvent.java b/src/main/java/com/juick/service/component/SystemEvent.java
index 749f6af8..f4e3ff90 100644
--- a/src/main/java/com/juick/service/component/SystemEvent.java
+++ b/src/main/java/com/juick/service/component/SystemEvent.java
@@ -17,6 +17,8 @@
package com.juick.service.component;
+import javax.annotation.Nonnull;
+
import com.juick.www.api.SystemActivity;
import org.springframework.context.ApplicationEvent;
@@ -28,12 +30,12 @@ public class SystemEvent extends ApplicationEvent {
* @param source the object on which the event initially occurred (never {@code null})
* @param activity system activity
*/
- public SystemEvent(Object source, SystemActivity activity) {
+ public SystemEvent(Object source, @Nonnull SystemActivity activity) {
super(source);
this.activity = activity;
}
- public SystemActivity getActivity() {
+ public @Nonnull SystemActivity getActivity() {
return activity;
}
}
diff --git a/src/main/java/com/juick/www/WebApp.java b/src/main/java/com/juick/www/WebApp.java
index 85e21b1a..69de1507 100644
--- a/src/main/java/com/juick/www/WebApp.java
+++ b/src/main/java/com/juick/www/WebApp.java
@@ -19,7 +19,6 @@ package com.juick.www;
import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;
-import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -31,7 +30,6 @@ import java.util.stream.Stream;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
-import com.juick.model.Attachment;
import com.juick.model.Message;
import com.juick.model.Tag;
import com.juick.model.User;
diff --git a/src/main/java/com/juick/www/api/Notifications.java b/src/main/java/com/juick/www/api/Notifications.java
index 613e6cfc..43465c1a 100644
--- a/src/main/java/com/juick/www/api/Notifications.java
+++ b/src/main/java/com/juick/www/api/Notifications.java
@@ -17,23 +17,28 @@
package com.juick.www.api;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.inject.Inject;
+
+import com.juick.model.AnonymousUser;
import com.juick.model.ExternalToken;
import com.juick.model.Message;
import com.juick.model.Status;
import com.juick.model.User;
-import com.juick.model.AnonymousUser;
-import com.juick.util.HttpBadRequestException;
-import com.juick.util.HttpForbiddenException;
import com.juick.service.MessagesService;
import com.juick.service.PushQueriesService;
import com.juick.service.SubscriptionService;
import com.juick.service.TelegramService;
import com.juick.service.UserService;
import com.juick.service.security.annotation.Visitor;
-import io.swagger.v3.oas.annotations.Hidden;
+import com.juick.util.HttpBadRequestException;
+import com.juick.util.HttpForbiddenException;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -41,10 +46,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
-import javax.inject.Inject;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
+import io.swagger.v3.oas.annotations.Hidden;
/**
* Created by vitalyster on 24.10.2016.
diff --git a/src/main/java/com/juick/www/api/SystemActivity.java b/src/main/java/com/juick/www/api/SystemActivity.java
index 5a7c810f..36bc3ad4 100644
--- a/src/main/java/com/juick/www/api/SystemActivity.java
+++ b/src/main/java/com/juick/www/api/SystemActivity.java
@@ -24,9 +24,11 @@ import java.util.Collections;
import java.util.List;
public class SystemActivity {
+ private SystemActivity(ActivityType type) {
+ this.type = type;
+ }
public static SystemActivity like(User from, Message message, List<User> subscribers) {
- var like = new SystemActivity();
- like.setType(ActivityType.like);
+ var like = new SystemActivity(ActivityType.like);
like.setFrom(from);
like.setMessage(message);
like.setTo(subscribers);
@@ -34,8 +36,7 @@ public class SystemActivity {
}
public static SystemActivity message(User from, Message message, List<User> subscribers) {
- var msg = new SystemActivity();
- msg.setType(ActivityType.message);
+ var msg = new SystemActivity(ActivityType.message);
msg.setFrom(from);
msg.setMessage(message);
msg.setTo(subscribers);
@@ -43,8 +44,7 @@ public class SystemActivity {
}
public static SystemActivity read(User from, Message message) {
- var read = new SystemActivity();
- read.setType(ActivityType.message);
+ var read = new SystemActivity(ActivityType.message);
read.setFrom(from);
read.setTo(Collections.emptyList());
var msg = new Message();
@@ -57,7 +57,7 @@ public class SystemActivity {
}
public static SystemActivity follow(User from, List<User> to) {
- var follow = new SystemActivity();
+ var follow = new SystemActivity(ActivityType.follow);
follow.setFrom(from);
follow.setTo(to);
return follow;
@@ -78,10 +78,6 @@ public class SystemActivity {
return type;
}
- public void setType(ActivityType type) {
- this.type = type;
- }
-
public User getFrom() {
return from;
}
diff --git a/src/main/java/com/juick/www/api/Users.java b/src/main/java/com/juick/www/api/Users.java
index 49a4494f..dd620380 100644
--- a/src/main/java/com/juick/www/api/Users.java
+++ b/src/main/java/com/juick/www/api/Users.java
@@ -17,34 +17,46 @@
package com.juick.www.api;
-import com.juick.model.User;
+import java.io.IOException;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.inject.Inject;
+
import com.juick.model.AnonymousUser;
import com.juick.model.ApplicationStatus;
+import com.juick.model.User;
+import com.juick.service.EmailService;
+import com.juick.service.MessagesService;
+import com.juick.service.StorageService;
+import com.juick.service.TagService;
+import com.juick.service.TelegramService;
+import com.juick.service.UserService;
+import com.juick.service.activities.UpdateUserEvent;
+import com.juick.service.component.MailVerificationEvent;
+import com.juick.service.security.annotation.Visitor;
import com.juick.util.HttpBadRequestException;
import com.juick.util.HttpNotFoundException;
import com.juick.util.HttpUtils;
import com.juick.util.WebUtils;
import com.juick.www.WebApp;
-import com.juick.service.*;
-import com.juick.service.activities.UpdateUserEvent;
-import com.juick.service.component.MailVerificationEvent;
-import com.juick.service.security.annotation.Visitor;
+
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.http.MediaType;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
-import javax.inject.Inject;
-import java.io.IOException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
/**
* @author ugnich
*/
diff --git a/src/main/java/com/juick/www/api/activity/Profile.java b/src/main/java/com/juick/www/api/activity/Profile.java
index 045e919d..26e2717c 100644
--- a/src/main/java/com/juick/www/api/activity/Profile.java
+++ b/src/main/java/com/juick/www/api/activity/Profile.java
@@ -422,6 +422,6 @@ public class Profile {
@PostMapping(value = { "/u/", "/api/u/" }, produces = MediaType.APPLICATION_JSON_VALUE)
public User fetchUser(@RequestParam URI uri) {
- return activityPubManager.personToUser(uri);
+ return activityPubManager.actorToUser(uri);
}
}
diff --git a/src/main/java/com/juick/www/controllers/Settings.java b/src/main/java/com/juick/www/controllers/Settings.java
index a5597735..8fefadc2 100644
--- a/src/main/java/com/juick/www/controllers/Settings.java
+++ b/src/main/java/com/juick/www/controllers/Settings.java
@@ -16,19 +16,43 @@
*/
package com.juick.www.controllers;
-import com.juick.model.User;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.ResourceBundle;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+import javax.inject.Inject;
+import javax.mail.Message;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.mail.Transport;
+import javax.mail.internet.InternetAddress;
+import javax.mail.internet.MimeMessage;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
import com.juick.model.NotifyOpts;
+import com.juick.model.User;
+import com.juick.service.EmailService;
+import com.juick.service.StorageService;
+import com.juick.service.SubscriptionService;
+import com.juick.service.TagService;
+import com.juick.service.TelegramService;
+import com.juick.service.UserService;
+import com.juick.service.activities.UpdateUserEvent;
+import com.juick.service.security.annotation.Visitor;
import com.juick.util.HttpBadRequestException;
import com.juick.util.HttpUtils;
import com.juick.www.WebApp;
-import com.juick.service.*;
-import com.juick.service.activities.UpdateUserEvent;
-import com.juick.service.security.annotation.Visitor;
+
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
@@ -37,24 +61,6 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
-import javax.inject.Inject;
-import javax.mail.Message;
-import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.Transport;
-import javax.mail.internet.InternetAddress;
-import javax.mail.internet.MimeMessage;
-import javax.servlet.http.Cookie;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Locale;
-import java.util.ResourceBundle;
-import java.util.stream.Collectors;
-import java.util.stream.IntStream;
-
/**
*
* @author Ugnich Anton