Attach group visibility to MessageSharedEvent.

This allows listeners to decide whether to act on the event.
This commit is contained in:
akwizgran
2022-08-10 12:33:53 +01:00
parent a261b8e739
commit a1f25c8101
8 changed files with 88 additions and 7 deletions

View File

@@ -283,6 +283,13 @@ public interface DatabaseComponent extends TransactionManager {
*/
Group getGroup(Transaction txn, GroupId g) throws DbException;
/**
* Returns the ID of the group containing the given message.
* <p/>
* Read-only.
*/
GroupId getGroupId(Transaction txn, MessageId m) throws DbException;
/**
* Returns the metadata for the given group.
* <p/>

View File

@@ -1,9 +1,13 @@
package org.briarproject.bramble.api.sync.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.Map;
import javax.annotation.concurrent.Immutable;
/**
@@ -14,12 +18,25 @@ import javax.annotation.concurrent.Immutable;
public class MessageSharedEvent extends Event {
private final MessageId messageId;
private final GroupId groupId;
private final Map<ContactId, Boolean> groupVisibility;
public MessageSharedEvent(MessageId message) {
public MessageSharedEvent(MessageId message, GroupId groupId,
Map<ContactId, Boolean> groupVisibility) {
this.messageId = message;
this.groupId = groupId;
this.groupVisibility = groupVisibility;
}
public MessageId getMessageId() {
return messageId;
}
public GroupId getGroupId() {
return groupId;
}
public Map<ContactId, Boolean> getGroupVisibility() {
return groupVisibility;
}
}