summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2024-04-30 22:09:15 +0500
committerilotterytea <iltsu@alright.party>2024-04-30 22:09:15 +0500
commit8b3bb2f83cbfc134aae274e18e92ed022938eb9e (patch)
tree4f9c909a61fb7aab3b04d5df1b72d32f2a1c2ef6 /src
parent3bf2e1e4a89fed00ee5853a2fd914917d163abd8 (diff)
feat: ChannelPreference model
Diffstat (limited to 'src')
-rw-r--r--src/schemas/channel.hpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/schemas/channel.hpp b/src/schemas/channel.hpp
index 2e92a5e..d0c8ab3 100644
--- a/src/schemas/channel.hpp
+++ b/src/schemas/channel.hpp
@@ -9,6 +9,8 @@
#include <stdexcept>
#include <string>
+#include "../constants.hpp"
+
namespace bot::schemas {
class Channel {
public:
@@ -63,4 +65,35 @@ namespace bot::schemas {
std::chrono::system_clock::time_point joined_at;
std::optional<std::chrono::system_clock::time_point> opted_out_at;
};
+
+ class ChannelPreference {
+ public:
+ ChannelPreference(const pqxx::row &row) {
+ this->id = row[0].as<int>();
+ this->channel_id = row[1].as<int>();
+
+ if (!row[2].is_null()) {
+ this->prefix = row[2].as<std::string>();
+ } else {
+ this->prefix = DEFAULT_PREFIX;
+ }
+
+ if (!row[3].is_null()) {
+ this->locale = row[3].as<std::string>();
+ } else {
+ this->locale = DEFAULT_LOCALE_ID;
+ }
+ }
+
+ ~ChannelPreference() = default;
+
+ const int &get_id() const { return this->id; }
+ const int &get_channel_id() const { return this->channel_id; }
+ const std::string &get_prefix() const { return this->prefix; }
+ const std::string &get_locale() const { return this->locale; }
+
+ private:
+ int id, channel_id;
+ std::string prefix, locale;
+ };
}