Skip notifying for your own messages
This commit is contained in:
parent
35673b5b52
commit
114fa0868a
@ -266,6 +266,18 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
|
|||||||
relatedEvents;
|
relatedEvents;
|
||||||
|
|
||||||
for (const auto &event : room.timeline.events) {
|
for (const auto &event : room.timeline.events) {
|
||||||
|
auto event_id = mtx::accessors::event_id(event);
|
||||||
|
|
||||||
|
// skip already read events
|
||||||
|
if (currentReadMarker &&
|
||||||
|
currentReadMarker > cache::getEventIndex(room_id, event_id))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// skip our messages
|
||||||
|
auto sender = mtx::accessors::sender(event);
|
||||||
|
if (sender == http::client()->user_id().to_string())
|
||||||
|
continue;
|
||||||
|
|
||||||
mtx::events::collections::TimelineEvent te{event};
|
mtx::events::collections::TimelineEvent te{event};
|
||||||
std::visit([room_id = room_id](auto &event_) { event_.room_id = room_id; },
|
std::visit([room_id = room_id](auto &event_) { event_.room_id = room_id; },
|
||||||
te.data);
|
te.data);
|
||||||
@ -304,13 +316,6 @@ ChatPage::ChatPage(QSharedPointer<UserSettings> userSettings, QObject *parent)
|
|||||||
actions.end(),
|
actions.end(),
|
||||||
mtx::pushrules::actions::Action{
|
mtx::pushrules::actions::Action{
|
||||||
mtx::pushrules::actions::notify{}}) != actions.end()) {
|
mtx::pushrules::actions::notify{}}) != actions.end()) {
|
||||||
auto event_id = mtx::accessors::event_id(event);
|
|
||||||
|
|
||||||
// skip already read events
|
|
||||||
if (currentReadMarker &&
|
|
||||||
currentReadMarker > cache::getEventIndex(room_id, event_id))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!cache::isNotificationSent(event_id)) {
|
if (!cache::isNotificationSent(event_id)) {
|
||||||
// We should only send one notification per event.
|
// We should only send one notification per event.
|
||||||
cache::markSentNotification(event_id);
|
cache::markSentNotification(event_id);
|
||||||
|
@ -747,6 +747,11 @@ TimelineModel::data(const mtx::events::collections::TimelineEvents &event, int r
|
|||||||
case Notificationlevel: {
|
case Notificationlevel: {
|
||||||
const auto &push = ChatPage::instance()->pushruleEvaluator();
|
const auto &push = ChatPage::instance()->pushruleEvaluator();
|
||||||
if (push) {
|
if (push) {
|
||||||
|
// skip our messages
|
||||||
|
auto sender = mtx::accessors::sender(event);
|
||||||
|
if (sender == http::client()->user_id().to_string())
|
||||||
|
return qml_mtx_events::NotificationLevel::Nothing;
|
||||||
|
|
||||||
const auto &id = event_id(event);
|
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::TimelineEvent>>
|
||||||
relatedEvents;
|
relatedEvents;
|
||||||
|
Loading…
Reference in New Issue
Block a user