From 8b3bb2f83cbfc134aae274e18e92ed022938eb9e Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 30 Apr 2024 22:09:15 +0500 Subject: feat: ChannelPreference model --- src/schemas/channel.hpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'src/schemas') 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 #include +#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 opted_out_at; }; + + class ChannelPreference { + public: + ChannelPreference(const pqxx::row &row) { + this->id = row[0].as(); + this->channel_id = row[1].as(); + + if (!row[2].is_null()) { + this->prefix = row[2].as(); + } else { + this->prefix = DEFAULT_PREFIX; + } + + if (!row[3].is_null()) { + this->locale = row[3].as(); + } 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; + }; } -- cgit v1.2.3