aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/juick/service
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2023-04-26 10:10:46 +0300
committerGravatar Vitaly Takmazov2023-04-30 11:41:27 +0300
commitcd6150df90a6ab86f20221c61c58c6864dc408fc (patch)
tree5919da0af4e716445bf5c6c4167af72263152538 /src/main/java/com/juick/service
parentc5bd1fed700c1c16c3680587a9556c06d477eb1f (diff)
Expose 'vip' and 'ignored' user lists over '/me' API endpoint
Diffstat (limited to 'src/main/java/com/juick/service')
-rw-r--r--src/main/java/com/juick/service/PostgresSearchService.java2
-rw-r--r--src/main/java/com/juick/service/SphinxSearchService.java2
-rw-r--r--src/main/java/com/juick/service/UserService.java3
-rw-r--r--src/main/java/com/juick/service/UserServiceImpl.java14
4 files changed, 17 insertions, 4 deletions
diff --git a/src/main/java/com/juick/service/PostgresSearchService.java b/src/main/java/com/juick/service/PostgresSearchService.java
index 79986670..a243b3f3 100644
--- a/src/main/java/com/juick/service/PostgresSearchService.java
+++ b/src/main/java/com/juick/service/PostgresSearchService.java
@@ -61,7 +61,7 @@ public class PostgresSearchService extends BaseJdbcService implements SearchServ
public List<Integer> search(final int visitorId, final int userId, final String searchString, final int page) {
- var usersFilter = userService.getUserBLUsers(visitorId).stream().map(User::getUid).toList();
+ var usersFilter = userService.getUserIgnoredUsers(visitorId).stream().map(User::getUid).toList();
var offset = page * maxResult;
var query = escapeQuery(searchString);
var isOneWord = query.split("[^\\S\\+]+").length == 1;
diff --git a/src/main/java/com/juick/service/SphinxSearchService.java b/src/main/java/com/juick/service/SphinxSearchService.java
index 3775d09f..8a608b44 100644
--- a/src/main/java/com/juick/service/SphinxSearchService.java
+++ b/src/main/java/com/juick/service/SphinxSearchService.java
@@ -60,7 +60,7 @@ public class SphinxSearchService extends BaseJdbcService implements SearchServic
sphinxQuery.put("limit", String.valueOf(maxResult));
sphinxQuery.put("mode", "any");
sphinxQuery.put("sort", sortHint(WebUtils.encodeSphinx(searchString)));
- String usersFilter = userService.getUserBLUsers(visitor.getUid()).stream().map(u -> String.valueOf(u.getUid())).collect(Collectors.joining(","));
+ String usersFilter = userService.getUserIgnoredUsers(visitor.getUid()).stream().map(u -> String.valueOf(u.getUid())).collect(Collectors.joining(","));
sphinxQuery.put("!filter", "user_id," + usersFilter);
if (page > 0) {
sphinxQuery.put("offset", String.valueOf(page * maxResult));
diff --git a/src/main/java/com/juick/service/UserService.java b/src/main/java/com/juick/service/UserService.java
index 0cbe104f..fe5ce23f 100644
--- a/src/main/java/com/juick/service/UserService.java
+++ b/src/main/java/com/juick/service/UserService.java
@@ -99,7 +99,8 @@ public interface UserService {
List<User> getUserFriends(int uid);
- List<User> getUserBLUsers(int uid);
+ List<User> getUserIgnoredUsers(int uid);
+ List<User> getUserVipUsers(int uid);
@CacheEvict(value = "twitter_user", key="{ #user.getUid() }")
boolean linkTwitterAccount(User user, String accessToken, String accessTokenSecret, String screenName);
diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java
index 442bd03c..c586886b 100644
--- a/src/main/java/com/juick/service/UserServiceImpl.java
+++ b/src/main/java/com/juick/service/UserServiceImpl.java
@@ -497,7 +497,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
@Transactional(readOnly = true)
@Override
- public List<User> getUserBLUsers(final int uid) {
+ public List<User> getUserIgnoredUsers(final int uid) {
return getJdbcTemplate().query("SELECT users.id,users.nick FROM users INNER JOIN bl_users " +
"ON(bl_users.bl_user_id=users.id) WHERE bl_users.user_id=? ORDER BY users.nick",
(rs, num) -> {
@@ -507,6 +507,18 @@ public class UserServiceImpl extends BaseJdbcService implements UserService {
return u;
}, uid);
}
+ @Transactional(readOnly = true)
+ @Override
+ public List<User> getUserVipUsers(final int uid) {
+ return getJdbcTemplate().query("SELECT users.id,users.nick FROM users INNER JOIN wl_users " +
+ "ON(wl_users.wl_user_id=users.id) WHERE wl_users.user_id=? ORDER BY users.nick",
+ (rs, num) -> {
+ User u = new User();
+ u.setUid(rs.getInt(1));
+ u.setName(rs.getString(2));
+ return u;
+ }, uid);
+ }
@Transactional
@Override