Local relock

This commit is contained in:
M66B 2020-11-24 09:11:24 +01:00
parent 2d1226daad
commit ece233c65d
2 changed files with 43 additions and 2 deletions

View File

@ -2894,7 +2894,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
(EntityMessage.SMIME_SIGNENCRYPT.equals(message.ui_encrypt) &&
!EntityMessage.SMIME_SIGNENCRYPT.equals(message.encrypt));
if (lock)
onMenuResync(message);
onActionLock(message);
else
onActionDecrypt(message, false);
break;
@ -3799,6 +3799,46 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.putExtra("type", encrypt));
}
private void onActionLock(TupleMessageEx message) {
Bundle args = new Bundle();
args.putLong("id", message.id);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) throws Throwable {
long id = args.getLong("id");
DB db = DB.getInstance(context);
try {
db.beginTransaction();
EntityMessage message = db.message().getMessage(id);
if (message == null)
return null;
File file = message.getFile(context);
Helper.writeText(file, null);
db.message().setMessageContent(message.id, true, null, null, null, null);
//db.message().setMessageSubject(id, subject);
db.attachment().deleteAttachments(message.id);
db.message().setMessageEncrypt(message.id, message.ui_encrypt);
db.message().setMessageStored(message.id, new Date().getTime());
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
return null;
}
@Override
protected void onException(Bundle args, Throwable ex) {
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
}
}.execute(context, owner, args, "message:lock");
}
private void onActionAnswer(TupleMessageEx message, View anchor) {
properties.reply(message, getSelectedText(), anchor);
}

View File

@ -123,6 +123,7 @@ public interface DaoAttachment {
int deleteAttachment(long id);
@Query("DELETE FROM attachment" +
" WHERE message = :message")
" WHERE message = :message" +
" AND encryption IS NULL")
int deleteAttachments(long message);
}