Messages in restricted groups should propagate without moderation.

If the group's owner is spamming, unsubscribe.
This commit is contained in:
akwizgran
2013-04-15 12:22:12 +01:00
parent 85875a4e6c
commit 42fd02d0b9
7 changed files with 786 additions and 773 deletions

View File

@@ -352,14 +352,6 @@ interface Database<T> {
Collection<PrivateMessageHeader> getPrivateMessageHeaders(T txn,
ContactId c) throws DbException;
/**
* Returns the IDs of all messages signed by the given author.
* <p>
* Locking: message read.
*/
Collection<MessageId> getMessagesByAuthor(T txn, AuthorId a)
throws DbException;
/**
* Returns the IDs of some messages received from the given contact that
* need to be acknowledged, up to the given number of messages.
@@ -554,6 +546,15 @@ interface Database<T> {
*/
Map<GroupId, Integer> getUnreadMessageCounts(T txn) throws DbException;
/**
* Returns the IDs of all messages posted by the given author to
* unrestricted groups.
* <p>
* Locking: message read.
*/
Collection<MessageId> getUnrestrictedGroupMessages(T txn, AuthorId a)
throws DbException;
/**
* Returns the contacts to which the given group is visible.
* <p>

File diff suppressed because it is too large Load Diff

View File

@@ -1601,27 +1601,6 @@ abstract class JdbcDatabase implements Database<Connection> {
}
}
public Collection<MessageId> getMessagesByAuthor(Connection txn, AuthorId a)
throws DbException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
String sql = "SELECT messageId FROM messages WHERE authorId = ?";
ps = txn.prepareStatement(sql);
ps.setBytes(1, a.getBytes());
rs = ps.executeQuery();
List<MessageId> ids = new ArrayList<MessageId>();
while(rs.next()) ids.add(new MessageId(rs.getBytes(1)));
rs.close();
ps.close();
return Collections.unmodifiableList(ids);
} catch(SQLException e) {
tryToClose(rs);
tryToClose(ps);
throw new DbException(e);
}
}
public Collection<MessageId> getMessagesToAck(Connection txn, ContactId c,
int maxMessages) throws DbException {
PreparedStatement ps = null;
@@ -2568,6 +2547,32 @@ abstract class JdbcDatabase implements Database<Connection> {
}
}
public Collection<MessageId> getUnrestrictedGroupMessages(Connection txn,
AuthorId a) throws DbException {
PreparedStatement ps = null;
ResultSet rs = null;
try {
String sql = "SELECT messageId"
+ " FROM messages AS m"
+ " JOIN groups AS g"
+ " ON m.groupId = g.groupId"
+ " WHERE authorId = ?"
+ " AND publicKey IS NULL";
ps = txn.prepareStatement(sql);
ps.setBytes(1, a.getBytes());
rs = ps.executeQuery();
List<MessageId> ids = new ArrayList<MessageId>();
while(rs.next()) ids.add(new MessageId(rs.getBytes(1)));
rs.close();
ps.close();
return Collections.unmodifiableList(ids);
} catch(SQLException e) {
tryToClose(rs);
tryToClose(ps);
throw new DbException(e);
}
}
public Collection<ContactId> getVisibility(Connection txn, GroupId g)
throws DbException {
PreparedStatement ps = null;