Replaced Easy::alertmap with Easy::alerts.

This commit is contained in:
tastytea 2019-04-13 02:45:27 +02:00
parent bc82dac69b
commit 4302814e17
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
3 changed files with 22 additions and 12 deletions

View File

@ -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;
}

View File

@ -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:
/*!

View File

@ -20,10 +20,11 @@
#include <string>
#include <utility>
#include <chrono>
#include <map>
#include <vector>
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<Easy::notification_type, bool> alertmap;
typedef vector<alert_type> alerts;
/*!
* @brief Type for time. Converts to time_point and string.