synchronize message body changes for message correction

This commit is contained in:
Daniel Gultsch 2016-06-16 11:47:40 +02:00
parent f8b1e8098c
commit 1eb776f39c
2 changed files with 72 additions and 68 deletions

View File

@ -104,6 +104,7 @@ public class PgpDecryptionService {
} }
private void executeApi(Message message) { private void executeApi(Message message) {
synchronized (message) {
Intent params = new Intent(); Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
if (message.getType() == Message.TYPE_TEXT) { if (message.getType() == Message.TYPE_TEXT) {
@ -174,6 +175,7 @@ public class PgpDecryptionService {
mXmppConnectionService.updateMessage(message); mXmppConnectionService.updateMessage(message);
} }
} }
}
notifyIfPending(message); notifyIfPending(message);
} }

View File

@ -468,6 +468,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
&& replacedMessage.getTrueCounterpart().equals(message.getTrueCounterpart()); && replacedMessage.getTrueCounterpart().equals(message.getTrueCounterpart());
if (fingerprintsMatch && (trueCountersMatch || !conversationMultiMode)) { if (fingerprintsMatch && (trueCountersMatch || !conversationMultiMode)) {
Log.d(Config.LOGTAG, "replaced message '" + replacedMessage.getBody() + "' with '" + message.getBody() + "'"); Log.d(Config.LOGTAG, "replaced message '" + replacedMessage.getBody() + "' with '" + message.getBody() + "'");
synchronized (replacedMessage) {
final String uuid = replacedMessage.getUuid(); final String uuid = replacedMessage.getUuid();
replacedMessage.setUuid(UUID.randomUUID().toString()); replacedMessage.setUuid(UUID.randomUUID().toString());
replacedMessage.setBody(message.getBody()); replacedMessage.setBody(message.getBody());
@ -486,6 +487,7 @@ public class MessageParser extends AbstractParser implements OnMessagePacketRece
conversation.getAccount().getPgpDecryptionService().discard(replacedMessage); conversation.getAccount().getPgpDecryptionService().discard(replacedMessage);
conversation.getAccount().getPgpDecryptionService().decrypt(replacedMessage, false); conversation.getAccount().getPgpDecryptionService().decrypt(replacedMessage, false);
} }
}
return; return;
} else { } else {
Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received message correction but verification didn't check out"); Log.d(Config.LOGTAG,account.getJid().toBareJid()+": received message correction but verification didn't check out");