ScopeLogger();
if (!initial_value || !end_value) {
- LoggerD("initial_value is %snull. end_value is %snull",
- initial_value ? "NOT " : "", end_value ? "NOT " : "");
+ LoggerD("initial_value is %snull. end_value is %snull", initial_value ? "NOT " : "",
+ end_value ? "NOT " : "");
return false;
}
- time_t from_time = initial_value->isNullOrUndefined() ?
- std::numeric_limits<time_t>::min() : initial_value->toTimeT();
+ time_t from_time = initial_value->isNullOrUndefined() ? std::numeric_limits<time_t>::min()
+ : initial_value->toTimeT();
- time_t to_time = end_value->isNullOrUndefined() ?
- std::numeric_limits<time_t>::max() : end_value->toTimeT();
+ time_t to_time =
+ end_value->isNullOrUndefined() ? std::numeric_limits<time_t>::max() : end_value->toTimeT();
bool is_in_range = FilterUtils::isBetweenTimeRange(time_stamp, from_time, to_time);
using common::ErrorCode;
using common::PlatformResult;
+namespace {
+
+using extension::messaging::AnyPtr;
+using common::AttributeMatchFlag;
+using namespace extension::messaging::FilterUtils;
+
+bool ContainsAllRequiredRecipients(AnyPtr match_value, std::vector<std::string> recipients,
+ const AttributeMatchFlag match_flag) {
+ ScopeLogger();
+ if (!match_value->getValue().is<picojson::array>()) {
+ LoggerE("AttributeFilter value for TO attribute must be an array of strings.");
+ return false;
+ }
+
+ const auto array = match_value->getValue().get<picojson::array>();
+ for (const auto value : array) {
+ if (!value.is<std::string>()) {
+ LoggerE("AttributeFilter value for TO attribute must be an array of strings.");
+ return false;
+ }
+
+ if (!isAnyStringMatching(value.get<std::string>(), recipients, match_flag)) {
+ LoggerD("AttributeFilter TO match failed on %s", value.get<std::string>().c_str());
+ return false;
+ }
+ }
+
+ return true;
+}
+
+} // namespace
+
+
namespace extension {
namespace messaging {
* bcc | Yes | No
* lastMessageId | Yes | No
*/
-
bool MessageConversation::isMatchingAttribute(const std::string& attribute_name,
const common::AttributeMatchFlag match_flag,
AnyPtr match_value) const {
} else if (MESSAGE_CONVERSATION_ATTRIBUTE_FROM == attribute_name) {
return FilterUtils::isMatching(*match_value, getFrom(), match_flag);
} else if (MESSAGE_CONVERSATION_ATTRIBUTE_TO == attribute_name) {
- return FilterUtils::isAnyStringMatching(match_value->toString(), getTo(), match_flag);
+ if (match_value->getValue().is<picojson::array>()) {
+ return ContainsAllRequiredRecipients(match_value, getTo(), match_flag);
+ } else if (match_value->getValue().is<std::string>()) {
+ return FilterUtils::isAnyStringMatching(match_value->toString(), getTo(), match_flag);
+ } else {
+ LoggerE("Unsupported type of AttributeFilter value for TO attribute.");
+ return false;
+ }
} else if (MESSAGE_CONVERSATION_ATTRIBUTE_CC == attribute_name) {
return FilterUtils::isAnyStringMatching(match_value->toString(), getCC(), match_flag);
} else if (MESSAGE_CONVERSATION_ATTRIBUTE_BCC == attribute_name) {
using std::placeholders::_1;
using std::placeholders::_2;
-#define REGISTER_METHOD(M) \
- RegisterSyncHandler(#M, std::bind(&MessagingInstance::M, this, _1, _2))
+#define REGISTER_METHOD(M) RegisterSyncHandler(#M, std::bind(&MessagingInstance::M, this, _1, _2))
REGISTER_METHOD(GetMessageServices);
REGISTER_METHOD(MessageServiceSendMessage);
REGISTER_METHOD(MessageServiceLoadMessageBody);
REGISTER_METHOD(MessageStorageRemoveConversations);
REGISTER_METHOD(MessageStorageFindFolders);
-
REGISTER_METHOD(MessageServiceSync);
REGISTER_METHOD(MessageServiceStopSync);
REGISTER_METHOD(MessageServiceSyncFolder);
}
}
-void MessagingInstance::MessageStorageAddDraftMessage(const picojson::value& args, picojson::object& out) {
+void MessagingInstance::MessageStorageAddDraftMessage(const picojson::value& args,
+ picojson::object& out) {
ScopeLogger();
CHECK_PRIVILEGE_ACCESS(kPrivilegeMessagingWrite, &out);