Add constant for NO_AUTO_DELETE_TIMER, address review comments.

This commit is contained in:
akwizgran
2020-11-19 15:58:33 +00:00
committed by Torsten Grote
parent b10ca5b77f
commit 113120b3ab
13 changed files with 75 additions and 32 deletions

View File

@@ -9,9 +9,10 @@ import java.util.List;
import javax.annotation.concurrent.Immutable;
import static java.util.Collections.emptyList;
import static org.briarproject.briar.api.messaging.PrivateMessageFormat.TEXT;
import static org.briarproject.bramble.api.autodelete.AutoDeleteConstants.NO_AUTO_DELETE_TIMER;
import static org.briarproject.briar.api.messaging.PrivateMessageFormat.TEXT_IMAGES;
import static org.briarproject.briar.api.messaging.PrivateMessageFormat.TEXT_IMAGES_AUTO_DELETE;
import static org.briarproject.briar.api.messaging.PrivateMessageFormat.TEXT_ONLY;
@Immutable
@NotNullByDefault
@@ -25,14 +26,14 @@ public class PrivateMessage {
/**
* Constructor for private messages in the
* {@link PrivateMessageFormat#TEXT TEXT} format.
* {@link PrivateMessageFormat#TEXT_ONLY TEXT_ONLY} format.
*/
public PrivateMessage(Message message) {
this.message = message;
hasText = true;
attachmentHeaders = emptyList();
autoDeleteTimer = -1;
format = TEXT;
autoDeleteTimer = NO_AUTO_DELETE_TIMER;
format = TEXT_ONLY;
}
/**
@@ -44,7 +45,7 @@ public class PrivateMessage {
this.message = message;
this.hasText = hasText;
this.attachmentHeaders = headers;
autoDeleteTimer = -1;
autoDeleteTimer = NO_AUTO_DELETE_TIMER;
format = TEXT_IMAGES;
}

View File

@@ -12,13 +12,28 @@ import javax.annotation.Nullable;
@NotNullByDefault
public interface PrivateMessageFactory {
/**
* Creates a private message in the
* {@link PrivateMessageFormat#TEXT_ONLY TEXT_ONLY} format.
*/
PrivateMessage createLegacyPrivateMessage(GroupId groupId, long timestamp,
String text) throws FormatException;
/**
* Creates a private message in the
* {@link PrivateMessageFormat#TEXT_IMAGES TEXT_IMAGES} format. This format
* requires the contact to support client version 0.1 or higher.
*/
PrivateMessage createPrivateMessage(GroupId groupId, long timestamp,
@Nullable String text, List<AttachmentHeader> headers)
throws FormatException;
/**
* Creates a private message in the
* {@link PrivateMessageFormat#TEXT_IMAGES_AUTO_DELETE TEXT_IMAGES_AUTO_DELETE}
* format. This format requires the contact to support client version 0.3
* or higher.
*/
PrivateMessage createPrivateMessage(GroupId groupId, long timestamp,
@Nullable String text, List<AttachmentHeader> headers,
long autoDeleteTimer) throws FormatException;

View File

@@ -6,7 +6,7 @@ public enum PrivateMessageFormat {
* First version of the private message format, which doesn't support
* image attachments or auto-deletion.
*/
TEXT,
TEXT_ONLY,
/**
* Second version of the private message format, which supports image