mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Restrict getMessage() method to small messages.
This commit is contained in:
@@ -317,7 +317,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
}
|
||||
|
||||
// Get body of message to be wrapped
|
||||
BdfList body = clientHelper.getMessageAsList(txn, header.getId());
|
||||
BdfList body = clientHelper.getSmallMessageAsList(txn, header.getId());
|
||||
long timestamp = header.getTimestamp();
|
||||
Message wrappedMessage;
|
||||
|
||||
@@ -465,7 +465,7 @@ class BlogManagerImpl extends BdfIncomingMessageHook implements BlogManager,
|
||||
@Override
|
||||
public String getPostText(MessageId m) throws DbException {
|
||||
try {
|
||||
return getPostText(clientHelper.getMessageAsList(m));
|
||||
return getPostText(clientHelper.getSmallMessageAsList(m));
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ class ForumManagerImpl extends BdfIncomingMessageHook implements ForumManager {
|
||||
@Override
|
||||
public String getPostText(MessageId m) throws DbException {
|
||||
try {
|
||||
return getPostText(clientHelper.getMessageAsList(m));
|
||||
return getPostText(clientHelper.getSmallMessageAsList(m));
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ class IntroductionManagerImpl extends ConversationClientImpl
|
||||
MessageStatus status, SessionId sessionId,
|
||||
Map<AuthorId, AuthorInfo> authorInfos)
|
||||
throws DbException, FormatException {
|
||||
Message msg = clientHelper.getMessage(txn, m);
|
||||
Message msg = clientHelper.getSmallMessage(txn, m);
|
||||
BdfList body = clientHelper.toList(msg);
|
||||
RequestMessage rm = messageParser.parseRequestMessage(msg, body);
|
||||
String text = rm.getText();
|
||||
|
||||
@@ -392,7 +392,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
@Override
|
||||
public String getMessageText(MessageId m) throws DbException {
|
||||
try {
|
||||
BdfList body = clientHelper.getMessageAsList(m);
|
||||
BdfList body = clientHelper.getSmallMessageAsList(m);
|
||||
if (body.size() == 1) return body.getString(0); // Legacy format
|
||||
else return body.getOptionalString(1);
|
||||
} catch (FormatException e) {
|
||||
@@ -404,7 +404,7 @@ class MessagingManagerImpl implements MessagingManager, IncomingMessageHook,
|
||||
public Attachment getAttachment(AttachmentHeader h) throws DbException {
|
||||
// TODO: Support large messages
|
||||
MessageId m = h.getMessageId();
|
||||
byte[] body = clientHelper.getMessage(m).getBody();
|
||||
byte[] body = clientHelper.getSmallMessage(m).getBody();
|
||||
try {
|
||||
BdfDictionary meta = clientHelper.getMessageMetadataAsDictionary(m);
|
||||
Long messageType = meta.getOptionalLong(MSG_KEY_MSG_TYPE);
|
||||
|
||||
@@ -304,7 +304,7 @@ class PrivateGroupManagerImpl extends BdfIncomingMessageHook
|
||||
@Override
|
||||
public String getMessageText(MessageId m) throws DbException {
|
||||
try {
|
||||
return getMessageText(clientHelper.getMessageAsList(m));
|
||||
return getMessageText(clientHelper.getSmallMessageAsList(m));
|
||||
} catch (FormatException e) {
|
||||
throw new DbException(e);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class MessageParserImpl implements MessageParser {
|
||||
@Override
|
||||
public InviteMessage getInviteMessage(Transaction txn, MessageId m)
|
||||
throws DbException, FormatException {
|
||||
Message message = clientHelper.getMessage(txn, m);
|
||||
Message message = clientHelper.getSmallMessage(txn, m);
|
||||
BdfList body = clientHelper.toList(message);
|
||||
return parseInviteMessage(message, body);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ abstract class MessageParserImpl<S extends Shareable>
|
||||
@Override
|
||||
public InviteMessage<S> getInviteMessage(Transaction txn, MessageId m)
|
||||
throws DbException, FormatException {
|
||||
Message message = clientHelper.getMessage(txn, m);
|
||||
Message message = clientHelper.getSmallMessage(txn, m);
|
||||
BdfList body = clientHelper.toList(message);
|
||||
return parseInviteMessage(message, body);
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
oneOf(db).startTransaction(false);
|
||||
will(returnValue(txn));
|
||||
// Wrap the original post for blog 2
|
||||
oneOf(clientHelper).getMessageAsList(txn, messageId);
|
||||
oneOf(clientHelper).getSmallMessageAsList(txn, messageId);
|
||||
will(returnValue(originalPostBody));
|
||||
oneOf(db).getGroup(txn, blog1.getId());
|
||||
will(returnValue(blog1.getGroup()));
|
||||
@@ -609,7 +609,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
oneOf(db).startTransaction(false);
|
||||
will(returnValue(txn));
|
||||
// Wrap the original post for blog 1
|
||||
oneOf(clientHelper).getMessageAsList(txn, rssMessageId);
|
||||
oneOf(clientHelper).getSmallMessageAsList(txn, rssMessageId);
|
||||
will(returnValue(originalPostBody));
|
||||
oneOf(db).getGroup(txn, rssBlog.getId());
|
||||
will(returnValue(rssBlog.getGroup()));
|
||||
@@ -734,7 +734,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
oneOf(db).startTransaction(false);
|
||||
will(returnValue(txn));
|
||||
// Rewrap the wrapped post for blog 2
|
||||
oneOf(clientHelper).getMessageAsList(txn, wrappedPostId);
|
||||
oneOf(clientHelper).getSmallMessageAsList(txn, wrappedPostId);
|
||||
will(returnValue(wrappedPostBody));
|
||||
oneOf(blogPostFactory).rewrapWrappedPost(blog2.getId(),
|
||||
wrappedPostBody);
|
||||
@@ -745,7 +745,7 @@ public class BlogManagerImplTest extends BriarTestCase {
|
||||
oneOf(clientHelper).addLocalMessage(txn, rewrappedPostMsg,
|
||||
rewrappedPostMeta, true, false);
|
||||
// Wrap the original comment for blog 2
|
||||
oneOf(clientHelper).getMessageAsList(txn, originalCommentId);
|
||||
oneOf(clientHelper).getSmallMessageAsList(txn, originalCommentId);
|
||||
will(returnValue(originalCommentBody));
|
||||
oneOf(clientHelper).getMessageMetadataAsDictionary(txn,
|
||||
wrappedPostId);
|
||||
|
||||
@@ -1870,8 +1870,8 @@ public class IntroductionIntegrationTest
|
||||
ch.getMessageMetadataAsDictionary(g.getId(), query);
|
||||
assertEquals(1, map.size());
|
||||
MessageId id = map.entrySet().iterator().next().getKey();
|
||||
Message m = ch.getMessage(id);
|
||||
BdfList body = ch.getMessageAsList(id);
|
||||
Message m = ch.getSmallMessage(id);
|
||||
BdfList body = ch.getSmallMessageAsList(id);
|
||||
if (type == ACCEPT) {
|
||||
return c0.getMessageParser().parseAcceptMessage(m, body);
|
||||
} else if (type == DECLINE) {
|
||||
|
||||
@@ -247,8 +247,10 @@ public class MessagingManagerIntegrationTest
|
||||
sendMessage(c0, c1, getRandomString(42), singletonList(h));
|
||||
|
||||
// attachment exists on both devices
|
||||
db0.transaction(true, txn -> db0.getMessage(txn, h.getMessageId()));
|
||||
db1.transaction(true, txn -> db1.getMessage(txn, h.getMessageId()));
|
||||
db0.transaction(true, txn ->
|
||||
db0.getSmallMessage(txn, h.getMessageId()));
|
||||
db1.transaction(true, txn ->
|
||||
db1.getSmallMessage(txn, h.getMessageId()));
|
||||
|
||||
// delete message on both sides (deletes all, because returns true)
|
||||
assertTrue(db0.transactionWithResult(false,
|
||||
@@ -260,13 +262,15 @@ public class MessagingManagerIntegrationTest
|
||||
|
||||
// attachment was deleted on both devices
|
||||
try {
|
||||
db0.transaction(true, txn -> db0.getMessage(txn, h.getMessageId()));
|
||||
db0.transaction(true, txn ->
|
||||
db0.getSmallMessage(txn, h.getMessageId()));
|
||||
fail();
|
||||
} catch (MessageDeletedException e) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
db1.transaction(true, txn -> db1.getMessage(txn, h.getMessageId()));
|
||||
db1.transaction(true, txn ->
|
||||
db1.getSmallMessage(txn, h.getMessageId()));
|
||||
fail();
|
||||
} catch (MessageDeletedException e) {
|
||||
// expected
|
||||
@@ -282,7 +286,7 @@ public class MessagingManagerIntegrationTest
|
||||
|
||||
// attachment exists on both devices, state set to PENDING for receiver
|
||||
db1.transaction(false, txn -> {
|
||||
db1.getMessage(txn, h.getMessageId());
|
||||
db1.getSmallMessage(txn, h.getMessageId());
|
||||
db1.setMessageState(txn, h.getMessageId(), PENDING);
|
||||
});
|
||||
|
||||
@@ -310,13 +314,15 @@ public class MessagingManagerIntegrationTest
|
||||
|
||||
// attachment was deleted on both devices
|
||||
try {
|
||||
db0.transaction(true, txn -> db0.getMessage(txn, h.getMessageId()));
|
||||
db0.transaction(true, txn ->
|
||||
db0.getSmallMessage(txn, h.getMessageId()));
|
||||
fail();
|
||||
} catch (MessageDeletedException e) {
|
||||
// expected
|
||||
}
|
||||
try {
|
||||
db1.transaction(true, txn -> db1.getMessage(txn, h.getMessageId()));
|
||||
db1.transaction(true, txn ->
|
||||
db1.getSmallMessage(txn, h.getMessageId()));
|
||||
fail();
|
||||
} catch (MessageDeletedException e) {
|
||||
// expected
|
||||
|
||||
@@ -242,7 +242,7 @@ public abstract class BriarIntegrationTest<C extends BriarIntegrationTestCompone
|
||||
executor.execute(() -> {
|
||||
if (DEBUG) {
|
||||
try {
|
||||
BdfList body = clientHelper.getMessageAsList(id);
|
||||
BdfList body = clientHelper.getSmallMessageAsList(id);
|
||||
LOG.info("Contents of " + id + ":\n"
|
||||
+ BdfStringUtils.toString(body));
|
||||
} catch (DbException | FormatException e) {
|
||||
|
||||
Reference in New Issue
Block a user