From 5605f89a4d6df79c7fc33f8cb559c6c93fc29b7e Mon Sep 17 00:00:00 2001 From: niansa Date: Fri, 15 Jan 2021 13:30:10 +0100 Subject: [PATCH] Fixed bot owner username invalidating on moderator edit --- controllers/views.cc | 9 ++++++--- views/botlist.csp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/controllers/views.cc b/controllers/views.cc index 45575bc..8748e5d 100644 --- a/controllers/views.cc +++ b/controllers/views.cc @@ -275,11 +275,14 @@ void views::botedit(const HttpRequestPtr& req, std::functionexecSqlAsync("UPDATE bots SET name = '"+dbEsc(botuser["username"].asString())+"'," - "avatar_url = '"+dbEsc(botuser["avatar_url"].asString())+"'," - "owner = '"+dbEsc(sessionData->discord_fullname())+"' " + "avatar_url = '"+dbEsc(botuser["avatar_url"].asString())+ + std::string(sessionData->discord_id==owner_id? + ("',owner = '"+dbEsc(sessionData->discord_fullname())+"' "): + ("' "))+ "WHERE app_id = '"+std::to_string(app_id)+"'", [final] (const orm::Result &) { final(); diff --git a/views/botlist.csp b/views/botlist.csp index 46110d8..e63edfd 100644 --- a/views/botlist.csp +++ b/views/botlist.csp @@ -10,7 +10,7 @@

Discordlist for Bots

Find a lot of bots that will be useful to your server

<%c++ if (@@.get("authed")) {%> - <%c++ if (justMine) {%> + <%c++ if (justMine or modView) {%> All bots <%c++ } else {%> My bots