From 828ab9cbaa717a70568db5b97e2e294514b03be4 Mon Sep 17 00:00:00 2001 From: niansa Date: Fri, 15 Jan 2021 10:32:49 +0100 Subject: [PATCH] Added list of unapproved bots --- controllers/views.cc | 17 ++++++++++++----- controllers/views.h | 1 + views/botdetail.csp | 2 +- views/global_layout.csp | 3 +++ views/menu.csp | 3 +++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/controllers/views.cc b/controllers/views.cc index 8c160ac..45575bc 100644 --- a/controllers/views.cc +++ b/controllers/views.cc @@ -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::functionmoderator) { 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()); diff --git a/controllers/views.h b/controllers/views.h index 33c4035..652a5e9 100644 --- a/controllers/views.h +++ b/controllers/views.h @@ -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); diff --git a/views/botdetail.csp b/views/botdetail.csp index f04ae71..3c4f29a 100644 --- a/views/botdetail.csp +++ b/views/botdetail.csp @@ -25,7 +25,7 @@ <%c++ if (sessionData->moderator and not bot.approved) {%> <%c++ }%> <%c++ }%> diff --git a/views/global_layout.csp b/views/global_layout.csp index 62688eb..c063b07 100644 --- a/views/global_layout.csp +++ b/views/global_layout.csp @@ -17,6 +17,9 @@ <%c++ if (sessionData) {%>
My bots + <%c++ if (sessionData->moderator) {%> + Unapproved bots + <%c++ }%> Register bot
<%c++ }%> diff --git a/views/menu.csp b/views/menu.csp index 352fdab..b4a0664 100644 --- a/views/menu.csp +++ b/views/menu.csp @@ -32,6 +32,9 @@ Start
<%c++ if (sessionData) {%> My bots
+ <%c++ if (sessionData->moderator) {%> + Unapproved bots
+ <%c++ }%> Register bot
Logout
<%c++ } else {%>