From 7824c772346e13f26eb878ce6a945fbb707e2247 Mon Sep 17 00:00:00 2001 From: Nicolas Werner Date: Tue, 31 Oct 2023 16:38:15 +0100 Subject: Cleanup headers a bit more --- src/encryption/DeviceVerificationFlow.cpp | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'src/encryption/DeviceVerificationFlow.cpp') diff --git a/src/encryption/DeviceVerificationFlow.cpp b/src/encryption/DeviceVerificationFlow.cpp index f0c7ed52..8c7204be 100644 --- a/src/encryption/DeviceVerificationFlow.cpp +++ b/src/encryption/DeviceVerificationFlow.cpp @@ -944,3 +944,33 @@ DeviceVerificationFlow::InitiateDeviceVerification(QObject *parent_, return flow; } +template +void +DeviceVerificationFlow::send(T msg) +{ + if (this->type == DeviceVerificationFlow::Type::ToDevice) { + mtx::requests::ToDeviceMessages body; + msg.transaction_id = this->transaction_id; + for (const auto &d : deviceIds) + body[this->toClient][d.toStdString()] = msg; + + http::client()->send_to_device( + http::client()->generate_txn_id(), body, [](mtx::http::RequestErr err) { + if (err) + nhlog::net()->warn("failed to send verification to_device message: {} {}", + err->matrix_error.error, + static_cast(err->status_code)); + }); + } else if (this->type == DeviceVerificationFlow::Type::RoomMsg && model_) { + if constexpr (!std::is_same_v) { + msg.relations.relations.push_back(this->relation); + // Set synthesized to surpress the nheko relation extensions + msg.relations.synthesized = true; + } + (model_)->sendMessageEvent(msg, mtx::events::to_device_content_to_type); + } + + nhlog::net()->debug("Sent verification step: {} in state: {}", + mtx::events::to_string(mtx::events::to_device_content_to_type), + state().toStdString()); +} -- cgit 1.5.1