From 1c10d4da4c75024930e7d6e099bcd91119070cf9 Mon Sep 17 00:00:00 2001 From: Green Sky Date: Wed, 6 Dec 2023 17:42:01 +0100 Subject: [PATCH] dont trust synced messages --- src/message_command_dispatcher.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/message_command_dispatcher.cpp b/src/message_command_dispatcher.cpp index 66f2948..338e43a 100644 --- a/src/message_command_dispatcher.cpp +++ b/src/message_command_dispatcher.cpp @@ -3,6 +3,7 @@ #include #include #include +#include // TODO: move SyncedBy to global #include #include @@ -249,7 +250,26 @@ bool MessageCommandDispatcher::onEvent(const Message::Events::MessageConstruct& return false; } - // TODO: skip unrelyable synced + // skip unrelyable synced + if (e.e.all_of()) { + const auto& list = e.e.get().list; + if ( + std::find_if( + list.cbegin(), list.cend(), + [this](const auto& it) { + // TODO: add weak self + return _cr.all_of< + Contact::Components::TagSelfStrong, + Contact::Components::TagSelfWeak // trust weak self + >(it); + } + ) == list.cend() + ) { + // self not found + // TODO: config for self only + return false; + } + } const bool is_private = _cr.any_of(e.e.get().c); @@ -285,7 +305,6 @@ bool MessageCommandDispatcher::onEvent(const Message::Events::MessageConstruct& std::cout << "MCD: got command '" << message_text << "'\n"; - std::string_view first_word; std::string_view second_word; std::string_view::size_type pos_next = 0;