From 3b140df508ad8946ce6347ec7743aefd65ed9551 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Sat, 25 Jun 2022 03:30:12 +0100 Subject: [PATCH] Improve bot message friendliness --- app/tasks/importtasks.py | 7 ++++--- app/utils/models.py | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/tasks/importtasks.py b/app/tasks/importtasks.py index afebed9..a0578a0 100644 --- a/app/tasks/importtasks.py +++ b/app/tasks/importtasks.py @@ -154,7 +154,8 @@ def postReleaseCheckUpdate(self, release: PackageRelease, path): except MinetestCheckError as err: db.session.rollback() - msg = f"{err}\n\nTask ID: {self.request.id}\n\nRelease: [View Release]({release.getEditURL()})" + task_url = url_for('tasks.check', id=self.request.id) + msg = f"{err}\n\n[View Release]({release.getEditURL()}) | [View Task]({task_url})" post_bot_message(release.package, f"Release {release.title} validation failed", msg) if "Fails validation" not in release.title: @@ -347,8 +348,8 @@ def check_update_config(self, package_id): .replace("Cloning into '/tmp/", "Cloning into '") \ .strip() - msg = "Error: {}.\n\nTask ID: {}\n\n[Change update configuration]({})" \ - .format(err, self.request.id, package.getURL("packages.update_config")) + msg = "Error: {}.\n\n[Change update configuration]({}) | [View task]({})" \ + .format(err, package.getURL("packages.update_config"), url_for("tasks.check", id=self.request.id)) post_bot_message(package, "Failed to check git repository", msg) diff --git a/app/utils/models.py b/app/utils/models.py index e061759..499d752 100644 --- a/app/utils/models.py +++ b/app/utils/models.py @@ -118,7 +118,7 @@ def post_bot_message(package: Package, title: str, message: str): if not thread: thread = Thread() thread.package = package - thread.title = "Bot messages for {}".format(package.title) + thread.title = "Messages for '{}'".format(package.title) thread.author = system_user thread.private = True thread.watchers.extend(package.maintainers) @@ -128,7 +128,7 @@ def post_bot_message(package: Package, title: str, message: str): reply = ThreadReply() reply.thread = thread reply.author = system_user - reply.comment = "**{}**\n\n{}".format(title, message) + reply.comment = "**{}**\n\n{}\n\nThis is an automated message, but you can reply if you need help".format(title, message) db.session.add(reply) addNotification(thread.watchers, system_user, NotificationType.BOT,