mirror of
https://github.com/minetest/contentdb.git
synced 2024-12-22 22:12:24 +01:00
Replace update bot message with notification only
This commit is contained in:
parent
4f920f011f
commit
ef9860b6cc
@ -144,9 +144,13 @@ def metapackages():
|
||||
return render_template("todo/metapackages.html", mpackages=mpackages)
|
||||
|
||||
|
||||
@bp.route("/user/todo/")
|
||||
@bp.route("/users/<username>/todo/")
|
||||
@login_required
|
||||
def view_user(username):
|
||||
def view_user(username=None):
|
||||
if username is None:
|
||||
return redirect(url_for("todo.view_user", username=current_user.username))
|
||||
|
||||
user : User = User.query.filter_by(username=username).first()
|
||||
if not user:
|
||||
abort(404)
|
||||
|
@ -27,7 +27,7 @@ from kombu import uuid
|
||||
|
||||
from app.models import *
|
||||
from app.tasks import celery, TaskError
|
||||
from app.utils import randomString, getExtension, post_bot_message
|
||||
from app.utils import randomString, getExtension, post_bot_message, addSystemNotification
|
||||
from .minetestcheck import build_tree, MinetestCheckError, ContentType
|
||||
|
||||
|
||||
@ -89,6 +89,8 @@ def clone_repo(urlstr, ref=None, recursive=False):
|
||||
|
||||
|
||||
def get_commit_hash(git_url, ref_name=None):
|
||||
git_url = generateGitURL(git_url)
|
||||
|
||||
if ref_name:
|
||||
ref_name = "refs/heads/" + ref_name
|
||||
else:
|
||||
@ -358,10 +360,12 @@ def check_update_config(self, package_id):
|
||||
if config.last_commit:
|
||||
msg_last = " The last commit was {}".format(config.last_commit[0:5])
|
||||
|
||||
msg = "New commit {} was found on the Git repository.{}\n\n[Change update configuration]({})" \
|
||||
.format(hash[0:5], msg_last, package.getUpdateConfigURL())
|
||||
msg = "New commit {} found on the Git repo, is the package outdated?{}" \
|
||||
.format(hash[0:5], msg_last)
|
||||
|
||||
post_bot_message(package, "New commit detected, package may be outdated", msg)
|
||||
for user in package.maintainers:
|
||||
addSystemNotification(user, NotificationType.BOT,
|
||||
msg, url_for("todo.view_user", username=user.username), package)
|
||||
|
||||
config.last_commit = hash
|
||||
db.session.commit()
|
||||
|
@ -26,7 +26,7 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link {% if current_tab == "topics" %}active{% endif %}"
|
||||
href="{{ url_for('todo.topics') }}">
|
||||
{{ _("Topics") }}
|
||||
{{ _("Forum Topics") }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
@ -213,7 +213,7 @@ def is_package_page(f):
|
||||
return decorated_function
|
||||
|
||||
|
||||
def addNotification(target: User, causer: User, type: NotificationType, title: str, url: str, package: Package =None):
|
||||
def addNotification(target, causer: User, type: NotificationType, title: str, url: str, package: Package = None):
|
||||
try:
|
||||
iter(target)
|
||||
for x in target:
|
||||
@ -255,6 +255,13 @@ def nonEmptyOrNone(str):
|
||||
return str
|
||||
|
||||
|
||||
def addSystemNotification(target, type: NotificationType, title: str, url: str, package: Package = None):
|
||||
system_user = User.query.filter_by(username="ContentDB").first()
|
||||
assert system_user
|
||||
|
||||
return addNotification(target, system_user, type, title, url, package)
|
||||
|
||||
|
||||
def post_bot_message(package: Package, title: str, message: str):
|
||||
system_user = User.query.filter_by(username="ContentDB").first()
|
||||
assert system_user
|
||||
|
Loading…
Reference in New Issue
Block a user