aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2016-06-27 23:36:36 +0300
committerGravatar Vitaly Takmazov2016-06-27 23:36:36 +0300
commitbbc05316ebbbd8da30ac12135791e110cacbebd5 (patch)
tree60d246f0d1b0c522782ddc4dfd46abda47dc4ed7 /src/main/java/com
parent9d182aa45b5e2428ba684973837a8d035c0d50a2 (diff)
fix canviewthread
Diffstat (limited to 'src/main/java/com')
-rw-r--r--src/main/java/com/juick/server/MessagesQueries.java22
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