Add notification when release creation fails

This commit is contained in:
rubenwardy 2021-07-19 23:49:29 +01:00
parent f83605c35f
commit 2f77a84ec5
3 changed files with 9 additions and 2 deletions

@ -448,8 +448,12 @@ def edit_maintainers(package):
usernames = [x.strip().lower() for x in form.maintainers_str.data.split(",")] usernames = [x.strip().lower() for x in form.maintainers_str.data.split(",")]
users = User.query.filter(func.lower(User.username).in_(usernames)).all() users = User.query.filter(func.lower(User.username).in_(usernames)).all()
thread = package.threads.filter_by(author=get_system_user()).first()
for user in users: for user in users:
if not user in package.maintainers: if not user in package.maintainers:
if thread:
thread.watchers.append(user)
addNotification(user, current_user, NotificationType.MAINTAINER, addNotification(user, current_user, NotificationType.MAINTAINER,
"Added you as a maintainer of {}".format(package.title), package.getDetailsURL(), package) "Added you as a maintainer of {}".format(package.title), package.getDetailsURL(), package)

@ -70,7 +70,7 @@ def getMeta(urlstr, author):
return result return result
def postReleaseCheckUpdate(self, release, path): def postReleaseCheckUpdate(self, release: PackageRelease, path):
try: try:
tree = build_tree(path, expected_type=ContentType[release.package.type.name], tree = build_tree(path, expected_type=ContentType[release.package.type.name],
author=release.package.author.username, name=release.package.name) author=release.package.author.username, name=release.package.name)
@ -130,6 +130,9 @@ def postReleaseCheckUpdate(self, release, 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()})"
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:
release.title += " (Fails validation)" release.title += " (Fails validation)"

@ -110,7 +110,7 @@ def post_bot_message(package: Package, title: str, message: str):
thread.title = "Bot messages for {}".format(package.title) thread.title = "Bot messages for {}".format(package.title)
thread.author = system_user thread.author = system_user
thread.private = True thread.private = True
thread.watchers.append(package.author) thread.watchers.extend(package.maintainers)
db.session.add(thread) db.session.add(thread)
db.session.flush() db.session.flush()