add: user profile setting message

This commit is contained in:
yystopf 2022-02-14 13:55:34 +08:00
parent 29dc3fff39
commit 959c1e8d95
5 changed files with 20 additions and 3 deletions

View File

@ -22,6 +22,8 @@ class Users::TemplateMessageSettingsController < Users::BaseController
def get_current_setting
@current_setting = @_observed_user.user_template_message_setting
@current_setting.notification_body.merge!(UserTemplateMessageSetting.init_notification_body.except(*@current_setting.notification_body.keys))
@current_setting.email_body.merge!(UserTemplateMessageSetting.init_email_body.except(*@current_setting.email_body.keys))
@current_setting = UserTemplateMessageSetting.build(@_observed_user.id) if @current_setting.nil?
end

View File

@ -12,8 +12,8 @@
# email_title :string(255)
#
# 我创建的疑修截止日期到达最后一天
class MessageTemplate::IssueCreatorExpire < MessageTemplate
# 我创建或负责的疑修截止日期到达最后一天
class MessageTemplate::IssueExpire < MessageTemplate
# MessageTemplate::IssueCreatorExpire.get_message_content(User.where(login: 'yystopf'), Issue.last)
def self.get_message_content(receivers, issue)
@ -23,7 +23,7 @@ class MessageTemplate::IssueCreatorExpire < MessageTemplate
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', issue&.id.to_s)
return receivers_string(receivers), content, url
rescue => e
Rails.logger.info("MessageTemplate::IssueAssignerExpire.get_message_content [ERROR] #{e}")
Rails.logger.info("MessageTemplate::IssueExpire.get_message_content [ERROR] #{e}")
return '', '', ''
end
end

View File

@ -27,5 +27,6 @@ class TemplateMessageSetting::CreateOrAssign < TemplateMessageSetting
def self.build_init_data
self.find_or_create_by(name: "疑修状态变更", key: "IssueChanged")
self.find_or_create_by(name: "合并请求状态变更", key: "PullRequestChanged")
self.find_or_create_by(name: "疑修截止日期到达最后一天", key: "IssueExpire", notification_disabled: false)
end
end

View File

@ -29,5 +29,9 @@ class TemplateMessageSetting::ManageProject < TemplateMessageSetting
self.find_or_create_by(name: "有新的合并请求", key: "PullRequest")
self.find_or_create_by(name: "有成员变动", key: "Member")
self.find_or_create_by(name: "仓库设置被更改", key: "SettingChanged")
self.find_or_create_by(name: "被点赞", key: "Praised", notification_disabled: false, email_disabled: true)
self.find_or_create_by(name: "被fork", key: "Forked", notification_disabled: false, email_disabled: true)
self.find_or_create_by(name: "有新的里程碑", key: "Milestone", notification_disabled: false)
self.find_or_create_by(name: "有里程碑已完成", key: "MilestoneCompleted", notification_disabled: false)
end
end

View File

@ -35,10 +35,15 @@ class UserTemplateMessageSetting < ApplicationRecord
"Normal::PullRequestAssigned": true,
"CreateOrAssign::IssueChanged": true,
"CreateOrAssign::PullRequestChanged": true,
"CreateOrAssign::IssueExpire": true,
"ManageProject::Issue": true,
"ManageProject::PullRequest": true,
"ManageProject::Member": true,
"ManageProject::SettingChanged": true,
"ManageProject::Praised": true,
"ManageProject::Forked": true,
"ManageProject::Milestone": true,
"ManageProject::MilestoneCompleted": true,
}.stringify_keys!
end
@ -51,10 +56,15 @@ class UserTemplateMessageSetting < ApplicationRecord
"Normal::PullRequestAssigned": false,
"CreateOrAssign::IssueChanged": false,
"CreateOrAssign::PullRequestChanged": false,
"CreateOrAssign::IssueExpire": false,
"ManageProject::Issue": false,
"ManageProject::PullRequest": false,
"ManageProject::Member": false,
"ManageProject::SettingChanged": false,
"ManageProject::Praised": false,
"ManageProject::Forked": false,
"ManageProject::Milestone": false,
"ManageProject::MilestoneCompleted": false,
}.stringify_keys!
end