diff options
author | Vitaly Takmazov | 2023-06-20 07:10:16 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-06-21 01:02:41 +0300 |
commit | 10dcb7324fac83c0190ff4a842360a035449f278 (patch) | |
tree | 95b90305ff7e7cdb3fd298878353ed702a0754a1 /src/main/java/com/juick/service/UserServiceImpl.java | |
parent | 314db08815ae98bff02a7489cddf861cd01f2629 (diff) |
VK: read premium status using Callback API
Diffstat (limited to 'src/main/java/com/juick/service/UserServiceImpl.java')
-rw-r--r-- | src/main/java/com/juick/service/UserServiceImpl.java | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/main/java/com/juick/service/UserServiceImpl.java b/src/main/java/com/juick/service/UserServiceImpl.java index c586886b..d19af067 100644 --- a/src/main/java/com/juick/service/UserServiceImpl.java +++ b/src/main/java/com/juick/service/UserServiceImpl.java @@ -741,14 +741,13 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { @Transactional(readOnly = true) @Override - public List<Pair<String, String>> getVkTokens(List<Integer> uids) { - return getNamedParameterJdbcTemplate().query( - """ - SELECT vk_id, access_token FROM vk WHERE crosspost = 1 AND access_token <> ''""" - + (uids.isEmpty() ? "" : " AND user_id IN (:uids)"), + public Pair<String, String> getVkTokens(int uid) { + var result = getNamedParameterJdbcTemplate().query( + "SELECT vk_id, access_token FROM vk WHERE user_id=:uid AND crosspost = 1 AND access_token <> ''", new MapSqlParameterSource() - .addValue("uids", uids), + .addValue("uid", uid), (rs, num) -> Pair.of(rs.getString(1), rs.getString(2))); + return result.isEmpty() ? null : result.get(0); } @Transactional @@ -885,7 +884,7 @@ public class UserServiceImpl extends BaseJdbcService implements UserService { @Transactional(readOnly = true) @Override public boolean canDeleteTelegramUser(User user) { - return getEmails(user).size() > 0 || getFbCrossPostStatus(user.getUid()).isConnected() || !getVkTokens(List.of(user.getUid())).isEmpty(); + return getEmails(user).size() > 0 || getFbCrossPostStatus(user.getUid()).isConnected() || getVkTokens(user.getUid()) != null; } private static class TokenMapper implements RowMapper<ExternalToken> { |