mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
Replace MessagesCleanedUpEvent with ConversationMessagesDeletedEvent
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.bramble.api.cleanup;
|
||||
|
||||
import org.briarproject.bramble.api.cleanup.event.MessagesCleanedUpEvent;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
import org.briarproject.bramble.api.db.Transaction;
|
||||
@@ -19,8 +18,6 @@ public interface CleanupHook {
|
||||
|
||||
/**
|
||||
* Called when the cleanup deadlines of one or more messages are reached.
|
||||
* When this method returns, a {@link MessagesCleanedUpEvent} will be
|
||||
* broadcast.
|
||||
* <p>
|
||||
* The callee is not required to delete the messages, but the hook won't be
|
||||
* called again for these messages unless another cleanup timer is set (see
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.briarproject.bramble.cleanup;
|
||||
import org.briarproject.bramble.api.cleanup.CleanupHook;
|
||||
import org.briarproject.bramble.api.cleanup.CleanupManager;
|
||||
import org.briarproject.bramble.api.cleanup.event.CleanupTimerStartedEvent;
|
||||
import org.briarproject.bramble.api.cleanup.event.MessagesCleanedUpEvent;
|
||||
import org.briarproject.bramble.api.db.DatabaseComponent;
|
||||
import org.briarproject.bramble.api.db.DatabaseExecutor;
|
||||
import org.briarproject.bramble.api.db.DbException;
|
||||
@@ -146,7 +145,6 @@ class CleanupManagerImpl implements CleanupManager, Service, EventListener {
|
||||
throw new IllegalStateException("No cleanup hook for " + cv);
|
||||
}
|
||||
hook.deleteMessages(txn, groupId, messageIds);
|
||||
txn.attach(new MessagesCleanedUpEvent(groupId, messageIds));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package org.briarproject.bramble.api.cleanup.event;
|
||||
package org.briarproject.briar.api.autodelete.event;
|
||||
|
||||
import org.briarproject.bramble.api.contact.ContactId;
|
||||
import org.briarproject.bramble.api.event.Event;
|
||||
import org.briarproject.bramble.api.nullsafety.NotNullByDefault;
|
||||
import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -10,24 +10,24 @@ import java.util.Collection;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
/**
|
||||
* An event that is broadcast when one or more messages in a group are
|
||||
* cleaned up.
|
||||
* An event that is broadcast when one or more messages
|
||||
* in the private conversation with a contact have been deleted.
|
||||
*/
|
||||
@Immutable
|
||||
@NotNullByDefault
|
||||
public class MessagesCleanedUpEvent extends Event {
|
||||
public class ConversationMessagesDeletedEvent extends Event {
|
||||
|
||||
private final GroupId groupId;
|
||||
private final ContactId contactId;
|
||||
private final Collection<MessageId> messageIds;
|
||||
|
||||
public MessagesCleanedUpEvent(GroupId groupId,
|
||||
public ConversationMessagesDeletedEvent(ContactId contactId,
|
||||
Collection<MessageId> messageIds) {
|
||||
this.groupId = groupId;
|
||||
this.contactId = contactId;
|
||||
this.messageIds = messageIds;
|
||||
}
|
||||
|
||||
public GroupId getGroupId() {
|
||||
return groupId;
|
||||
public ContactId getContactId() {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
public Collection<MessageId> getMessageIds() {
|
||||
@@ -31,6 +31,7 @@ import org.briarproject.bramble.api.versioning.ClientVersioningManager.ClientVer
|
||||
import org.briarproject.briar.api.attachment.AttachmentHeader;
|
||||
import org.briarproject.briar.api.attachment.FileTooBigException;
|
||||
import org.briarproject.briar.api.autodelete.AutoDeleteManager;
|
||||
import org.briarproject.briar.api.autodelete.event.ConversationMessagesDeletedEvent;
|
||||
import org.briarproject.briar.api.client.MessageTracker;
|
||||
import org.briarproject.briar.api.client.MessageTracker.GroupCount;
|
||||
import org.briarproject.briar.api.conversation.ConversationManager.ConversationClient;
|
||||
@@ -532,6 +533,8 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
Collection<MessageId> messageIds) throws DbException {
|
||||
for (MessageId m : messageIds) deleteMessage(txn, g, m);
|
||||
recalculateGroupCount(txn, g);
|
||||
ContactId c = getContactId(txn, g);
|
||||
txn.attach(new ConversationMessagesDeletedEvent(c, messageIds));
|
||||
}
|
||||
|
||||
private void deleteMessage(Transaction txn, GroupId g, MessageId m)
|
||||
|
||||
Reference in New Issue
Block a user