From 02723131139806c761539a42a5fa80b68ecadee8 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Thu, 29 Jun 2017 14:03:04 +0300 Subject: project structure: split server into jdbc + web --- .../com/juick/server/helpers/AnonymousUser.java | 132 +++++++ .../juick/server/helpers/ApplicationStatus.java | 35 ++ .../main/java/com/juick/server/helpers/Auth.java | 22 ++ .../java/com/juick/server/helpers/EmailOpts.java | 24 ++ .../java/com/juick/server/helpers/NotifyOpts.java | 34 ++ .../java/com/juick/server/helpers/PrivacyOpts.java | 29 ++ .../com/juick/server/helpers/PrivateChats.java | 22 ++ .../com/juick/server/helpers/ResponseReply.java | 72 ++++ .../java/com/juick/server/helpers/TagStats.java | 29 ++ .../java/com/juick/server/helpers/UserInfo.java | 43 +++ .../com/juick/server/protocol/JuickProtocol.java | 426 +++++++++++++++++++++ .../juick/server/protocol/ProtocolListener.java | 13 + .../server/protocol/annotation/UserCommand.java | 33 ++ .../main/java/com/juick/server/util/HashUtils.java | 19 + .../main/java/com/juick/server/util/TagUtils.java | 25 ++ .../java/com/juick/service/CrosspostService.java | 58 +++ .../main/java/com/juick/service/EmailService.java | 11 + .../java/com/juick/service/MessagesService.java | 86 +++++ .../java/com/juick/service/PMQueriesService.java | 28 ++ .../com/juick/service/PrivacyQueriesService.java | 17 + .../java/com/juick/service/PushQueriesService.java | 33 ++ .../java/com/juick/service/ShowQueriesService.java | 14 + .../com/juick/service/SubscriptionService.java | 38 ++ .../main/java/com/juick/service/TagService.java | 37 ++ .../java/com/juick/service/TelegramService.java | 22 ++ .../main/java/com/juick/service/UserService.java | 126 ++++++ .../com/juick/service/search/SearchService.java | 14 + 27 files changed, 1442 insertions(+) create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/AnonymousUser.java create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/ApplicationStatus.java create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/Auth.java create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/EmailOpts.java create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/NotifyOpts.java create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/PrivacyOpts.java create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/PrivateChats.java create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/ResponseReply.java create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/TagStats.java create mode 100644 juick-server-core/src/main/java/com/juick/server/helpers/UserInfo.java create mode 100644 juick-server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java create mode 100644 juick-server-core/src/main/java/com/juick/server/protocol/ProtocolListener.java create mode 100644 juick-server-core/src/main/java/com/juick/server/protocol/annotation/UserCommand.java create mode 100644 juick-server-core/src/main/java/com/juick/server/util/HashUtils.java create mode 100644 juick-server-core/src/main/java/com/juick/server/util/TagUtils.java create mode 100644 juick-server-core/src/main/java/com/juick/service/CrosspostService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/EmailService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/MessagesService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/PMQueriesService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/PrivacyQueriesService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/PushQueriesService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/ShowQueriesService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/SubscriptionService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/TagService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/TelegramService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/UserService.java create mode 100644 juick-server-core/src/main/java/com/juick/service/search/SearchService.java (limited to 'juick-server-core/src/main/java') diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/AnonymousUser.java b/juick-server-core/src/main/java/com/juick/server/helpers/AnonymousUser.java new file mode 100644 index 00000000..1ce1c2c2 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/AnonymousUser.java @@ -0,0 +1,132 @@ +package com.juick.server.helpers; + +import com.juick.User; + +/** + * Created by aalexeev on 12/11/16. + */ +public final class AnonymousUser extends User { + public static final AnonymousUser INSTANCE = new AnonymousUser(); + + private AnonymousUser() { + super.setUid(getUid()); + super.setName(getName()); + super.setAvatar(getAvatar()); + super.setFullName(getFullName()); + super.setJid(getJid()); + super.setMessagesCount(getMessagesCount()); + super.setAuthHash(getAuthHash()); + super.setBanned(isBanned()); + super.setCredentials(getCredentials()); + super.setLang(getLang()); + } + + @Override + public boolean equals(Object obj) { + return obj == this || obj instanceof AnonymousUser; + } + + @Override + public int getUid() { + return 0; + } + + @Override + public String getName() { + return "Anonymous"; + } + + @Override + public String getFullName() { + return getName(); + } + + @Override + public String getJid() { + return "anonym@localhost"; + } + + @Override + public String getAuthHash() { + return null; + } + + @Override + public Integer getUnreadCount() { + return 0; + } + + @Override + public boolean isBanned() { + return false; + } + + @Override + public Object getAvatar() { + return null; + } + + @Override + public String getCredentials() { + return null; + } + + @Override + public String getLang() { + return "__"; + } + + @Override + public int getMessagesCount() { + return 0; + } + + @Override + public boolean isAnonymous() { + return true; + } + + @Override + public void setUid(int uid) { + } + + @Override + public void setName(String name) { + } + + @Override + public void setFullName(String fullName) { + } + + @Override + public void setJid(String jid) { + } + + @Override + public void setAuthHash(String authHash) { + } + + @Override + public void setUnreadCount(Integer count) { + } + + @Override + public void setBanned(boolean banned) { + } + + @Override + public void setAvatar(Object avatar) { + } + + @Override + public void setCredentials(String credentials) { + } + + @Override + public void setLang(String lang) { + } + + @Override + public void setMessagesCount(int messagesCount) { + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/ApplicationStatus.java b/juick-server-core/src/main/java/com/juick/server/helpers/ApplicationStatus.java new file mode 100644 index 00000000..61109c47 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/ApplicationStatus.java @@ -0,0 +1,35 @@ +package com.juick.server.helpers; + +import org.apache.commons.lang3.builder.ToStringBuilder; + +/** + * Created by vt on 03/09/16. + */ +public class ApplicationStatus { + private boolean connected; + private boolean crosspostEnabled; + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("connected", connected) + .append("crosspostEnabled", crosspostEnabled) + .toString(); + } + + public boolean isConnected() { + return connected; + } + + public void setConnected(boolean connected) { + this.connected = connected; + } + + public boolean isCrosspostEnabled() { + return crosspostEnabled; + } + + public void setCrosspostEnabled(boolean crosspostEnabled) { + this.crosspostEnabled = crosspostEnabled; + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/Auth.java b/juick-server-core/src/main/java/com/juick/server/helpers/Auth.java new file mode 100644 index 00000000..3e1f0bd9 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/Auth.java @@ -0,0 +1,22 @@ +package com.juick.server.helpers; + +/** + * Created by vt on 09/02/16. + */ +public class Auth { + private String account; + private String authCode; + + public Auth(String account, String authCode) { + this.account = account; + this.authCode = authCode; + } + + public String getAccount() { + return account; + } + + public String getAuthCode() { + return authCode; + } +} \ No newline at end of file diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/EmailOpts.java b/juick-server-core/src/main/java/com/juick/server/helpers/EmailOpts.java new file mode 100644 index 00000000..679d1a8d --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/EmailOpts.java @@ -0,0 +1,24 @@ +package com.juick.server.helpers; + +import org.apache.commons.lang3.StringUtils; + +/** + * Created by vitalyster on 09.02.2016. + */ +public class EmailOpts { + private String email; + private String subscriptionHour; + + public EmailOpts(String email, int subscriptionHour) { + this.email = email; + this.subscriptionHour = StringUtils.leftPad(String.format("%d", subscriptionHour), 2, "0"); + } + + public String getSubscriptionHour() { + return subscriptionHour; + } + + public String getEmail() { + return email; + } +} \ No newline at end of file diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/NotifyOpts.java b/juick-server-core/src/main/java/com/juick/server/helpers/NotifyOpts.java new file mode 100644 index 00000000..377b0a50 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/NotifyOpts.java @@ -0,0 +1,34 @@ +package com.juick.server.helpers; + +/** + * Created by vt on 03/09/16. + */ +public class NotifyOpts { + private boolean repliesEnabled; + private boolean subscriptionsEnabled; + private boolean recommendationsEnabled; + + public boolean isRepliesEnabled() { + return repliesEnabled; + } + + public void setRepliesEnabled(boolean repliesEnabled) { + this.repliesEnabled = repliesEnabled; + } + + public boolean isSubscriptionsEnabled() { + return subscriptionsEnabled; + } + + public void setSubscriptionsEnabled(boolean subscriptionsEnabled) { + this.subscriptionsEnabled = subscriptionsEnabled; + } + + public boolean isRecommendationsEnabled() { + return recommendationsEnabled; + } + + public void setRecommendationsEnabled(boolean recommendationsEnabled) { + this.recommendationsEnabled = recommendationsEnabled; + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/PrivacyOpts.java b/juick-server-core/src/main/java/com/juick/server/helpers/PrivacyOpts.java new file mode 100644 index 00000000..66cf9410 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/PrivacyOpts.java @@ -0,0 +1,29 @@ +package com.juick.server.helpers; + +/** + * Created by vt on 16/01/16. + */ +public class PrivacyOpts { + private int uid; + private int privacy; + + public PrivacyOpts() { + + } + + public int getUid() { + return uid; + } + + public void setUid(int uid) { + this.uid = uid; + } + + public int getPrivacy() { + return privacy; + } + + public void setPrivacy(int privacy) { + this.privacy = privacy; + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/PrivateChats.java b/juick-server-core/src/main/java/com/juick/server/helpers/PrivateChats.java new file mode 100644 index 00000000..b1bfccf8 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/PrivateChats.java @@ -0,0 +1,22 @@ +package com.juick.server.helpers; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.juick.User; + +import java.util.List; + +/** + * Created by vt on 24/11/2016. + */ +public class PrivateChats { + private List users; + + @JsonProperty("pms") + public List getUsers() { + return users; + } + + public void setUsers(List users) { + this.users = users; + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/ResponseReply.java b/juick-server-core/src/main/java/com/juick/server/helpers/ResponseReply.java new file mode 100644 index 00000000..f941c743 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/ResponseReply.java @@ -0,0 +1,72 @@ +package com.juick.server.helpers; + +import java.util.Date; + +/** + * Created by vitalyster on 13.12.2016. + */ +public class ResponseReply { + private String muname; + private int mid; + private int rid; + private String uname; + private String description; + private Date pubDate; + private String attachmentType; + + public String getMuname() { + return muname; + } + + public void setMuname(String muname) { + this.muname = muname; + } + + public int getMid() { + return mid; + } + + public void setMid(int mid) { + this.mid = mid; + } + + public int getRid() { + return rid; + } + + public void setRid(int rid) { + this.rid = rid; + } + + public String getUname() { + return uname; + } + + public void setUname(String uname) { + this.uname = uname; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Date getPubDate() { + return pubDate; + } + + public void setPubDate(Date pubDate) { + this.pubDate = pubDate; + } + + public String getAttachmentType() { + return attachmentType; + } + + public void setAttachmentType(String attachmentType) { + this.attachmentType = attachmentType; + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/TagStats.java b/juick-server-core/src/main/java/com/juick/server/helpers/TagStats.java new file mode 100644 index 00000000..e8720991 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/TagStats.java @@ -0,0 +1,29 @@ +package com.juick.server.helpers; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.juick.Tag; + +/** + * Created by vitalyster on 01.12.2016. + */ +public class TagStats { + private Tag tag; + private int usageCount; + + public Tag getTag() { + return tag; + } + + public void setTag(Tag tag) { + this.tag = tag; + } + + @JsonProperty("messages") + public int getUsageCount() { + return usageCount; + } + + public void setUsageCount(int usageCount) { + this.usageCount = usageCount; + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/helpers/UserInfo.java b/juick-server-core/src/main/java/com/juick/server/helpers/UserInfo.java new file mode 100644 index 00000000..5a4b6894 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/helpers/UserInfo.java @@ -0,0 +1,43 @@ +package com.juick.server.helpers; + +/** + * Created by vt on 03/09/16. + */ +public class UserInfo { + private String fullName; + private String country; + private String url; + private String description; + + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java b/juick-server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java new file mode 100644 index 00000000..6ac05624 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/protocol/JuickProtocol.java @@ -0,0 +1,426 @@ +package com.juick.server.protocol; + +import com.juick.Message; +import com.juick.Tag; +import com.juick.User; +import com.juick.formatters.PlainTextFormatter; +import com.juick.server.helpers.TagStats; +import com.juick.server.protocol.annotation.UserCommand; +import com.juick.server.util.TagUtils; +import com.juick.service.*; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; +import org.apache.commons.lang3.reflect.MethodUtils; + +import javax.inject.Inject; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; + +/** + * Created by oxpa on 22.03.16. + */ + +public class JuickProtocol { + + private String baseUri; + private ProtocolListener listener; + + @Inject + UserService userService; + @Inject + TagService tagService; + @Inject + MessagesService messagesService; + @Inject + SubscriptionService subscriptionService; + @Inject + PMQueriesService pmQueriesService; + @Inject + PrivacyQueriesService privacyQueriesService; + @Inject + ShowQueriesService showQueriesService; + + public JuickProtocol(String baseUri) { + this.baseUri = baseUri; + } + + /** + * find command by pattern and invoke + * @param user who send command + * @param userInput given by user + * @return command result + * @throws InvocationTargetException + * @throws IllegalAccessException + * @throws NoSuchMethodException + */ + public String getReply(User user, String userInput) throws InvocationTargetException, + IllegalAccessException, NoSuchMethodException { + Optional cmd = MethodUtils.getMethodsListWithAnnotation(getClass(), UserCommand.class).stream() + .filter(m -> Pattern.compile(m.getAnnotation(UserCommand.class).pattern(), + m.getAnnotation(UserCommand.class).patternFlags()).matcher(userInput).matches()) + .findFirst(); + if (!cmd.isPresent()) { + // default command - post as new message + return postMessage(user, userInput.trim()); + } else { + Matcher matcher = Pattern.compile(cmd.get().getAnnotation(UserCommand.class).pattern(), + cmd.get().getAnnotation(UserCommand.class).patternFlags()).matcher(userInput.trim()); + List groups = new ArrayList<>(); + while (matcher.find()) { + for (int i = 1; i <= matcher.groupCount(); i++) { + groups.add(matcher.group(i)); + } + } + return (String) getClass().getMethod(cmd.get().getName(), User.class, String[].class) + .invoke(this, user, groups.toArray(new String[groups.size()])); + } + } + + public String postMessage(User user, String input) { + List tags = tagService.fromString(input, false); + String body = input.substring(TagUtils.toString(tags).length()); + int mid = messagesService.createMessage(user.getUid(), body, null, tags); + subscriptionService.subscribeMessage(mid, user.getUid()); + listener.messagePosted(messagesService.getMessage(mid)); + return "New message posted.\n#" + mid + " " + baseUri + mid; + } + + @UserCommand(pattern = "^#\\+$", help = "#+ - Show last Juick messages") + public String commandLast(User user, String... arguments) { + List mids = messagesService.getAll(user.getUid(), 0); + List messages = messagesService.getMessages(mids); + return "Last messages: \n" + + messages.stream().sorted(Collections.reverseOrder()).map(PlainTextFormatter::formatPostSummary) + .collect(Collectors.joining("\n\n")); + } + + @UserCommand(pattern = "^bl$", patternFlags = Pattern.CASE_INSENSITIVE, + help = "BL - Show your blacklist") + public String commandBL(User user_from, String... arguments) { + List blusers; + List bltags; + + blusers = userService.getUserBLUsers(user_from.getUid()); + bltags = tagService.getUserBLTags(user_from.getUid()); + + + String txt = StringUtils.EMPTY; + if (bltags.size() > 0) { + for (String bltag : bltags) { + txt += "*" + bltag + "\n"; + } + + if (blusers.size() > 0) { + txt += "\n"; + } + } + if (blusers.size() > 0) { + for (User bluser : blusers) { + txt += "@" + bluser.getName() + "\n"; + } + } + if (txt.isEmpty()) { + txt = "You don't have any users or tags in your blacklist."; + } + return txt; + } + + @UserCommand(pattern = "^bl\\s+@([^\\s\\n\\+]+)", patternFlags = Pattern.CASE_INSENSITIVE, + help = "BL @username - add @username to your blacklist") + public String blacklistUser(User from, String... arguments) { + User blUser = userService.getUserByName(arguments[0]); + if (blUser != null) { + PrivacyQueriesService.PrivacyResult result = privacyQueriesService.blacklistUser(from, blUser); + if (result == PrivacyQueriesService.PrivacyResult.Added) { + return "User added to your blacklist"; + } else { + return "User removed from your blacklist"; + } + } + return "User not found"; + } + + @UserCommand(pattern = "^bl\\s\\*(\\S+)$", patternFlags = Pattern.CASE_INSENSITIVE, + help = "BL *tag - add *tag to your blacklist") + public String blacklistTag(User from, String... arguments) { + User blUser = userService.getUserByName(arguments[0]); + if (blUser != null) { + Tag tag = tagService.getTag(arguments[0], false); + if (tag != null) { + PrivacyQueriesService.PrivacyResult result = privacyQueriesService.blacklistTag(from, tag); + if (result == PrivacyQueriesService.PrivacyResult.Added) { + return "Tag added to your blacklist"; + } else { + return "Tag removed from your blacklist"; + } + } + } + return "Tag not found"; + } + + @UserCommand(pattern = "@", help = "@ - Show recommendations and popular personal blogs") + public String commandUsers(User currentUser, String... args) { + StringBuilder msg = new StringBuilder(); + msg.append("Recommended blogs"); + List recommendedUsers = showQueriesService.getRecommendedUsers(currentUser); + if (recommendedUsers.size() > 0) { + for (String user : recommendedUsers) { + msg.append("\n@").append(user); + } + } else { + msg.append("\nNo recommendations now. Subscribe to more blogs. ;)"); + } + msg.append("\n\nTop 10 personal blogs:"); + List topUsers = showQueriesService.getTopUsers(); + if (topUsers.size() > 0) { + for (String user : topUsers) { + msg.append("\n@").append(user); + } + } else { + msg.append("\nNo top users. Empty DB? ;)"); + } + return msg.toString(); + } + + @UserCommand(pattern = "\\*", help = "* - Show your tags") + public String commandTags(User currentUser, String... args) { + List tags = tagService.getUserTagStats(currentUser.getUid()); + String msg = "Your tags: (tag - messages)\n" + + tags.stream() + .map(t -> String.format("\n*%s - %d", t.getTag().getName(), t.getUsageCount())).collect(Collectors.joining()); + return msg; + } + + @UserCommand(pattern = "S", help = "S - Show your subscriptions") + public String commandSubscriptions(User currentUser, String... args) { + List friends = userService.getUserFriends(currentUser.getUid()); + List tags = subscriptionService.getSubscribedTags(currentUser); + String msg = friends.size() > 0 ? "You are subscribed to users:" + friends.stream().map(u -> "\n@" + u.getName()) + .collect(Collectors.joining()) + : "You are not subscribed to any user."; + msg += tags.size() > 0 ? "\nYou are subscribed to tags:" + tags.stream().map(t -> "\n*" + t) + .collect(Collectors.joining()) + : "\nYou are not subscribed to any tag."; + return msg; + } + + @UserCommand(pattern = "!", help = "! - Show your favorite messages") + public String commandFavorites(User currentUser, String... args) { + List mids = messagesService.getUserRecommendations(currentUser.getUid(), 0); + if (mids.size() > 0) { + List messages = messagesService.getMessages(mids); + return "Favorite messages: \n" + String.join("\n", messages.stream().map(PlainTextFormatter::formatPost) + .collect(Collectors.toList())); + } + return "No favorite messages, try to \"like\" something ;)"; + } + + @UserCommand(pattern = "^\\@([^\\s\\n\\+]+)(\\+?)$", + help = "@username+ - Show user's info and last 10 messages (@username++ - second page, ..)") + public String commandUser(User user, String... arguments) { + User blogUser = userService.getUserByName(arguments[0]); + int page = arguments[1].length(); + if (blogUser.getUid() > 0) { + List mids = messagesService.getUserBlog(blogUser.getUid(), 0, page); + List messages = messagesService.getMessages(mids); + return String.format("Last messages from @%s:\n%s", arguments[0], + String.join("\n", messages.stream() + .map(PlainTextFormatter::formatPost).collect(Collectors.toList()))); + } + return "User not found"; + } + + @UserCommand(pattern = "^d\\s*\\#([0-9]+)$", patternFlags = Pattern.CASE_INSENSITIVE, + help = "D #12345 - delete the message") + public String commandDel(User user, String... args) { + int mid = NumberUtils.toInt(args[0], 0); + if (messagesService.deleteMessage(user.getUid(), mid)) { + return String.format("Message %s deleted", mid); + } + return "Error"; + } + + @UserCommand(pattern = "^login$", patternFlags = Pattern.CASE_INSENSITIVE, + help = "LOGIN - log in to Juick website") + public String commandLogin(User user, String... arguments) { + return baseUri + "?" + userService.getHashByUID(user.getUid()); + } + + @UserCommand(pattern = "^(#+)$", help = "# - Show last messages from your feed (## - second page, ...)") + public String commandMyFeed(User user, String... arguments) { + // number of # is the page count + int page = arguments[0].length() - 1; + List mids = messagesService.getMyFeed(user.getUid(), page); + List messages = messagesService.getMessages(mids); + // TODO: add instructions for empty feed + return "Your feed: \n" + String.join("\n", + messages.stream().map(PlainTextFormatter::formatPost).collect(Collectors.toList())); + } + + @UserCommand(pattern = "^(on|off)$", patternFlags = Pattern.CASE_INSENSITIVE, + help = "ON/OFF - Enable/disable subscriptions delivery") + public String commandOnOff(User user, String[] input) { + UserService.ActiveStatus newStatus; + String retValUpdated; + if (input[0].toLowerCase().equals("on")) { + newStatus = UserService.ActiveStatus.Active; + retValUpdated = "Notifications are activated for " + user.getJid(); + } else { + newStatus = UserService.ActiveStatus.Inactive; + retValUpdated = "Notifications are disabled for " + user.getJid(); + } + + if (userService.setActiveStatusForJID(user.getJid(), newStatus)) { + return retValUpdated; + } else { + return String.format("Subscriptions status for %s was not changed", user.getJid()); + } + } + + @UserCommand(pattern = "^ping$", patternFlags = Pattern.CASE_INSENSITIVE, + help = "PING - returns you a PONG") + public String commandPing(User user, String[] input) { + return "PONG"; + } + + @UserCommand(pattern = "^\\@(\\S+)\\s+([\\s\\S]+)$", help = "@username message - send PM to username") + public String commandPM(User user_from, String... arguments) { + String user_to = arguments[0]; + String body = arguments[1]; + + User toUser = userService.getUserByName(user_to); + + if (toUser.getUid() > 0) { + if (!userService.isInBLAny(toUser.getUid(), user_from.getUid())) { + if (pmQueriesService.createPM(user_from.getUid(), toUser.getUid(), body)) { + listener.privateMessage(user_from, toUser, body); + return "Private message sent"; + } + } + } + return "Error"; + } + + @UserCommand(pattern = "^#(\\d+)(\\+?)$", help = "#1234 - Show message (#1234+ - message with replies)") + public String commandShow(User user, String... arguments) { + boolean showReplies = arguments[1].length() > 0; + int mid = NumberUtils.toInt(arguments[0], 0); + if (mid == 0) { + return "Error"; + } + Message msg = messagesService.getMessage(mid); + if (msg != null) { + if (showReplies) { + List replies = messagesService.getReplies(mid); + replies.add(0, msg); + return String.join("\n", + replies.stream().map(PlainTextFormatter::formatPost).collect(Collectors.toList())); + } + return PlainTextFormatter.formatPost(msg); + } + return "Message not found"; + } + @UserCommand(pattern = "^(#|\\.)(\\d+)((\\.|\\-|\\/)(\\d+))?\\s([\\s\\S]+)", + help = "#1234 *tag *tag2 - edit tags\n#1234 text - reply to message") + public String EditOrReply(User user, String... args) { + int mid = NumberUtils.toInt(args[1]); + int rid = NumberUtils.toInt(args[4], 0); + String txt = args[5]; + List messageTags = tagService.fromString(txt, true); + if (messageTags.size() > 0) { + if (user.getUid() != messagesService.getMessageAuthor(mid).getUid()) { + return "It is not your message"; + } + tagService.updateTags(mid, messageTags); + return "Tags are updated"; + } else { + int newrid = messagesService.createReply(mid, rid, user.getUid(), txt, null); + listener.messagePosted(messagesService.getReply(mid, newrid)); + return "Reply posted.\n#" + mid + "/" + newrid + " " + + baseUri + mid + "#" + newrid; + } + } + + @UserCommand(pattern = "^(s|u)\\s+#(\\d+)$", help = "S #1234 - subscribe to comments", + patternFlags = Pattern.CASE_INSENSITIVE) + public String commandSubscribeMessage(User user, String... args) { + boolean subscribe = args[0].equalsIgnoreCase("s"); + int mid = NumberUtils.toInt(args[1], 0); + if (messagesService.getMessage(mid) != null) { + if (subscribe) { + if (subscriptionService.subscribeMessage(mid, user.getUid())) { + return "Subscribed"; + } + } else { + if (subscriptionService.unSubscribeMessage(mid, user.getUid())) { + return "Unsubscribed from #" + mid; + } + return "You was not subscribed to #" + mid; + } + } + return "Error"; + } + @UserCommand(pattern = "^(s|u)\\s+\\@(\\S+)$", help = "S @user - subscribe to user's posts", + patternFlags = Pattern.CASE_INSENSITIVE) + public String commandSubscribeUser(User user, String... args) { + boolean subscribe = args[0].equalsIgnoreCase("s"); + User toUser = userService.getUserByName(args[1]); + if (toUser.getUid() > 0) { + if (subscribe) { + if (subscriptionService.subscribeUser(user, toUser)) { + listener.userSubscribed(user, toUser); + return "Subscribed"; + // TODO: already subscribed case + } + } else { + if (subscriptionService.unSubscribeUser(user, toUser)) { + return "Unsubscribed from @" + toUser.getName(); + } + return "You was not subscribed to @" + toUser.getName(); + } + } + return "Error"; + } + @UserCommand(pattern = "^(s|u)\\s+\\*(\\S+)$", help = "S *tag - subscribe to tag" + + "\nU *tag - unsubscribe from tag", patternFlags = Pattern.CASE_INSENSITIVE) + public String commandSubscribeTag(User user, String... args) { + boolean subscribe = args[0].equalsIgnoreCase("s"); + Tag tag = tagService.getTag(args[1], true); + if (subscribe) { + if (subscriptionService.subscribeTag(user, tag)) { + return "Subscribed"; + } + } else { + if (subscriptionService.unSubscribeTag(user, tag)) { + return "Unsubscribed from " + tag.getName(); + } + return "You was not subscribed to " + tag.getName(); + } + return "Error"; + } + + @UserCommand(pattern = "^help$", patternFlags = Pattern.CASE_INSENSITIVE, + help = "HELP - returns this help message") + public String commandHelp(User user, String[] input) { + return Arrays.stream(getClass().getDeclaredMethods()) + .filter(m -> m.isAnnotationPresent(UserCommand.class)) + .map(m -> m.getAnnotation(UserCommand.class).help()) + .collect(Collectors.joining("\n")); + } + + public String getBaseUri() { + return baseUri; + } + + public ProtocolListener getListener() { + return listener; + } + + public void setListener(ProtocolListener listener) { + this.listener = listener; + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/protocol/ProtocolListener.java b/juick-server-core/src/main/java/com/juick/server/protocol/ProtocolListener.java new file mode 100644 index 00000000..11231e04 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/protocol/ProtocolListener.java @@ -0,0 +1,13 @@ +package com.juick.server.protocol; + +import com.juick.Message; +import com.juick.User; + +/** + * Created by vitalyster on 19.12.2016. + */ +public interface ProtocolListener { + void privateMessage(User from, User to, String body); + void userSubscribed(User from, User to); + void messagePosted(Message msg); +} diff --git a/juick-server-core/src/main/java/com/juick/server/protocol/annotation/UserCommand.java b/juick-server-core/src/main/java/com/juick/server/protocol/annotation/UserCommand.java new file mode 100644 index 00000000..42a9bb59 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/protocol/annotation/UserCommand.java @@ -0,0 +1,33 @@ +package com.juick.server.protocol.annotation; + +import org.apache.commons.lang3.StringUtils; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Created by oxpa on 22.03.16. + */ +@Target({ElementType.TYPE, ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface UserCommand { + /** + * + * @return a command pattern + */ + String pattern() default StringUtils.EMPTY; + + /** + * + * @return pattern flags + */ + int patternFlags() default 0; + + /** + * + * @return a string used in HELP command output. Basically, only 1 string + */ + String help() default StringUtils.EMPTY; +} diff --git a/juick-server-core/src/main/java/com/juick/server/util/HashUtils.java b/juick-server-core/src/main/java/com/juick/server/util/HashUtils.java new file mode 100644 index 00000000..7e166d43 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/util/HashUtils.java @@ -0,0 +1,19 @@ +package com.juick.server.util; + +import java.util.Random; + +/** + * Created by vitalyster on 29.06.2017. + */ +public class HashUtils { + private static final String ABCDEF = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + public static String generateHash(final int len) { + Random rnd = new Random(); + StringBuilder sb = new StringBuilder(len); + for (int i = 0; i < len; i++) { + sb.append(ABCDEF.charAt(rnd.nextInt(ABCDEF.length()))); + } + return sb.toString(); + } +} diff --git a/juick-server-core/src/main/java/com/juick/server/util/TagUtils.java b/juick-server-core/src/main/java/com/juick/server/util/TagUtils.java new file mode 100644 index 00000000..1a92d6d1 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/server/util/TagUtils.java @@ -0,0 +1,25 @@ +package com.juick.server.util; + +import com.juick.Tag; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; + +import java.util.List; +import java.util.stream.Collectors; + +/** + * Created by aalexeev on 11/13/16. + */ +public class TagUtils { + private TagUtils() { + throw new IllegalStateException(); + } + + public static String toString(final List tags) { + if (CollectionUtils.isEmpty(tags)) + return StringUtils.EMPTY; + + return tags.stream().map(t -> " *" + t.getName()) + .collect(Collectors.joining()); + } +} diff --git a/juick-server-core/src/main/java/com/juick/service/CrosspostService.java b/juick-server-core/src/main/java/com/juick/service/CrosspostService.java new file mode 100644 index 00000000..467d1cbe --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/CrosspostService.java @@ -0,0 +1,58 @@ +package com.juick.service; + +import com.juick.server.helpers.ApplicationStatus; +import org.apache.commons.lang3.tuple.Pair; + +import java.util.Optional; + +/** + * Created by aalexeev on 11/13/16. + */ +public interface CrosspostService { + + Optional> getTwitterTokens(int uid); + + boolean deleteTwitterToken(Integer uid); + + Optional getFacebookToken(int uid); + + ApplicationStatus getFbCrossPostStatus(int uid); + + boolean enableFBCrosspost(Integer uid); + + void disableFBCrosspost(Integer uid); + + String getTwitterName(int uid); + + String getTelegramName(int uid); + + Optional> getVkTokens(int uid); + + void deleteVKUser(Integer uid); + + int getUIDbyFBID(long fbID); + + boolean createFacebookUser(long fbID, String loginhash, String token, String fbName, String fbLink); + + boolean updateFacebookUser(long fbID, String token, String fbName, String fbLink); + + int getUIDbyVKID(long vkID); + + boolean createVKUser(long vkID, String loginhash, String token, String vkName, String vkLink); + + String getFacebookNameByHash(String hash); + + String getTelegramNameByHash(String hash); + + boolean setFacebookUser(String hash, int uid); + + String getVKNameByHash(String hash); + + boolean setVKUser(String hash, int uid); + + boolean setTelegramUser(String hash, int uid); + + String getJIDByHash(String hash); + + boolean setJIDUser(String hash, int uid); +} diff --git a/juick-server-core/src/main/java/com/juick/service/EmailService.java b/juick-server-core/src/main/java/com/juick/service/EmailService.java new file mode 100644 index 00000000..67925ec1 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/EmailService.java @@ -0,0 +1,11 @@ +package com.juick.service; + +/** + * Created by vitalyster on 09.12.2016. + */ +public interface EmailService { + boolean verifyAddressByCode(Integer userId, String code); + boolean addVerificationCode(Integer userId, String account, String code); + boolean deleteEmail(Integer userId, String account); + boolean setSubscriptionHour(Integer userId, String account, String hour); +} diff --git a/juick-server-core/src/main/java/com/juick/service/MessagesService.java b/juick-server-core/src/main/java/com/juick/service/MessagesService.java new file mode 100644 index 00000000..37ca5eac --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/MessagesService.java @@ -0,0 +1,86 @@ +package com.juick.service; + +import com.juick.User; +import com.juick.server.helpers.ResponseReply; + +import java.util.Collection; +import java.util.List; + +/** + * Created by aalexeev on 11/13/16. + */ +public interface MessagesService { + int createMessage(int uid, String txt, String attachment, Collection tags); + + int createReply(int mid, int rid, int uid, String txt, String attachment); + + int getReplyIDIncrement(int mid); + + boolean recommendMessage(int mid, int vuid); + + boolean canViewThread(int mid, int uid); + + boolean isReadOnly(int mid); + + boolean isSubscribed(int uid, int mid); + + int getMessagePrivacy(int mid); + + com.juick.Message getMessage(int mid); + + com.juick.Message getReply(int mid, int rid); + + User getMessageAuthor(int mid); + + List getMessageRecommendations(int mid); + + List getAll(int visitorUid, int before); + + List getTag(int tid, int visitorUid, int before, int cnt); + + List getTags(String tids, int visitorUid, int before, int cnt); + + List getPlace(int placeId, int visitorUid, int before); + + List getMyFeed(int uid, int before); + + List getPrivate(int uid, int before); + + List getDiscussions(int uid, int before); + + List getRecommended(int uid, int before); + + List getPopular(int visitorUid, int before); + + List getPhotos(int visitorUid, int before); + + List getSearch(String search, int before); + + List getUserBlog(int uid, int privacy, int before); + + List getUserTag(int uid, int tid, int privacy, int before); + + List getUserBlogAtDay(int uid, int privacy, int daysback); + + List getUserBlogWithRecommendations(int uid, int privacy, int before); + + List getUserRecommendations(int uid, int before); + + List getUserPhotos(int uid, int privacy, int before); + + List getUserSearch(int UID, String search, int privacy, int before); + + List getMessages(Collection mids); + + List getReplies(int mid); + + boolean setMessagePopular(int mid, int popular); + + boolean setMessagePrivacy(int mid); + + boolean deleteMessage(int uid, int mid); + + List getLastMessages(int hours); + + List getLastReplies(int hours); +} diff --git a/juick-server-core/src/main/java/com/juick/service/PMQueriesService.java b/juick-server-core/src/main/java/com/juick/service/PMQueriesService.java new file mode 100644 index 00000000..e20bb3a5 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/PMQueriesService.java @@ -0,0 +1,28 @@ +package com.juick.service; + +import com.juick.User; + +import java.util.List; + +/** + * Created by aalexeev on 11/13/16. + */ +public interface PMQueriesService { + boolean createPM(int uidFrom, int uid_to, String body); + + boolean addPMinRoster(int uid, String jid); + + boolean removePMinRoster(int uid, String jid); + + boolean havePMinRoster(int uid, String jid); + + String getLastView(int uidFrom, int uidTo); + + List getPMLastConversationsUsers(int uid, int cnt); + + List getPMMessages(int uid, int uidTo); + + List getLastPMInbox(int uid); + + List getLastPMSent(int uid); +} diff --git a/juick-server-core/src/main/java/com/juick/service/PrivacyQueriesService.java b/juick-server-core/src/main/java/com/juick/service/PrivacyQueriesService.java new file mode 100644 index 00000000..61eb199b --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/PrivacyQueriesService.java @@ -0,0 +1,17 @@ +package com.juick.service; + +import com.juick.Tag; +import com.juick.User; + +/** + * Created by aalexeev on 11/13/16. + */ +public interface PrivacyQueriesService { + enum PrivacyResult { + Removed, Added + } + + PrivacyResult blacklistUser(User user, User target); + + PrivacyResult blacklistTag(User user, Tag tag); +} diff --git a/juick-server-core/src/main/java/com/juick/service/PushQueriesService.java b/juick-server-core/src/main/java/com/juick/service/PushQueriesService.java new file mode 100644 index 00000000..7d4bc295 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/PushQueriesService.java @@ -0,0 +1,33 @@ +package com.juick.service; + +import java.util.Collection; +import java.util.List; + +/** + * Created by aalexeev on 11/13/16. + */ +public interface PushQueriesService { + List getGCMRegID(int uid); + + List getGCMTokens(Collection uids); + + boolean addGCMToken(Integer uid, String token); + + boolean deleteGCMToken(String token); + + List getMPNSURL(int uid); + + List getMPNSTokens(Collection uids); + + boolean addMPNSToken(Integer uid, String token); + + boolean deleteMPNSToken(String token); + + List getAPNSToken(int uid); + + List getAPNSTokens(Collection uids); + + boolean addAPNSToken(Integer uid, String token); + + boolean deleteAPNSToken(String token); +} diff --git a/juick-server-core/src/main/java/com/juick/service/ShowQueriesService.java b/juick-server-core/src/main/java/com/juick/service/ShowQueriesService.java new file mode 100644 index 00000000..a7e1c364 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/ShowQueriesService.java @@ -0,0 +1,14 @@ +package com.juick.service; + +import com.juick.User; + +import java.util.List; + +/** + * Created by aalexeev on 11/13/16. + */ +public interface ShowQueriesService { + List getRecommendedUsers(User forUser); + + List getTopUsers(); +} diff --git a/juick-server-core/src/main/java/com/juick/service/SubscriptionService.java b/juick-server-core/src/main/java/com/juick/service/SubscriptionService.java new file mode 100644 index 00000000..074c73f5 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/SubscriptionService.java @@ -0,0 +1,38 @@ +package com.juick.service; + +import com.juick.Tag; +import com.juick.User; +import com.juick.server.helpers.NotifyOpts; + +import java.util.List; + +/** + * Created by aalexeev on 11/13/16. + */ +public interface SubscriptionService { + List getJIDSubscribedToUser(int uid, boolean friendsonly); + + List getSubscribedUsers(int uid, int mid); + + List getUsersSubscribedToComments(int mid, int ignore_uid); + + List getUsersSubscribedToUserRecommendations(int uid, int mid, int muid); + + boolean subscribeMessage(int mid, int vuid); + + boolean unSubscribeMessage(int mid, int vuid); + + boolean subscribeUser(User user, User toUser); + + boolean unSubscribeUser(User user, User fromUser); + + boolean subscribeTag(User user, Tag toTag); + + boolean unSubscribeTag(User user, Tag toTag); + + List getSubscribedTags(User user); + + NotifyOpts getNotifyOptions(User user); + + boolean setNotifyOptions(User user, NotifyOpts options); +} diff --git a/juick-server-core/src/main/java/com/juick/service/TagService.java b/juick-server-core/src/main/java/com/juick/service/TagService.java new file mode 100644 index 00000000..2fcc7097 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/TagService.java @@ -0,0 +1,37 @@ +package com.juick.service; + +import com.juick.Tag; +import com.juick.server.helpers.TagStats; + +import java.util.Collection; +import java.util.List; + +/** + * Created by aalexeev on 11/13/16. + */ +public interface TagService { + com.juick.Tag getTag(int tid); + + com.juick.Tag getTag(String tag, boolean autoCreate); + + List getTags(String[] tags, boolean autoCreate); + + boolean getTagNoIndex(int tagId); + + int createTag(String name); + + List getUserTagStats(int uid); + + List getUserBLTags(int uid); + + List getPopularTags(); + List getTagStats(); + + List updateTags(int mid, Collection newTags); + + List fromString(String txt, boolean tagsOnly); + + List getMessageTags(int mid); + + List getMessageTagsIDs(int mid); +} diff --git a/juick-server-core/src/main/java/com/juick/service/TelegramService.java b/juick-server-core/src/main/java/com/juick/service/TelegramService.java new file mode 100644 index 00000000..b23e3405 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/TelegramService.java @@ -0,0 +1,22 @@ +package com.juick.service; + +import java.util.List; + +/** + * Created by vt on 24/11/2016. + */ +public interface TelegramService { + boolean addChat(Long id); + + List getChats(); + + int getUser(long tgId); + + boolean createTelegramUser(long tgID, String tgName); + + boolean deleteTelegramUser(Integer uid); + + List getSubscribers(int uid); + + List getSubscribersToComments(int mid, int ignore_uid); +} diff --git a/juick-server-core/src/main/java/com/juick/service/UserService.java b/juick-server-core/src/main/java/com/juick/service/UserService.java new file mode 100644 index 00000000..a6db9f82 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/UserService.java @@ -0,0 +1,126 @@ +package com.juick.service; + +import com.juick.User; +import com.juick.server.helpers.Auth; +import com.juick.server.helpers.EmailOpts; +import com.juick.server.helpers.UserInfo; + +import java.util.Collection; +import java.util.List; +import java.util.Optional; + +/** + * Created by aalexeev on 11/13/16. + */ +public interface UserService { + enum ActiveStatus { + Inactive, + Active + } + + String getSignUpHashByJID(String jid); + + String getSignUpHashByTelegramID(Long telegramId, String username); + + int createUser(String username, String password); + + Optional getUserByUID(int uid); + + User getUserByName(String username); + + User getFullyUserByName(String username); + + User getUserByEmail(String email); + + List getFullyUsersByNames(Collection usernames); + + User getUserByJID(String jid); + + List getUsersByName(Collection unames); + + List getUsersByID(Collection uids); + + List getUsersByJID(Collection jids); + + List getJIDsbyUID(int uid); + + int getUIDbyJID(String jid); + + int getUIDbyName(String uname); + + int getUIDbyHash(String hash); + + com.juick.User getUserByHash(String hash); + + String getHashByUID(int uid); + + int getUIDByHttpAuth(String header); + + int checkPassword(String username, String password); + + boolean updatePassword(User user, String newPassword); + + int getUserOptionInt(int uid, String option, int defaultValue); + + int setUserOptionInt(int uid, String option, int value); + + UserInfo getUserInfo(User user); + + boolean updateUserInfo(User user, UserInfo info); + + boolean getCanMedia(int uid); + + boolean isInWL(int uid, int check); + + boolean isInBL(int uid, int check); + + boolean isInBLAny(int uid, int uid2); + + List checkBL(int visitor, Collection uids); + + boolean isSubscribed(int uid, int check); + + List getUserRead(int uid); + + List getUserReadLeastPopular(int uid, int cnt); + + List getUserReaders(int uid); + + List getUserFriends(int uid); + + List getUserBLUsers(int uid); + + boolean linkTwitterAccount(User user, String accessToken, String accessTokenSecret, String screenName); + + int getStatsIRead(int uid); + + int getStatsMyReaders(int uid); + + int getStatsMessages(int uid); + + int getStatsReplies(int uid); + + boolean setActiveStatusForJID(String JID, ActiveStatus jidStatus); + + List getAllJIDs(User user); + + List getAuthCodes(User user); + + List getEmails(User user); + + EmailOpts getEmailOpts(User user); + + String getEmailHash(User user); + + int deleteLoginForUser(String name); + + int setLoginForUser(int uid, String loginHash); + + void logout(int uid); + + boolean deleteJID(int uid, String jid); + + boolean unauthJID(int uid, String jid); + + List getActiveJIDs(); +} diff --git a/juick-server-core/src/main/java/com/juick/service/search/SearchService.java b/juick-server-core/src/main/java/com/juick/service/search/SearchService.java new file mode 100644 index 00000000..21deb0b1 --- /dev/null +++ b/juick-server-core/src/main/java/com/juick/service/search/SearchService.java @@ -0,0 +1,14 @@ +package com.juick.service.search; + +import java.util.List; + +/** + * Created by aalexeev on 11/18/16. + */ +public interface SearchService { + void setMaxResult(int maxResult); + + List searchInAllMessages(String searchString, int messageIdBefore); + + List searchByStringAndUser(String searchString, final int userId, int messageIdBefore); +} -- cgit v1.2.3