From 4302814e178e1392aeb855c0248cb0b425bdceed Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 13 Apr 2019 02:45:27 +0200 Subject: [PATCH] Replaced Easy::alertmap with Easy::alerts. --- src/easy/entities/pushsubscription.cpp | 6 +++--- src/easy/entities/pushsubscription.hpp | 7 +++---- src/easy/types_easy.hpp | 21 ++++++++++++++++----- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/easy/entities/pushsubscription.cpp b/src/easy/entities/pushsubscription.cpp index 14c8c10..c8e2964 100644 --- a/src/easy/entities/pushsubscription.cpp +++ b/src/easy/entities/pushsubscription.cpp @@ -46,9 +46,9 @@ const string PushSubscription::server_key() const return get_string("server_key"); } -const Easy::alertmap PushSubscription::alerts() const +const Easy::alerts PushSubscription::alerts() const { - alertmap alerts; + Easy::alerts alerts; const Json::Value node = get("alerts"); for (auto it = node.begin(); it != node.end(); ++it) { @@ -75,7 +75,7 @@ const Easy::alertmap PushSubscription::alerts() const type = notification_type::Undefined; } - alerts.insert({{ type, s_to_b(it->asString()) }}); + alerts.push_back({ type, s_to_b(it->asString()) }); } return alerts; } diff --git a/src/easy/entities/pushsubscription.hpp b/src/easy/entities/pushsubscription.hpp index 4707233..a0ac5a8 100644 --- a/src/easy/entities/pushsubscription.hpp +++ b/src/easy/entities/pushsubscription.hpp @@ -71,12 +71,11 @@ namespace Easy // TODO: Look up what the data looks like /*! - * @brief Returns a map of 'notification event type' and - * 'push is requested or not' + * @brief Returns a vector of Easy::alert_type. * - * @since 0.14.0 + * @since 0.100.0 */ - const Easy::alertmap alerts() const; + const Easy::alerts alerts() const; protected: /*! diff --git a/src/easy/types_easy.hpp b/src/easy/types_easy.hpp index 54b59b7..429224d 100644 --- a/src/easy/types_easy.hpp +++ b/src/easy/types_easy.hpp @@ -20,10 +20,11 @@ #include #include #include -#include +#include using std::string; using std::chrono::system_clock; +using std::vector; namespace Mastodon { @@ -113,14 +114,24 @@ namespace Easy } stream_event; /*! - * @brief Map of 'notification type' and 'push is requested or not'. + * @brief Type of notification and 'push is requested or not'. + * + * @since 0.100.0 + */ + typedef struct alert_type + { + Easy::notification_type type = Easy::notification_type::Undefined; + bool pushreq = false; + } alert_type; + + /*! + * @brief Vector of Easy::alert_type. * * Used in PushSubscription::alerts(). * - * @since 0.13.3 + * @since 0.100.0 */ - // TODO: Replace with struct? - typedef std::map alertmap; + typedef vector alerts; /*! * @brief Type for time. Converts to time_point and string.