From 97ffb90f765078aca3e4d6d173a6c93182d9165c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 12 Apr 2018 00:41:57 +0300 Subject: subscription mark all comments read --- juick-common/src/main/java/com/juick/server/CommandsManager.java | 7 ++++--- .../src/main/java/com/juick/service/SubscriptionService.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'juick-common') diff --git a/juick-common/src/main/java/com/juick/server/CommandsManager.java b/juick-common/src/main/java/com/juick/server/CommandsManager.java index 734d68fb..cde6a4bf 100644 --- a/juick-common/src/main/java/com/juick/server/CommandsManager.java +++ b/juick-common/src/main/java/com/juick/server/CommandsManager.java @@ -102,7 +102,7 @@ public class CommandsManager { String body = TagUtils.toString(tags).equals(input) ? StringUtils.EMPTY : input.substring(TagUtils.toString(tags).length()).trim(); String attachmentType = StringUtils.isNotEmpty(attachment.toString()) ? attachment.toString().substring(attachment.toString().length() - 3) : null; int mid = messagesService.createMessage(user.getUid(), body, attachmentType, tags); - subscriptionService.subscribeMessage(mid, user.getUid()); + subscriptionService.subscribeMessage(messagesService.getMessage(mid), user); if (StringUtils.isNotEmpty(attachmentType)) { String attachmentFName = attachment.getScheme().equals("juick") ? attachment.getHost() : HttpUtils.downloadImage(attachment.toURL(), tmpDir).getHost(); @@ -335,9 +335,10 @@ public class CommandsManager { public CommandResult commandSubscribeMessage(User user, URI attachment, String... args) { boolean subscribe = args[0].equalsIgnoreCase("s"); int mid = NumberUtils.toInt(args[1], 0); - if (messagesService.getMessage(mid) != null) { + Message msg = messagesService.getMessage(mid); + if (msg != null) { if (subscribe) { - if (subscriptionService.subscribeMessage(mid, user.getUid())) { + if (subscriptionService.subscribeMessage(msg, user)) { return CommandResult.fromString("Subscribed"); } } else { diff --git a/juick-common/src/main/java/com/juick/service/SubscriptionService.java b/juick-common/src/main/java/com/juick/service/SubscriptionService.java index 3bd58aed..d5b9f28d 100644 --- a/juick-common/src/main/java/com/juick/service/SubscriptionService.java +++ b/juick-common/src/main/java/com/juick/service/SubscriptionService.java @@ -36,7 +36,7 @@ public interface SubscriptionService { List getUsersSubscribedToUserRecommendations(int uid, int mid, int muid); - boolean subscribeMessage(int mid, int vuid); + boolean subscribeMessage(Message message, User user); boolean unSubscribeMessage(int mid, int vuid); -- cgit v1.2.3