mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 12:49:55 +01:00
Remove unnecessary information from private message classes
This commit is contained in:
@@ -41,7 +41,6 @@ import javax.inject.Inject;
|
||||
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.bramble.util.LogUtils.logException;
|
||||
import static org.briarproject.briar.api.introduction.Role.INTRODUCEE;
|
||||
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_AUTH;
|
||||
import static org.briarproject.briar.introduction.IntroduceeState.AWAIT_RESPONSES;
|
||||
import static org.briarproject.briar.introduction.IntroduceeState.LOCAL_ACCEPTED;
|
||||
@@ -255,11 +254,10 @@ class IntroduceeProtocolEngine
|
||||
localAuthor.getId());
|
||||
boolean contactExists = contactManager
|
||||
.contactExists(txn, m.getAuthor().getId(), localAuthor.getId());
|
||||
IntroductionRequest request =
|
||||
new IntroductionRequest(s.getSessionId(), m.getMessageId(),
|
||||
m.getGroupId(), INTRODUCEE, m.getTimestamp(), false,
|
||||
false, false, false, m.getAuthor().getName(), false,
|
||||
m.getMessage(), false, contactExists);
|
||||
IntroductionRequest request = new IntroductionRequest(s.getSessionId(),
|
||||
m.getMessageId(), m.getGroupId(), m.getTimestamp(), false,
|
||||
false, false, false, m.getAuthor(), m.getMessage(), false,
|
||||
contactExists);
|
||||
IntroductionRequestReceivedEvent e =
|
||||
new IntroductionRequestReceivedEvent(c.getId(), request);
|
||||
txn.attach(e);
|
||||
|
||||
@@ -472,10 +472,9 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
||||
localAuthor.getId());
|
||||
|
||||
return new IntroductionRequest(sessionId, m, contactGroupId,
|
||||
role, meta.getTimestamp(), meta.isLocal(),
|
||||
status.isSent(), status.isSeen(), meta.isRead(),
|
||||
author.getName(), false, message, !meta.isAvailableToAnswer(),
|
||||
contactExists);
|
||||
meta.getTimestamp(), meta.isLocal(), status.isSent(),
|
||||
status.isSeen(), meta.isRead(), author, message,
|
||||
!meta.isAvailableToAnswer(), contactExists);
|
||||
}
|
||||
|
||||
private IntroductionResponse parseInvitationResponse(GroupId contactGroupId,
|
||||
|
||||
@@ -258,6 +258,6 @@ class CreatorProtocolEngine extends AbstractProtocolEngine<CreatorSession> {
|
||||
SessionId sessionId = new SessionId(m.getPrivateGroupId().getBytes());
|
||||
return new GroupInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||
m.getTimestamp(), false, false, true, false, sessionId,
|
||||
m.getPrivateGroupId(), c, accept);
|
||||
m.getPrivateGroupId(), accept);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ class GroupInvitationManagerImpl extends ConversationClientImpl
|
||||
return new GroupInvitationResponse(m, contactGroupId,
|
||||
meta.getTimestamp(), meta.isLocal(), status.isSent(),
|
||||
status.isSeen(), meta.isRead(), sessionId,
|
||||
meta.getPrivateGroupId(), c, accept);
|
||||
meta.getPrivateGroupId(), accept);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -30,11 +30,10 @@ public class BlogInvitationFactoryImpl
|
||||
@Override
|
||||
public BlogInvitationResponse createInvitationResponse(MessageId id,
|
||||
GroupId contactGroupId, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, GroupId shareableId,
|
||||
ContactId contactId, boolean accept) {
|
||||
boolean seen, boolean read, GroupId shareableId, boolean accept) {
|
||||
SessionId sessionId = new SessionId(shareableId.getBytes());
|
||||
return new BlogInvitationResponse(id, contactGroupId, time, local,
|
||||
sent, seen, read, sessionId, shareableId, contactId, accept);
|
||||
sent, seen, read, sessionId, shareableId, accept);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
|
||||
BlogInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||
m.getTimestamp(), false, false, true, false,
|
||||
m.getShareableId(), contactId, true);
|
||||
m.getShareableId(), true);
|
||||
return new BlogInvitationResponseReceivedEvent(contactId, response);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class BlogProtocolEngineImpl extends ProtocolEngineImpl<Blog> {
|
||||
BlogInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||
m.getTimestamp(), false, false, true, false,
|
||||
m.getShareableId(), contactId, true);
|
||||
m.getShareableId(), true);
|
||||
return new BlogInvitationResponseReceivedEvent(contactId, response);
|
||||
}
|
||||
|
||||
|
||||
@@ -80,8 +80,8 @@ class BlogSharingManagerImpl extends SharingManagerImpl<Blog>
|
||||
|
||||
// Pre-share both blogs, if they have not been shared already
|
||||
try {
|
||||
preShareShareable(txn, c, ourBlog);
|
||||
preShareShareable(txn, c, theirBlog);
|
||||
preShareGroup(txn, c, ourBlog.getGroup());
|
||||
preShareGroup(txn, c, theirBlog.getGroup());
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
|
||||
@@ -31,10 +31,10 @@ public class ForumInvitationFactoryImpl
|
||||
public ForumInvitationResponse createInvitationResponse(MessageId id,
|
||||
GroupId contactGroupId, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, GroupId shareableId,
|
||||
ContactId contactId, boolean accept) {
|
||||
boolean accept) {
|
||||
SessionId sessionId = new SessionId(shareableId.getBytes());
|
||||
return new ForumInvitationResponse(id, contactGroupId, time, local,
|
||||
sent, seen, read, sessionId, shareableId, contactId, accept);
|
||||
sent, seen, read, sessionId, shareableId, accept);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ class ForumProtocolEngineImpl extends ProtocolEngineImpl<Forum> {
|
||||
ForumInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||
m.getTimestamp(), false, false, true, false,
|
||||
m.getShareableId(), contactId, true);
|
||||
m.getShareableId(), true);
|
||||
return new ForumInvitationResponseReceivedEvent(contactId, response);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ class ForumProtocolEngineImpl extends ProtocolEngineImpl<Forum> {
|
||||
ForumInvitationResponse response = invitationFactory
|
||||
.createInvitationResponse(m.getId(), m.getContactGroupId(),
|
||||
m.getTimestamp(), false, false, true, false,
|
||||
m.getShareableId(), contactId, true);
|
||||
m.getShareableId(), true);
|
||||
return new ForumInvitationResponseReceivedEvent(contactId, response);
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,6 @@ public interface InvitationFactory<S extends Shareable, I extends InvitationResp
|
||||
I createInvitationResponse(MessageId id,
|
||||
GroupId contactGroupId, long time, boolean local, boolean sent,
|
||||
boolean seen, boolean read, GroupId shareableId,
|
||||
ContactId contactId, boolean accept);
|
||||
boolean accept);
|
||||
|
||||
}
|
||||
|
||||
@@ -156,29 +156,29 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given Shareable and initializes a session between us
|
||||
* Adds the given Group and initializes a session between us
|
||||
* and the Contact c in state SHARING.
|
||||
* If a session already exists, this does nothing.
|
||||
*/
|
||||
void preShareShareable(Transaction txn, Contact c, S shareable)
|
||||
void preShareGroup(Transaction txn, Contact c, Group g)
|
||||
throws DbException, FormatException {
|
||||
// Return if a session already exists with the contact
|
||||
GroupId contactGroupId = getContactGroup(c).getId();
|
||||
StoredSession existingSession = getSession(txn, contactGroupId,
|
||||
getSessionId(shareable.getId()));
|
||||
getSessionId(g.getId()));
|
||||
if (existingSession != null) return;
|
||||
|
||||
// Add the shareable
|
||||
db.addGroup(txn, shareable.getGroup());
|
||||
// Add the shareable's group
|
||||
db.addGroup(txn, g);
|
||||
|
||||
// Apply the client's visibility
|
||||
Visibility client = clientVersioningManager.getClientVisibility(txn,
|
||||
c.getId(), getShareableClientId(), getShareableMajorVersion());
|
||||
db.setGroupVisibility(txn, c.getId(), shareable.getId(), client);
|
||||
db.setGroupVisibility(txn, c.getId(), g.getId(), client);
|
||||
|
||||
// Initialize session in sharing state
|
||||
Session session = new Session(SHARING, contactGroupId,
|
||||
shareable.getId(), null, null, 0, 0);
|
||||
Session session = new Session(SHARING, contactGroupId, g.getId(),
|
||||
null, null, 0, 0);
|
||||
MessageId storageId = createStorageId(txn, contactGroupId);
|
||||
storeSession(txn, storageId, session);
|
||||
}
|
||||
@@ -343,11 +343,11 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
parseInvitationRequest(txn, c, m, meta, status));
|
||||
} else if (type == ACCEPT) {
|
||||
messages.add(
|
||||
parseInvitationResponse(c, contactGroupId, m, meta,
|
||||
parseInvitationResponse(contactGroupId, m, meta,
|
||||
status, true));
|
||||
} else if (type == DECLINE) {
|
||||
messages.add(
|
||||
parseInvitationResponse(c, contactGroupId, m, meta,
|
||||
parseInvitationResponse(contactGroupId, m, meta,
|
||||
status, false));
|
||||
}
|
||||
}
|
||||
@@ -374,13 +374,12 @@ abstract class SharingManagerImpl<S extends Shareable>
|
||||
meta.isAvailableToAnswer(), canBeOpened);
|
||||
}
|
||||
|
||||
private InvitationResponse parseInvitationResponse(ContactId c,
|
||||
GroupId contactGroupId, MessageId m, MessageMetadata meta,
|
||||
MessageStatus status, boolean accept)
|
||||
throws DbException, FormatException {
|
||||
private InvitationResponse parseInvitationResponse(GroupId contactGroupId,
|
||||
MessageId m, MessageMetadata meta, MessageStatus status,
|
||||
boolean accept) {
|
||||
return invitationFactory.createInvitationResponse(m, contactGroupId,
|
||||
meta.getTimestamp(), meta.isLocal(), status.isSent(),
|
||||
status.isSeen(), meta.isRead(), meta.getShareableId(), c,
|
||||
status.isSeen(), meta.isRead(), meta.getShareableId(),
|
||||
accept);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,7 +100,6 @@ public class GroupInvitationIntegrationTest
|
||||
assertEquals(msg, request.getMessage());
|
||||
assertEquals(author0, request.getShareable().getCreator());
|
||||
assertEquals(timestamp, request.getTimestamp());
|
||||
assertEquals(contactId0From1, request.getContactId());
|
||||
assertEquals(privateGroup0.getName(), request.getShareable().getName());
|
||||
assertFalse(request.isLocal());
|
||||
assertFalse(request.isRead());
|
||||
@@ -126,7 +125,6 @@ public class GroupInvitationIntegrationTest
|
||||
if (m instanceof GroupInvitationResponse) {
|
||||
foundResponse = true;
|
||||
InvitationResponse response = (GroupInvitationResponse) m;
|
||||
assertEquals(contactId0From1, response.getContactId());
|
||||
assertTrue(response.isLocal());
|
||||
assertFalse(response.wasAccepted());
|
||||
}
|
||||
@@ -143,7 +141,6 @@ public class GroupInvitationIntegrationTest
|
||||
if (m instanceof GroupInvitationResponse) {
|
||||
foundResponse = true;
|
||||
InvitationResponse response = (GroupInvitationResponse) m;
|
||||
assertEquals(contactId0From1, response.getContactId());
|
||||
assertFalse(response.isLocal());
|
||||
assertFalse(response.wasAccepted());
|
||||
}
|
||||
|
||||
@@ -706,7 +706,6 @@ public class GroupInvitationManagerImplTest extends BrambleMockTestCase {
|
||||
assertEquals(2, messages.size());
|
||||
for (InvitationMessage m : messages) {
|
||||
assertEquals(contactGroup.getId(), m.getGroupId());
|
||||
assertEquals(contactId, m.getContactId());
|
||||
if (m.getId().equals(message.getId())) {
|
||||
assertTrue(m instanceof GroupInvitationRequest);
|
||||
assertEquals(time1, m.getTimestamp());
|
||||
|
||||
@@ -153,18 +153,14 @@ public class BlogSharingIntegrationTest
|
||||
// check other things are alright with the message
|
||||
for (InvitationMessage m : list) {
|
||||
if (m instanceof BlogInvitationRequest) {
|
||||
BlogInvitationRequest invitation =
|
||||
(BlogInvitationRequest) m;
|
||||
BlogInvitationRequest invitation = (BlogInvitationRequest) m;
|
||||
assertFalse(invitation.isAvailable());
|
||||
assertEquals(blog2.getAuthor().getName(),
|
||||
invitation.getBlogAuthorName());
|
||||
assertFalse(invitation.getShareable().isRssFeed());
|
||||
assertEquals(contactId1From0, invitation.getContactId());
|
||||
assertEquals("Hi!", invitation.getMessage());
|
||||
} else {
|
||||
BlogInvitationResponse response =
|
||||
(BlogInvitationResponse) m;
|
||||
assertEquals(contactId0From1, response.getContactId());
|
||||
BlogInvitationResponse response = (BlogInvitationResponse) m;
|
||||
assertTrue(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
@@ -228,18 +224,14 @@ public class BlogSharingIntegrationTest
|
||||
// check other things are alright with the message
|
||||
for (InvitationMessage m : list) {
|
||||
if (m instanceof BlogInvitationRequest) {
|
||||
BlogInvitationRequest invitation =
|
||||
(BlogInvitationRequest) m;
|
||||
BlogInvitationRequest invitation = (BlogInvitationRequest) m;
|
||||
assertFalse(invitation.isAvailable());
|
||||
assertEquals(rssBlog.getAuthor().getName(),
|
||||
invitation.getBlogAuthorName());
|
||||
assertTrue(invitation.getShareable().isRssFeed());
|
||||
assertEquals(contactId1From0, invitation.getContactId());
|
||||
assertEquals("Hi!", invitation.getMessage());
|
||||
} else {
|
||||
BlogInvitationResponse response =
|
||||
(BlogInvitationResponse) m;
|
||||
assertEquals(contactId0From1, response.getContactId());
|
||||
BlogInvitationResponse response = (BlogInvitationResponse) m;
|
||||
assertTrue(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
@@ -291,17 +283,13 @@ public class BlogSharingIntegrationTest
|
||||
// check things are alright with the message
|
||||
for (InvitationMessage m : list) {
|
||||
if (m instanceof BlogInvitationRequest) {
|
||||
BlogInvitationRequest invitation =
|
||||
(BlogInvitationRequest) m;
|
||||
BlogInvitationRequest invitation = (BlogInvitationRequest) m;
|
||||
assertFalse(invitation.isAvailable());
|
||||
assertEquals(blog2.getAuthor().getName(),
|
||||
invitation.getBlogAuthorName());
|
||||
assertEquals(contactId1From0, invitation.getContactId());
|
||||
assertEquals(null, invitation.getMessage());
|
||||
} else {
|
||||
BlogInvitationResponse response =
|
||||
(BlogInvitationResponse) m;
|
||||
assertEquals(contactId0From1, response.getContactId());
|
||||
BlogInvitationResponse response = (BlogInvitationResponse) m;
|
||||
assertFalse(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
|
||||
@@ -141,13 +141,11 @@ public class ForumSharingIntegrationTest
|
||||
(ForumInvitationRequest) m;
|
||||
assertFalse(invitation.isAvailable());
|
||||
assertEquals(forum0.getName(), invitation.getForumName());
|
||||
assertEquals(contactId1From0, invitation.getContactId());
|
||||
assertEquals("Hi!", invitation.getMessage());
|
||||
assertTrue(invitation.canBeOpened());
|
||||
} else {
|
||||
ForumInvitationResponse response =
|
||||
(ForumInvitationResponse) m;
|
||||
assertEquals(contactId0From1, response.getContactId());
|
||||
assertTrue(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
@@ -196,17 +194,13 @@ public class ForumSharingIntegrationTest
|
||||
// check things are alright with the forum message
|
||||
for (InvitationMessage m : list) {
|
||||
if (m instanceof ForumInvitationRequest) {
|
||||
ForumInvitationRequest invitation =
|
||||
(ForumInvitationRequest) m;
|
||||
ForumInvitationRequest invitation = (ForumInvitationRequest) m;
|
||||
assertFalse(invitation.isAvailable());
|
||||
assertEquals(forum0.getName(), invitation.getForumName());
|
||||
assertEquals(contactId1From0, invitation.getContactId());
|
||||
assertEquals(null, invitation.getMessage());
|
||||
assertFalse(invitation.canBeOpened());
|
||||
} else {
|
||||
ForumInvitationResponse response =
|
||||
(ForumInvitationResponse) m;
|
||||
assertEquals(contactId0From1, response.getContactId());
|
||||
ForumInvitationResponse response = (ForumInvitationResponse) m;
|
||||
assertFalse(response.wasAccepted());
|
||||
assertTrue(response.isLocal());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user