mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-19 14:19:53 +01:00
Merge branch '793-show-open-button-after-accepting-invitations' into 'master'
Show open button in private conversation after accepting invitations To keep the implementation simple, the Open button does appear where the Accept button had been previously. In order to make the Open button functional, I had to make the `GroupId` of the invitation target available to the UI. Most code in this MR is due to that.  Closes #793 See merge request !457
This commit is contained in:
@@ -49,8 +49,11 @@ import org.briarproject.bramble.util.StringUtils;
|
|||||||
import org.briarproject.briar.R;
|
import org.briarproject.briar.R;
|
||||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||||
import org.briarproject.briar.android.activity.BriarActivity;
|
import org.briarproject.briar.android.activity.BriarActivity;
|
||||||
|
import org.briarproject.briar.android.blog.BlogActivity;
|
||||||
import org.briarproject.briar.android.contact.ConversationAdapter.ConversationListener;
|
import org.briarproject.briar.android.contact.ConversationAdapter.ConversationListener;
|
||||||
|
import org.briarproject.briar.android.forum.ForumActivity;
|
||||||
import org.briarproject.briar.android.introduction.IntroductionActivity;
|
import org.briarproject.briar.android.introduction.IntroductionActivity;
|
||||||
|
import org.briarproject.briar.android.privategroup.conversation.GroupActivity;
|
||||||
import org.briarproject.briar.android.view.BriarRecyclerView;
|
import org.briarproject.briar.android.view.BriarRecyclerView;
|
||||||
import org.briarproject.briar.android.view.TextInputView;
|
import org.briarproject.briar.android.view.TextInputView;
|
||||||
import org.briarproject.briar.android.view.TextInputView.TextInputListener;
|
import org.briarproject.briar.android.view.TextInputView.TextInputListener;
|
||||||
@@ -850,6 +853,29 @@ public class ConversationActivity extends BriarActivity
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UiThread
|
||||||
|
@Override
|
||||||
|
public void openRequestedShareable(ConversationRequestItem item) {
|
||||||
|
if (item.getRequestedGroupId() == null)
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
Intent i;
|
||||||
|
switch (item.getRequestType()) {
|
||||||
|
case FORUM:
|
||||||
|
i = new Intent(this, ForumActivity.class);
|
||||||
|
break;
|
||||||
|
case BLOG:
|
||||||
|
i = new Intent(this, BlogActivity.class);
|
||||||
|
break;
|
||||||
|
case GROUP:
|
||||||
|
i = new Intent(this, GroupActivity.class);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Unknown Request Type");
|
||||||
|
}
|
||||||
|
i.putExtra(GROUP_ID, item.getRequestedGroupId().getBytes());
|
||||||
|
startActivity(i);
|
||||||
|
}
|
||||||
|
|
||||||
@DatabaseExecutor
|
@DatabaseExecutor
|
||||||
private void respondToIntroductionRequest(SessionId sessionId,
|
private void respondToIntroductionRequest(SessionId sessionId,
|
||||||
boolean accept, long time) throws DbException, FormatException {
|
boolean accept, long time) throws DbException, FormatException {
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ class ConversationAdapter
|
|||||||
void onItemVisible(ConversationItem item);
|
void onItemVisible(ConversationItem item);
|
||||||
|
|
||||||
void respondToRequest(ConversationRequestItem item, boolean accept);
|
void respondToRequest(ConversationRequestItem item, boolean accept);
|
||||||
|
|
||||||
|
void openRequestedShareable(ConversationRequestItem item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,9 +101,6 @@ abstract class ConversationItem {
|
|||||||
text = ctx.getString(
|
text = ctx.getString(
|
||||||
R.string.introduction_request_answered_received,
|
R.string.introduction_request_answered_received,
|
||||||
contactName, ir.getName());
|
contactName, ir.getName());
|
||||||
return new ConversationNoticeInItem(ir.getMessageId(),
|
|
||||||
ir.getGroupId(), text, ir.getMessage(), ir.getTimestamp(),
|
|
||||||
ir.isRead());
|
|
||||||
} else if (ir.contactExists()){
|
} else if (ir.contactExists()){
|
||||||
text = ctx.getString(
|
text = ctx.getString(
|
||||||
R.string.introduction_request_exists_received,
|
R.string.introduction_request_exists_received,
|
||||||
@@ -114,8 +111,8 @@ abstract class ConversationItem {
|
|||||||
}
|
}
|
||||||
return new ConversationRequestItem(ir.getMessageId(),
|
return new ConversationRequestItem(ir.getMessageId(),
|
||||||
ir.getGroupId(), INTRODUCTION, ir.getSessionId(), text,
|
ir.getGroupId(), INTRODUCTION, ir.getSessionId(), text,
|
||||||
ir.getMessage(), ir.getTimestamp(), ir.isRead(),
|
ir.getMessage(), ir.getTimestamp(), ir.isRead(), null,
|
||||||
ir.wasAnswered());
|
ir.wasAnswered(), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -203,14 +200,11 @@ abstract class ConversationItem {
|
|||||||
} else {
|
} else {
|
||||||
throw new IllegalArgumentException("Unknown InvitationRequest");
|
throw new IllegalArgumentException("Unknown InvitationRequest");
|
||||||
}
|
}
|
||||||
if (!ir.isAvailable()) {
|
|
||||||
return new ConversationNoticeInItem(ir.getId(), ir.getGroupId(),
|
|
||||||
text, ir.getMessage(), ir.getTimestamp(), ir.isRead());
|
|
||||||
}
|
|
||||||
return new ConversationRequestItem(ir.getId(),
|
return new ConversationRequestItem(ir.getId(),
|
||||||
ir.getGroupId(), type, ir.getSessionId(), text,
|
ir.getGroupId(), type, ir.getSessionId(), text,
|
||||||
ir.getMessage(), ir.getTimestamp(), ir.isRead(),
|
ir.getMessage(), ir.getTimestamp(), ir.isRead(),
|
||||||
!ir.isAvailable());
|
ir.getInvitedGroupId(), !ir.isAvailable(),
|
||||||
|
ir.canBeOpened());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,18 +17,23 @@ class ConversationRequestItem extends ConversationNoticeInItem {
|
|||||||
|
|
||||||
enum RequestType { INTRODUCTION, FORUM, BLOG, GROUP }
|
enum RequestType { INTRODUCTION, FORUM, BLOG, GROUP }
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private final GroupId requestedGroupId;
|
||||||
private final RequestType requestType;
|
private final RequestType requestType;
|
||||||
private final SessionId sessionId;
|
private final SessionId sessionId;
|
||||||
private boolean answered;
|
private final boolean answered, canBeOpened;
|
||||||
|
|
||||||
ConversationRequestItem(MessageId id, GroupId groupId,
|
ConversationRequestItem(MessageId id, GroupId groupId,
|
||||||
RequestType requestType, SessionId sessionId, String text,
|
RequestType requestType, SessionId sessionId, String text,
|
||||||
@Nullable String msgText, long time, boolean read,
|
@Nullable String msgText, long time, boolean read,
|
||||||
boolean answered) {
|
@Nullable GroupId requestedGroupId, boolean answered,
|
||||||
|
boolean canBeOpened) {
|
||||||
super(id, groupId, text, msgText, time, read);
|
super(id, groupId, text, msgText, time, read);
|
||||||
this.requestType = requestType;
|
this.requestType = requestType;
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
|
this.requestedGroupId = requestedGroupId;
|
||||||
this.answered = answered;
|
this.answered = answered;
|
||||||
|
this.canBeOpened = canBeOpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
RequestType getRequestType() {
|
RequestType getRequestType() {
|
||||||
@@ -39,12 +44,17 @@ class ConversationRequestItem extends ConversationNoticeInItem {
|
|||||||
return sessionId;
|
return sessionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public GroupId getRequestedGroupId() {
|
||||||
|
return requestedGroupId;
|
||||||
|
}
|
||||||
|
|
||||||
boolean wasAnswered() {
|
boolean wasAnswered() {
|
||||||
return answered;
|
return answered;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setAnswered(boolean answered) {
|
public boolean canBeOpened() {
|
||||||
this.answered = answered;
|
return canBeOpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
@LayoutRes
|
@LayoutRes
|
||||||
|
|||||||
@@ -32,15 +32,25 @@ class ConversationRequestViewHolder extends ConversationNoticeInViewHolder {
|
|||||||
final ConversationRequestItem item =
|
final ConversationRequestItem item =
|
||||||
(ConversationRequestItem) conversationItem;
|
(ConversationRequestItem) conversationItem;
|
||||||
|
|
||||||
if (item.wasAnswered()) {
|
if (item.wasAnswered() && item.canBeOpened()) {
|
||||||
|
acceptButton.setVisibility(VISIBLE);
|
||||||
|
acceptButton.setText(R.string.open);
|
||||||
|
acceptButton.setOnClickListener(new OnClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
listener.openRequestedShareable(item);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
declineButton.setVisibility(GONE);
|
||||||
|
} else if (item.wasAnswered()) {
|
||||||
acceptButton.setVisibility(GONE);
|
acceptButton.setVisibility(GONE);
|
||||||
declineButton.setVisibility(GONE);
|
declineButton.setVisibility(GONE);
|
||||||
} else {
|
} else {
|
||||||
acceptButton.setVisibility(VISIBLE);
|
acceptButton.setVisibility(VISIBLE);
|
||||||
|
acceptButton.setText(R.string.accept);
|
||||||
acceptButton.setOnClickListener(new OnClickListener() {
|
acceptButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
item.setAnswered(true);
|
|
||||||
listener.respondToRequest(item, true);
|
listener.respondToRequest(item, true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -48,7 +58,6 @@ class ConversationRequestViewHolder extends ConversationNoticeInViewHolder {
|
|||||||
declineButton.setOnClickListener(new OnClickListener() {
|
declineButton.setOnClickListener(new OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
item.setAnswered(true);
|
|
||||||
listener.respondToRequest(item, false);
|
listener.respondToRequest(item, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignEnd="@+id/text"
|
android:layout_alignEnd="@+id/text"
|
||||||
android:layout_alignRight="@+id/text"
|
android:layout_alignRight="@+id/text"
|
||||||
android:layout_below="@+id/declineButton"
|
android:layout_below="@+id/acceptButton"
|
||||||
android:layout_marginTop="@dimen/message_bubble_timestamp_margin"
|
android:layout_marginTop="@dimen/message_bubble_timestamp_margin"
|
||||||
android:textColor="@color/private_message_date"
|
android:textColor="@color/private_message_date"
|
||||||
android:textSize="@dimen/text_size_tiny"
|
android:textSize="@dimen/text_size_tiny"
|
||||||
@@ -57,6 +57,7 @@
|
|||||||
android:layout_alignEnd="@+id/text"
|
android:layout_alignEnd="@+id/text"
|
||||||
android:layout_alignRight="@+id/text"
|
android:layout_alignRight="@+id/text"
|
||||||
android:layout_below="@+id/text"
|
android:layout_below="@+id/text"
|
||||||
|
android:layout_marginBottom="-10dp"
|
||||||
android:text="@string/accept"/>
|
android:text="@string/accept"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
@@ -64,8 +65,8 @@
|
|||||||
style="@style/BriarButtonFlat.Negative"
|
style="@style/BriarButtonFlat.Negative"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/text"
|
android:layout_alignBottom="@+id/acceptButton"
|
||||||
android:layout_marginBottom="-15dp"
|
android:layout_alignTop="@+id/acceptButton"
|
||||||
android:layout_toLeftOf="@+id/acceptButton"
|
android:layout_toLeftOf="@+id/acceptButton"
|
||||||
android:layout_toStartOf="@+id/acceptButton"
|
android:layout_toStartOf="@+id/acceptButton"
|
||||||
android:text="@string/decline"/>
|
android:text="@string/decline"/>
|
||||||
|
|||||||
@@ -77,6 +77,7 @@
|
|||||||
<string name="offline">Offline</string>
|
<string name="offline">Offline</string>
|
||||||
<string name="send">Send</string>
|
<string name="send">Send</string>
|
||||||
<string name="allow">Allow</string>
|
<string name="allow">Allow</string>
|
||||||
|
<string name="open">Open</string>
|
||||||
<string name="no_data">No data</string>
|
<string name="no_data">No data</string>
|
||||||
<string name="ellipsis">…</string>
|
<string name="ellipsis">…</string>
|
||||||
<string name="text_too_long">The entered text is too long</string>
|
<string name="text_too_long">The entered text is too long</string>
|
||||||
@@ -182,8 +183,8 @@
|
|||||||
|
|
||||||
<!-- Private Group Invitations -->
|
<!-- Private Group Invitations -->
|
||||||
<string name="groups_invitations_title">Group Invitations</string>
|
<string name="groups_invitations_title">Group Invitations</string>
|
||||||
<string name="groups_invitations_invitation_sent">You have invited %1$s to join the group "%2$s".</string>
|
<string name="groups_invitations_invitation_sent">You have invited %1$s to join the group \"%2$s\".</string>
|
||||||
<string name="groups_invitations_invitation_received">%1$s has invited you to join the group "%2$s".</string>
|
<string name="groups_invitations_invitation_received">%1$s has invited you to join the group \"%2$s\".</string>
|
||||||
<string name="groups_invitations_joined">Joined group</string>
|
<string name="groups_invitations_joined">Joined group</string>
|
||||||
<string name="groups_invitations_declined">Group invitation declined</string>
|
<string name="groups_invitations_declined">Group invitation declined</string>
|
||||||
<plurals name="groups_invitations_open">
|
<plurals name="groups_invitations_open">
|
||||||
|
|||||||
@@ -37,13 +37,11 @@
|
|||||||
<style name="BriarButtonFlat.Negative" parent="Widget.AppCompat.Button.Borderless">
|
<style name="BriarButtonFlat.Negative" parent="Widget.AppCompat.Button.Borderless">
|
||||||
<item name="android:textColor">@color/briar_button_negative</item>
|
<item name="android:textColor">@color/briar_button_negative</item>
|
||||||
<item name="android:textSize">@dimen/text_size_medium</item>
|
<item name="android:textSize">@dimen/text_size_medium</item>
|
||||||
<item name="android:padding">@dimen/margin_large</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="BriarButtonFlat.Positive" parent="Widget.AppCompat.Button.Borderless">
|
<style name="BriarButtonFlat.Positive" parent="Widget.AppCompat.Button.Borderless">
|
||||||
<item name="android:textColor">@color/briar_button_positive</item>
|
<item name="android:textColor">@color/briar_button_positive</item>
|
||||||
<item name="android:textSize">@dimen/text_size_medium</item>
|
<item name="android:textSize">@dimen/text_size_medium</item>
|
||||||
<item name="android:padding">@dimen/margin_large</item>
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="BriarButtonFlat.Positive.Tiny" parent="BriarButtonFlat.Positive">
|
<style name="BriarButtonFlat.Positive.Tiny" parent="BriarButtonFlat.Positive">
|
||||||
|
|||||||
@@ -16,11 +16,12 @@ public class BlogInvitationRequest extends InvitationRequest {
|
|||||||
|
|
||||||
public BlogInvitationRequest(MessageId id, SessionId sessionId,
|
public BlogInvitationRequest(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, String blogAuthorName,
|
GroupId groupId, ContactId contactId, String blogAuthorName,
|
||||||
@Nullable String message, boolean available, long time,
|
@Nullable String message, GroupId blogId,
|
||||||
|
boolean available, boolean canBeOpened, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, sessionId, groupId, contactId, message, available, time,
|
super(id, sessionId, groupId, contactId, message, blogId, available,
|
||||||
local, sent, seen, read);
|
canBeOpened, time, local, sent, seen, read);
|
||||||
this.blogAuthorName = blogAuthorName;
|
this.blogAuthorName = blogAuthorName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,12 @@ import org.briarproject.briar.api.sharing.InvitationResponse;
|
|||||||
public class BlogInvitationResponse extends InvitationResponse {
|
public class BlogInvitationResponse extends InvitationResponse {
|
||||||
|
|
||||||
public BlogInvitationResponse(MessageId id, SessionId sessionId,
|
public BlogInvitationResponse(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, boolean accept, long time,
|
GroupId groupId, ContactId contactId, GroupId blogId,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean accept, long time, boolean local, boolean sent,
|
||||||
|
boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, sessionId, groupId, contactId, accept, time, local, sent,
|
super(id, sessionId, groupId, contactId, blogId, accept, time, local,
|
||||||
seen, read);
|
sent, seen, read);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,12 +17,13 @@ public class ForumInvitationRequest extends InvitationRequest {
|
|||||||
private final String forumName;
|
private final String forumName;
|
||||||
|
|
||||||
public ForumInvitationRequest(MessageId id, SessionId sessionId,
|
public ForumInvitationRequest(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, String forumName,
|
GroupId groupId, ContactId contactId, GroupId forumId,
|
||||||
@Nullable String message, boolean available, long time,
|
String forumName, @Nullable String message, boolean available,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean canBeOpened, long time, boolean local, boolean sent,
|
||||||
|
boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, sessionId, groupId, contactId, message, available, time,
|
super(id, sessionId, groupId, contactId, message, forumId, available,
|
||||||
local, sent, seen, read);
|
canBeOpened, time, local, sent, seen, read);
|
||||||
this.forumName = forumName;
|
this.forumName = forumName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,12 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
public class ForumInvitationResponse extends InvitationResponse {
|
public class ForumInvitationResponse extends InvitationResponse {
|
||||||
|
|
||||||
public ForumInvitationResponse(MessageId id, SessionId sessionId,
|
public ForumInvitationResponse(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, boolean accept, long time,
|
GroupId groupId, ContactId contactId, GroupId forumId,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean accept, long time, boolean local, boolean sent,
|
||||||
|
boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, sessionId, groupId, contactId, accept, time, local, sent,
|
super(id, sessionId, groupId, contactId, forumId, accept, time, local,
|
||||||
seen, read);
|
sent, seen, read);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,10 +20,11 @@ public class GroupInvitationRequest extends InvitationRequest {
|
|||||||
|
|
||||||
public GroupInvitationRequest(MessageId id, SessionId sessionId,
|
public GroupInvitationRequest(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, @Nullable String message,
|
GroupId groupId, ContactId contactId, @Nullable String message,
|
||||||
String groupName, Author creator, boolean available, long time,
|
GroupId privateGroupId, String groupName, Author creator,
|
||||||
|
boolean available, boolean canBeOpened, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
super(id, sessionId, groupId, contactId, message, available, time,
|
super(id, sessionId, groupId, contactId, message, privateGroupId,
|
||||||
local, sent, seen, read);
|
available, canBeOpened, time, local, sent, seen, read);
|
||||||
this.groupName = groupName;
|
this.groupName = groupName;
|
||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ import javax.annotation.concurrent.Immutable;
|
|||||||
public class GroupInvitationResponse extends InvitationResponse {
|
public class GroupInvitationResponse extends InvitationResponse {
|
||||||
|
|
||||||
public GroupInvitationResponse(MessageId id, SessionId sessionId,
|
public GroupInvitationResponse(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, boolean accept, long time,
|
GroupId groupId, ContactId contactId, GroupId privateGroupId,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean accept, long time, boolean local, boolean sent,
|
||||||
super(id, sessionId, groupId, contactId, accept, time, local, sent,
|
boolean seen, boolean read) {
|
||||||
seen, read);
|
super(id, sessionId, groupId, contactId, privateGroupId, accept, time,
|
||||||
|
local, sent, seen, read);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import org.briarproject.bramble.api.sync.MessageId;
|
|||||||
import org.briarproject.briar.api.client.BaseMessageHeader;
|
import org.briarproject.briar.api.client.BaseMessageHeader;
|
||||||
import org.briarproject.briar.api.client.SessionId;
|
import org.briarproject.briar.api.client.SessionId;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
@Immutable
|
@Immutable
|
||||||
@@ -15,14 +16,16 @@ public abstract class InvitationMessage extends BaseMessageHeader {
|
|||||||
|
|
||||||
private final SessionId sessionId;
|
private final SessionId sessionId;
|
||||||
private final ContactId contactId;
|
private final ContactId contactId;
|
||||||
|
private final GroupId invitedGroupId;
|
||||||
|
|
||||||
public InvitationMessage(MessageId id, SessionId sessionId, GroupId groupId,
|
public InvitationMessage(MessageId id, SessionId sessionId, GroupId groupId,
|
||||||
ContactId contactId, long time, boolean local, boolean sent,
|
ContactId contactId, GroupId invitedGroupId, long time,
|
||||||
boolean seen, boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, groupId, time, local, read, sent, seen);
|
super(id, groupId, time, local, read, sent, seen);
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
this.contactId = contactId;
|
this.contactId = contactId;
|
||||||
|
this.invitedGroupId = invitedGroupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionId getSessionId() {
|
public SessionId getSessionId() {
|
||||||
@@ -33,4 +36,9 @@ public abstract class InvitationMessage extends BaseMessageHeader {
|
|||||||
return contactId;
|
return contactId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public GroupId getInvitedGroupId() {
|
||||||
|
return invitedGroupId;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,16 +15,19 @@ public abstract class InvitationRequest extends InvitationMessage {
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String message;
|
private final String message;
|
||||||
private final boolean available;
|
private final boolean available, canBeOpened;
|
||||||
|
|
||||||
public InvitationRequest(MessageId id, SessionId sessionId, GroupId groupId,
|
public InvitationRequest(MessageId id, SessionId sessionId, GroupId groupId,
|
||||||
ContactId contactId, @Nullable String message, boolean available,
|
ContactId contactId, @Nullable String message,
|
||||||
long time, boolean local, boolean sent, boolean seen,
|
GroupId invitedGroupId, boolean available,
|
||||||
boolean read) {
|
boolean canBeOpened, long time, boolean local, boolean sent,
|
||||||
|
boolean seen, boolean read) {
|
||||||
super(id, sessionId, groupId, contactId, time, local, sent, seen, read);
|
super(id, sessionId, groupId, contactId, invitedGroupId, time, local,
|
||||||
|
sent, seen, read);
|
||||||
|
if (available && canBeOpened) throw new IllegalArgumentException();
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.available = available;
|
this.available = available;
|
||||||
|
this.canBeOpened = canBeOpened;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -36,4 +39,8 @@ public abstract class InvitationRequest extends InvitationMessage {
|
|||||||
return available;
|
return available;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean canBeOpened() {
|
||||||
|
return canBeOpened;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,10 +15,12 @@ public abstract class InvitationResponse extends InvitationMessage {
|
|||||||
private final boolean accept;
|
private final boolean accept;
|
||||||
|
|
||||||
public InvitationResponse(MessageId id, SessionId sessionId,
|
public InvitationResponse(MessageId id, SessionId sessionId,
|
||||||
GroupId groupId, ContactId contactId, boolean accept, long time,
|
GroupId groupId, ContactId contactId,
|
||||||
|
GroupId invitedGroupId, boolean accept, long time,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
|
|
||||||
super(id, sessionId, groupId, contactId, time, local, sent, seen, read);
|
super(id, sessionId, groupId, contactId, invitedGroupId, time, local,
|
||||||
|
sent, seen, read);
|
||||||
this.accept = accept;
|
this.accept = accept;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ class CreatorProtocolEngine extends AbstractProtocolEngine<CreatorSession> {
|
|||||||
GroupInvitationMessage m, ContactId c, boolean accept) {
|
GroupInvitationMessage m, ContactId c, boolean accept) {
|
||||||
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
||||||
return new GroupInvitationResponse(m.getId(), sessionId,
|
return new GroupInvitationResponse(m.getId(), sessionId,
|
||||||
m.getPrivateGroupId(), c, accept, m.getTimestamp(), false,
|
m.getContactGroupId(), c, m.getPrivateGroupId(), accept,
|
||||||
false, true, false);
|
m.getTimestamp(), false, false, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -381,10 +381,12 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
|||||||
m, meta, status));
|
m, meta, status));
|
||||||
} else if (type == JOIN) {
|
} else if (type == JOIN) {
|
||||||
messages.add(
|
messages.add(
|
||||||
parseInvitationResponse(c, m, meta, status, true));
|
parseInvitationResponse(c, contactGroupId, m, meta,
|
||||||
|
status, true));
|
||||||
} else if (type == LEAVE) {
|
} else if (type == LEAVE) {
|
||||||
messages.add(
|
messages.add(
|
||||||
parseInvitationResponse(c, m, meta, status, false));
|
parseInvitationResponse(c, contactGroupId, m, meta,
|
||||||
|
status, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.commitTransaction(txn);
|
db.commitTransaction(txn);
|
||||||
@@ -403,10 +405,13 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
|||||||
SessionId sessionId = getSessionId(meta.getPrivateGroupId());
|
SessionId sessionId = getSessionId(meta.getPrivateGroupId());
|
||||||
// Look up the invite message to get the details of the private group
|
// Look up the invite message to get the details of the private group
|
||||||
InviteMessage invite = getInviteMessage(txn, m);
|
InviteMessage invite = getInviteMessage(txn, m);
|
||||||
|
boolean canBeOpened = db.containsGroup(txn, invite.getPrivateGroupId());
|
||||||
return new GroupInvitationRequest(m, sessionId, contactGroupId, c,
|
return new GroupInvitationRequest(m, sessionId, contactGroupId, c,
|
||||||
invite.getMessage(), invite.getGroupName(), invite.getCreator(),
|
invite.getMessage(), invite.getPrivateGroupId(),
|
||||||
meta.isAvailableToAnswer(), meta.getTimestamp(), meta.isLocal(),
|
invite.getGroupName(), invite.getCreator(),
|
||||||
status.isSent(), status.isSeen(), meta.isRead());
|
meta.isAvailableToAnswer(), canBeOpened, meta.getTimestamp(),
|
||||||
|
meta.isLocal(), status.isSent(), status.isSeen(),
|
||||||
|
meta.isRead());
|
||||||
}
|
}
|
||||||
|
|
||||||
private InviteMessage getInviteMessage(Transaction txn, MessageId m)
|
private InviteMessage getInviteMessage(Transaction txn, MessageId m)
|
||||||
@@ -418,11 +423,12 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private GroupInvitationResponse parseInvitationResponse(ContactId c,
|
private GroupInvitationResponse parseInvitationResponse(ContactId c,
|
||||||
MessageId m, MessageMetadata meta, MessageStatus status,
|
GroupId contactGroupId, MessageId m, MessageMetadata meta,
|
||||||
boolean accept) throws DbException, FormatException {
|
MessageStatus status, boolean accept)
|
||||||
|
throws DbException, FormatException {
|
||||||
SessionId sessionId = getSessionId(meta.getPrivateGroupId());
|
SessionId sessionId = getSessionId(meta.getPrivateGroupId());
|
||||||
return new GroupInvitationResponse(m, sessionId,
|
return new GroupInvitationResponse(m, sessionId, contactGroupId, c,
|
||||||
meta.getPrivateGroupId(), c, accept, meta.getTimestamp(),
|
meta.getPrivateGroupId(), accept, meta.getTimestamp(),
|
||||||
meta.isLocal(), status.isSent(), status.isSeen(),
|
meta.isLocal(), status.isSent(), status.isSeen(),
|
||||||
meta.isRead());
|
meta.isRead());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -318,8 +318,8 @@ class InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> {
|
|||||||
ContactId c) {
|
ContactId c) {
|
||||||
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
||||||
return new GroupInvitationRequest(m.getId(), sessionId,
|
return new GroupInvitationRequest(m.getId(), sessionId,
|
||||||
m.getContactGroupId(), c, m.getMessage(), m.getGroupName(),
|
m.getContactGroupId(), c, m.getMessage(), m.getPrivateGroupId(),
|
||||||
m.getCreator(), true, m.getTimestamp(), false, false, true,
|
m.getGroupName(), m.getCreator(), true, false, m.getTimestamp(),
|
||||||
false);
|
false, false, true, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import org.briarproject.briar.api.sharing.InvitationMessage;
|
|||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.annotation.concurrent.Immutable;
|
import javax.annotation.concurrent.Immutable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
@@ -133,21 +134,23 @@ class BlogSharingManagerImpl extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InvitationMessage createInvitationRequest(MessageId id,
|
protected InvitationMessage createInvitationRequest(MessageId id,
|
||||||
BlogInvitation msg, ContactId contactId, boolean available,
|
BlogInvitation msg, ContactId contactId, GroupId blogId,
|
||||||
long time, boolean local, boolean sent, boolean seen,
|
boolean available, boolean canBeOpened, long time, boolean local,
|
||||||
boolean read) {
|
boolean sent, boolean seen, boolean read) {
|
||||||
|
|
||||||
return new BlogInvitationRequest(id, msg.getSessionId(),
|
return new BlogInvitationRequest(id, msg.getSessionId(),
|
||||||
msg.getGroupId(), contactId, msg.getBlogAuthorName(),
|
msg.getGroupId(), contactId, msg.getBlogAuthorName(),
|
||||||
msg.getMessage(), available, time, local, sent, seen, read);
|
msg.getMessage(), blogId, available, canBeOpened, time, local,
|
||||||
|
sent, seen, read);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InvitationMessage createInvitationResponse(MessageId id,
|
protected InvitationMessage createInvitationResponse(MessageId id,
|
||||||
SessionId sessionId, GroupId groupId, ContactId contactId,
|
SessionId sessionId, GroupId groupId, ContactId contactId,
|
||||||
boolean accept, long time,
|
GroupId blogId, boolean accept, long time, boolean local,
|
||||||
boolean local, boolean sent, boolean seen, boolean read) {
|
boolean sent, boolean seen, boolean read) {
|
||||||
return new BlogInvitationResponse(id, sessionId, groupId, contactId,
|
return new BlogInvitationResponse(id, sessionId, groupId, contactId,
|
||||||
accept, time, local, sent, seen, read);
|
blogId, accept, time, local, sent, seen, read);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -333,14 +336,17 @@ class BlogSharingManagerImpl extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlogInvitationRequestReceivedEvent build(
|
public BlogInvitationRequestReceivedEvent build(
|
||||||
BlogInviteeSessionState localState, long time, String msg) {
|
BlogInviteeSessionState localState, long time,
|
||||||
|
@Nullable String msg) {
|
||||||
Blog blog = sFactory.parse(localState);
|
Blog blog = sFactory.parse(localState);
|
||||||
ContactId contactId = localState.getContactId();
|
ContactId contactId = localState.getContactId();
|
||||||
BlogInvitationRequest request =
|
BlogInvitationRequest request =
|
||||||
new BlogInvitationRequest(localState.getInvitationId(),
|
new BlogInvitationRequest(localState.getInvitationId(),
|
||||||
localState.getSessionId(), localState.getContactGroupId(),
|
localState.getSessionId(),
|
||||||
contactId, blog.getAuthor().getName(), msg, true,
|
localState.getContactGroupId(), contactId,
|
||||||
time, false, false, false, false);
|
blog.getAuthor().getName(), msg,
|
||||||
|
localState.getShareableId(), true, false, time,
|
||||||
|
false, false, false, false);
|
||||||
return new BlogInvitationRequestReceivedEvent(blog, contactId,
|
return new BlogInvitationRequestReceivedEvent(blog, contactId,
|
||||||
request);
|
request);
|
||||||
}
|
}
|
||||||
@@ -358,8 +364,9 @@ class BlogSharingManagerImpl extends
|
|||||||
BlogInvitationResponse response =
|
BlogInvitationResponse response =
|
||||||
new BlogInvitationResponse(responseId,
|
new BlogInvitationResponse(responseId,
|
||||||
localState.getSessionId(),
|
localState.getSessionId(),
|
||||||
localState.getShareableId(),
|
localState.getContactGroupId(),
|
||||||
localState.getContactId(), accept, time, false,
|
localState.getContactId(),
|
||||||
|
localState.getShareableId(), accept, time, false,
|
||||||
false, false, false);
|
false, false, false);
|
||||||
return new BlogInvitationResponseReceivedEvent(c, response);
|
return new BlogInvitationResponseReceivedEvent(c, response);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import org.briarproject.briar.api.sharing.InvitationMessage;
|
|||||||
|
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static org.briarproject.briar.api.forum.ForumConstants.FORUM_NAME;
|
import static org.briarproject.briar.api.forum.ForumConstants.FORUM_NAME;
|
||||||
@@ -81,21 +82,22 @@ class ForumSharingManagerImpl extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InvitationMessage createInvitationRequest(MessageId id,
|
protected InvitationMessage createInvitationRequest(MessageId id,
|
||||||
ForumInvitation msg, ContactId contactId, boolean available,
|
ForumInvitation msg, ContactId contactId, GroupId forumId,
|
||||||
long time, boolean local, boolean sent, boolean seen,
|
boolean available, boolean canBeOpened, long time,
|
||||||
boolean read) {
|
boolean local, boolean sent, boolean seen, boolean read) {
|
||||||
return new ForumInvitationRequest(id, msg.getSessionId(),
|
return new ForumInvitationRequest(id, msg.getSessionId(),
|
||||||
msg.getGroupId(), contactId, msg.getForumName(),
|
msg.getGroupId(), contactId, forumId, msg.getForumName(),
|
||||||
msg.getMessage(), available, time, local, sent, seen, read);
|
msg.getMessage(), available, canBeOpened, time, local, sent,
|
||||||
|
seen, read);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected InvitationMessage createInvitationResponse(MessageId id,
|
protected InvitationMessage createInvitationResponse(MessageId id,
|
||||||
SessionId sessionId, GroupId groupId, ContactId contactId,
|
SessionId sessionId, GroupId groupId, ContactId contactId,
|
||||||
boolean accept, long time, boolean local, boolean sent,
|
GroupId forumId, boolean accept, long time, boolean local,
|
||||||
boolean seen, boolean read) {
|
boolean sent, boolean seen, boolean read) {
|
||||||
return new ForumInvitationResponse(id, sessionId, groupId, contactId,
|
return new ForumInvitationResponse(id, sessionId, groupId, contactId,
|
||||||
accept, time, local, sent, seen, read);
|
forumId, accept, time, local, sent, seen, read);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -263,13 +265,15 @@ class ForumSharingManagerImpl extends
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ForumInvitationRequestReceivedEvent build(
|
public ForumInvitationRequestReceivedEvent build(
|
||||||
ForumInviteeSessionState localState, long time, String msg) {
|
ForumInviteeSessionState localState, long time,
|
||||||
|
@Nullable String msg) {
|
||||||
Forum forum = sFactory.parse(localState);
|
Forum forum = sFactory.parse(localState);
|
||||||
ContactId contactId = localState.getContactId();
|
ContactId contactId = localState.getContactId();
|
||||||
ForumInvitationRequest request = new ForumInvitationRequest(
|
ForumInvitationRequest request = new ForumInvitationRequest(
|
||||||
localState.getInvitationId(), localState.getSessionId(),
|
localState.getInvitationId(), localState.getSessionId(),
|
||||||
localState.getContactGroupId(), contactId, forum.getName(), msg,
|
localState.getContactGroupId(), contactId,
|
||||||
true, time, false, false, false, false);
|
localState.getShareableId(), forum.getName(), msg, true,
|
||||||
|
false, time, false, false, false, false);
|
||||||
return new ForumInvitationRequestReceivedEvent(forum, contactId,
|
return new ForumInvitationRequestReceivedEvent(forum, contactId,
|
||||||
request);
|
request);
|
||||||
}
|
}
|
||||||
@@ -287,8 +291,9 @@ class ForumSharingManagerImpl extends
|
|||||||
throw new IllegalStateException("No responseId");
|
throw new IllegalStateException("No responseId");
|
||||||
ForumInvitationResponse response = new ForumInvitationResponse(
|
ForumInvitationResponse response = new ForumInvitationResponse(
|
||||||
responseId, localState.getSessionId(),
|
responseId, localState.getSessionId(),
|
||||||
localState.getShareableId(), localState.getContactId(),
|
localState.getContactGroupId(), localState.getContactId(),
|
||||||
accept, time, false, false, false, false);
|
localState.getShareableId(), accept, time, false, false,
|
||||||
|
false, false);
|
||||||
return new ForumInvitationResponseReceivedEvent(name, c, response);
|
return new ForumInvitationResponseReceivedEvent(name, c, response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,13 +125,14 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
protected abstract ClientId getClientId();
|
protected abstract ClientId getClientId();
|
||||||
|
|
||||||
protected abstract InvitationMessage createInvitationRequest(MessageId id,
|
protected abstract InvitationMessage createInvitationRequest(MessageId id,
|
||||||
I msg, ContactId contactId, boolean available, long time,
|
I msg, ContactId contactId, GroupId shareableId, boolean available,
|
||||||
boolean local, boolean sent, boolean seen, boolean read);
|
boolean canBeOpened, long time, boolean local, boolean sent,
|
||||||
|
boolean seen, boolean read);
|
||||||
|
|
||||||
protected abstract InvitationMessage createInvitationResponse(MessageId id,
|
protected abstract InvitationMessage createInvitationResponse(MessageId id,
|
||||||
SessionId sessionId, GroupId groupId, ContactId contactId,
|
SessionId sessionId, GroupId groupId, ContactId contactId,
|
||||||
boolean accept, long time, boolean local, boolean sent,
|
GroupId shareableId, boolean accept, long time, boolean local,
|
||||||
boolean seen, boolean read);
|
boolean sent, boolean seen, boolean read);
|
||||||
|
|
||||||
protected abstract ShareableFactory<S, I, IS, SS> getSFactory();
|
protected abstract ShareableFactory<S, I, IS, SS> getSFactory();
|
||||||
|
|
||||||
@@ -391,26 +392,31 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
try {
|
try {
|
||||||
MessageStatus status =
|
MessageStatus status =
|
||||||
db.getMessageStatus(txn, contactId, m.getKey());
|
db.getMessageStatus(txn, contactId, m.getKey());
|
||||||
|
SharingSessionState s;
|
||||||
long time = d.getLong(TIME);
|
long time = d.getLong(TIME);
|
||||||
boolean local = d.getBoolean(LOCAL);
|
boolean local = d.getBoolean(LOCAL);
|
||||||
boolean read = d.getBoolean(MSG_KEY_READ, false);
|
boolean read = d.getBoolean(MSG_KEY_READ, false);
|
||||||
boolean available = false;
|
boolean available = false, canBeOpened = false;
|
||||||
|
|
||||||
if (type == SHARE_MSG_TYPE_INVITATION) {
|
if (type == SHARE_MSG_TYPE_INVITATION) {
|
||||||
I msg = getIFactory().build(group.getId(), d);
|
I msg = getIFactory().build(group.getId(), d);
|
||||||
|
SessionId sessionId = msg.getSessionId();
|
||||||
|
s = getSessionState(txn, sessionId, true);
|
||||||
if (!local) {
|
if (!local) {
|
||||||
// figure out whether the shareable is still available
|
// figure out whether the shareable is still available
|
||||||
SharingSessionState s =
|
|
||||||
getSessionState(txn, msg.getSessionId(),
|
|
||||||
true);
|
|
||||||
if (!(s instanceof InviteeSessionState))
|
if (!(s instanceof InviteeSessionState))
|
||||||
continue;
|
continue;
|
||||||
available = ((InviteeSessionState) s).getState() ==
|
available = ((InviteeSessionState) s).getState() ==
|
||||||
AWAIT_LOCAL_RESPONSE;
|
AWAIT_LOCAL_RESPONSE;
|
||||||
|
if (!available) {
|
||||||
|
canBeOpened = db.containsGroup(txn,
|
||||||
|
s.getShareableId());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
InvitationMessage im =
|
InvitationMessage im =
|
||||||
createInvitationRequest(m.getKey(), msg,
|
createInvitationRequest(m.getKey(), msg,
|
||||||
contactId, available, time, local,
|
contactId, s.getShareableId(),
|
||||||
|
available, canBeOpened, time, local,
|
||||||
status.isSent(), status.isSeen(), read);
|
status.isSent(), status.isSeen(), read);
|
||||||
list.add(im);
|
list.add(im);
|
||||||
} else if (type == SHARE_MSG_TYPE_ACCEPT ||
|
} else if (type == SHARE_MSG_TYPE_ACCEPT ||
|
||||||
@@ -419,10 +425,12 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
|||||||
BaseMessage msg = BaseMessage
|
BaseMessage msg = BaseMessage
|
||||||
.from(getIFactory(), group.getId(), d);
|
.from(getIFactory(), group.getId(), d);
|
||||||
SessionId sessionId = msg.getSessionId();
|
SessionId sessionId = msg.getSessionId();
|
||||||
InvitationMessage im = createInvitationResponse(
|
s = getSessionState(txn, sessionId, true);
|
||||||
m.getKey(), sessionId, group.getId(), contactId,
|
InvitationMessage im =
|
||||||
accept, time, local, status.isSent(),
|
createInvitationResponse(m.getKey(), sessionId,
|
||||||
status.isSeen(), read);
|
group.getId(), contactId,
|
||||||
|
s.getShareableId(), accept, time, local,
|
||||||
|
status.isSent(), status.isSeen(), read);
|
||||||
list.add(im);
|
list.add(im);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("Unexpected Message Type");
|
throw new RuntimeException("Unexpected Message Type");
|
||||||
|
|||||||
@@ -640,13 +640,17 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
new HashMap<MessageId, BdfDictionary>();
|
new HashMap<MessageId, BdfDictionary>();
|
||||||
results.put(message.getId(), meta);
|
results.put(message.getId(), meta);
|
||||||
results.put(messageId2, meta2);
|
results.put(messageId2, meta2);
|
||||||
long time1 = 1L, time2 = 2L;
|
final long time1 = 1L, time2 = 2L;
|
||||||
final MessageMetadata messageMetadata1 =
|
final MessageMetadata messageMetadata1 =
|
||||||
new MessageMetadata(INVITE, privateGroup.getId(), time1, true,
|
new MessageMetadata(INVITE, privateGroup.getId(), time1, true,
|
||||||
true, true, true);
|
true, true, false);
|
||||||
final MessageMetadata messageMetadata2 =
|
final MessageMetadata messageMetadata2 =
|
||||||
new MessageMetadata(JOIN, privateGroup.getId(), time2, true,
|
new MessageMetadata(JOIN, privateGroup.getId(), time2, true,
|
||||||
true, true, true);
|
true, true, true);
|
||||||
|
final InviteMessage invite =
|
||||||
|
new InviteMessage(message.getId(), contactGroup.getId(),
|
||||||
|
privateGroup.getId(), time1, "name", author,
|
||||||
|
new byte[0], null, new byte[0]);
|
||||||
|
|
||||||
context.checking(new Expectations() {{
|
context.checking(new Expectations() {{
|
||||||
oneOf(db).startTransaction(true);
|
oneOf(db).startTransaction(true);
|
||||||
@@ -669,6 +673,9 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
|||||||
oneOf(clientHelper).toList(message);
|
oneOf(clientHelper).toList(message);
|
||||||
will(returnValue(body));
|
will(returnValue(body));
|
||||||
oneOf(messageParser).parseInviteMessage(message, body);
|
oneOf(messageParser).parseInviteMessage(message, body);
|
||||||
|
will(returnValue(invite));
|
||||||
|
oneOf(db).containsGroup(txn, privateGroup.getId());
|
||||||
|
will(returnValue(true));
|
||||||
// second message
|
// second message
|
||||||
oneOf(messageParser).parseMetadata(meta2);
|
oneOf(messageParser).parseMetadata(meta2);
|
||||||
will(returnValue(messageMetadata2));
|
will(returnValue(messageMetadata2));
|
||||||
|
|||||||
Reference in New Issue
Block a user