diff options
author | Vitaly Takmazov | 2016-06-27 23:36:36 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2016-06-27 23:36:36 +0300 |
commit | bbc05316ebbbd8da30ac12135791e110cacbebd5 (patch) | |
tree | 60d246f0d1b0c522782ddc4dfd46abda47dc4ed7 /src/main/java/com/juick/server/MessagesQueries.java | |
parent | 9d182aa45b5e2428ba684973837a8d035c0d50a2 (diff) |
fix canviewthread
Diffstat (limited to 'src/main/java/com/juick/server/MessagesQueries.java')
-rw-r--r-- | src/main/java/com/juick/server/MessagesQueries.java | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/main/java/com/juick/server/MessagesQueries.java b/src/main/java/com/juick/server/MessagesQueries.java index 77998d16..cd098ec6 100644 --- a/src/main/java/com/juick/server/MessagesQueries.java +++ b/src/main/java/com/juick/server/MessagesQueries.java @@ -155,16 +155,18 @@ public class MessagesQueries { } public static boolean canViewThread(JdbcTemplate sql, int mid, int uid) { - - PrivacyOpts privacyOpts = sql.queryForObject("SELECT user_id,privacy FROM messages WHERE messages.message_id=?", - new Object[] {mid}, - (rs, rowNum) -> { - PrivacyOpts res = new PrivacyOpts(); - res.setUid(rs.getInt(1)); - res.setPrivacy(rs.getInt(2)); - return res; - }); - + PrivacyOpts privacyOpts; + try { + privacyOpts = sql.queryForObject("SELECT user_id,privacy FROM messages WHERE messages.message_id=?", + (rs, rowNum) -> { + PrivacyOpts res = new PrivacyOpts(); + res.setUid(rs.getInt(1)); + res.setPrivacy(rs.getInt(2)); + return res; + }, mid); + } catch (EmptyResultDataAccessException e) { + return true; + } return privacyOpts.getPrivacy() >= 0 || uid == privacyOpts.getUid() || ((privacyOpts.getPrivacy() == -1 || privacyOpts.getPrivacy() == -2) && uid > 0 |