mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 21:29:54 +01:00
Database.hasSendableMessages() should check for private messages.
This commit is contained in:
@@ -1475,26 +1475,42 @@ abstract class JdbcDatabase implements Database<Connection> {
|
|||||||
PreparedStatement ps = null;
|
PreparedStatement ps = null;
|
||||||
ResultSet rs = null;
|
ResultSet rs = null;
|
||||||
try {
|
try {
|
||||||
|
// Do we have any sendable private messages?
|
||||||
String sql = "SELECT messages.messageId FROM messages"
|
String sql = "SELECT messages.messageId FROM messages"
|
||||||
|
+ " JOIN statuses ON messages.messageId = statuses.messageId"
|
||||||
|
+ " WHERE messages.contactId = ? AND status = ?"
|
||||||
|
+ " LIMIT ?";
|
||||||
|
ps = txn.prepareStatement(sql);
|
||||||
|
ps.setInt(1, c.getInt());
|
||||||
|
ps.setShort(2, (short) Status.NEW.ordinal());
|
||||||
|
ps.setInt(3, 1);
|
||||||
|
rs = ps.executeQuery();
|
||||||
|
boolean found = rs.next();
|
||||||
|
if(rs.next()) throw new DbStateException();
|
||||||
|
rs.close();
|
||||||
|
ps.close();
|
||||||
|
if(found) return true;
|
||||||
|
// Do we have any sendable group messages?
|
||||||
|
sql = "SELECT messages.messageId FROM messages"
|
||||||
+ " JOIN contactSubscriptions"
|
+ " JOIN contactSubscriptions"
|
||||||
+ " ON messages.groupId = contactSubscriptions.groupId"
|
+ " ON messages.groupId = contactSubscriptions.groupId"
|
||||||
+ " JOIN visibilities"
|
+ " JOIN visibilities"
|
||||||
+ " ON messages.groupId = visibilities.groupId"
|
+ " ON messages.groupId = visibilities.groupId"
|
||||||
+ " JOIN statuses ON messages.messageId = statuses.messageId"
|
+ " AND contactSubscriptions.contactId = visibilities.contactId"
|
||||||
|
+ " JOIN statuses"
|
||||||
|
+ " ON messages.messageId = statuses.messageId"
|
||||||
|
+ " AND contactSubscriptions.contactId = statuses.contactId"
|
||||||
+ " WHERE contactSubscriptions.contactId = ?"
|
+ " WHERE contactSubscriptions.contactId = ?"
|
||||||
+ " AND visibilities.contactId = ?"
|
|
||||||
+ " AND statuses.contactId = ?"
|
|
||||||
+ " AND timestamp >= start"
|
+ " AND timestamp >= start"
|
||||||
+ " AND status = ? AND sendability > ZERO()"
|
+ " AND status = ?"
|
||||||
|
+ " AND sendability > ZERO()"
|
||||||
+ " LIMIT ?";
|
+ " LIMIT ?";
|
||||||
ps = txn.prepareStatement(sql);
|
ps = txn.prepareStatement(sql);
|
||||||
ps.setInt(1, c.getInt());
|
ps.setInt(1, c.getInt());
|
||||||
ps.setInt(2, c.getInt());
|
ps.setShort(2, (short) Status.NEW.ordinal());
|
||||||
ps.setInt(3, c.getInt());
|
ps.setInt(3, 1);
|
||||||
ps.setShort(4, (short) Status.NEW.ordinal());
|
|
||||||
ps.setInt(5, 1);
|
|
||||||
rs = ps.executeQuery();
|
rs = ps.executeQuery();
|
||||||
boolean found = rs.next();
|
found = rs.next();
|
||||||
if(rs.next()) throw new DbStateException();
|
if(rs.next()) throw new DbStateException();
|
||||||
rs.close();
|
rs.close();
|
||||||
ps.close();
|
ps.close();
|
||||||
|
|||||||
Reference in New Issue
Block a user