diff options
author | Vitaly Takmazov | 2023-04-10 22:53:40 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-04-13 19:49:55 +0300 |
commit | 379f1a8661da46040332923a5ccfb555656b0a8b (patch) | |
tree | 12b3d6121d749c4dc942b10c733f77d7d6dbba94 /src/main/java/com/juick/service/MessagesServiceImpl.java | |
parent | 3a1e45d3015df62eb5768a8e6929cb41dcaf9913 (diff) |
Premium users
Diffstat (limited to 'src/main/java/com/juick/service/MessagesServiceImpl.java')
-rw-r--r-- | src/main/java/com/juick/service/MessagesServiceImpl.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java index 083524b1..53f2407c 100644 --- a/src/main/java/com/juick/service/MessagesServiceImpl.java +++ b/src/main/java/com/juick/service/MessagesServiceImpl.java @@ -83,6 +83,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ user.setName(Optional.ofNullable(rs.getString(5)).orElse(AnonymousUser.INSTANCE.getName())); user.setBanned(rs.getBoolean(6)); user.setUri(URI.create(Optional.ofNullable(rs.getString(22)).orElse(StringUtils.EMPTY))); + user.setPremium(rs.getInt("premium") > 0); msg.setUser(user); msg.setCreated(MessagesServiceImpl.this.getOffsetDateTime(rs, 7).toInstant()); msg.ReadOnly = rs.getBoolean(8); @@ -797,7 +798,8 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ COALESCE(messages.txt, '') txt, '' as q, messages.updated, 0 as to_uid, NULL as to_name, messages.updated_at, '' as m_user_uri, '' as to_uri, '' as msg_reply_uri, 0 as html, (1.*messages.replies - subscr_messages.last_read_rid) as unread, - (SELECT CASE WHEN EXISTS(SELECT * from subscr_messages where message_id=messages.message_id and suser_id=:uid) THEN 1 ELSE 0 END) subscribed + (SELECT CASE WHEN EXISTS(SELECT * from subscr_messages where message_id=messages.message_id and suser_id=:uid) THEN 1 ELSE 0 END) subscribed, + users.premium FROM messages INNER JOIN users ON messages.user_id=users.id LEFT JOIN subscr_messages ON messages.message_id=subscr_messages.message_id AND subscr_messages.suser_id=:uid LEFT JOIN favorites ON messages.message_id = favorites.message_id AND favorites.like_id=1 @@ -808,7 +810,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ messages.message_id, messages.user_id, users.nick, users.banned, messages.ts, messages.readonly, messages.privacy, messages.attach, messages.hidden, messages.repliesby, messages.txt, messages.updated, messages.replies, updated_at, - subscr_messages.last_read_rid"""; + subscr_messages.last_read_rid, users.premium"""; List<Message> msgs = getNamedParameterJdbcTemplate().query(query, new MapSqlParameterSource("ids", mids) .addValue("uid", uid), new MessageMapper()); @@ -867,7 +869,7 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ + "COALESCE(qw.user_id, m.user_id) as to_uid, COALESCE(qu.nick, mu.nick) as to_name, " + "replies.updated_at, replies.user_uri as uri, " + "qw.user_uri as to_uri, replies.reply_uri, replies.html, 0 as unread, " - + "0 as subscribed " + + "0 as subscribed, users.premium " + "FROM replies LEFT JOIN users " + "ON replies.user_id = users.id " + "LEFT JOIN replies qw ON replies.message_id = qw.message_id and replies.replyto = qw.reply_id " + "LEFT JOIN messages m on replies.message_id = m.message_id " |