transactional versions for GroupInvitationManager

This commit is contained in:
ialokim
2023-02-26 22:08:23 +01:00
parent b09ea495e7
commit ee9234e12e
3 changed files with 111 additions and 50 deletions

View File

@@ -3,6 +3,7 @@ package org.briarproject.briar.api.privategroup.invitation;
import org.briarproject.bramble.api.contact.Contact;
import org.briarproject.bramble.api.contact.ContactId;
import org.briarproject.bramble.api.db.DbException;
import org.briarproject.bramble.api.db.Transaction;
import org.briarproject.bramble.api.sync.ClientId;
import org.briarproject.bramble.api.sync.GroupId;
import org.briarproject.briar.api.client.ProtocolStateException;
@@ -47,6 +48,18 @@ public interface GroupInvitationManager extends ConversationClient {
long timestamp, byte[] signature, long autoDeleteTimer)
throws DbException;
/**
* Sends an invitation to share the given private group with the given
* contact, including an optional message.
*
* @throws ProtocolStateException if the group is no longer eligible to be
* shared with the contact, for example because an invitation is already
* pending.
*/
void sendInvitation(Transaction txn, GroupId g, ContactId c,
@Nullable String text, long timestamp, byte[] signature,
long autoDeleteTimer) throws DbException;
/**
* Responds to a pending private group invitation from the given contact.
*
@@ -56,6 +69,15 @@ public interface GroupInvitationManager extends ConversationClient {
void respondToInvitation(ContactId c, PrivateGroup g, boolean accept)
throws DbException;
/**
* Responds to a pending private group invitation from the given contact.
*
* @throws ProtocolStateException if the invitation is no longer pending,
* for example because the group has been dissolved.
*/
void respondToInvitation(Transaction txn, ContactId c, PrivateGroup g,
boolean accept) throws DbException;
/**
* Responds to a pending private group invitation from the given contact.
*
@@ -65,6 +87,15 @@ public interface GroupInvitationManager extends ConversationClient {
void respondToInvitation(ContactId c, SessionId s, boolean accept)
throws DbException;
/**
* Responds to a pending private group invitation from the given contact.
*
* @throws ProtocolStateException if the invitation is no longer pending,
* for example because the group has been dissolved.
*/
void respondToInvitation(Transaction txn, ContactId c, SessionId s,
boolean accept) throws DbException;
/**
* Makes the user's relationship with the given contact visible to the
* given private group.
@@ -74,11 +105,27 @@ public interface GroupInvitationManager extends ConversationClient {
*/
void revealRelationship(ContactId c, GroupId g) throws DbException;
/**
* Makes the user's relationship with the given contact visible to the
* given private group.
*
* @throws ProtocolStateException if the relationship is no longer eligible
* to be revealed, for example because the contact has revealed it.
*/
void revealRelationship(Transaction txn, ContactId c, GroupId g)
throws DbException;
/**
* Returns all private groups to which the user has been invited.
*/
Collection<GroupInvitationItem> getInvitations() throws DbException;
/**
* Returns all private groups to which the user has been invited.
*/
Collection<GroupInvitationItem> getInvitations(Transaction txn)
throws DbException;
/**
* Returns the current {@link SharingStatus} for the given {@link Contact}
* and {@link PrivateGroup} identified by the given {@link GroupId}.
@@ -89,4 +136,16 @@ public interface GroupInvitationManager extends ConversationClient {
* was already dissolved.
*/
SharingStatus getSharingStatus(Contact c, GroupId g) throws DbException;
/**
* Returns the current {@link SharingStatus} for the given {@link Contact}
* and {@link PrivateGroup} identified by the given {@link GroupId}.
* This indicates whether the {@link PrivateGroup} can be shared
* with the contact.
*
* @throws ProtocolStateException if {@link PrivateGroup}
* was already dissolved.
*/
SharingStatus getSharingStatus(Transaction txn, Contact c, GroupId g)
throws DbException;
}