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) {
synchronized (message) {
Intent params = new Intent();
params.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
if (message.getType() == Message.TYPE_TEXT) {
@ -151,7 +152,7 @@ public class PgpDecryptionService {
switch (result.getIntExtra(OpenPgpApi.RESULT_CODE, OpenPgpApi.RESULT_CODE_ERROR)) {
case OpenPgpApi.RESULT_CODE_SUCCESS:
URL url = message.getFileParams().url;
mXmppConnectionService.getFileBackend().updateFileParams(message,url);
mXmppConnectionService.getFileBackend().updateFileParams(message, url);
message.setEncryption(Message.ENCRYPTION_DECRYPTED);
inputFile.delete();
mXmppConnectionService.getFileBackend().updateMediaScanner(outputFile);
@ -174,6 +175,7 @@ public class PgpDecryptionService {
mXmppConnectionService.updateMessage(message);
}
}
}
notifyIfPending(message);
}

View file

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