Add notification type for bot messages
This commit is contained in:
@@ -956,4 +956,6 @@ class PackageUpdateConfig(db.Model):
|
||||
outdated = db.Column(db.Boolean, nullable=False, default=False)
|
||||
|
||||
trigger = db.Column(db.Enum(PackageUpdateTrigger), nullable=False, default=PackageUpdateTrigger.COMMIT)
|
||||
ref = db.Column(db.String(41), nullable=True, default=None)
|
||||
|
||||
make_release = db.Column(db.Boolean, nullable=False, default=False)
|
||||
|
||||
@@ -313,14 +313,17 @@ class NotificationType(enum.Enum):
|
||||
# Posted reply to subscribed thread
|
||||
THREAD_REPLY = 5
|
||||
|
||||
# A bot notification
|
||||
BOT = 6
|
||||
|
||||
# Added / removed as maintainer
|
||||
MAINTAINER = 6
|
||||
MAINTAINER = 7
|
||||
|
||||
# Editor misc
|
||||
EDITOR_ALERT = 7
|
||||
EDITOR_ALERT = 8
|
||||
|
||||
# Editor misc
|
||||
EDITOR_MISC = 8
|
||||
EDITOR_MISC = 9
|
||||
|
||||
# Any other
|
||||
OTHER = 0
|
||||
@@ -343,6 +346,8 @@ class NotificationType(enum.Enum):
|
||||
return "When a user posts a review on your package."
|
||||
elif self == NotificationType.THREAD_REPLY:
|
||||
return "When someone replies to a thread you're watching."
|
||||
elif self == NotificationType.BOT:
|
||||
return "From a bot - for example, update notifications."
|
||||
elif self == NotificationType.MAINTAINER:
|
||||
return "When your package's maintainers change."
|
||||
elif self == NotificationType.EDITOR_ALERT:
|
||||
@@ -424,6 +429,7 @@ class UserNotificationPreferences(db.Model):
|
||||
pref_new_thread = db.Column(db.Integer, nullable=False)
|
||||
pref_new_review = db.Column(db.Integer, nullable=False)
|
||||
pref_thread_reply = db.Column(db.Integer, nullable=False)
|
||||
pref_bot = db.Column(db.Integer, nullable=False)
|
||||
pref_maintainer = db.Column(db.Integer, nullable=False)
|
||||
pref_editor_alert = db.Column(db.Integer, nullable=False)
|
||||
pref_editor_misc = db.Column(db.Integer, nullable=False)
|
||||
@@ -436,6 +442,7 @@ class UserNotificationPreferences(db.Model):
|
||||
self.pref_new_thread = 1
|
||||
self.pref_new_review = 1
|
||||
self.pref_thread_reply = 2
|
||||
self.pref_bot = 1
|
||||
self.pref_maintainer = 1
|
||||
self.pref_editor_alert = 1
|
||||
self.pref_editor_misc = 0
|
||||
|
||||
@@ -276,7 +276,7 @@ def post_system_thread(package: Package, title: str, message: str):
|
||||
reply.comment = "# {}\n\n{}".format(title, message)
|
||||
db.session.add(reply)
|
||||
|
||||
addNotification(thread.watchers, system_user, NotificationType.THREAD_REPLY,
|
||||
addNotification(thread.watchers, system_user, NotificationType.BOT,
|
||||
title, thread.getViewURL(), thread.package)
|
||||
|
||||
thread.replies.append(reply)
|
||||
|
||||
Reference in New Issue
Block a user