aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com/juick/service/SphinxSearchService.java
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-09-13 15:45:52 +0300
committerGravatar Vitaly Takmazov2018-09-13 15:45:52 +0300
commit62d4f6f3fabe69b0e08195e99eedd72442bffa68 (patch)
tree65d54c9d2ffe5620d27224825fb4050abe2ea912 /juick-server/src/main/java/com/juick/service/SphinxSearchService.java
parentd6bd717e553be5d339cf05bca099539844ba68a5 (diff)
hide banned from search
Diffstat (limited to 'juick-server/src/main/java/com/juick/service/SphinxSearchService.java')
-rw-r--r--juick-server/src/main/java/com/juick/service/SphinxSearchService.java11
1 files changed, 9 insertions, 2 deletions
diff --git a/juick-server/src/main/java/com/juick/service/SphinxSearchService.java b/juick-server/src/main/java/com/juick/service/SphinxSearchService.java
index 40927bbb..cdd5e92d 100644
--- a/juick-server/src/main/java/com/juick/service/SphinxSearchService.java
+++ b/juick-server/src/main/java/com/juick/service/SphinxSearchService.java
@@ -17,10 +17,12 @@
package com.juick.service;
+import com.juick.User;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
+import javax.inject.Inject;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -38,13 +40,16 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic
private int maxResult = DEFAULT_MAX_RESULT;
+ @Inject
+ UserService userService;
+
public String sortHint(String searchString) {
boolean isOneWord = searchString.split("[^\\S\\+]+").length == 1;
return isOneWord ? "extended:@id desc" : "extended:@weight desc, @id desc";
}
@Override
- public List<Integer> searchInAllMessages(final String searchString, final int page) {
+ public List<Integer> searchInAllMessages(User visitor, final String searchString, final int page) {
if (StringUtils.isBlank(searchString))
return Collections.emptyList();
@@ -52,6 +57,8 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic
sphinxQuery.put("limit", String.valueOf(maxResult));
sphinxQuery.put("mode", "any");
sphinxQuery.put("sort", sortHint(searchString));
+ String usersFilter = userService.getUserBLUsers(visitor.getUid()).stream().map(u -> String.valueOf(u.getUid())).collect(Collectors.joining(","));
+ sphinxQuery.put("!filter", usersFilter);
if (page > 0) {
sphinxQuery.put("offset", String.valueOf(page * maxResult));
}
@@ -63,7 +70,7 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic
}
@Override
- public List<Integer> searchByStringAndUser(final String searchString, final int userId, int page) {
+ public List<Integer> searchByStringAndUser(User visitor, final String searchString, final int userId, int page) {
if (StringUtils.isBlank(searchString))
return Collections.emptyList();