mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Show open button in private conversation after accepting invitations
This commit is contained in:
@@ -49,8 +49,11 @@ import org.briarproject.bramble.util.StringUtils;
|
||||
import org.briarproject.briar.R;
|
||||
import org.briarproject.briar.android.activity.ActivityComponent;
|
||||
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.forum.ForumActivity;
|
||||
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.TextInputView;
|
||||
import org.briarproject.briar.android.view.TextInputView.TextInputListener;
|
||||
@@ -850,6 +853,28 @@ public class ConversationActivity extends BriarActivity
|
||||
});
|
||||
}
|
||||
|
||||
@UiThread
|
||||
@Override
|
||||
public void open(ConversationRequestItem item) {
|
||||
if (item.getRequestedGroupId() == null) return;
|
||||
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
|
||||
private void respondToIntroductionRequest(SessionId sessionId,
|
||||
boolean accept, long time) throws DbException, FormatException {
|
||||
|
||||
@@ -139,6 +139,9 @@ class ConversationAdapter
|
||||
void onItemVisible(ConversationItem item);
|
||||
|
||||
void respondToRequest(ConversationRequestItem item, boolean accept);
|
||||
|
||||
void open(ConversationRequestItem item);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -101,9 +101,6 @@ abstract class ConversationItem {
|
||||
text = ctx.getString(
|
||||
R.string.introduction_request_answered_received,
|
||||
contactName, ir.getName());
|
||||
return new ConversationNoticeInItem(ir.getMessageId(),
|
||||
ir.getGroupId(), text, ir.getMessage(), ir.getTimestamp(),
|
||||
ir.isRead());
|
||||
} else if (ir.contactExists()){
|
||||
text = ctx.getString(
|
||||
R.string.introduction_request_exists_received,
|
||||
@@ -114,7 +111,7 @@ abstract class ConversationItem {
|
||||
}
|
||||
return new ConversationRequestItem(ir.getMessageId(),
|
||||
ir.getGroupId(), INTRODUCTION, ir.getSessionId(), text,
|
||||
ir.getMessage(), ir.getTimestamp(), ir.isRead(),
|
||||
ir.getMessage(), ir.getTimestamp(), ir.isRead(), null,
|
||||
ir.wasAnswered());
|
||||
}
|
||||
}
|
||||
@@ -203,14 +200,10 @@ abstract class ConversationItem {
|
||||
} else {
|
||||
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(),
|
||||
ir.getGroupId(), type, ir.getSessionId(), text,
|
||||
ir.getMessage(), ir.getTimestamp(), ir.isRead(),
|
||||
!ir.isAvailable());
|
||||
ir.getInvitedGroupId(), !ir.isAvailable());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,8 @@ class ConversationRequestItem extends ConversationNoticeInItem {
|
||||
|
||||
enum RequestType { INTRODUCTION, FORUM, BLOG, GROUP }
|
||||
|
||||
@Nullable
|
||||
private final GroupId requestedGroupId;
|
||||
private final RequestType requestType;
|
||||
private final SessionId sessionId;
|
||||
private boolean answered;
|
||||
@@ -24,10 +26,11 @@ class ConversationRequestItem extends ConversationNoticeInItem {
|
||||
ConversationRequestItem(MessageId id, GroupId groupId,
|
||||
RequestType requestType, SessionId sessionId, String text,
|
||||
@Nullable String msgText, long time, boolean read,
|
||||
boolean answered) {
|
||||
@Nullable GroupId requestedGroupId, boolean answered) {
|
||||
super(id, groupId, text, msgText, time, read);
|
||||
this.requestType = requestType;
|
||||
this.sessionId = sessionId;
|
||||
this.requestedGroupId = requestedGroupId;
|
||||
this.answered = answered;
|
||||
}
|
||||
|
||||
@@ -39,6 +42,11 @@ class ConversationRequestItem extends ConversationNoticeInItem {
|
||||
return sessionId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GroupId getRequestedGroupId() {
|
||||
return requestedGroupId;
|
||||
}
|
||||
|
||||
boolean wasAnswered() {
|
||||
return answered;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.briarproject.briar.android.contact.ConversationAdapter.ConversationLi
|
||||
|
||||
import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static org.briarproject.briar.android.contact.ConversationRequestItem.RequestType.INTRODUCTION;
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
@@ -32,11 +33,23 @@ class ConversationRequestViewHolder extends ConversationNoticeInViewHolder {
|
||||
final ConversationRequestItem item =
|
||||
(ConversationRequestItem) conversationItem;
|
||||
|
||||
if (item.wasAnswered()) {
|
||||
if (item.getRequestType() == INTRODUCTION && item.wasAnswered()) {
|
||||
acceptButton.setVisibility(GONE);
|
||||
declineButton.setVisibility(GONE);
|
||||
} else if (item.wasAnswered()) {
|
||||
acceptButton.setVisibility(VISIBLE);
|
||||
acceptButton.setText(R.string.open);
|
||||
acceptButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
item.setAnswered(true);
|
||||
listener.open(item);
|
||||
}
|
||||
});
|
||||
declineButton.setVisibility(GONE);
|
||||
} else {
|
||||
acceptButton.setVisibility(VISIBLE);
|
||||
acceptButton.setText(R.string.accept);
|
||||
acceptButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignEnd="@+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:textColor="@color/private_message_date"
|
||||
android:textSize="@dimen/text_size_tiny"
|
||||
@@ -57,6 +57,7 @@
|
||||
android:layout_alignEnd="@+id/text"
|
||||
android:layout_alignRight="@+id/text"
|
||||
android:layout_below="@+id/text"
|
||||
android:layout_marginBottom="-10dp"
|
||||
android:text="@string/accept"/>
|
||||
|
||||
<Button
|
||||
@@ -64,8 +65,8 @@
|
||||
style="@style/BriarButtonFlat.Negative"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/text"
|
||||
android:layout_marginBottom="-15dp"
|
||||
android:layout_alignBottom="@+id/acceptButton"
|
||||
android:layout_alignTop="@+id/acceptButton"
|
||||
android:layout_toLeftOf="@+id/acceptButton"
|
||||
android:layout_toStartOf="@+id/acceptButton"
|
||||
android:text="@string/decline"/>
|
||||
|
||||
@@ -77,6 +77,7 @@
|
||||
<string name="offline">Offline</string>
|
||||
<string name="send">Send</string>
|
||||
<string name="allow">Allow</string>
|
||||
<string name="open">Open</string>
|
||||
<string name="no_data">No data</string>
|
||||
<string name="ellipsis">…</string>
|
||||
<string name="text_too_long">The entered text is too long</string>
|
||||
@@ -182,8 +183,8 @@
|
||||
|
||||
<!-- Private Group Invitations -->
|
||||
<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_received">%1$s has invited you 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_joined">Joined group</string>
|
||||
<string name="groups_invitations_declined">Group invitation declined</string>
|
||||
<plurals name="groups_invitations_open">
|
||||
|
||||
@@ -37,13 +37,11 @@
|
||||
<style name="BriarButtonFlat.Negative" parent="Widget.AppCompat.Button.Borderless">
|
||||
<item name="android:textColor">@color/briar_button_negative</item>
|
||||
<item name="android:textSize">@dimen/text_size_medium</item>
|
||||
<item name="android:padding">@dimen/margin_large</item>
|
||||
</style>
|
||||
|
||||
<style name="BriarButtonFlat.Positive" parent="Widget.AppCompat.Button.Borderless">
|
||||
<item name="android:textColor">@color/briar_button_positive</item>
|
||||
<item name="android:textSize">@dimen/text_size_medium</item>
|
||||
<item name="android:padding">@dimen/margin_large</item>
|
||||
</style>
|
||||
|
||||
<style name="BriarButtonFlat.Positive.Tiny" parent="BriarButtonFlat.Positive">
|
||||
|
||||
@@ -16,11 +16,12 @@ public class BlogInvitationRequest extends InvitationRequest {
|
||||
|
||||
public BlogInvitationRequest(MessageId id, SessionId sessionId,
|
||||
GroupId groupId, ContactId contactId, String blogAuthorName,
|
||||
@Nullable String message, boolean available, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
@Nullable String message, @Nullable GroupId blogId,
|
||||
boolean available, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
|
||||
super(id, sessionId, groupId, contactId, message, available, time,
|
||||
local, sent, seen, read);
|
||||
super(id, sessionId, groupId, contactId, message, blogId, available,
|
||||
time, local, sent, seen, read);
|
||||
this.blogAuthorName = blogAuthorName;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,11 +11,12 @@ import org.briarproject.briar.api.sharing.InvitationResponse;
|
||||
public class BlogInvitationResponse extends InvitationResponse {
|
||||
|
||||
public BlogInvitationResponse(MessageId id, SessionId sessionId,
|
||||
GroupId groupId, ContactId contactId, boolean accept, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
GroupId groupId, ContactId contactId, GroupId blogId,
|
||||
boolean accept, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
|
||||
super(id, sessionId, groupId, contactId, accept, time, local, sent,
|
||||
seen, read);
|
||||
super(id, sessionId, groupId, contactId, blogId, accept, time, local,
|
||||
sent, seen, read);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,12 +17,13 @@ public class ForumInvitationRequest extends InvitationRequest {
|
||||
private final String forumName;
|
||||
|
||||
public ForumInvitationRequest(MessageId id, SessionId sessionId,
|
||||
GroupId groupId, ContactId contactId, String forumName,
|
||||
@Nullable String message, boolean available, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
GroupId groupId, ContactId contactId, GroupId forumId,
|
||||
String forumName, @Nullable String message, boolean available,
|
||||
long time, boolean local, boolean sent, boolean seen,
|
||||
boolean read) {
|
||||
|
||||
super(id, sessionId, groupId, contactId, message, available, time,
|
||||
local, sent, seen, read);
|
||||
super(id, sessionId, groupId, contactId, message, forumId, available,
|
||||
time, local, sent, seen, read);
|
||||
this.forumName = forumName;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,11 +14,12 @@ import javax.annotation.concurrent.Immutable;
|
||||
public class ForumInvitationResponse extends InvitationResponse {
|
||||
|
||||
public ForumInvitationResponse(MessageId id, SessionId sessionId,
|
||||
GroupId groupId, ContactId contactId, boolean accept, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
GroupId groupId, ContactId contactId, GroupId forumId,
|
||||
boolean accept, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
|
||||
super(id, sessionId, groupId, contactId, accept, time, local, sent,
|
||||
seen, read);
|
||||
super(id, sessionId, groupId, contactId, forumId, accept, time, local,
|
||||
sent, seen, read);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,10 +20,11 @@ public class GroupInvitationRequest extends InvitationRequest {
|
||||
|
||||
public GroupInvitationRequest(MessageId id, SessionId sessionId,
|
||||
GroupId groupId, ContactId contactId, @Nullable String message,
|
||||
String groupName, Author creator, boolean available, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
super(id, sessionId, groupId, contactId, message, available, time,
|
||||
local, sent, seen, read);
|
||||
GroupId privateGroupId, String groupName, Author creator,
|
||||
boolean available, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
super(id, sessionId, groupId, contactId, message, privateGroupId,
|
||||
available, time, local, sent, seen, read);
|
||||
this.groupName = groupName;
|
||||
this.creator = creator;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,10 @@ import javax.annotation.concurrent.Immutable;
|
||||
public class GroupInvitationResponse extends InvitationResponse {
|
||||
|
||||
public GroupInvitationResponse(MessageId id, SessionId sessionId,
|
||||
GroupId groupId, ContactId contactId, boolean accept, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
super(id, sessionId, groupId, contactId, accept, time, local, sent,
|
||||
seen, read);
|
||||
GroupId groupId, ContactId contactId, GroupId privateGroupId,
|
||||
boolean accept, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean 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.SessionId;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@@ -15,14 +16,17 @@ public abstract class InvitationMessage extends BaseMessageHeader {
|
||||
|
||||
private final SessionId sessionId;
|
||||
private final ContactId contactId;
|
||||
@Nullable
|
||||
private final GroupId invitedGroupId;
|
||||
|
||||
public InvitationMessage(MessageId id, SessionId sessionId, GroupId groupId,
|
||||
ContactId contactId, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
ContactId contactId, @Nullable GroupId invitedGroupId, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
|
||||
super(id, groupId, time, local, read, sent, seen);
|
||||
this.sessionId = sessionId;
|
||||
this.contactId = contactId;
|
||||
this.invitedGroupId = invitedGroupId;
|
||||
}
|
||||
|
||||
public SessionId getSessionId() {
|
||||
@@ -33,4 +37,9 @@ public abstract class InvitationMessage extends BaseMessageHeader {
|
||||
return contactId;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public GroupId getInvitedGroupId() {
|
||||
return invitedGroupId;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,11 +18,12 @@ public abstract class InvitationRequest extends InvitationMessage {
|
||||
private final boolean available;
|
||||
|
||||
public InvitationRequest(MessageId id, SessionId sessionId, GroupId groupId,
|
||||
ContactId contactId, @Nullable String message, boolean available,
|
||||
long time, boolean local, boolean sent, boolean seen,
|
||||
boolean read) {
|
||||
ContactId contactId, @Nullable String message,
|
||||
@Nullable GroupId invitedGroupId, boolean available, 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);
|
||||
this.message = message;
|
||||
this.available = available;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import org.briarproject.bramble.api.sync.GroupId;
|
||||
import org.briarproject.bramble.api.sync.MessageId;
|
||||
import org.briarproject.briar.api.client.SessionId;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
|
||||
@Immutable
|
||||
@@ -15,10 +16,12 @@ public abstract class InvitationResponse extends InvitationMessage {
|
||||
private final boolean accept;
|
||||
|
||||
public InvitationResponse(MessageId id, SessionId sessionId,
|
||||
GroupId groupId, ContactId contactId, boolean accept, long time,
|
||||
GroupId groupId, ContactId contactId,
|
||||
@Nullable GroupId invitedGroupId, boolean accept, 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);
|
||||
this.accept = accept;
|
||||
}
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ class CreatorProtocolEngine extends AbstractProtocolEngine<CreatorSession> {
|
||||
GroupInvitationMessage m, ContactId c, boolean accept) {
|
||||
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
||||
return new GroupInvitationResponse(m.getId(), sessionId,
|
||||
m.getPrivateGroupId(), c, accept, m.getTimestamp(), false,
|
||||
false, true, false);
|
||||
m.getContactGroupId(), c, m.getPrivateGroupId(), accept,
|
||||
m.getTimestamp(), false, false, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,10 +381,12 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
m, meta, status));
|
||||
} else if (type == JOIN) {
|
||||
messages.add(
|
||||
parseInvitationResponse(c, m, meta, status, true));
|
||||
parseInvitationResponse(c, contactGroupId, m, meta,
|
||||
status, true));
|
||||
} else if (type == LEAVE) {
|
||||
messages.add(
|
||||
parseInvitationResponse(c, m, meta, status, false));
|
||||
parseInvitationResponse(c, contactGroupId, m, meta,
|
||||
status, false));
|
||||
}
|
||||
}
|
||||
db.commitTransaction(txn);
|
||||
@@ -404,7 +406,8 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
// Look up the invite message to get the details of the private group
|
||||
InviteMessage invite = getInviteMessage(txn, m);
|
||||
return new GroupInvitationRequest(m, sessionId, contactGroupId, c,
|
||||
invite.getMessage(), invite.getGroupName(), invite.getCreator(),
|
||||
invite.getMessage(), invite.getPrivateGroupId(),
|
||||
invite.getGroupName(), invite.getCreator(),
|
||||
meta.isAvailableToAnswer(), meta.getTimestamp(), meta.isLocal(),
|
||||
status.isSent(), status.isSeen(), meta.isRead());
|
||||
}
|
||||
@@ -418,11 +421,12 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
}
|
||||
|
||||
private GroupInvitationResponse parseInvitationResponse(ContactId c,
|
||||
MessageId m, MessageMetadata meta, MessageStatus status,
|
||||
boolean accept) throws DbException, FormatException {
|
||||
GroupId contactGroupId, MessageId m, MessageMetadata meta,
|
||||
MessageStatus status, boolean accept)
|
||||
throws DbException, FormatException {
|
||||
SessionId sessionId = getSessionId(meta.getPrivateGroupId());
|
||||
return new GroupInvitationResponse(m, sessionId,
|
||||
meta.getPrivateGroupId(), c, accept, meta.getTimestamp(),
|
||||
return new GroupInvitationResponse(m, sessionId, contactGroupId, c,
|
||||
meta.getPrivateGroupId(), accept, meta.getTimestamp(),
|
||||
meta.isLocal(), status.isSent(), status.isSeen(),
|
||||
meta.isRead());
|
||||
}
|
||||
|
||||
@@ -318,8 +318,8 @@ class InviteeProtocolEngine extends AbstractProtocolEngine<InviteeSession> {
|
||||
ContactId c) {
|
||||
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
||||
return new GroupInvitationRequest(m.getId(), sessionId,
|
||||
m.getContactGroupId(), c, m.getMessage(), m.getGroupName(),
|
||||
m.getCreator(), true, m.getTimestamp(), false, false, true,
|
||||
false);
|
||||
m.getContactGroupId(), c, m.getMessage(), m.getPrivateGroupId(),
|
||||
m.getGroupName(), m.getCreator(), true, m.getTimestamp(), false,
|
||||
false, true, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.briarproject.briar.api.sharing.InvitationMessage;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.annotation.concurrent.Immutable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -133,21 +134,23 @@ class BlogSharingManagerImpl extends
|
||||
|
||||
@Override
|
||||
protected InvitationMessage createInvitationRequest(MessageId id,
|
||||
BlogInvitation msg, ContactId contactId, boolean available,
|
||||
long time, boolean local, boolean sent, boolean seen,
|
||||
boolean read) {
|
||||
BlogInvitation msg, ContactId contactId, GroupId blogId,
|
||||
boolean available, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
|
||||
return new BlogInvitationRequest(id, msg.getSessionId(),
|
||||
msg.getGroupId(), contactId, msg.getBlogAuthorName(),
|
||||
msg.getMessage(), available, time, local, sent, seen, read);
|
||||
msg.getMessage(), blogId, available, time, local, sent, seen,
|
||||
read);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InvitationMessage createInvitationResponse(MessageId id,
|
||||
SessionId sessionId, GroupId groupId, ContactId contactId,
|
||||
boolean accept, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read) {
|
||||
GroupId blogId, boolean accept, long time, boolean local,
|
||||
boolean sent, boolean seen, boolean read) {
|
||||
return new BlogInvitationResponse(id, sessionId, groupId, contactId,
|
||||
accept, time, local, sent, seen, read);
|
||||
blogId, accept, time, local, sent, seen, read);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -333,14 +336,17 @@ class BlogSharingManagerImpl extends
|
||||
|
||||
@Override
|
||||
public BlogInvitationRequestReceivedEvent build(
|
||||
BlogInviteeSessionState localState, long time, String msg) {
|
||||
BlogInviteeSessionState localState, long time,
|
||||
@Nullable String msg) {
|
||||
Blog blog = sFactory.parse(localState);
|
||||
ContactId contactId = localState.getContactId();
|
||||
BlogInvitationRequest request =
|
||||
new BlogInvitationRequest(localState.getInvitationId(),
|
||||
localState.getSessionId(), localState.getContactGroupId(),
|
||||
contactId, blog.getAuthor().getName(), msg, true,
|
||||
time, false, false, false, false);
|
||||
localState.getSessionId(),
|
||||
localState.getContactGroupId(), contactId,
|
||||
blog.getAuthor().getName(), msg,
|
||||
localState.getShareableId(), true, time, false,
|
||||
false, false, false);
|
||||
return new BlogInvitationRequestReceivedEvent(blog, contactId,
|
||||
request);
|
||||
}
|
||||
@@ -358,8 +364,9 @@ class BlogSharingManagerImpl extends
|
||||
BlogInvitationResponse response =
|
||||
new BlogInvitationResponse(responseId,
|
||||
localState.getSessionId(),
|
||||
localState.getShareableId(),
|
||||
localState.getContactId(), accept, time, false,
|
||||
localState.getContactGroupId(),
|
||||
localState.getContactId(),
|
||||
localState.getShareableId(), accept, time, false,
|
||||
false, false, false);
|
||||
return new BlogInvitationResponseReceivedEvent(c, response);
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.briarproject.briar.api.sharing.InvitationMessage;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.briar.api.forum.ForumConstants.FORUM_NAME;
|
||||
@@ -81,21 +82,21 @@ class ForumSharingManagerImpl extends
|
||||
|
||||
@Override
|
||||
protected InvitationMessage createInvitationRequest(MessageId id,
|
||||
ForumInvitation msg, ContactId contactId, boolean available,
|
||||
long time, boolean local, boolean sent, boolean seen,
|
||||
boolean read) {
|
||||
ForumInvitation msg, ContactId contactId, GroupId forumId,
|
||||
boolean available, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected InvitationMessage createInvitationResponse(MessageId id,
|
||||
SessionId sessionId, GroupId groupId, ContactId contactId,
|
||||
boolean accept, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read) {
|
||||
GroupId forumId, boolean accept, long time, boolean local,
|
||||
boolean sent, boolean seen, boolean read) {
|
||||
return new ForumInvitationResponse(id, sessionId, groupId, contactId,
|
||||
accept, time, local, sent, seen, read);
|
||||
forumId, accept, time, local, sent, seen, read);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -263,13 +264,15 @@ class ForumSharingManagerImpl extends
|
||||
|
||||
@Override
|
||||
public ForumInvitationRequestReceivedEvent build(
|
||||
ForumInviteeSessionState localState, long time, String msg) {
|
||||
ForumInviteeSessionState localState, long time,
|
||||
@Nullable String msg) {
|
||||
Forum forum = sFactory.parse(localState);
|
||||
ContactId contactId = localState.getContactId();
|
||||
ForumInvitationRequest request = new ForumInvitationRequest(
|
||||
localState.getInvitationId(), localState.getSessionId(),
|
||||
localState.getContactGroupId(), contactId, forum.getName(), msg,
|
||||
true, time, false, false, false, false);
|
||||
localState.getContactGroupId(), contactId,
|
||||
localState.getShareableId(), forum.getName(), msg, true,
|
||||
time, false, false, false, false);
|
||||
return new ForumInvitationRequestReceivedEvent(forum, contactId,
|
||||
request);
|
||||
}
|
||||
@@ -287,8 +290,9 @@ class ForumSharingManagerImpl extends
|
||||
throw new IllegalStateException("No responseId");
|
||||
ForumInvitationResponse response = new ForumInvitationResponse(
|
||||
responseId, localState.getSessionId(),
|
||||
localState.getShareableId(), localState.getContactId(),
|
||||
accept, time, false, false, false, false);
|
||||
localState.getContactGroupId(), localState.getContactId(),
|
||||
localState.getShareableId(), accept, time, false, false,
|
||||
false, false);
|
||||
return new ForumInvitationResponseReceivedEvent(name, c, response);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,13 +125,13 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
protected abstract ClientId getClientId();
|
||||
|
||||
protected abstract InvitationMessage createInvitationRequest(MessageId id,
|
||||
I msg, ContactId contactId, boolean available, long time,
|
||||
boolean local, boolean sent, boolean seen, boolean read);
|
||||
I msg, ContactId contactId, GroupId shareableId, boolean available,
|
||||
long time, boolean local, boolean sent, boolean seen, boolean read);
|
||||
|
||||
protected abstract InvitationMessage createInvitationResponse(MessageId id,
|
||||
SessionId sessionId, GroupId groupId, ContactId contactId,
|
||||
boolean accept, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read);
|
||||
GroupId shareableId, boolean accept, long time, boolean local,
|
||||
boolean sent, boolean seen, boolean read);
|
||||
|
||||
protected abstract ShareableFactory<S, I, IS, SS> getSFactory();
|
||||
|
||||
@@ -391,6 +391,7 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
try {
|
||||
MessageStatus status =
|
||||
db.getMessageStatus(txn, contactId, m.getKey());
|
||||
SharingSessionState s;
|
||||
long time = d.getLong(TIME);
|
||||
boolean local = d.getBoolean(LOCAL);
|
||||
boolean read = d.getBoolean(MSG_KEY_READ, false);
|
||||
@@ -398,11 +399,10 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
|
||||
if (type == SHARE_MSG_TYPE_INVITATION) {
|
||||
I msg = getIFactory().build(group.getId(), d);
|
||||
SessionId sessionId = msg.getSessionId();
|
||||
s = getSessionState(txn, sessionId, true);
|
||||
if (!local) {
|
||||
// figure out whether the shareable is still available
|
||||
SharingSessionState s =
|
||||
getSessionState(txn, msg.getSessionId(),
|
||||
true);
|
||||
if (!(s instanceof InviteeSessionState))
|
||||
continue;
|
||||
available = ((InviteeSessionState) s).getState() ==
|
||||
@@ -410,8 +410,9 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
}
|
||||
InvitationMessage im =
|
||||
createInvitationRequest(m.getKey(), msg,
|
||||
contactId, available, time, local,
|
||||
status.isSent(), status.isSeen(), read);
|
||||
contactId, s.getShareableId(),
|
||||
available, time, local, status.isSent(),
|
||||
status.isSeen(), read);
|
||||
list.add(im);
|
||||
} else if (type == SHARE_MSG_TYPE_ACCEPT ||
|
||||
type == SHARE_MSG_TYPE_DECLINE) {
|
||||
@@ -419,10 +420,12 @@ abstract class SharingManagerImpl<S extends Shareable, I extends Invitation, IS
|
||||
BaseMessage msg = BaseMessage
|
||||
.from(getIFactory(), group.getId(), d);
|
||||
SessionId sessionId = msg.getSessionId();
|
||||
InvitationMessage im = createInvitationResponse(
|
||||
m.getKey(), sessionId, group.getId(), contactId,
|
||||
accept, time, local, status.isSent(),
|
||||
status.isSeen(), read);
|
||||
s = getSessionState(txn, sessionId, true);
|
||||
InvitationMessage im =
|
||||
createInvitationResponse(m.getKey(), sessionId,
|
||||
group.getId(), contactId,
|
||||
s.getShareableId(), accept, time, local,
|
||||
status.isSent(), status.isSeen(), read);
|
||||
list.add(im);
|
||||
} else {
|
||||
throw new RuntimeException("Unexpected Message Type");
|
||||
|
||||
Reference in New Issue
Block a user