Add comments for group visibility.

This commit is contained in:
akwizgran
2022-08-16 14:06:12 +01:00
parent 24d4debde0
commit a57c784b47
4 changed files with 19 additions and 2 deletions

View File

@@ -3,6 +3,7 @@ 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.Group.Visibility;
import org.briarproject.bramble.api.sync.GroupId;
import org.briarproject.bramble.api.sync.MessageId;
@@ -36,6 +37,13 @@ public class MessageSharedEvent extends Event {
return groupId;
}
/**
* Returns the IDs of all contacts for which the visibility of the
* message's group is either {@link Visibility#SHARED shared} or
* {@link Visibility#VISIBLE visible}. The value in the map is true if the
* group is {@link Visibility#SHARED shared} or false if the group is
* {@link Visibility#VISIBLE visible}.
*/
public Map<ContactId, Boolean> getGroupVisibility() {
return groupVisibility;
}

View File

@@ -352,8 +352,11 @@ interface Database<T> {
throws DbException;
/**
* Returns the IDs of all contacts to which the given group's visibility is
* either {@link Visibility VISIBLE} or {@link Visibility SHARED}.
* Returns the IDs of all contacts for which the given group's visibility
* is either {@link Visibility#SHARED shared} or
* {@link Visibility#VISIBLE visible}. The value in the map is true if the
* group is {@link Visibility#SHARED shared} or false if the group is
* {@link Visibility#VISIBLE visible}.
* <p/>
* Read-only.
*/

View File

@@ -385,6 +385,9 @@ class MailboxUploadWorker implements MailboxWorker, ConnectivityObserver,
}
} else if (e instanceof MessageSharedEvent) {
MessageSharedEvent m = (MessageSharedEvent) e;
// If the contact is present in the map (ie the value is not null)
// and the value is true, the message's group is shared with the
// contact and therefore the message may now be sendable
if (m.getGroupVisibility().get(contactId) == TRUE) {
LOG.info("Message shared");
onDataToSend();

View File

@@ -235,6 +235,9 @@ class DuplexOutgoingSession implements SyncSession, EventListener {
if (c.getContactId().equals(contactId)) interrupt();
} else if (e instanceof MessageSharedEvent) {
MessageSharedEvent m = (MessageSharedEvent) e;
// If the contact is present in the map (ie the value is not null)
// and the value is true, the message's group is shared with the
// contact and therefore the message may now be sendable
if (m.getGroupVisibility().get(contactId) == TRUE) {
generateOffer();
}