diff options
Diffstat (limited to 'src/main/java/com/juick/www/api')
-rw-r--r-- | src/main/java/com/juick/www/api/Notifications.java | 20 | ||||
-rw-r--r-- | src/main/java/com/juick/www/api/SystemActivity.java | 18 | ||||
-rw-r--r-- | src/main/java/com/juick/www/api/Users.java | 40 | ||||
-rw-r--r-- | src/main/java/com/juick/www/api/activity/Profile.java | 2 |
4 files changed, 45 insertions, 35 deletions
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); } } |