mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-23 03:18:49 +03:00
Don't fail on missing key for a device and /rotate-megolm-session command
This commit is contained in:
parent
abff61bb6c
commit
2a79cd2b6b
7 changed files with 40 additions and 0 deletions
|
@ -372,6 +372,25 @@ Cache::updateOutboundMegolmSession(const std::string &room_id, int message_index
|
||||||
txn.commit();
|
txn.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Cache::dropOutboundMegolmSession(const std::string &room_id)
|
||||||
|
{
|
||||||
|
using namespace mtx::crypto;
|
||||||
|
|
||||||
|
if (!outboundMegolmSessionExists(room_id))
|
||||||
|
return;
|
||||||
|
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> lock(session_storage.group_outbound_mtx);
|
||||||
|
session_storage.group_outbound_session_data.erase(room_id);
|
||||||
|
session_storage.group_outbound_sessions.erase(room_id);
|
||||||
|
|
||||||
|
auto txn = lmdb::txn::begin(env_);
|
||||||
|
lmdb::dbi_del(txn, outboundMegolmSessionDb_, lmdb::val(room_id), nullptr);
|
||||||
|
txn.commit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Cache::saveOutboundMegolmSession(const std::string &room_id,
|
Cache::saveOutboundMegolmSession(const std::string &room_id,
|
||||||
const OutboundGroupSessionData &data,
|
const OutboundGroupSessionData &data,
|
||||||
|
@ -3889,6 +3908,11 @@ updateOutboundMegolmSession(const std::string &room_id, int message_index)
|
||||||
{
|
{
|
||||||
instance_->updateOutboundMegolmSession(room_id, message_index);
|
instance_->updateOutboundMegolmSession(room_id, message_index);
|
||||||
}
|
}
|
||||||
|
void
|
||||||
|
dropOutboundMegolmSession(const std::string &room_id)
|
||||||
|
{
|
||||||
|
instance_->dropOutboundMegolmSession(room_id);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
importSessionKeys(const mtx::crypto::ExportedSessionKeys &keys)
|
importSessionKeys(const mtx::crypto::ExportedSessionKeys &keys)
|
||||||
|
|
|
@ -271,6 +271,8 @@ bool
|
||||||
outboundMegolmSessionExists(const std::string &room_id) noexcept;
|
outboundMegolmSessionExists(const std::string &room_id) noexcept;
|
||||||
void
|
void
|
||||||
updateOutboundMegolmSession(const std::string &room_id, int message_index);
|
updateOutboundMegolmSession(const std::string &room_id, int message_index);
|
||||||
|
void
|
||||||
|
dropOutboundMegolmSession(const std::string &room_id);
|
||||||
|
|
||||||
void
|
void
|
||||||
importSessionKeys(const mtx::crypto::ExportedSessionKeys &keys);
|
importSessionKeys(const mtx::crypto::ExportedSessionKeys &keys);
|
||||||
|
|
|
@ -251,6 +251,7 @@ public:
|
||||||
OutboundGroupSessionDataRef getOutboundMegolmSession(const std::string &room_id);
|
OutboundGroupSessionDataRef getOutboundMegolmSession(const std::string &room_id);
|
||||||
bool outboundMegolmSessionExists(const std::string &room_id) noexcept;
|
bool outboundMegolmSessionExists(const std::string &room_id) noexcept;
|
||||||
void updateOutboundMegolmSession(const std::string &room_id, int message_index);
|
void updateOutboundMegolmSession(const std::string &room_id, int message_index);
|
||||||
|
void dropOutboundMegolmSession(const std::string &room_id);
|
||||||
|
|
||||||
void importSessionKeys(const mtx::crypto::ExportedSessionKeys &keys);
|
void importSessionKeys(const mtx::crypto::ExportedSessionKeys &keys);
|
||||||
mtx::crypto::ExportedSessionKeys exportSessionKeys();
|
mtx::crypto::ExportedSessionKeys exportSessionKeys();
|
||||||
|
|
|
@ -168,6 +168,10 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QWidget *parent)
|
||||||
view_manager_,
|
view_manager_,
|
||||||
&TimelineViewManager::clearCurrentRoomTimeline);
|
&TimelineViewManager::clearCurrentRoomTimeline);
|
||||||
|
|
||||||
|
connect(text_input_, &TextInputWidget::rotateMegolmSession, this, [this]() {
|
||||||
|
cache::dropOutboundMegolmSession(current_room_.toStdString());
|
||||||
|
});
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
new QShortcut(QKeySequence("Ctrl+Down"), this), &QShortcut::activated, this, [this]() {
|
new QShortcut(QKeySequence("Ctrl+Down"), this), &QShortcut::activated, this, [this]() {
|
||||||
if (isVisible())
|
if (isVisible())
|
||||||
|
|
|
@ -709,6 +709,8 @@ TextInputWidget::command(QString command, QString args)
|
||||||
emit sendTextMessage("ノ┬─┬ノ ︵ ( \\o°o)\\");
|
emit sendTextMessage("ノ┬─┬ノ ︵ ( \\o°o)\\");
|
||||||
} else if (command == "clear-timeline") {
|
} else if (command == "clear-timeline") {
|
||||||
emit clearRoomTimeline();
|
emit clearRoomTimeline();
|
||||||
|
} else if (command == "rotate-megolm-session") {
|
||||||
|
emit rotateMegolmSession();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -186,6 +186,7 @@ signals:
|
||||||
void sendBanRoomRequest(const QString &userid, const QString &reason);
|
void sendBanRoomRequest(const QString &userid, const QString &reason);
|
||||||
void sendUnbanRoomRequest(const QString &userid, const QString &reason);
|
void sendUnbanRoomRequest(const QString &userid, const QString &reason);
|
||||||
void changeRoomNick(const QString &displayname);
|
void changeRoomNick(const QString &displayname);
|
||||||
|
void rotateMegolmSession();
|
||||||
|
|
||||||
void startedTyping();
|
void startedTyping();
|
||||||
void stoppedTyping();
|
void stoppedTyping();
|
||||||
|
|
|
@ -1120,6 +1120,12 @@ TimelineModel::handleClaimedKeys(
|
||||||
|
|
||||||
nhlog::net()->debug("{} : \n {}", device_id, rd.second.dump(2));
|
nhlog::net()->debug("{} : \n {}", device_id, rd.second.dump(2));
|
||||||
|
|
||||||
|
if (rd.second.empty() || !rd.second.begin()->contains("key")) {
|
||||||
|
nhlog::net()->warn("Skipping device {} as it has no key.",
|
||||||
|
device_id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Verify signatures
|
// TODO: Verify signatures
|
||||||
auto otk = rd.second.begin()->at("key");
|
auto otk = rd.second.begin()->at("key");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue