Add auto-deletion timer to private messages.

This commit is contained in:
akwizgran
2020-11-19 12:57:07 +00:00
committed by Torsten Grote
parent 5305dd62d1
commit 3b6cc9c633
18 changed files with 208 additions and 75 deletions

View File

@@ -25,6 +25,7 @@ import java.util.List;
import javax.inject.Inject;
import static org.briarproject.bramble.api.autodelete.AutoDeleteConstants.MAX_AUTO_DELETE_TIMER_MS;
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
import static org.briarproject.bramble.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
import static org.briarproject.bramble.api.record.Record.MAX_RECORD_PAYLOAD_BYTES;
@@ -92,12 +93,12 @@ public class MessageSizeIntegrationTest extends BriarTestCase {
getRandomString(MAX_CONTENT_TYPE_BYTES)));
}
PrivateMessage message = privateMessageFactory.createPrivateMessage(
groupId, timestamp, text, headers);
groupId, timestamp, text, headers, MAX_AUTO_DELETE_TIMER_MS);
// Check the size of the serialised message
int length = message.getMessage().getRawLength();
assertTrue(length > UniqueId.LENGTH + 8
+ MAX_PRIVATE_MESSAGE_TEXT_LENGTH + MAX_ATTACHMENTS_PER_MESSAGE
* (UniqueId.LENGTH + MAX_CONTENT_TYPE_BYTES));
* (UniqueId.LENGTH + MAX_CONTENT_TYPE_BYTES) + 4);
assertTrue(length <= MAX_RECORD_PAYLOAD_BYTES);
}

View File

@@ -340,8 +340,9 @@ public class MessagingManagerIntegrationTest
BriarIntegrationTestComponent to, @Nullable String text,
List<AttachmentHeader> attachments) throws Exception {
GroupId g = from.getMessagingManager().getConversationId(contactId);
// TODO: Add tests for auto-deletion timer
PrivateMessage m = messageFactory.createPrivateMessage(g,
clock.currentTimeMillis(), text, attachments);
clock.currentTimeMillis(), text, attachments, -1);
from.getMessagingManager().addLocalMessage(m);
syncMessage(from, to, contactId, 1 + attachments.size(), true);
return m;

View File

@@ -123,7 +123,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
PrivateMessageFactory privateMessageFactory =
device.getPrivateMessageFactory();
PrivateMessage message = privateMessageFactory.createPrivateMessage(
groupId, timestamp, "Hi!", singletonList(attachmentHeader));
groupId, timestamp, "Hi!", singletonList(attachmentHeader), -1);
messagingManager.addLocalMessage(message);
}