+ clear = _notmuch_crypto_decrypt (&attempted, notmuch_indexopts_get_decrypt_policy (indexopts),
+ message, encrypted_data, get_sk ? &decrypt_result : NULL, &err);
+ if (! attempted)
+ return;
+ if (err || ! clear) {
+ if (decrypt_result)
+ g_object_unref (decrypt_result);
+ if (err) {
+ _notmuch_database_log (notmuch, "Failed to decrypt during indexing. (%d:%d) [%s]\n",
+ err->domain, err->code, err->message);
+ g_error_free (err);
+ } else {
+ _notmuch_database_log (notmuch, "Failed to decrypt during indexing. (unknown error)\n");
+ }
+ /* Indicate that we failed to decrypt during indexing */
+ status = notmuch_message_add_property (message, "index.decryption", "failure");
+ if (status)
+ _notmuch_database_log_append (notmuch, "failed to add index.decryption "
+ "property (%d)\n", status);
+ return;
+ }
+ if (decrypt_result) {
+ status = _notmuch_message_crypto_successful_decryption (msg_crypto);
+ if (status)
+ _notmuch_database_log_append (notmuch, "failed to mark the message as decrypted (%s)\n",
+ notmuch_status_to_string (status));
+ if (get_sk) {
+ status = notmuch_message_add_property (message, "session-key",
+ g_mime_decrypt_result_get_session_key (
+ decrypt_result));
+ if (status)
+ _notmuch_database_log (notmuch, "failed to add session-key "
+ "property (%d)\n", status);
+ }
+ g_object_unref (decrypt_result);
+ }
+ GMimeObject *toindex = clear;
+
+ if (_notmuch_message_crypto_potential_payload (msg_crypto, clear, encrypted_data,
+ GMIME_MULTIPART_ENCRYPTED_CONTENT) &&
+ msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL) {
+ toindex = _notmuch_repair_crypto_payload_skip_legacy_display (clear);
+ if (toindex != clear)
+ notmuch_message_add_property (message, "index.repaired",
+ "skip-protected-headers-legacy-display");
+ }
+ _index_mime_part (message, indexopts, toindex, msg_crypto);
+ g_object_unref (clear);
+
+ status = notmuch_message_add_property (message, "index.decryption", "success");
+ if (status)
+ _notmuch_database_log (notmuch, "failed to add index.decryption "
+ "property (%d)\n", status);