handle mutable categories

This commit is contained in:
ouwou
2022-01-05 03:52:20 -05:00
parent 8695562cb4
commit 40106ddeb1
9 changed files with 94 additions and 3 deletions

View File

@@ -571,6 +571,21 @@ std::vector<ChannelData> Store::GetActiveThreads(Snowflake channel_id) const {
return ret;
}
std::vector<Snowflake> Store::GetChannelIDsWithParentID(Snowflake channel_id) const {
auto &s = m_stmt_get_chan_ids_parent;
s->Bind(1, channel_id);
std::vector<Snowflake> ret;
while (s->FetchOne()) {
Snowflake x;
s->Get(0, x);
ret.push_back(x);
}
return ret;
}
void Store::AddReaction(const MessageReactionAddObject &data, bool byself) {
auto &s = m_stmt_add_reaction;
@@ -2120,6 +2135,14 @@ bool Store::CreateStatements() {
return false;
}
m_stmt_get_chan_ids_parent = std::make_unique<Statement>(m_db, R"(
SELECT id FROM channels WHERE parent_id = ?
)");
if (!m_stmt_get_chan_ids_parent->OK()) {
fprintf(stderr, "failed to prepare get channel ids for parent statement: %s\n", m_db.ErrStr());
return false;
}
return true;
}