diff options
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/juick/server/SubscriptionsQueries.java | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/main/java/com/juick/server/SubscriptionsQueries.java b/src/main/java/com/juick/server/SubscriptionsQueries.java index 3a76e23e..b271435b 100644 --- a/src/main/java/com/juick/server/SubscriptionsQueries.java +++ b/src/main/java/com/juick/server/SubscriptionsQueries.java @@ -6,6 +6,7 @@ package com.juick.server; import com.juick.User; import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.util.StringUtils; import java.sql.Connection; import java.sql.PreparedStatement; @@ -55,12 +56,14 @@ public class SubscriptionsQueries { public static List<User> getSubscribedUsers(JdbcTemplate sql, int uid, int mid) { List<Integer> userids = UserQueries.getUserRead(sql, uid); - List<Integer> tags = MessagesQueries.getMessageTagsIDs(sql, mid); - List<Integer> tagUsers = sql.queryForList("SELECT suser_id FROM subscr_tags " + - "WHERE tag_id IN (" + Utils.convertArrayInt2String(tags) + ") AND suser_id!=" + uid, Integer.class); Set<Integer> set = new HashSet<>(); set.addAll(userids); - set.addAll(tagUsers); + List<Integer> tags = MessagesQueries.getMessageTagsIDs(sql, mid); + if (tags.size() > 0) { + List<Integer> tagUsers = sql.queryForList("SELECT suser_id FROM subscr_tags " + + "WHERE tag_id IN (" + StringUtils.arrayToCommaDelimitedString(tags.toArray()) + ") AND suser_id!=" + uid, Integer.class); + set.addAll(tagUsers); + } return UserQueries.getUsersByID(sql, new ArrayList<>(set)); } |