顺便提一下,如果你想在无需执行实际触发这些通知的操作的情况下测试该组件的设置(且你拥有 SSH 访问权限),可以在 Rails 控制台中使用以下命令来触发相应的事件通知(请使用适用于你组件设置的触发器):
cd /var/discourse
.launcher enter app
rails c
# 查找并设置你的用户变量
u = User.find_by_username("YOUR ADMIN USERNAME")
# 触发:新功能
Notification.create!(
user: u,
notification_type: Notification.types[:new_features],
read: false,
data: {}.to_json
)
# 触发:受邀者已接受
Notification.create!(
user: u,
notification_type: Notification.types[:invitee_accepted],
read: false,
data: { display_username: "awesome_new_user" }.to_json
)
# 触发:群组成员资格已接受
Notification.create!(
user: u,
notification_type: Notification.types[:membership_request_accepted],
read: false,
data: { group_name: "Trust_Level_4" }.to_json
)
# 触发:授予徽章
Notification.create!(
user: u,
notification_type: Notification.types[:granted_badge],
read: false,
data: { badge_name: "Great Topic", badge_id: 10 }.to_json
)
# 触发:即将进行的变更已自动提升
Notification.create!(
user: u,
notification_type: Notification.types[:upcoming_change_automatically_promoted],
read: false,
data: {
upcoming_change_humanized_name: "Experimental CSS",
upcoming_change_name: "experimental_css"
}.to_json
)
# 广播(在另一个窗口或标签页中观察你的浏览器,按下回车后!)
u.publish_notifications_state
测试的最佳方法是:在你想要测试的组件中禁用该设置,运行相关的 Rails 触发器命令,查看通知弹出;然后启用该设置并进行硬刷新,观察它们消失。