Adapt to the new inherited variant

new-timelineevents
Nicolas Werner 2 years ago
parent 7973fbce8c
commit 10b65b78fa
No known key found for this signature in database
GPG Key ID: C8D75E610773F2D9
  1. 2
      CMakeLists.txt
  2. 2
      io.github.NhekoReborn.Nheko.yaml
  3. 50
      src/Cache.cpp
  4. 10
      src/Cache_p.h
  5. 17
      src/ChatPage.cpp
  6. 2
      src/EventAccessors.cpp
  7. 8
      src/Utils.cpp
  8. 9
      src/Utils.h
  9. 8
      src/encryption/Olm.cpp
  10. 36
      src/timeline/EventStore.cpp
  11. 6
      src/timeline/EventStore.h
  12. 2
      src/timeline/InputBar.cpp
  13. 37
      src/timeline/TimelineModel.cpp
  14. 2
      src/timeline/TimelineModel.h
  15. 2
      src/timeline/TimelineViewManager.cpp
  16. 2
      src/timeline/TimelineViewManager.h

@ -602,7 +602,7 @@ if(USE_BUNDLED_MTXCLIENT)
FetchContent_Declare(
MatrixClient
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
GIT_TAG dd2bdbd104ae8f70f82da9ff7b4b60007fc105c3
GIT_TAG e136bc27b28d3bb5683735eb5a65d6ef2534ca3a
)
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")

@ -213,7 +213,7 @@ modules:
buildsystem: cmake-ninja
name: mtxclient
sources:
- commit: dd2bdbd104ae8f70f82da9ff7b4b60007fc105c3
- commit: e136bc27b28d3bb5683735eb5a65d6ef2534ca3a
#tag: v0.9.2
type: git
url: https://github.com/Nheko-Reborn/mtxclient.git

@ -1284,9 +1284,8 @@ Cache::runMigrations()
else if (j["token"].get<std::string>() != oldMessages.prev_batch)
break;
mtx::events::collections::TimelineEvent te;
from_json(j["event"], te);
oldMessages.events.push_back(te.data);
oldMessages.events.push_back(
j["event"].get<mtx::events::collections::TimelineEvents>());
}
// messages were stored in reverse order, so we
// need to reverse them
@ -2398,15 +2397,13 @@ Cache::getTimelineMessages(lmdb::txn &txn, const std::string &room_id, uint64_t
if (!success)
continue;
mtx::events::collections::TimelineEvent te;
try {
from_json(nlohmann::json::parse(event), te);
messages.timeline.events.push_back(
nlohmann::json::parse(event).get<mtx::events::collections::TimelineEvents>());
} catch (std::exception &e) {
nhlog::db()->error("Failed to parse message from cache {}", e.what());
continue;
}
messages.timeline.events.push_back(std::move(te.data));
}
cursor.close();
@ -2417,7 +2414,7 @@ Cache::getTimelineMessages(lmdb::txn &txn, const std::string &room_id, uint64_t
return messages;
}
std::optional<mtx::events::collections::TimelineEvent>
std::optional<mtx::events::collections::TimelineEvents>
Cache::getEvent(const std::string &room_id, std::string_view event_id)
{
auto txn = ro_txn(env_);
@ -2428,24 +2425,21 @@ Cache::getEvent(const std::string &room_id, std::string_view event_id)
if (!success)
return {};
mtx::events::collections::TimelineEvent te;
try {
from_json(nlohmann::json::parse(event), te);
return nlohmann::json::parse(event).get<mtx::events::collections::TimelineEvents>();
} catch (std::exception &e) {
nhlog::db()->error("Failed to parse message from cache {}", e.what());
return std::nullopt;
}
return te;
}
void
Cache::storeEvent(const std::string &room_id,
const std::string &event_id,
const mtx::events::collections::TimelineEvent &event)
const mtx::events::collections::TimelineEvents &event)
{
auto txn = lmdb::txn::begin(env_);
auto eventsDb = getEventsDb(txn, room_id);
auto event_json = mtx::accessors::serialize_event(event.data);
auto event_json = mtx::accessors::serialize_event(event);
eventsDb.put(txn, event_id, event_json.dump());
txn.commit();
}
@ -2453,17 +2447,17 @@ Cache::storeEvent(const std::string &room_id,
void
Cache::replaceEvent(const std::string &room_id,
const std::string &event_id,
const mtx::events::collections::TimelineEvent &event)
const mtx::events::collections::TimelineEvents &event)
{
auto txn = lmdb::txn::begin(env_);
auto eventsDb = getEventsDb(txn, room_id);
auto relationsDb = getRelationsDb(txn, room_id);
auto event_json = mtx::accessors::serialize_event(event.data).dump();
auto event_json = mtx::accessors::serialize_event(event).dump();
{
eventsDb.del(txn, event_id);
eventsDb.put(txn, event_id, event_json);
for (const auto &relation : mtx::accessors::relations(event.data).relations) {
for (const auto &relation : mtx::accessors::relations(event).relations) {
relationsDb.put(txn, relation.event_id, event_id);
}
}
@ -3430,19 +3424,19 @@ Cache::isRoomMember(const std::string &user_id, const std::string &room_id)
void
Cache::savePendingMessage(const std::string &room_id,
const mtx::events::collections::TimelineEvent &message)
const mtx::events::collections::TimelineEvents &message)
{
auto txn = lmdb::txn::begin(env_);
auto eventsDb = getEventsDb(txn, room_id);
mtx::responses::Timeline timeline;
timeline.events.push_back(message.data);
timeline.events.push_back(message);
saveTimelineMessages(txn, eventsDb, room_id, timeline);
auto pending = getPendingMessagesDb(txn, room_id);
int64_t now = QDateTime::currentMSecsSinceEpoch();
pending.put(txn, lmdb::to_sv(now), mtx::accessors::event_id(message.data));
pending.put(txn, lmdb::to_sv(now), mtx::accessors::event_id(message));
txn.commit();
}
@ -3469,7 +3463,7 @@ Cache::pendingEvents(const std::string &room_id)
return related_ids;
}
std::optional<mtx::events::collections::TimelineEvent>
std::optional<mtx::events::collections::TimelineEvents>
Cache::firstPendingMessage(const std::string &room_id)
{
auto txn = lmdb::txn::begin(env_);
@ -3487,8 +3481,8 @@ Cache::firstPendingMessage(const std::string &room_id)
}
try {
mtx::events::collections::TimelineEvent te;
from_json(nlohmann::json::parse(event), te);
mtx::events::collections::TimelineEvents te =
nlohmann::json::parse(event).get<mtx::events::collections::TimelineEvents>();
pendingCursor.close();
return te;
@ -3622,10 +3616,10 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
if (!success)
continue;
mtx::events::collections::TimelineEvent te;
try {
from_json(nlohmann::json::parse(std::string_view(oldEvent.data(), oldEvent.size())),
te);
auto te = nlohmann::json::parse(std::string_view(oldEvent.data(), oldEvent.size()))
.get<mtx::events::collections::TimelineEvents>();
// overwrite the content and add redation data
std::visit(
[&redaction, &room_id, &txn, &eventsDb, this](auto &ev) {
@ -3652,8 +3646,8 @@ Cache::saveTimelineMessages(lmdb::txn &txn,
mtx::events::collections::StateEvents{redactedEvent});
}
},
te.data);
event = mtx::accessors::serialize_event(te.data);
te);
event = mtx::accessors::serialize_event(te);
event["content"].clear();
} catch (std::exception &e) {

@ -193,14 +193,14 @@ public:
uint64_t index = std::numeric_limits<uint64_t>::max(),
bool forward = false);
std::optional<mtx::events::collections::TimelineEvent>
std::optional<mtx::events::collections::TimelineEvents>
getEvent(const std::string &room_id, std::string_view event_id);
void storeEvent(const std::string &room_id,
const std::string &event_id,
const mtx::events::collections::TimelineEvent &event);
const mtx::events::collections::TimelineEvents &event);
void replaceEvent(const std::string &room_id,
const std::string &event_id,
const mtx::events::collections::TimelineEvent &event);
const mtx::events::collections::TimelineEvents &event);
std::vector<std::string> relatedEvents(const std::string &room_id, const std::string &event_id);
struct TimelineRange
@ -219,9 +219,9 @@ public:
std::string previousBatchToken(const std::string &room_id);
uint64_t saveOldMessages(const std::string &room_id, const mtx::responses::Messages &res);
void savePendingMessage(const std::string &room_id,
const mtx::events::collections::TimelineEvent &message);
const mtx::events::collections::TimelineEvents &message);
std::vector<std::string> pendingEvents(const std::string &room_id);
std::optional<mtx::events::collections::TimelineEvent>
std::optional<mtx::events::collections::TimelineEvents>
firstPendingMessage(const std::string &room_id);
void removePendingStatus(const std::string &room_id, const std::string &txn_id);

@ -270,7 +270,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
auto ctx = roomModel->pushrulesRoomContext();
std::vector<
std::pair<mtx::common::Relation, mtx::events::collections::TimelineEvent>>
std::pair<mtx::common::Relation, mtx::events::collections::TimelineEvents>>
relatedEvents;
for (const auto &event : room.timeline.events) {
@ -286,9 +286,9 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
if (sender == http::client()->user_id().to_string())
continue;
mtx::events::collections::TimelineEvent te{event};
mtx::events::collections::TimelineEvents te{event};
std::visit([room_id = room_id](auto &event_) { event_.room_id = room_id; },
te.data);
te);
if (auto encryptedEvent =
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
@ -298,23 +298,24 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
auto result = olm::decryptEvent(index, *encryptedEvent);
if (result.event)
te.data = result.event.value();
te = std::move(result.event).value();
}
relatedEvents.clear();
for (const auto &r : mtx::accessors::relations(te.data).relations) {
for (const auto &r : mtx::accessors::relations(te).relations) {
auto related = cache::client()->getEvent(room_id, r.event_id);
if (related) {
relatedEvents.emplace_back(r, *related);
if (auto encryptedEvent = std::get_if<
mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
&related->data);
&related.value());
encryptedEvent && userSettings_->decryptNotifications()) {
MegolmSessionIndex index(room_id, encryptedEvent->content);
auto result = olm::decryptEvent(index, *encryptedEvent);
if (result.event)
relatedEvents.back().second.data = result.event.value();
relatedEvents.back().second =
std::move(result.event).value();
}
}
}
@ -343,7 +344,7 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
notificationsManager->postNotification(
mtx::responses::Notification{
.actions = actions,
.event = te.data,
.event = std::move(te),
.read = false,
.profile_tag = "",
.room_id = room_id,

@ -461,7 +461,7 @@ mtx::accessors::media_width(const mtx::events::collections::TimelineEvents &even
nlohmann::json
mtx::accessors::serialize_event(const mtx::events::collections::TimelineEvents &event)
{
return std::visit([](const auto &e) { return nlohmann::json(e); }, event);
return nlohmann::json(event);
}
bool

@ -37,8 +37,6 @@
#include "UserSettingsPage.h"
#include "timeline/Permissions.h"
using TimelineEvent = mtx::events::collections::TimelineEvents;
template<class T, class Event>
static DescInfo
createDescriptionInfo(const Event &event, const QString &localUser, const QString &displayName)
@ -89,7 +87,9 @@ utils::stripReplyFromFormattedBody(const std::string &formatted_bodyi)
}
RelatedInfo
utils::stripReplyFallbacks(const TimelineEvent &event, std::string id, QString room_id_)
utils::stripReplyFallbacks(const mtx::events::collections::TimelineEvents &event,
std::string id,
QString room_id_)
{
RelatedInfo related = {};
related.quoted_user = QString::fromStdString(mtx::accessors::sender(event));
@ -211,7 +211,7 @@ utils::descriptiveTime(const QDateTime &then)
}
DescInfo
utils::getMessageDescription(const TimelineEvent &event,
utils::getMessageDescription(const mtx::events::collections::TimelineEvents &event,
const QString &localUser,
const QString &displayName)
{

@ -39,9 +39,6 @@ struct RelatedInfo
};
namespace utils {
using TimelineEvent = mtx::events::collections::TimelineEvents;
//! Helper function to remove reply fallback from body
std::string
stripReplyFromBody(const std::string &body);
@ -51,7 +48,9 @@ std::string
stripReplyFromFormattedBody(const std::string &formatted_body);
RelatedInfo
stripReplyFallbacks(const TimelineEvent &event, std::string id, QString room_id_);
stripReplyFallbacks(const mtx::events::collections::TimelineEvents &event,
std::string id,
QString room_id_);
bool
codepointIsEmoji(uint code);
@ -75,7 +74,7 @@ descriptiveTime(const QDateTime &then);
//! Generate a message description from the event to be displayed
//! in the RoomList.
DescInfo
getMessageDescription(const TimelineEvent &event,
getMessageDescription(const mtx::events::collections::TimelineEvents &event,
const QString &localUser,
const QString &displayName);

@ -1273,13 +1273,13 @@ decryptEvent(const MegolmSessionIndex &index,
body["origin_server_ts"] = event.origin_server_ts;
body["unsigned"] = event.unsigned_data;
mtx::events::collections::TimelineEvent te;
from_json(body, te);
mtx::events::collections::TimelineEvents te =
body.get<mtx::events::collections::TimelineEvents>();
// relations are unencrypted in content...
mtx::accessors::set_relations(te.data, std::move(event.content.relations));
mtx::accessors::set_relations(te, std::move(event.content.relations));
return {DecryptionErrorCode::NoError, std::nullopt, std::move(te.data)};
return {DecryptionErrorCode::NoError, std::nullopt, std::move(te)};
} catch (std::exception &e) {
return {DecryptionErrorCode::ParsingFailed, e.what(), std::nullopt};
}

@ -155,7 +155,7 @@ EventStore::EventStore(std::string room_id, QObject *)
}
});
},
event->data);
event.value());
});
connect(
@ -195,20 +195,20 @@ EventStore::EventStore(std::string room_id, QObject *)
mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> original_encrypted;
if (auto encrypted =
std::get_if<mtx::events::EncryptedEvent<mtx::events::msg::Encrypted>>(
&pending_event->data)) {
&pending_event.value())) {
auto d_event = decryptEvent({room_id_, encrypted->event_id}, *encrypted);
if (d_event->event) {
was_encrypted = true;
original_encrypted = *encrypted;
pending_event->data = *d_event->event;
original_encrypted = std::move(*encrypted);
*pending_event = std::move(*d_event->event);
}
}
auto relations = mtx::accessors::relations(pending_event->data);
auto relations = mtx::accessors::relations(pending_event.value());
// Replace the blockquote in fallback reply
auto related_text = std::get_if<mtx::events::RoomEvent<mtx::events::msg::Text>>(
&pending_event->data);
&pending_event.value());
if (related_text && relations.reply_to() == txn_id) {
size_t index = related_text->content.formatted_body.find(txn_id);
if (index != std::string::npos) {
@ -228,7 +228,7 @@ EventStore::EventStore(std::string room_id, QObject *)
if (!replaced_txn)
continue;
mtx::accessors::set_relations(pending_event->data, std::move(relations));
mtx::accessors::set_relations(pending_event.value(), std::move(relations));
// reencrypt. This is a bit of a hack and might make people able to read the
// message, that were in the room at the time of sending the last pending message.
@ -246,7 +246,7 @@ EventStore::EventStore(std::string room_id, QObject *)
{"content", nlohmann::json(msg.content)},
{"room_id", room_id_}};
},
pending_event->data);
pending_event.value());
auto data = olm::encrypt_group_message_with_session(
session.session, http::client()->device_id(), std::move(doc));
@ -255,8 +255,8 @@ EventStore::EventStore(std::string room_id, QObject *)
olm_outbound_group_session_message_index(session.session.get());
cache::updateOutboundMegolmSession(room_id_, session.data, session.session);
original_encrypted.content = data;
pending_event->data = original_encrypted;
original_encrypted.content = std::move(data);
*pending_event = std::move(original_encrypted);
}
cache::client()->replaceEvent(room_id_, pending_event_id, *pending_event);
@ -629,7 +629,7 @@ EventStore::reactions(const std::string &event_id)
return temp;
}
mtx::events::collections::TimelineEvents *
mtx::events::collections::TimelineEvents const *
EventStore::get(int idx, bool decrypt)
{
if (this->thread() != QThread::currentThread())
@ -645,17 +645,17 @@ EventStore::get(int idx, bool decrypt)
if (!event_id)
return nullptr;
std::optional<mtx::events::collections::TimelineEvent> event;
std::optional<mtx::events::collections::TimelineEvents> event;
auto edits_ = edits(*event_id);
if (edits_.empty())
event = cache::client()->getEvent(room_id_, *event_id);
else
event = mtx::events::collections::TimelineEvent{edits_.back()};
event = mtx::events::collections::TimelineEvents{edits_.back()};
if (!event)
return nullptr;
else
event_ptr = new mtx::events::collections::TimelineEvents(std::move(event->data));
event_ptr = new mtx::events::collections::TimelineEvents(std::move(*event));
events_.insert(index, event_ptr);
}
@ -692,7 +692,7 @@ EventStore::indexToId(int idx) const
return cache::client()->getTimelineEventId(room_id_, toInternalIdx(idx));
}
olm::DecryptionResult *
olm::DecryptionResult const *
EventStore::decryptEvent(const IdIndex &idx,
const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e)
{
@ -813,7 +813,7 @@ EventStore::enableKeyRequests(bool suppressKeyRequests_)
suppressKeyRequests = true;
}
mtx::events::collections::TimelineEvents *
mtx::events::collections::TimelineEvents const *
EventStore::get(const std::string &id,
std::string_view related_to,
bool decrypt,
@ -856,7 +856,7 @@ EventStore::get(const std::string &id,
});
return nullptr;
}
event_ptr = new mtx::events::collections::TimelineEvents(std::move(event->data));
event_ptr = new mtx::events::collections::TimelineEvents(std::move(*event));
events_by_id_.insert(index, event_ptr);
}
@ -895,7 +895,7 @@ EventStore::decryptionError(std::string id)
if (!event) {
return olm::DecryptionErrorCode::NoError;
}
event_ptr = new mtx::events::collections::TimelineEvents(std::move(event->data));
event_ptr = new mtx::events::collections::TimelineEvents(std::move(*event));
events_by_id_.insert(index, event_ptr);
}

@ -73,12 +73,12 @@ public:
// optionally returns the event or nullptr and fetches it, after which it emits a
// relatedFetched event
mtx::events::collections::TimelineEvents *get(const std::string &id,
mtx::events::collections::TimelineEvents const *get(const std::string &id,
std::string_view related_to,
bool decrypt = true,
bool resolve_edits = true);
// always returns a proper event as long as the idx is valid
mtx::events::collections::TimelineEvents *get(int idx, bool decrypt = true);
mtx::events::collections::TimelineEvents const *get(int idx, bool decrypt = true);
QVariantList reactions(const std::string &event_id);
std::vector<mtx::events::collections::TimelineEvents> edits(const std::string &event_id);
@ -126,7 +126,7 @@ public slots:
void enableKeyRequests(bool suppressKeyRequests_);
private:
olm::DecryptionResult *
olm::DecryptionResult const *
decryptEvent(const IdIndex &idx,
const mtx::events::EncryptedEvent<mtx::events::msg::Encrypted> &e);

@ -53,7 +53,7 @@ threadFallbackEventId(const std::string &room_id, const std::string &thread_id)
for (const auto &[index, event_id] : orderedEvents) {
(void)index;
if (auto event = cache::client()->getEvent(room_id, event_id)) {
if (mtx::accessors::relations(event->data).thread() == thread_id)
if (mtx::accessors::relations(event.value()).thread() == thread_id)
return std::string(event_id);
}
}

@ -776,13 +776,12 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
return qml_mtx_events::NotificationLevel::Nothing;
const auto &id = event_id(event);
std::vector<std::pair<mtx::common::Relation, mtx::events::collections::TimelineEvent>>
std::vector<std::pair<mtx::common::Relation, mtx::events::collections::TimelineEvents>>
relatedEvents;
for (const auto &r : mtx::accessors::relations(event).relations) {
auto related = events.get(r.event_id, id);
if (related) {
relatedEvents.emplace_back(r,
mtx::events::collections::TimelineEvent{*related});
relatedEvents.emplace_back(r, *related);
}
}
@ -1790,7 +1789,7 @@ TimelineModel::openMedia(const QString &eventId)
bool
TimelineModel::saveMedia(const QString &eventId) const
{
mtx::events::collections::TimelineEvents *event = events.get(eventId.toStdString(), "");
auto event = events.get(eventId.toStdString(), "");
if (!event)
return false;
@ -1865,7 +1864,7 @@ void
TimelineModel::cacheMedia(const QString &eventId,
const std::function<void(const QString)> &callback)
{
mtx::events::collections::TimelineEvents *event = events.get(eventId.toStdString(), "");
auto event = events.get(eventId.toStdString(), "");
if (!event)
return;
@ -2150,7 +2149,7 @@ TimelineModel::formatTypingUsers(const std::vector<QString> &users, const QColor
QString
TimelineModel::formatJoinRuleEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return {};
@ -2187,7 +2186,7 @@ TimelineModel::formatJoinRuleEvent(const QString &id)
QString
TimelineModel::formatGuestAccessEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return {};
@ -2211,7 +2210,7 @@ TimelineModel::formatGuestAccessEvent(const QString &id)
QString
TimelineModel::formatHistoryVisibilityEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return {};
@ -2243,7 +2242,7 @@ TimelineModel::formatHistoryVisibilityEvent(const QString &id)
QString
TimelineModel::formatPowerLevelEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return {};
@ -2251,7 +2250,7 @@ TimelineModel::formatPowerLevelEvent(const QString &id)
if (!event)
return QString();
mtx::events::StateEvent<mtx::events::state::PowerLevels> *prevEvent = nullptr;
mtx::events::StateEvent<mtx::events::state::PowerLevels> const *prevEvent = nullptr;
if (!event->unsigned_data.replaces_state.empty()) {
auto tempPrevEvent = events.get(event->unsigned_data.replaces_state, event->event_id);
if (tempPrevEvent) {
@ -2519,7 +2518,7 @@ TimelineModel::formatPowerLevelEvent(const QString &id)
QString
TimelineModel::formatImagePackEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return {};
@ -2527,7 +2526,7 @@ TimelineModel::formatImagePackEvent(const QString &id)
if (!event)
return {};
mtx::events::StateEvent<mtx::events::msc2545::ImagePack> *prevEvent = nullptr;
mtx::events::StateEvent<mtx::events::msc2545::ImagePack> const *prevEvent = nullptr;
if (!event->unsigned_data.replaces_state.empty()) {
auto tempPrevEvent = events.get(event->unsigned_data.replaces_state, event->event_id);
if (tempPrevEvent) {
@ -2592,7 +2591,7 @@ QString
TimelineModel::formatPolicyRule(const QString &id)
{
auto idStr = id.toStdString();
mtx::events::collections::TimelineEvents *e = events.get(idStr, "");
auto e = events.get(idStr, "");
if (!e)
return {};
@ -2683,7 +2682,7 @@ QVariantMap
TimelineModel::formatRedactedEvent(const QString &id)
{
QVariantMap pair{{"first", ""}, {"second", ""}};
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return pair;
@ -2720,7 +2719,7 @@ TimelineModel::formatRedactedEvent(const QString &id)
void
TimelineModel::acceptKnock(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return;
@ -2745,7 +2744,7 @@ TimelineModel::acceptKnock(const QString &id)
bool
TimelineModel::showAcceptKnockButton(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return false;
@ -2766,7 +2765,7 @@ TimelineModel::showAcceptKnockButton(const QString &id)
void
TimelineModel::joinReplacementRoom(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return;
@ -2792,7 +2791,7 @@ TimelineModel::joinReplacementRoom(const QString &id)
QString
TimelineModel::formatMemberEvent(const QString &id)
{
mtx::events::collections::TimelineEvents *e = events.get(id.toStdString(), "");
auto e = events.get(id.toStdString(), "");
if (!e)
return {};
@ -2800,7 +2799,7 @@ TimelineModel::formatMemberEvent(const QString &id)
if (!event)
return {};
mtx::events::StateEvent<mtx::events::state::Member> *prevEvent = nullptr;
mtx::events::StateEvent<mtx::events::state::Member> const *prevEvent = nullptr;
if (!event->unsigned_data.replaces_state.empty()) {
auto tempPrevEvent = events.get(event->unsigned_data.replaces_state, event->event_id);
if (tempPrevEvent) {

@ -483,7 +483,7 @@ signals:
void isDirectChanged();
void directChatOtherUserIdChanged();
void permissionsChanged();
void forwardToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
void forwardToRoom(mtx::events::collections::TimelineEvents const *e, QString roomId);
void scrollTargetChanged();

@ -461,7 +461,7 @@ TimelineViewManager::completerFor(const QString &completerName, const QString &r
}
void
TimelineViewManager::forwardMessageToRoom(mtx::events::collections::TimelineEvents *e,
TimelineViewManager::forwardMessageToRoom(mtx::events::collections::TimelineEvents const *e,
QString roomId)
{
auto room = rooms_->getRoomById(roomId);

@ -113,7 +113,7 @@ public slots:
QObject *completerFor(const QString &completerName,
const QString &roomId = QLatin1String(QLatin1String("")));
void forwardMessageToRoom(mtx::events::collections::TimelineEvents *e, QString roomId);
void forwardMessageToRoom(mtx::events::collections::TimelineEvents const *e, QString roomId);
RoomlistModel *rooms() { return rooms_; }

Loading…
Cancel
Save