mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-25 20:48:52 +03:00
Remove redacted events from other users (#171)
This commit is contained in:
parent
49270d10b4
commit
81d3bd8ce6
3 changed files with 17 additions and 52 deletions
|
@ -23,7 +23,7 @@ ExternalProject_Add(
|
||||||
MatrixStructs
|
MatrixStructs
|
||||||
|
|
||||||
GIT_REPOSITORY https://github.com/mujx/matrix-structs
|
GIT_REPOSITORY https://github.com/mujx/matrix-structs
|
||||||
GIT_TAG 701eb5b06c370c23bca35a957f5a208c2115b52f
|
GIT_TAG e503c4ff27cd8159c377d9a7d2e6e91698a5517b
|
||||||
|
|
||||||
BUILD_IN_SOURCE 1
|
BUILD_IN_SOURCE 1
|
||||||
SOURCE_DIR ${MATRIX_STRUCTS_ROOT}
|
SOURCE_DIR ${MATRIX_STRUCTS_ROOT}
|
||||||
|
|
|
@ -230,12 +230,6 @@ private:
|
||||||
//! Render the given timeline events to the top of the timeline.
|
//! Render the given timeline events to the top of the timeline.
|
||||||
void renderTopEvents(const std::vector<TimelineEvent> &events);
|
void renderTopEvents(const std::vector<TimelineEvent> &events);
|
||||||
|
|
||||||
//! Decide if the given timeline event can be rendered.
|
|
||||||
inline bool isViewable(const TimelineEvent &event) const;
|
|
||||||
|
|
||||||
//! Decide if the given event should trigger a notification.
|
|
||||||
inline bool isNotifiable(const TimelineEvent &event) const;
|
|
||||||
|
|
||||||
// The events currently rendered. Used for duplicate detection.
|
// The events currently rendered. Used for duplicate detection.
|
||||||
QMap<QString, TimelineItem *> eventIds_;
|
QMap<QString, TimelineItem *> eventIds_;
|
||||||
QQueue<PendingMessage> pending_msgs_;
|
QQueue<PendingMessage> pending_msgs_;
|
||||||
|
|
|
@ -163,10 +163,8 @@ TimelineView::addBackwardsEvents(const QString &room_id, const mtx::responses::M
|
||||||
isTimelineFinished = false;
|
isTimelineFinished = false;
|
||||||
|
|
||||||
// Queue incoming messages to be rendered later.
|
// Queue incoming messages to be rendered later.
|
||||||
for (auto const &e : msgs.chunk) {
|
for (auto const &e : msgs.chunk)
|
||||||
if (isViewable(e))
|
|
||||||
topMessages_.emplace_back(e);
|
topMessages_.emplace_back(e);
|
||||||
}
|
|
||||||
|
|
||||||
// The RoomList message preview will be updated only if this
|
// The RoomList message preview will be updated only if this
|
||||||
// is the first batch of messages received through /messages
|
// is the first batch of messages received through /messages
|
||||||
|
@ -202,7 +200,18 @@ TimelineView::parseMessageEvent(const mtx::events::collections::TimelineEvents &
|
||||||
using TextEvent = mtx::events::RoomEvent<msg::Text>;
|
using TextEvent = mtx::events::RoomEvent<msg::Text>;
|
||||||
using VideoEvent = mtx::events::RoomEvent<msg::Video>;
|
using VideoEvent = mtx::events::RoomEvent<msg::Video>;
|
||||||
|
|
||||||
if (mpark::holds_alternative<mtx::events::RoomEvent<msg::Audio>>(event)) {
|
if (mpark::holds_alternative<mtx::events::RedactionEvent<msg::Redaction>>(event)) {
|
||||||
|
auto redaction_event =
|
||||||
|
mpark::get<mtx::events::RedactionEvent<msg::Redaction>>(event);
|
||||||
|
const auto event_id = QString::fromStdString(redaction_event.redacts);
|
||||||
|
|
||||||
|
QTimer::singleShot(0, this, [event_id, this]() {
|
||||||
|
if (eventIds_.contains(event_id))
|
||||||
|
removeEvent(event_id);
|
||||||
|
});
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
} else if (mpark::holds_alternative<mtx::events::RoomEvent<msg::Audio>>(event)) {
|
||||||
auto audio = mpark::get<mtx::events::RoomEvent<msg::Audio>>(event);
|
auto audio = mpark::get<mtx::events::RoomEvent<msg::Audio>>(event);
|
||||||
return processMessageEvent<AudioEvent, AudioItem>(audio, direction);
|
return processMessageEvent<AudioEvent, AudioItem>(audio, direction);
|
||||||
} else if (mpark::holds_alternative<mtx::events::RoomEvent<msg::Emote>>(event)) {
|
} else if (mpark::holds_alternative<mtx::events::RoomEvent<msg::Emote>>(event)) {
|
||||||
|
@ -300,16 +309,9 @@ TimelineView::addEvents(const mtx::responses::Timeline &timeline)
|
||||||
isInitialSync = false;
|
isInitialSync = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &e : timeline.events) {
|
for (const auto &e : timeline.events)
|
||||||
// Save the message if it can be rendered.
|
|
||||||
if (isViewable(e))
|
|
||||||
bottomMessages_.push_back(e);
|
bottomMessages_.push_back(e);
|
||||||
|
|
||||||
// Calculate notifications.
|
|
||||||
/* if (isNotifiable(e)) */
|
|
||||||
/* sendNotification() */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!bottomMessages_.empty())
|
if (!bottomMessages_.empty())
|
||||||
notifyForLastEvent(bottomMessages_[bottomMessages_.size() - 1]);
|
notifyForLastEvent(bottomMessages_[bottomMessages_.size() - 1]);
|
||||||
|
|
||||||
|
@ -326,37 +328,6 @@ TimelineView::addEvents(const mtx::responses::Timeline &timeline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
|
||||||
TimelineView::isViewable(const TimelineEvent &event) const
|
|
||||||
{
|
|
||||||
namespace msg = mtx::events::msg;
|
|
||||||
|
|
||||||
return mpark::holds_alternative<mtx::events::RoomEvent<msg::Audio>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Emote>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::File>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Image>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Notice>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Text>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Video>>(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool
|
|
||||||
TimelineView::isNotifiable(const TimelineEvent &event) const
|
|
||||||
{
|
|
||||||
namespace msg = mtx::events::msg;
|
|
||||||
|
|
||||||
if (local_user_ == getEventSender(event))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return mpark::holds_alternative<mtx::events::RoomEvent<msg::Audio>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Emote>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::File>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Image>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Notice>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Text>>(event) ||
|
|
||||||
mpark::holds_alternative<mtx::events::RoomEvent<msg::Video>>(event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TimelineView::init()
|
TimelineView::init()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue