Improve bot message friendliness

This commit is contained in:
rubenwardy 2022-06-25 03:30:12 +01:00
parent cef8985d38
commit 3b140df508
2 changed files with 6 additions and 5 deletions

@ -154,7 +154,8 @@ def postReleaseCheckUpdate(self, release: PackageRelease, path):
except MinetestCheckError as err: except MinetestCheckError as err:
db.session.rollback() 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) post_bot_message(release.package, f"Release {release.title} validation failed", msg)
if "Fails validation" not in release.title: if "Fails validation" not in release.title:
@ -347,8 +348,8 @@ def check_update_config(self, package_id):
.replace("Cloning into '/tmp/", "Cloning into '") \ .replace("Cloning into '/tmp/", "Cloning into '") \
.strip() .strip()
msg = "Error: {}.\n\nTask ID: {}\n\n[Change update configuration]({})" \ msg = "Error: {}.\n\n[Change update configuration]({}) | [View task]({})" \
.format(err, self.request.id, package.getURL("packages.update_config")) .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) post_bot_message(package, "Failed to check git repository", msg)

@ -118,7 +118,7 @@ def post_bot_message(package: Package, title: str, message: str):
if not thread: if not thread:
thread = Thread() thread = Thread()
thread.package = package thread.package = package
thread.title = "Bot messages for {}".format(package.title) thread.title = "Messages for '{}'".format(package.title)
thread.author = system_user thread.author = system_user
thread.private = True thread.private = True
thread.watchers.extend(package.maintainers) thread.watchers.extend(package.maintainers)
@ -128,7 +128,7 @@ def post_bot_message(package: Package, title: str, message: str):
reply = ThreadReply() reply = ThreadReply()
reply.thread = thread reply.thread = thread
reply.author = system_user 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) db.session.add(reply)
addNotification(thread.watchers, system_user, NotificationType.BOT, addNotification(thread.watchers, system_user, NotificationType.BOT,