// SPDX-FileCopyrightText: Nheko Contributors // // SPDX-License-Identifier: GPL-3.0-or-later #include "notifications/Manager.h" #include "Cache.h" #include "EventAccessors.h" #include "Utils.h" QString NotificationsManager::getMessageTemplate(const mtx::responses::Notification ¬ification) { const auto sender = cache::displayName(QString::fromStdString(notification.room_id), QString::fromStdString(mtx::accessors::sender(notification.event))); // TODO: decrypt this message if the decryption setting is on in the UserSettings if (auto msg = std::get_if>( ¬ification.event); msg != nullptr) { return tr("%1 sent an encrypted message").arg(sender); } bool containsSpoiler = mtx::accessors::formatted_body(notification.event).find(" &eventIds) { std::string room_id = roomId_.toStdString(); std::uint64_t markerPos = 0; for (const auto &e : eventIds) { markerPos = std::max(markerPos, cache::getEventIndex(room_id, e.toStdString()).value_or(0)); } for (const auto &[roomId, eventId] : std::as_const(this->notificationIds)) { if (roomId != roomId_) continue; auto idx = cache::getEventIndex(room_id, eventId.toStdString()); if (!idx || markerPos >= idx) { removeNotification(roomId, eventId); } } } #include "moc_Manager.cpp"