fix and add some message feature

This commit is contained in:
yystopf 2021-09-16 16:54:49 +08:00
parent b8a52107a5
commit dbcbc01251
24 changed files with 250 additions and 89 deletions

View File

@ -26,11 +26,11 @@ POST accounts/remote_register
*示例*
```bash
curl -X POST \
-d "email=yystopf@163.com" \
-d "password=a19960425" \
-d "username=yystopf" \
-d "email=2456233122@qq.com" \
-d "password=djs_D_00001" \
-d "username=16895620" \
-d "platform=forge" \
http://120.132.31.109:8080/api/accounts/remote_register | jq
http://localhost:3000/api/accounts/remote_register | jq
```
*请求参数说明:*

View File

@ -112,6 +112,7 @@ class IssuesController < ApplicationController
@issue = Issue.new(issue_params)
if @issue.save!
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id)
SendTemplateMessageJob.perform_later('ProjectIssue', current_user.id, @issue&.id)
if params[:attachment_ids].present?
params[:attachment_ids].each do |id|
attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id)
@ -288,8 +289,12 @@ class IssuesController < ApplicationController
def clean
#批量删除,暂时只能删除未悬赏的
issue_ids = params[:ids]
if issue_ids.present?
if Issue.where(id: issue_ids, issue_type: "1").destroy_all
issues = Issue.where(id: issue_ids, issue_type: "1")
if issues.present?
issues.find_each do |i|
SendTemplateMessageJob.perform_later('IssueDeleted', current_user.id, i&.subject, i.assigned_to_id, i.author_id)
end
if issues.destroy_all
normal_status(0, "删除成功")
else
normal_status(-1, "删除失败")
@ -323,7 +328,18 @@ class IssuesController < ApplicationController
if update_hash.blank?
normal_status(-1, "请选择批量更新内容")
elsif issues&.update(update_hash)
issues.map{|i| i.create_journal_detail(false, [], [], current_user&.id) if i.previous_changes.present?}
issues.each do |i|
i.create_journal_detail(false, [], [], current_user&.id) if i.previous_changes.present?
previous_changes = i.previous_changes.slice(:status_id, :assigned_to_id, :tracker_id, :priority_id, :fixed_version_id, :done_ratio, :issue_tags_value, :branch_name)
if i.previous_changes[:start_date].present?
previous_changes.merge!(start_date: [i.previous_changes[:start_date][0].to_s, i.previous_changes[:start_date][1].to_s])
end
if i.previous_changes[:due_date].present?
previous_changes.merge!(due_date: [i.previous_changes[:due_date][0].to_s, i.previous_changes[:due_date][1].to_s])
end
SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, i&.id, previous_changes)
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, i&.id) if i.previous_changes[:assigned_to_id].present?
end
normal_status(0, "批量更新成功")
else
normal_status(-1, "批量更新失败")

View File

@ -9,7 +9,8 @@ class MembersController < ApplicationController
def create
interactor = Projects::AddMemberInteractor.call(@project.owner, @project, @user)
SendTemplateMessageJob.perform_later('ProjectJoined', @user.id, @project.id)
SendTemplateMessageJob.perform_later('ProjectJoined', current_user.id, @user.id, @project.id)
SendTemplateMessageJob.perform_later('ProjectMemberJoined', current_user.id, @user.id, @project.id)
render_response(interactor)
rescue Exception => e
uid_logger_error(e.message)
@ -29,7 +30,8 @@ class MembersController < ApplicationController
def remove
interactor = Projects::DeleteMemberInteractor.call(@project.owner, @project, @user)
SendTemplateMessageJob.perform_later('ProjectLeft', @user.id, @project.id)
SendTemplateMessageJob.perform_later('ProjectLeft', current_user.id, @user.id, @project.id)
SendTemplateMessageJob.perform_later('ProjectMemberLeft', current_user.id, @user.id, @project.id)
render_response(interactor)
rescue Exception => e
uid_logger_error(e.message)
@ -38,7 +40,7 @@ class MembersController < ApplicationController
def change_role
interactor = Projects::ChangeMemberRoleInteractor.call(@project.owner, @project, @user, params[:role])
SendTemplateMessageJob.perform_later('ProjectRole', @user.id, @project.id, message_role_name)
SendTemplateMessageJob.perform_later('ProjectRole', current_user.id, @user.id, @project.id, message_role_name)
render_response(interactor)
rescue Exception => e
uid_logger_error(e.message)

View File

@ -60,6 +60,7 @@ class PullRequestsController < ApplicationController
if @gitea_pull_request[:status] == :success
@pull_request.bind_gitea_pull_request!(@gitea_pull_request[:body]["number"])
SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id)
SendTemplateMessageJob.perform_later('ProjectPullRequest', current_user.id, @pull_request&.id)
render_ok
else
render_error("create pull request error: #{@gitea_pull_request[:status]}")

View File

@ -91,8 +91,12 @@ class UsersController < ApplicationController
def get_user_info
begin
@user = current_user
result = Notice::Read::CountService.call(current_user.id)
@message_unread_total = result.nil? ? 0 : result[2]["unread_notification"]
begin
result = Notice::Read::CountService.call(current_user.id)
@message_unread_total = result.nil? ? 0 : result[2]["unread_notification"]
rescue
@message_unread_total = 0
end
# TODO 等消息上线再打开注释
#@tidding_count = unviewed_tiddings(current_user) if current_user.present?
rescue Exception => e

View File

@ -17,7 +17,7 @@ class SendTemplateMessageJob < ApplicationJob
operator = User.find_by_id(operator_id)
issue = Issue.find_by_id(issue_id)
return unless operator.present? && issue.present?
receivers = User.where(id: issue&.assigned_to_id)
receivers = User.where(id: issue&.assigned_to_id).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::IssueAssigned.get_message_content(receivers, operator, issue)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, issue_id: issue.id})
when 'IssueAssignerExpire'
@ -32,6 +32,7 @@ class SendTemplateMessageJob < ApplicationJob
operator = User.find_by_id(operator_id)
issue = Issue.find_by_id(issue_id)
return unless operator.present? && issue.present?
receivers = receivers.where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::IssueAtme.get_message_content(receivers, operator, issue)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, issue_id: issue.id}, 2)
when 'IssueChanged'
@ -39,7 +40,7 @@ class SendTemplateMessageJob < ApplicationJob
operator = User.find_by_id(operator_id)
issue = Issue.find_by_id(issue_id)
return unless operator.present? && issue.present?
receivers = User.where(id: [issue&.assigned_to_id, issue&.author_id])
receivers = User.where(id: [issue&.assigned_to_id, issue&.author_id]).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::IssueChanged.get_message_content(receivers, operator, issue, change_params)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, issue_id: issue.id, change_params: change_params.symbolize_keys})
when 'IssueCreatorExpire'
@ -53,7 +54,7 @@ class SendTemplateMessageJob < ApplicationJob
operator_id, issue_title, issue_assigned_to_id, issue_author_id = args[0], args[1], args[2], args[3]
operator = User.find_by_id(operator_id)
return unless operator.present?
receivers = User.where(id: [issue_assigned_to_id, issue_author_id])
receivers = User.where(id: [issue_assigned_to_id, issue_author_id]).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::IssueDeleted.get_message_content(receivers, operator, issue_title)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, issue_title: issue_title})
when 'OrganizationJoined'
@ -80,36 +81,75 @@ class SendTemplateMessageJob < ApplicationJob
receivers = User.where(id: user.id)
receivers_string, content, notification_url = MessageTemplate::OrganizationRole.get_message_content(receivers, organization, role)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {user_id: user.id, organization_id: organization.id, role: role})
when 'ProjectIssue'
operator_id, issue_id = args[0], args[1]
operator = User.find_by_id(operator_id)
issue = Issue.find_by_id(issue_id)
return unless operator.present? && issue.present? && issue&.project.present?
managers = issue&.project&.all_managers.where.not(id: operator&.id)
followers = [] # TODO
receivers_string, content, notification_url = MessageTemplate::ProjectIssue.get_message_content(managers, followers, operator, issue)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, issue_id: issue.id})
when 'ProjectJoined'
user_id, project_id = args[0], args[1]
operator_id, user_id, project_id = args[0], args[1], args[2]
operator = User.find_by_id(operator_id)
user = User.find_by_id(user_id)
project = Project.find_by_id(project_id)
return unless user.present? && project.present?
receivers = User.where(id: user.id)
return unless operator.present? && user.present? && project.present?
receivers = User.where(id: user.id).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::ProjectJoined.get_message_content(receivers, project)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {user_id: user.id, project_id: project.id})
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, user_id: user.id, project_id: project.id})
when 'ProjectLeft'
user_id, project_id = args[0], args[1]
operator_id, user_id, project_id = args[0], args[1], args[2]
operator = User.find_by_id(operator_id)
user = User.find_by_id(user_id)
project = Project.find_by_id(project_id)
return unless user.present? && project.present?
receivers = User.where(id: user.id)
return unless operator.present? && user.present? && project.present?
receivers = User.where(id: user.id).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::ProjectLeft.get_message_content(receivers, project)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {user_id: user.id, project_id: project.id})
when 'ProjectRole'
user_id, project_id, role = args[0], args[1], args[2]
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, user_id: user.id, project_id: project.id})
when 'ProjectMemberJoined'
operator_id, user_id, project_id = args[0], args[1], args[2]
operator = User.find_by_id(operator_id)
user = User.find_by_id(user_id)
project = Project.find_by_id(project_id)
return unless user.present? && project.present?
receivers = User.where(id: user.id)
return unless operator.present? && user.present? && project.present?
receivers = project&.all_managers.where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::ProjectMemberJoined.get_message_content(receivers, user, project)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, user_id: user.id, project_id: project.id})
when 'ProjectMemberLeft'
operator_id, user_id, project_id = args[0], args[1], args[2]
operator = User.find_by_id(operator_id)
user = User.find_by_id(user_id)
project = Project.find_by_id(project_id)
return unless operator.present? && user.present? && project.present?
receivers = project&.all_managers.where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::ProjectMemberLeft.get_message_content(receivers, user, project)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, user_id: user.id, project_id: project.id})
when 'ProjectPullRequest'
operator_id, pull_request_id = args[0], args[1]
operator = User.find_by_id(operator_id)
pull_request = PullRequest.find_by_id(pull_request_id)
return unless operator.present? && pull_request.present? && pull_request&.project.present?
managers = pull_request&.project&.all_managers.where.not(id: operator&.id)
followers = [] # TODO
receivers_string, content, notification_url = MessageTemplate::ProjectPullRequest.get_message_content(managers, followers, operator, pull_request)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id})
when 'ProjectRole'
operator_id, user_id, project_id, role = args[0], args[1], args[2], args[3]
operator = User.find_by_id(operator_id)
user = User.find_by_id(user_id)
project = Project.find_by_id(project_id)
return unless operator.present? && user.present? && project.present?
receivers = User.where(id: user.id).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::ProjectRole.get_message_content(receivers, project, role)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {user_id: user.id, project_id: project.id, role: role})
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, user_id: user.id, project_id: project.id, role: role})
when 'ProjectSettingChanged'
operator_id, project_id, change_params = args[0], args[1], args[2]
operator = User.find_by_id(operator_id)
project = Project.find_by_id(project_id)
return unless operator.present? && project.present?
receivers = project.all_managers
receivers = project.all_managers.where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::ProjectSettingChanged.get_message_content(receivers, operator, project, change_params.symbolize_keys)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, project_id: project.id, change_params: change_params})
when 'PullRequestAssigned'
@ -117,7 +157,7 @@ class SendTemplateMessageJob < ApplicationJob
operator = User.find_by_id(operator_id)
pull_request = PullRequest.find_by_id(pull_request_id)
return unless operator.present? && pull_request.present?
receivers = User.where(id: pull_request&.issue&.assigned_to_id)
receivers = User.where(id: pull_request&.issue&.assigned_to_id).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::PullRequestAssigned.get_message_content(receivers, operator, pull_request)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id})
when 'PullRequestAtme'
@ -125,6 +165,7 @@ class SendTemplateMessageJob < ApplicationJob
operator = User.find_by_id(operator_id)
pull_request = PullRequest.find_by_id(pull_request_id)
return unless operator.present? && pull_request.present?
receivers = receivers.where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::PullRequestAtme.get_message_content(receivers, operator, pull_request)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id}, 2)
when 'PullRequestChanged'
@ -132,7 +173,7 @@ class SendTemplateMessageJob < ApplicationJob
operator = User.find_by_id(operator_id)
pull_request = PullRequest.find_by_id(pull_request_id)
return unless operator.present? && pull_request.present?
receivers = User.where(id: [pull_request&.issue&.assigned_to_id, pull_request&.user_id])
receivers = User.where(id: [pull_request&.issue&.assigned_to_id, pull_request&.user_id]).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::PullRequestChanged.get_message_content(receivers, operator, pull_request, change_params.symbolize_keys)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id, change_params: change_params})
when 'PullRequestClosed'
@ -140,7 +181,7 @@ class SendTemplateMessageJob < ApplicationJob
operator = User.find_by_id(operator_id)
pull_request = PullRequest.find_by_id(pull_request_id)
return unless operator.present? && pull_request.present?
receivers = User.where(id: [pull_request&.issue&.assigned_to_id, pull_request&.user_id])
receivers = User.where(id: [pull_request&.issue&.assigned_to_id, pull_request&.user_id]).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::PullRequestClosed.get_message_content(receivers, operator, pull_request)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id})
when 'PullRequestMerged'
@ -148,7 +189,7 @@ class SendTemplateMessageJob < ApplicationJob
operator = User.find_by_id(operator_id)
pull_request = PullRequest.find_by_id(pull_request_id)
return unless operator.present? && pull_request.present?
receivers = User.where(id: [pull_request&.issue&.assigned_to_id, pull_request&.user_id])
receivers = User.where(id: [pull_request&.issue&.assigned_to_id, pull_request&.user_id]).where.not(id: operator&.id)
receivers_string, content, notification_url = MessageTemplate::PullRequestMerged.get_message_content(receivers, operator, pull_request)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id})
end

View File

@ -18,7 +18,7 @@ class MessageTemplate <ApplicationRecord
self.create(type: 'MessageTemplate::IssueAssigned', sys_notice: '{nickname1}在<b>{nickname2}/{repository}</b>指派给你一个易修:<b>{title}<b>', notification_url: '{baseurl}/{owner}/{identifier}/issues/{id}')
self.create(type: 'MessageTemplate::IssueAssignerExpire', sys_notice: '您负责的易修<b>{title}</b>已临近截止日期,请尽快处理', notification_url: '{baseurl}/{owner}/{identifier}/issues/{id}')
self.create(type: 'MessageTemplate::IssueAtme', sys_notice: '<b>{nickname}</b>在易修<b>{title}</b>中@我', notification_url: '{baseurl}/{owner}/{identifier}/issues/{id}')
self.create(type: 'MessageTemplate::IssueChanged', sys_notice: '在项目{nickname2}/{repository}的易修<b>{title}</b>中:{ifassigner}{nickname1}将负责人从<b>{assigner1}</b>修改为<b>{assigner2}</b><br/>{endassigner}{ifstatus}{nickname1}将状态从<b>{status1}</b>修改为<b>{status2}</b><br/>{endstatus}{iftracker}{nickname1}将类型从<b>{tracker1}</b>修改为<b>{tracker2}</b><br/>{endtracker}{ifpriority}{nickname1}将优先级从<b>{priority1}</b>修改为<b>{priority2}</b><br/>{endpriority}{ifmilestone}{nickname1}将里程碑从<b>{milestone1}</b>修改为<b>{milestone2}</b><br/>{endmilestone}{iftag}{nickname1}将标签从<b>{tag1}</b>修改为<b>{tag2}</b><br/>{endtag}{ifdoneratio}{nickname1}将完成度从<b>{doneratio2}</b>修改为<b>{doneratio1}</b>{enddoneratio}<br/>{ifbranch}{nickname1}将指定分支从<b>{branch1}</b>修改为<b>{branch2}</b><br/>{endbranch}{ifstartdate}{nickname1}将开始日期从<b>{startdate1}</b>修改为<b>{startdate2}</b><br/>{endstartdate}{ifduedate}{nickname1}将结束日期从<b>{duedate1}</b>修改为<b>{duedate2}</b><br/>{endduedate}', notification_url: '{baseurl}/{owner}/{identifier}/issues/{id}')
self.create(type: 'MessageTemplate::IssueChanged', sys_notice: '在项目{nickname2}/{repository}的易修<b>{title}</b>中:{ifassigner}{nickname1}将负责人从<b>{assigner1}</b>修改为<b>{assigner2}</b>{endassigner}{ifstatus}{nickname1}将状态从<b>{status1}</b>修改为<b>{status2}</b>{endstatus}{iftracker}{nickname1}将类型从<b>{tracker1}</b>修改为<b>{tracker2}</b>{endtracker}{ifpriority}{nickname1}将优先级从<b>{priority1}</b>修改为<b>{priority2}</b>{endpriority}{ifmilestone}{nickname1}将里程碑从<b>{milestone1}</b>修改为<b>{milestone2}</b>{endmilestone}{iftag}{nickname1}将标签从<b>{tag1}</b>修改为<b>{tag2}</b>{endtag}{ifdoneratio}{nickname1}将完成度从<b>{doneratio1}</b>修改为<b>{doneratio2}</b>{enddoneratio}{ifbranch}{nickname1}将指定分支从<b>{branch1}</b>修改为<b>{branch2}</b>{endbranch}{ifstartdate}{nickname1}将开始日期从<b>{startdate1}</b>修改为<b>{startdate2}</b>{endstartdate}{ifduedate}{nickname1}将结束日期从<b>{duedate1}</b>修改为<b>{duedate2}</b>{endduedate}', notification_url: '{baseurl}/{owner}/{identifier}/issues/{id}')
self.create(type: 'MessageTemplate::IssueCreatorExpire', sys_notice: '您发布的易修<b>{title}</b>已临近截止日期,请尽快处理', notification_url: '{baseurl}/{owner}/{identifier}/issues/{id}')
self.create(type: 'MessageTemplate::IssueDeleted', sys_notice: '{nickname}已将易修<b>{title}</b>删除', notification_url: '')
self.create(type: 'MessageTemplate::IssueJournal', sys_notice: '{nickname}评论易修{title}<b>{notes}</b>', notification_url: '{baseurl}/{owner}/{identifier}/issues/{id}')
@ -38,12 +38,12 @@ class MessageTemplate <ApplicationRecord
self.create(type: 'MessageTemplate::ProjectPraised', sys_notice: '<b>{nickname}</b>点赞了你管理的仓库', notification_url: '{baseurl}/{login}')
self.create(type: 'MessageTemplate::ProjectPullRequest', sys_notice: '{nickname1}在<b>{nickname2}/{repository}</b>提交了一个合并请求:<b>{title}</b>', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
self.create(type: 'MessageTemplate::ProjectRole', sys_notice: '仓库{repository}已把你的角色改为<b>{role}</b>', notification_url: '{baseurl}/{owner}/{identifier}')
self.create(type: 'MessageTemplate::ProjectSettingChanged', sys_notice: '<b>{nickname1}</b>更改了{nickname2}/{repository}仓库设置:{ifname}更改项目名称为"<b>{name}</b>";{endname}{ifdescription}更改项目简介为"<b>{description}</b>";{enddescription}{ifcategory}更改项目类别为"<b>{category}</b>";{endcategory}{iflanguage}更改项目语言为"<b>{language}</b>";{endlanguage}{ifpermission}将仓库设为"<b>{permission}</b>";{endpermission}{ifnavbar}将项目导航更改为"<b>{navbar}</b>";{endnavbar}', notification_url: '{baseurl}/{owner}/{identifier}/settings')
self.create(type: 'MessageTemplate::ProjectSettingChanged', sys_notice: '{nickname1}更改了<b>{nickname2}/{repository}<b>仓库设置:{ifname}更改项目名称为"<b>{name}</b>"{endname}{ifdescription}更改项目简介为"<b>{description}</b>"{enddescription}{ifcategory}更改项目类别为"<b>{category}</b>"{endcategory}{iflanguage}更改项目语言为"<b>{language}</b>"{endlanguage}{ifpermission}将仓库设为"<b>{permission}</b>"{endpermission}{ifnavbar}将项目导航更改为"<b>{navbar}</b>"{endnavbar}', notification_url: '{baseurl}/{owner}/{identifier}/settings')
self.create(type: 'MessageTemplate::ProjectTransfer', sys_notice: '你关注的仓库{nickname1}/{repository1}已被转移至{nickname2}/{repository2}', notification_url: '{baseurl}/{owner}/{identifier}')
self.create(type: 'MessageTemplate::ProjectVersion', sys_notice: '{nickname1}在<b>{nickname2}/{repository}</b>创建了发行版:<b>{title}</b>', notification_url: '{baseurl}/{owner}/{identifier}/releases')
self.create(type: 'MessageTemplate::PullRequestAssigned', sys_notice: '{nickname1}在<b>{nickname2}/{repository}</b>指派给你一个合并请求:<b>{title}<b>', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
self.create(type: 'MessageTemplate::PullRequestAtme', sys_notice: '<b>{nickname}</b>在合并请求<b>{title}</b>中@我', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
self.create(type: 'MessageTemplate::PullRequestChanged', sys_notice: '在项目{nickname2}/{repository}的合并请求<b>{title}</b>中:{ifassigner}{nickname1}将审查成员从<b>{assigner1}</b>修改为<b>{assigner2}</b><br/>{endassigner}{ifmilestone}{nickname1}将里程碑从<b>{milestone1}</b>修改为<b>{milestone2}</b><br/>{endmilestone}{iftag}{nickname1}将标签从<b>{tag1}</b>修改为<b>{tag2}</b><br/>{endtag}{ifpriority}{nickname1}将优先级从<b>{priority1}</b>修改为<b>{priority2}</b><br/>{endpriority}', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
self.create(type: 'MessageTemplate::PullRequestChanged', sys_notice: '在项目{nickname2}/{repository}的合并请求<b>{title}</b>中:{ifassigner}{nickname1}将审查成员从<b>{assigner1}</b>修改为<b>{assigner2}</b>{endassigner}{ifmilestone}{nickname1}将里程碑从<b>{milestone1}</b>修改为<b>{milestone2}</b>{endmilestone}{iftag}{nickname1}将标签从<b>{tag1}</b>修改为<b>{tag2}</b>{endtag}{ifpriority}{nickname1}将优先级从<b>{priority1}</b>修改为<b>{priority2}</b>{endpriority}', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
self.create(type: 'MessageTemplate::PullRequestClosed', sys_notice: '你提交的合并请求:{title}被拒绝', notification_url: '')
self.create(type: 'MessageTemplate::PullRequestJournal', sys_notice: '{nickname}评论合并请求{title}<b>{notes}</b>', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
self.create(type: 'MessageTemplate::PullRequestMerged', sys_notice: '你提交的合并请求:{title}被合并', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')

View File

@ -16,7 +16,7 @@ class MessageTemplate::FollowedTip < MessageTemplate
# MessageTemplate::FollowedTip.get_message_content(User.where(login: 'yystopf'), User.last)
def self.get_message_content(receivers, followeder)
return receivers_string(receivers), sys_notice.gsub('{nickname}', followeder&.nickname), notification_url.gsub('{login}', followeder.login)
return receivers_string(receivers), sys_notice.gsub('{nickname}', followeder&.real_name), notification_url.gsub('{login}', followeder.login)
rescue
return '', '', ''
end

View File

@ -18,7 +18,7 @@ class MessageTemplate::IssueAssigned < MessageTemplate
def self.get_message_content(receivers, operator, issue)
project = issue&.project
owner = project&.owner
content = sys_notice.gsub('{nickname1}', operator&.nickname).gsub('{nickname2}', owner&.nickname).gsub('{repository}', project&.name).gsub('{title}', issue&.subject)
content = sys_notice.gsub('{nickname1}', operator&.real_name).gsub('{nickname2}', owner&.real_name).gsub('{repository}', project&.name).gsub('{title}', issue&.subject)
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

View File

@ -18,7 +18,7 @@ class MessageTemplate::IssueAtme < MessageTemplate
def self.get_message_content(receivers, operator, issue)
project = issue&.project
owner = project&.owner
content = sys_notice.gsub('{nickname}', operator&.nickname).gsub('{title}', issue&.subject)
content = sys_notice.gsub('{nickname}', operator&.real_name).gsub('{title}', issue&.subject)
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

View File

@ -19,16 +19,21 @@ class MessageTemplate::IssueChanged < MessageTemplate
return '', '', '' if change_params.blank?
project = issue&.project
owner = project&.owner
content = MessageTemplate::IssueChanged.sys_notice.gsub('{nickname1}', operator&.nickname).gsub('{nickname2}', owner&.nickname).gsub('{repository}', project&.name).gsub('{title}', issue&.subject)
content = MessageTemplate::IssueChanged.sys_notice.gsub('{nickname1}', operator&.real_name).gsub('{nickname2}', owner&.real_name).gsub('{repository}', project&.name).gsub('{title}', issue&.subject)
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', issue&.id.to_s)
change_count = change_params.keys.size
# 易修负责人修改
if change_params[:assigned_to_id].present?
assigner1 = User.find_by_id(change_params[:assigned_to_id][0])
assigner2 = User.find_by_id(change_params[:assigned_to_id][1])
content.sub!('{ifassigner}', '')
if change_count > 1
content.sub!('{ifassigner}', '<br/>')
else
content.sub!('{ifassigner}', '')
end
content.sub!('{endassigner}', '')
content.gsub!('{assigner1}', assigner1.present? ? assigner1&.nickname || assigner1.login : '未指派成员')
content.gsub!('{assigner2}', assigner2.present? ? assigner2&.nickname || assigner2.login : '未指派成员')
content.gsub!('{assigner1}', assigner1.present? ? assigner1&.real_name : '未指派成员')
content.gsub!('{assigner2}', assigner2.present? ? assigner2&.real_name : '未指派成员')
else
content.gsub!(/({ifassigner})(.*)({endassigner})/, '')
end
@ -36,7 +41,11 @@ class MessageTemplate::IssueChanged < MessageTemplate
if change_params[:status_id].present?
status1 = IssueStatus.find_by_id(change_params[:status_id][0])
status2 = IssueStatus.find_by_id(change_params[:status_id][1])
content.sub!('{ifstatus}', '')
if change_count > 1
content.sub!('{ifstatus}', '<br/>')
else
content.sub!('{ifstatus}', '')
end
content.sub!('{endstatus}', '')
content.gsub!('{status1}', status1&.name)
content.gsub!('{status2}', status2&.name)
@ -47,7 +56,11 @@ class MessageTemplate::IssueChanged < MessageTemplate
if change_params[:tracker_id].present?
tracker1 = Tracker.find_by_id(change_params[:tracker_id][0])
tracker2 = Tracker.find_by_id(change_params[:tracker_id][1])
content.sub!('{iftracker}', '')
if change_count > 1
content.sub!('{iftracker}', '<br/>')
else
content.sub!('{iftracker}', '')
end
content.sub!('{endtracker}', '')
content.gsub!('{tracker1}', tracker1&.name)
content.gsub!('{tracker2}', tracker2&.name)
@ -58,7 +71,11 @@ class MessageTemplate::IssueChanged < MessageTemplate
if change_params[:fixed_version_id].present?
fix_version1 = Version.find_by_id(change_params[:fixed_version_id][0])
fix_version2 = Version.find_by_id(change_params[:fixed_version_id][1])
content.sub!('{ifmilestone}', '')
if change_count > 1
content.sub!('{ifmilestone}', '<br/>')
else
content.sub!('{ifmilestone}', '')
end
content.sub!('{endmilestone}', '')
content.gsub!('{milestone1}', fix_version1.present? ? fix_version1&.name : '未选择里程碑')
content.gsub!('{milestone2}', fix_version2.present? ? fix_version2&.name : '未选择里程碑')
@ -71,8 +88,11 @@ class MessageTemplate::IssueChanged < MessageTemplate
issue_tags2 = IssueTag.where(id: change_params[:issue_tags_value][1]).distinct
tag1 = issue_tags1.pluck(:name).join(",").blank? ? '未选择标签' : issue_tags1.pluck(:name).join(",")
tag2 = issue_tags2.pluck(:name).join(",").blank? ? '未选择标签' : issue_tags2.pluck(:name).join(",")
content.sub!('{iftag}', '')
content.sub!('{endtag}', '')
if change_count > 1
content.sub!('{iftag}', '<br/>')
else
content.sub!('{endtag}', '')
end
content.gsub!('{tag1}', tag1)
content.gsub!('{tag2}', tag2)
else
@ -82,8 +102,11 @@ class MessageTemplate::IssueChanged < MessageTemplate
if change_params[:priority_id].present?
priority1 = IssuePriority.find_by_id(change_params[:priority_id][0])
priority2 = IssuePriority.find_by_id(change_params[:priority_id][1])
content.sub!('{ifpriority}', '')
if change_count > 1
content.sub!('{ifpriority}', '<br/>')
else
content.sub!('{ifpriority}', '')
end
content.sub!('{endpriority}', '')
content.gsub!('{priority1}', priority1&.name)
content.gsub!('{priority2}', priority2&.name)
@ -94,8 +117,11 @@ class MessageTemplate::IssueChanged < MessageTemplate
if change_params[:done_ratio].present?
doneratio1 = change_params[:done_ratio][0]
doneratio2 = change_params[:done_ratio][1]
content.sub!('{ifdoneratio}', '')
if change_count > 1
content.sub!('{ifdoneratio}', '<br/>')
else
content.sub!('{ifdoneratio}', '')
end
content.sub!('{enddoneratio}', '')
content.gsub!('{doneratio1}', "#{doneratio1}%")
content.gsub!('{doneratio2}', "#{doneratio2}%")
@ -106,8 +132,11 @@ class MessageTemplate::IssueChanged < MessageTemplate
if change_params[:branch_name].present?
branch1 = change_params[:branch_name][0].blank? ? '分支未指定' : change_params[:branch_name][0]
branch2 = change_params[:branch_name][1].blank? ? '分支未指定' : change_params[:branch_name][1]
content.sub!('{ifbranch}', '')
if change_count > 1
content.sub!('{ifbranch}', '<br/>')
else
content.sub!('{ifbranch}', '')
end
content.sub!('{endbranch}', '')
content.gsub!('{branch1}', branch1)
content.gsub!('{branch2}', branch2)
@ -118,8 +147,11 @@ class MessageTemplate::IssueChanged < MessageTemplate
if change_params[:start_date].present?
startdate1 = change_params[:start_date][0].blank? ? "未选择开始日期" : change_params[:start_date][0]
startdate2 = change_params[:start_date][1].blank? ? "未选择开始日期" : change_params[:start_date][1]
content.sub!('{ifstartdate}', '')
if change_count > 1
content.sub!('{ifstartdate}', '<br/>')
else
content.sub!('{ifstartdate}', '')
end
content.sub!('{endstartdate}', '')
content.gsub!('{startdate1}', startdate1 )
content.gsub!('{startdate2}', startdate2)
@ -130,7 +162,11 @@ class MessageTemplate::IssueChanged < MessageTemplate
if change_params[:due_date].present?
duedate1 = change_params[:due_date][0].blank? ? '未选择结束日期' : change_params[:due_date][0]
duedate2 = change_params[:due_date][1].blank? ? '未选择结束日期' : change_params[:due_date][1]
content.sub!('{ifduedate}', '')
if change_count > 1
content.sub!('{ifduedate}', '<br/>')
else
content.sub!('{ifduedate}', '')
end
content.sub!('{endduedate}', '')
content.gsub!('{duedate1}', duedate1)
content.gsub!('{duedate2}', duedate2)

View File

@ -16,7 +16,7 @@ class MessageTemplate::IssueDeleted < MessageTemplate
# MessageTemplate::IssueDeleted.get_message_content(User.where(login: 'yystopf'), User.last, "hahah")
def self.get_message_content(receivers, operator, issue_title)
content = sys_notice.gsub('{nickname}', operator&.nickname).gsub('{title}', issue_title)
content = sys_notice.gsub('{nickname}', operator&.real_name).gsub('{title}', issue_title)
return receivers_string(receivers), content, notification_url
rescue => e
Rails.logger.info("MessageTemplate::IssueAtme.get_message_content [ERROR] #{e}")

View File

@ -16,7 +16,7 @@ class MessageTemplate::OrganizationJoined < MessageTemplate
# MessageTemplate::OrganizationJoined.get_message_content(User.where(login: 'yystopf'), Organization.last)
def self.get_message_content(receivers, organization)
content = sys_notice.gsub('{organization}', organization&.name)
content = sys_notice.gsub('{organization}', organization&.real_name)
url = notification_url.gsub('{login}', organization&.name)
return receivers_string(receivers), content, url
rescue => e

View File

@ -16,7 +16,7 @@ class MessageTemplate::OrganizationLeft < MessageTemplate
# MessageTemplate::OrganizationLeft.get_message_content(User.where(login: 'yystopf'), Organization.last)
def self.get_message_content(receivers, organization)
content = sys_notice.gsub('{organization}', organization&.name)
content = sys_notice.gsub('{organization}', organization&.real_name)
url = notification_url.gsub('{login}', organization&.name)
return receivers_string(receivers), content, url
rescue => e

View File

@ -16,7 +16,7 @@ class MessageTemplate::OrganizationRole < MessageTemplate
# MessageTemplate::OrganizationRole.get_message_content(User.where(login: 'yystopf'), Organization.last, '管理员')
def self.get_message_content(receivers, organization, role)
content = sys_notice.gsub('{organization}', organization&.name).gsub('{role}', role)
content = sys_notice.gsub('{organization}', organization&.real_name).gsub('{role}', role)
url = notification_url.gsub('{login}', organization&.login)
return receivers_string(receivers), content, url
rescue => e

View File

@ -14,8 +14,14 @@
# TODO 我管理/关注的仓库有新的易修
class MessageTemplate::ProjectIssue < MessageTemplate
# MessageTemplate::ProjectIssue.get_message_content(User.where(login: 'yystopf'))
def self.get_message_content(receivers)
# MessageTemplate::ProjectIssue.get_message_content(User.where(login: 'yystopf'), User.where(login: 'forgetest1'), User.last, Issue.last)
def self.get_message_content(managers, followers, operator, issue)
project = issue&.project
owner = project&.owner
receivers = managers + followers
content = sys_notice.gsub('{nickname1}', operator&.real_name).gsub('{nickname2}', owner&.real_name).gsub('{repository}', project&.name).gsub('{title}', issue&.subject)
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::ProjectIssue.get_message_content [ERROR] #{e}")

View File

@ -11,11 +11,13 @@
# notification_url :string(255)
#
# TODO 我管理的仓库有成员加入
# 我管理的仓库有成员加入
class MessageTemplate::ProjectMemberJoined < MessageTemplate
# MessageTemplate::ProjectMemberJoined.get_message_content(User.where(login: 'yystopf'))
def self.get_message_content(receivers)
def self.get_message_content(receivers, user, project)
content = sys_notice.gsub('{nickname1}', user&.real_name).gsub('{nickname2}', project&.owner&.real_name).gsub('{repository}', project&.name)
url = notification_url.gsub('{owner}', project&.owner&.login).gsub('{identifier}', project&.identifier)
return receivers_string(receivers), content, url
rescue => e
Rails.logger.info("MessageTemplate::ProjectMemberJoined.get_message_content [ERROR] #{e}")

View File

@ -11,11 +11,13 @@
# notification_url :string(255)
#
# TODO 我管理的仓库有成员移出
# 我管理的仓库有成员移出
class MessageTemplate::ProjectMemberLeft < MessageTemplate
# MessageTemplate::ProjectMemberLeft.get_message_content(User.where(login: 'yystopf'))
def self.get_message_content(receivers)
# MessageTemplate::ProjectMemberLeft.get_message_content(User.where(login: 'yystopf'), User.last, Project.last)
def self.get_message_content(receivers, user, project)
content = sys_notice.gsub('{nickname1}', user&.real_name).gsub('{nickname2}', project&.owner&.real_name).gsub('{repository}', project&.name)
url = notification_url.gsub('{owner}', project&.owner&.login).gsub('{identifier}', project&.identifier)
return receivers_string(receivers), content, url
rescue => e
Rails.logger.info("MessageTemplate::ProjectMemberLeft.get_message_content [ERROR] #{e}")

View File

@ -14,8 +14,14 @@
# TODO 我管理/关注的仓库有新的合并请求
class MessageTemplate::ProjectPullRequest < MessageTemplate
# MessageTemplate::ProjectPullRequest.get_message_content(User.where(login: 'yystopf'))
def self.get_message_content(receivers)
# MessageTemplate::ProjectPullRequest.get_message_content(User.where(login: 'yystopf'), User.where(login: 'testforge2'), User.last, PullRequest.last)
def self.get_message_content(managers, followers, operator, pull_request)
project = pull_request&.project
owner = project&.owner
receivers = managers + followers
content = sys_notice.gsub('{nickname1}', operator&.real_name).gsub('{nickname2}', owner&.real_name).gsub('{repository}', project&.name).gsub('{title}', pull_request&.title)
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', pull_request&.id.to_s)
return receivers_string(receivers), content, url
rescue => e
Rails.logger.info("MessageTemplate::ProjectPullRequest.get_message_content [ERROR] #{e}")

View File

@ -18,11 +18,16 @@ class MessageTemplate::ProjectSettingChanged < MessageTemplate
def self.get_message_content(receivers, operator, project, change_params)
return '', '', '' if change_params.blank?
owner = project&.owner
content = sys_notice.gsub('{nickname1}', operator&.nickname).gsub('{nickname2}', owner&.nickname).gsub('{repository}', project&.name)
content = sys_notice.gsub('{nickname1}', operator&.real_name).gsub('{nickname2}', owner&.real_name).gsub('{repository}', project&.name)
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier)
change_count = change_params.keys.size
# 项目名称更改
if change_params[:name].present?
content.sub!('{ifname}', '')
if change_count > 1
content.sub!('{ifname}', '<br/>')
else
content.sub!('{ifname}', '')
end
content.sub!('{endname}', '')
content.gsub!('{name}', change_params[:name][1])
else
@ -30,7 +35,11 @@ class MessageTemplate::ProjectSettingChanged < MessageTemplate
end
# 项目简介更改
if change_params[:description].present?
content.sub!('{ifdescription}', '')
if change_count > 1
content.sub!('{ifdescription}', '<br/>')
else
content.sub!('{ifdescription}', '')
end
content.sub!('{enddescription}', '')
content.gsub!('{description}', change_params[:description][1])
else
@ -39,7 +48,11 @@ class MessageTemplate::ProjectSettingChanged < MessageTemplate
# 项目类别更改
if change_params[:project_category_id].present?
category = ProjectCategory.find_by_id(change_params[:project_category_id][1])
content.sub!('{ifcategory}', '')
if change_count > 1
content.sub!('{ifcategory}', '<br/>')
else
content.sub!('{ifcategory}', '')
end
content.sub!('{endcategory}', '')
content.gsub!('{category}', category&.name)
else
@ -48,7 +61,11 @@ class MessageTemplate::ProjectSettingChanged < MessageTemplate
# 项目语言更改
if change_params[:project_language_id].present?
language = ProjectLanguage.find_by_id(change_params[:project_language_id][1])
content.sub!('{iflanguage}', '')
if change_count > 1
content.sub!('{iflanguage}', '<br/>')
else
content.sub!('{iflanguage}', '')
end
content.sub!('{endlanguage}', '')
content.gsub!('{language}', language&.name)
else
@ -57,7 +74,11 @@ class MessageTemplate::ProjectSettingChanged < MessageTemplate
# 项目公私有更改
if change_params[:is_public].present?
permission = change_params[:is_public][1] ? '公有' : '私有'
content.sub!('{ifpermission}', '')
if change_count > 1
content.sub!('{ifpermission}', '<br/>')
else
content.sub!('{ifpermission}', '')
end
content.sub!('{endpermission}', '')
content.gsub!('{permission}', permission)
else
@ -73,16 +94,20 @@ class MessageTemplate::ProjectSettingChanged < MessageTemplate
navbar.gsub!('devops', '工作流')
navbar.gsub!('versions', '里程碑')
navbar.gsub!('resources', '资源库')
content.sub!('{ifnavbar}', '')
if change_count > 1
content.sub!('{ifnavbar}', '<br/>')
else
content.sub!('{ifnavbar}', '')
end
content.sub!('{endnavbar}', '')
content.gsub!('{navbar}', navbar)
else
content.gsub!(/({ifnavbar})(.*)({endnavbar})/, '')
end
return receivers_string(receivers.where.not(id: operator.id)), content, url
# rescue => e
# Rails.logger.info("MessageTemplate::ProjectSettingChanged.get_message_content [ERROR] #{e}")
# return '', '', ''
return receivers_string(receivers), content, url
rescue => e
Rails.logger.info("MessageTemplate::ProjectSettingChanged.get_message_content [ERROR] #{e}")
return '', '', ''
end
end

View File

@ -18,7 +18,7 @@ class MessageTemplate::PullRequestAssigned < MessageTemplate
def self.get_message_content(receivers, operator, pull_request)
project = pull_request&.project
owner = project&.owner
content = sys_notice.gsub('{nickname1}', operator&.nickname).gsub('{nickname2}', owner&.nickname).gsub('{repository}', project&.name).gsub('{title}', pull_request&.title)
content = sys_notice.gsub('{nickname1}', operator&.real_name).gsub('{nickname2}', owner&.real_name).gsub('{repository}', project&.name).gsub('{title}', pull_request&.title)
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', pull_request&.id.to_s)
return receivers_string(receivers), content, url
rescue => e

View File

@ -17,7 +17,7 @@ class MessageTemplate::PullRequestAtme < MessageTemplate
def self.get_message_content(receivers, operator, pull_request)
project = pull_request&.project
owner = project&.owner
content = sys_notice.gsub('{nickname}', operator&.nickname).gsub('{title}', pull_request&.title)
content = sys_notice.gsub('{nickname}', operator&.real_name).gsub('{title}', pull_request&.title)
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', pull_request&.id.to_s)
return receivers_string(receivers), content, url
rescue => e

View File

@ -20,16 +20,21 @@ class MessageTemplate::PullRequestChanged < MessageTemplate
project = pull_request&.project
owner = project&.owner
issue = pull_request&.issue
content = sys_notice.gsub('{nickname1}', operator&.nickname).gsub('{nickname2}', owner&.nickname).gsub('{repository}', project&.name).gsub("{title}", pull_request&.title)
content = sys_notice.gsub('{nickname1}', operator&.real_name).gsub('{nickname2}', owner&.real_name).gsub('{repository}', project&.name).gsub("{title}", pull_request&.title)
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', pull_request&.id.to_s)
change_count = change_params.keys.size
# 合并请求审查成员修改
if change_params[:assigned_to_id].present?
assigner1 = User.find_by_id(change_params[:assigned_to_id][0])
assigner2 = User.find_by_id(change_params[:assigned_to_id][1])
content.sub!('{ifassigner}', '')
if change_count > 1
content.sub!('{ifassigner}', '<br/>')
else
content.sub!('{ifassigner}', '')
end
content.sub!('{endassigner}', '')
content.gsub!('{assigner1}', assigner1.present? ? assigner1&.nickname || assigner1.login : '未指派成员')
content.gsub!('{assigner2}', assigner2.present? ? assigner2&.nickname || assigner2.login : '未指派成员')
content.gsub!('{assigner1}', assigner1.present? ? assigner1&.real_name : '未指派成员')
content.gsub!('{assigner2}', assigner2.present? ? assigner2&.real_name : '未指派成员')
else
content.gsub!(/({ifassigner})(.*)({endassigner})/, '')
end
@ -37,7 +42,11 @@ class MessageTemplate::PullRequestChanged < MessageTemplate
if change_params[:fixed_version_id].present?
fix_version1 = Version.find_by_id(change_params[:fixed_version_id][0])
fix_version2 = Version.find_by_id(change_params[:fixed_version_id][1])
content.sub!('{ifmilestone}', '')
if change_count > 1
content.sub!('{ifmilestone}', '<br/>')
else
content.sub!('{ifmilestone}', '')
end
content.sub!('{endmilestone}', '')
content.gsub!('{milestone1}', fix_version1.present? ? fix_version1&.name : '未选择里程碑')
content.gsub!('{milestone2}', fix_version2.present? ? fix_version2&.name : '未选择里程碑')
@ -50,7 +59,11 @@ class MessageTemplate::PullRequestChanged < MessageTemplate
issue_tags2 = IssueTag.where(id: change_params[:issue_tags_value][1]).distinct
tag1 = issue_tags1.pluck(:name).join(",").blank? ? '未选择标签' : issue_tags1.pluck(:name).join(",")
tag2 = issue_tags2.pluck(:name).join(",").blank? ? '未选择标签' : issue_tags2.pluck(:name).join(",")
content.sub!('{iftag}', '')
if change_count > 1
content.sub!('{iftag}', '<br/>')
else
content.sub!('{iftag}', '')
end
content.sub!('{endtag}', '')
content.gsub!('{tag1}', tag1)
content.gsub!('{tag2}', tag2)
@ -61,6 +74,11 @@ class MessageTemplate::PullRequestChanged < MessageTemplate
if change_params[:priority_id].present?
priority1 = IssuePriority.find_by_id(change_params[:priority_id][0])
priority2 = IssuePriority.find_by_id(change_params[:priority_id][1])
if change_count > 1
content.sub!('{ifpriority}', '<br/>')
else
content.sub!('{ifpriority}', '')
end
content.sub!('{ifpriority}', '')
content.sub!('{endpriority}', '')
content.gsub!('{priority1}', priority1&.name)

View File

@ -53,6 +53,8 @@ class Projects::AcceptJoinService < ApplicationService
def operate_project_member
Projects::AddMemberInteractor.call(@project.owner, @project, @applied_project.user, permission)
SendTemplateMessageJob.perform_later('ProjectJoined', @user.id, @applied_project.user_id, @project.id)
SendTemplateMessageJob.perform_later('ProjectMemberJoined', @user.id, @applied_project.user_id, @project.id)
end
def send_apply_message