1
0
Fork 0
mirror of https://gitlab.com/niansa/discordlistforbots.git synced 2025-03-06 20:49:22 +01:00

Added list of unapproved bots

This commit is contained in:
niansa 2021-01-15 10:32:49 +01:00
parent 9032764caa
commit 828ab9cbaa
5 changed files with 20 additions and 6 deletions

View file

@ -154,8 +154,13 @@ void views::botlist(
)
{
auto sessionData = getSessionData(req->session());
auto justMine = req->getPath()=="/bots/@me";
auto modView = req->getPath()=="/bots/@unapproved";
auto justMine = req->getPath() == "/bots/@me";
auto modView = req->getPath() == "/bots/@unapproved";
if (modView and not sessionData->moderator) {
callback(HttpResponse::newNotFoundResponse());
return;
}
std::string q = "SELECT * FROM bots WHERE ";
if (justMine) {
@ -309,9 +314,11 @@ void views::botedit(const HttpRequestPtr& req, std::function<void (const HttpRes
} else if (not sessionData->moderator) {
goto else_part;
} else if (action == "approve") {
// TODO
} else if (action == "decline") {
// TODO
db->execSqlAsync("UPDATE bots SET approved = 't' "
"WHERE app_id = '"+std::to_string(bot.app_id)+"'",
[final] (const orm::Result &) {
final();
}, dbErr);
} else {
else_part:
callback(HttpResponse::newNotFoundResponse());

View file

@ -51,6 +51,7 @@ public:
ADD_METHOD_TO(views::start, "/", Get);
ADD_METHOD_TO(views::botlist, "/bots/@all", Get);
ADD_METHOD_TO(views::botlist, "/bots/@me", Get, "LoginFilter");
ADD_METHOD_TO(views::botlist, "/bots/@unapproved", Get, "LoginFilter");
ADD_METHOD_TO(views::botregister_view, "/bots/register?error={1}", Get, "LoginFilter");
ADD_METHOD_TO(views::botregister_submit, "/bots/register", Post, "LoginFilter");
ADD_METHOD_TO(views::botdetail, "/bots/{1}/detail", Get);

View file

@ -25,7 +25,7 @@
<%c++ if (sessionData->moderator and not bot.approved) {%>
<div class="actionsWrapper actions">
<a class="special-button" href="edit/approve" style="background-color:green;color:white;">Approve</a>
<a class="special-button" href="edit/decline" style="background-color:black;color:white;">Decline</a>
<a class="special-button" href="edit/delete" style="background-color:black;color:white;">Decline</a>
</div>
<%c++ }%>
<%c++ }%>

View file

@ -17,6 +17,9 @@
<%c++ if (sessionData) {%>
<div style="text-align:left;">
<a class="special-button noborder" href="/bots/@me">My bots</a>
<%c++ if (sessionData->moderator) {%>
<a class="special-button noborder" href="/bots/@unapproved">Unapproved bots</a>
<%c++ }%>
<a class="special-button noborder" href="/bots/register">Register bot</a>
</div>
<%c++ }%>

View file

@ -32,6 +32,9 @@
<a class="special-button" href="/">Start</a><br>
<%c++ if (sessionData) {%>
<a class="special-button" href="/bots/@me">My bots</a><br>
<%c++ if (sessionData->moderator) {%>
<a class="special-button" href="/bots/@unapproved">Unapproved bots</a><br>
<%c++ }%>
<a class="special-button" href="/bots/register">Register bot</a><br>
<a class="special-button" href="/discorddeauth">Logout</a><br>
<%c++ } else {%>