forked from Gitlink/forgeplus
add: join message content be necessary
This commit is contained in:
parent
ca4f416f0a
commit
65af40c29b
|
@ -18,14 +18,14 @@ 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}/{repository1}的易修<b>{title}</b>中:{ifassigner}{nickname1}将负责人从<b>{assigner1}</b>修改为<b>{assigner1}</b>{endassigner}<br/>{ifstatus}{nickname1}将状态从<b>{status1}</b>修改为<b>{status1}</b>{endstatus}<br/>{iftracker}{nickname1}将类型从<b>{tracker1}</b>修改为<b>{tracker1}</b>{endtracker}<br/>{ifpriority}{nickname1}将优先度从<b>{priority1}</b>修改为<b>{priority1}</b>{endpriority}<br/>{ifmilestone}{nickname1}将里程碑从<b>{milestone1}</b>修改为<b>{milestone1}</b>{endmilestone}<br/>{iftag}{nickname1}将标签从<b>{tag1}</b>修改为<b>{tag1}</b>{endtag}<br/>{ifdoneratio}{nickname1}将完成度从<b>{doneratio1}</b>修改为<b>{doneratio1}</b>{enddoneratio}<br/>{ifbranch}{nickname1}将指定分支从<b>{branch1}</b>修改为<b>{branch1}</b>{endbranch}<br/>{ifstartdate}{nickname1}将开始日期从<b>{startdate1}</b>修改为<b>{startdate1}</b>{endstartdate}<br/>{ifduedate}{nickname1}将结束日期从<b>{duedate1}</b>修改为<b>{duedate1}</b>{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><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::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}')
|
||||
self.create(type: 'MessageTemplate::LoginIpTip', sys_notice: '您的账号{nickname}于{login_time)在非常用的IP地址{ip}登录,如非本人操作,请立即修改密码', notification_url: '')
|
||||
self.create(type: 'MessageTemplate::OrganizationJoined', sys_notice: '你已加入<b>{organization}</b>组织', notification_url: '{baseurl}/{login}')
|
||||
self.create(type: 'MessageTemplate::OrganizationLeft', sys_notice: '你已被移出<b>{organization}</b>组织', notification_url: '')
|
||||
self.create(type: 'MessageTemplate::OrganizationRole', sys_notice: '组织{organization}已把你的角色改为<b>{role}</b>', notification_url: '{baseurl}/{owner}')
|
||||
self.create(type: 'MessageTemplate::OrganizationRole', sys_notice: '组织{organization}已把你的角色改为<b>{role}</b>', notification_url: '{baseurl}/{login}')
|
||||
self.create(type: 'MessageTemplate::ProjectDeleted', sys_notice: '你关注的仓库{nickname}/{repository}已被删除', notification_url: '')
|
||||
self.create(type: 'MessageTemplate::ProjectFollowed', sys_notice: '<b>{nickname}</b>关注了你管理的仓库', notification_url: '{baseurl}/{login}')
|
||||
self.create(type: 'MessageTemplate::ProjectForked', sys_notice: '<b>{nickname1}</b>复刻了你管理的仓库{nickname1}/{repository1}到{nickname2}/{repository2}', notification_url: '{baseurl}/{owner}/{identifier}')
|
||||
|
@ -43,8 +43,8 @@ class MessageTemplate <ApplicationRecord
|
|||
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}/{repository1}的合并请求<b>{title}</b>中:{ifassigner}{nickname1}将审查成员从<b>{assigner1}</b>修改为<b>{assigner1}</b>{endassigner}<br/>{ifmilestone}{nickname1}将里程碑从<b>{milestone1}</b>修改为<b>{milestone1}</b>{endmilestone}<br/>{iftag}{nickname1}将标签从<b>{tag1}</b>修改为<b>{tag1}</b>{endtag}<br/>{ifpriority}{nickname1}将优先度从<b>{priority1}</b>修改为<b>{priority1}</b>{endpriority}<br/>', notification_url: '{baseurl}/{owner}/{identifier}/pulls/{id}/Messagecount')
|
||||
self.create(type: 'MessageTemplate::PullRequestClosed', sys_notice: '你提交的合并请求:{title]被拒绝', notification_url: '')
|
||||
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::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')
|
||||
end
|
||||
|
@ -52,4 +52,16 @@ class MessageTemplate <ApplicationRecord
|
|||
def self.sys_notice
|
||||
self.last&.sys_notice
|
||||
end
|
||||
|
||||
def self.notification_url
|
||||
self.last&.notification_url.gsub('{baseurl}', base_url)
|
||||
end
|
||||
|
||||
def self.base_url
|
||||
Rails.application.config_for(:configuration)['platform_url']
|
||||
end
|
||||
|
||||
def self.receivers_string(receivers)
|
||||
receivers.pluck(:id).join(",")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,11 @@
|
|||
|
||||
# 被关注提示
|
||||
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)
|
||||
rescue
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,16 @@
|
|||
|
||||
# 有新指派给我的易修
|
||||
class MessageTemplate::IssueAssigned < MessageTemplate
|
||||
|
||||
# MessageTemplate::IssueAssigned.get_message_content(User.where(login: 'yystopf'), User.last, Issue.last)
|
||||
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)
|
||||
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::IssueAssigned.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,16 @@
|
|||
|
||||
# 我负责的易修截止日期到达最后一天
|
||||
class MessageTemplate::IssueAssignerExpire < MessageTemplate
|
||||
|
||||
# MessageTemplate::IssueAssignerExpire.get_message_content(User.where(login: 'yystopf'), Issue.last)
|
||||
def self.get_message_content(receivers, issue)
|
||||
project = issue&.project
|
||||
owner = project&.owner
|
||||
content = sys_notice.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::IssueAssignerExpire.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,16 @@
|
|||
|
||||
# 在易修中@我
|
||||
class MessageTemplate::IssueAtme < MessageTemplate
|
||||
|
||||
# MessageTemplate::IssueAtme.get_message_content(User.where(login: 'yystopf'), User.last, Issue.last)
|
||||
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)
|
||||
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifer}', project&.identifier).gsub('{id}', issue&.id.to_s)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::IssueAtme.get_message_content [ERROR] #{e}")
|
||||
return 0, '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,117 @@
|
|||
|
||||
# 我创建或负责的易修状态变更
|
||||
class MessageTemplate::IssueChanged < MessageTemplate
|
||||
|
||||
# MessageTemplate::IssueChanged.get_message_content(User.where(login: 'yystopf'), User.last, Issue.last, {assigner: 'testforge2', milestone: '里程碑', tag: '标签', priority: '低', tracker: '支持', doneratio: '70', branch: 'master', startdate: Date.today, duedate: Date.today + 1.days})
|
||||
def self.get_message_content(receivers, operator, issue, change_params)
|
||||
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)
|
||||
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', issue&.id.to_s)
|
||||
# 易修负责人修改
|
||||
if change_params[:assigner].present?
|
||||
assigner = issue&.get_assign_user&.nickname || '未指派成员'
|
||||
content.sub!('{ifassigner}', '')
|
||||
content.sub!('{endassigner}', '')
|
||||
content.gsub!('{assigner1}', assigner)
|
||||
content.gsub!('{assigner2}', change_params[:assigner])
|
||||
else
|
||||
content.gsub!(/({ifassigner})(.*)({endassigner})/, '')
|
||||
end
|
||||
# 易修状态修改
|
||||
if change_params[:status].present?
|
||||
status = issue&.issue_status&.name
|
||||
content.sub!('{ifstatus}', '')
|
||||
content.sub!('{endstatus}', '')
|
||||
content.gsub!('{status1}', status)
|
||||
content.gsub!('{status2}', change_params[:status])
|
||||
else
|
||||
content.gsub!(/({ifstatus})(.*)({endstatus})/, '')
|
||||
end
|
||||
# 易修类型修改
|
||||
if change_params[:tracker].present?
|
||||
tracker = issue&.tracker&.name
|
||||
content.sub!('{iftracker}', '')
|
||||
content.sub!('{endtracker}', '')
|
||||
content.gsub!('{tracker1}', tracker)
|
||||
content.gsub!('{tracker2}', change_params[:tracker])
|
||||
else
|
||||
content.gsub!(/({iftracker})(.*)({endtracker})/, '')
|
||||
end
|
||||
# 合并请求里程碑修改
|
||||
if change_params[:milestone].present?
|
||||
milestone = issue&.version&.name || '未选择里程碑'
|
||||
content.sub!('{ifmilestone}', '')
|
||||
content.sub!('{endmilestone}', '')
|
||||
content.gsub!('{milestone1}', milestone)
|
||||
content.gsub!('{milestone2}', change_params[:milestone])
|
||||
else
|
||||
content.gsub!(/({ifmilestone})(.*)({endmilestone})/, '')
|
||||
end
|
||||
# 合并请求标签修改
|
||||
if change_params[:tag].present?
|
||||
tag = issue&.issue_tags.distinct.pluck(:name).join(",")
|
||||
tag = '未选择标签' if tag == ''
|
||||
content.sub!('{iftag}', '')
|
||||
content.sub!('{endtag}', '')
|
||||
content.gsub!('{tag1}', tag)
|
||||
content.gsub!('{tag2}', change_params[:tag])
|
||||
else
|
||||
content.gsub!(/({iftag})(.*)({endtag})()/, '')
|
||||
end
|
||||
# 合并请求优先级修改
|
||||
if change_params[:priority].present?
|
||||
priority = issue&.priority&.name
|
||||
content.sub!('{ifpriority}', '')
|
||||
content.sub!('{endpriority}', '')
|
||||
content.gsub!('{priority1}', priority)
|
||||
content.gsub!('{priority2}', change_params[:priority])
|
||||
else
|
||||
content.gsub!(/({ifpriority})(.*)({endpriority})/, '')
|
||||
end
|
||||
# 易修完成度修改
|
||||
if change_params[:doneratio].present?
|
||||
doneratio = issue&.done_ratio
|
||||
content.sub!('{ifdoneratio}', '')
|
||||
content.sub!('{enddoneratio}', '')
|
||||
content.gsub!('{doneratio1}', "#{doneratio}%")
|
||||
content.gsub!('{doneratio2}', "#{change_params[:doneratio]}%")
|
||||
else
|
||||
content.gsub!(/({ifdoneratio})(.*)({enddoneratio})/, '')
|
||||
end
|
||||
# 易修指定分支修改
|
||||
if change_params[:branch].present?
|
||||
branch = issue&.branch_name || '分支未指定'
|
||||
content.sub!('{ifbranch}', '')
|
||||
content.sub!('{endbranch}', '')
|
||||
content.gsub!('{branch1}', branch )
|
||||
content.gsub!('{branch2}', change_params[:branch])
|
||||
else
|
||||
content.gsub!(/({ifbranch})(.*)({endbranch})/, '')
|
||||
end
|
||||
# 易修开始日期修改
|
||||
if change_params[:startdate].present?
|
||||
startdate = issue&.start_date || "未选择开始日期"
|
||||
content.sub!('{ifstartdate}', '')
|
||||
content.sub!('{endstartdate}', '')
|
||||
content.gsub!('{startdate1}', startdate.to_s )
|
||||
content.gsub!('{startdate2}', change_params[:startdate].to_s)
|
||||
else
|
||||
content.gsub!(/({ifstartdate})(.*)({endstartdate})/, '')
|
||||
end
|
||||
# 易修结束日期修改
|
||||
if change_params[:duedate].present?
|
||||
duedate = issue&.due_date || '未选择结束日期'
|
||||
content.sub!('{ifduedate}', '')
|
||||
content.sub!('{endduedate}', '')
|
||||
content.gsub!('{duedate1}', duedate.to_s)
|
||||
content.gsub!('{duedate2}', change_params[:duedate].to_s)
|
||||
else
|
||||
content.gsub!(/({ifduedate})(.*)({endduedate})/, '')
|
||||
end
|
||||
return receivers_string(receivers), content, url
|
||||
# rescue => e
|
||||
# Rails.logger.info("MessageTemplate::IssueAssigned.get_message_content [ERROR] #{e}")
|
||||
# return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,16 @@
|
|||
|
||||
# 我创建的易修截止日期到达最后一天
|
||||
class MessageTemplate::IssueCreatorExpire < MessageTemplate
|
||||
|
||||
# MessageTemplate::IssueCreatorExpire.get_message_content(User.where(login: 'yystopf'), Issue.last)
|
||||
def self.get_message_content(receivers, issue)
|
||||
project = issue&.project
|
||||
owner = project&.owner
|
||||
content = sys_notice.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::IssueAssignerExpire.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,15 @@
|
|||
|
||||
# 我创建或负责的易修删除
|
||||
class MessageTemplate::IssueDeleted < MessageTemplate
|
||||
|
||||
# MessageTemplate::IssueDeleted.get_message_content(User.where(login: 'yystopf'), User.last, Issue.last)
|
||||
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)
|
||||
return receivers_string(receivers), content, notification_url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::IssueAtme.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我创建或负责的易修有新的评论
|
||||
# TODO 我创建或负责的易修有新的评论
|
||||
class MessageTemplate::IssueJournal < MessageTemplate
|
||||
|
||||
# MessageTemplate::IssueJournal.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::IssueJournal.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 登录异常提示
|
||||
# TODO 登录异常提示
|
||||
class MessageTemplate::LoginIpTip < MessageTemplate
|
||||
|
||||
# MessageTemplate::LoginIpTip.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::LoginIpTip.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,14 @@
|
|||
|
||||
# 账号被拉入组织
|
||||
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)
|
||||
url = notification_url.gsub('{login}', organization&.name)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::OrganizationJoined.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,14 @@
|
|||
|
||||
# 账号被移出组织
|
||||
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)
|
||||
url = notification_url.gsub('{login}', organization&.name)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::OrganizationLeft.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,14 @@
|
|||
|
||||
# 账号组织权限变更
|
||||
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)
|
||||
url = notification_url.gsub('{login}', organization&.login)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::OrganizationRole.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我关注的仓库被删除
|
||||
# TODO 我关注的仓库被删除
|
||||
class MessageTemplate::ProjectDeleted < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectDeleted.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectDeleted.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我管理的仓库被关注
|
||||
# TODO 我管理的仓库被关注
|
||||
class MessageTemplate::ProjectFollowed < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectFollowed.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectFollowed.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我管理的仓库被复刻
|
||||
# TODO 我管理的仓库被复刻
|
||||
class MessageTemplate::ProjectForked < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectForked.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectForked.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我管理/关注的仓库有新的易修
|
||||
# TODO 我管理/关注的仓库有新的易修
|
||||
class MessageTemplate::ProjectIssue < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectIssue.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectIssue.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,14 @@
|
|||
|
||||
# 账号被拉入项目
|
||||
class MessageTemplate::ProjectJoined < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectJoined.get_message_content(User.where(login: 'yystopf'), Project.last)
|
||||
def self.get_message_content(receivers, project)
|
||||
content = sys_notice.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::ProjectJoined.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,4 +14,13 @@
|
|||
# 账号被移出项目
|
||||
class MessageTemplate::ProjectLeft < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectLeft.get_message_content(User.where(login: 'yystopf'), Project.last)
|
||||
def self.get_message_content(receivers, project)
|
||||
content = sys_notice.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::ProjectLeft.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我管理的仓库有成员加入
|
||||
# TODO 我管理的仓库有成员加入
|
||||
class MessageTemplate::ProjectMemberJoined < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectMemberJoined.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectMemberJoined.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我管理的仓库有成员移出
|
||||
# TODO 我管理的仓库有成员移出
|
||||
class MessageTemplate::ProjectMemberLeft < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectMemberLeft.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectMemberLeft.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我管理的仓库有新的里程碑
|
||||
# TODO 我管理的仓库有新的里程碑
|
||||
class MessageTemplate::ProjectMilestone < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectMilestone.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectMilestone.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我管理的仓库被点赞
|
||||
# TODO 我管理的仓库被点赞
|
||||
class MessageTemplate::ProjectPraised < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectPraised.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectPraised.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我管理/关注的仓库有新的合并请求
|
||||
# TODO 我管理/关注的仓库有新的合并请求
|
||||
class MessageTemplate::ProjectPullRequest < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectPullRequest.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectPullRequest.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,14 @@
|
|||
|
||||
# 账号仓库权限变更
|
||||
class MessageTemplate::ProjectRole < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectRole.get_message_content(User.where(login: 'yystopf'), Project.last, '管理员')
|
||||
def self.get_message_content(receivers, project, role)
|
||||
content = sys_notice.gsub('{repository}', project&.name).gsub('{role}', role)
|
||||
url = notification_url.gsub('{owner}', project&.owner&.login).gsub('{identifier}', project&.identifier)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectRole.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,64 @@
|
|||
|
||||
# 我管理的仓库项目设置被更改
|
||||
class MessageTemplate::ProjectSettingChanged < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectSettingChanged.get_message_content(User.where(login: 'yystopf'), User.last, Project.last, {description: '测试修改项目简介', category: '大数据', language: 'Ruby', permission: '公有', navbar: '易修, 合并请求'})
|
||||
def self.get_message_content(receivers, operator, project, change_params)
|
||||
owner = project&.owner
|
||||
content = sys_notice.gsub('{nickname1}', operator&.nickname).gsub('{nickname2}', owner&.nickname).gsub('{repository}', project&.name)
|
||||
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier)
|
||||
# 项目名称更改
|
||||
if change_params[:name].present?
|
||||
content.sub!('{ifname}', '')
|
||||
content.sub!('{endname}', '')
|
||||
content.gsub!('{name}', change_params[:name])
|
||||
else
|
||||
content.gsub!(/({ifname})(.*)({endname})/, '')
|
||||
end
|
||||
# 项目简介更改
|
||||
if change_params[:description].present?
|
||||
content.sub!('{ifdescription}', '')
|
||||
content.sub!('{enddescription}', '')
|
||||
content.gsub!('{description}', change_params[:description])
|
||||
else
|
||||
content.gsub!(/({ifdescription})(.*)({enddescription})/, '')
|
||||
end
|
||||
# 项目类别更改
|
||||
if change_params[:category].present?
|
||||
content.sub!('{ifcategory}', '')
|
||||
content.sub!('{endcategory}', '')
|
||||
content.gsub!('{category}', change_params[:category])
|
||||
else
|
||||
content.gsub!(/({ifcategory})(.*)({endcategory})/, '')
|
||||
end
|
||||
# 项目语言更改
|
||||
if change_params[:language].present?
|
||||
content.sub!('{iflanguage}', '')
|
||||
content.sub!('{endlanguage}', '')
|
||||
content.gsub!('{language}', change_params[:language])
|
||||
else
|
||||
content.gsub!(/({iflanguage})(.*)({endlanguage})/, '')
|
||||
end
|
||||
# 项目公私有更改
|
||||
if change_params[:permission].present?
|
||||
content.sub!('{ifpermission}', '')
|
||||
content.sub!('{endpermission}', '')
|
||||
content.gsub!('{permission}', change_params[:permission])
|
||||
else
|
||||
content.gsub!(/({ifpermission})(.*)({endpermission})/, '')
|
||||
end
|
||||
# 项目导航更改
|
||||
if change_params[:navbar].present?
|
||||
content.sub!('{ifnavbar}', '')
|
||||
content.sub!('{endnavbar}', '')
|
||||
content.gsub!('{navbar}', change_params[: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 '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我关注的仓库被转移
|
||||
# TODO 我关注的仓库被转移
|
||||
class MessageTemplate::ProjectTransfer < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectTransfer.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectTransfer.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我关注的仓库有新的发行版
|
||||
# TODO 我关注的仓库有新的发行版
|
||||
class MessageTemplate::ProjectVersion < MessageTemplate
|
||||
|
||||
# MessageTemplate::ProjectVersion.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::ProjectVersion.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,16 @@
|
|||
|
||||
# 有新指派给我的合并请求
|
||||
class MessageTemplate::PullRequestAssigned < MessageTemplate
|
||||
|
||||
# MessageTemplate::PullRequestAssigned.get_message_content(User.where(login: 'yystopf'), User.last, PullRequest.last)
|
||||
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)
|
||||
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::PullRequestAssigned.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,4 +12,16 @@
|
|||
|
||||
# 在合并请求中@我
|
||||
class MessageTemplate::PullRequestAtme < MessageTemplate
|
||||
|
||||
# MessageTemplate::PullRequestAtme.get_message_content(User.where(login: 'yystopf'), User.last, PullRequest.last)
|
||||
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)
|
||||
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::PullRequestAtme.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
|
@ -13,4 +13,58 @@
|
|||
|
||||
# 我创建或负责的合并请求状态变更
|
||||
class MessageTemplate::PullRequestChanged < MessageTemplate
|
||||
|
||||
# MessageTemplate::PullRequestChanged.get_message_content(User.where(login: 'yystopf'), User.last, PullRequest.last, {assigner: 'testforge2', tag: '标签', priority: '低'})
|
||||
def self.get_message_content(receivers, operator, pull_request, change_params)
|
||||
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)
|
||||
url = notification_url.gsub('{owner}', owner&.login).gsub('{identifier}', project&.identifier).gsub('{id}', pull_request&.id.to_s)
|
||||
# 合并请求审查成员修改
|
||||
if change_params[:assigner].present?
|
||||
assigner = issue&.get_assign_user&.nickname || '未指派成员'
|
||||
content.sub!('{ifassigner}', '')
|
||||
content.sub!('{endassigner}', '')
|
||||
content.gsub!('{assigner1}', assigner)
|
||||
content.gsub!('{assigner2}', change_params[:assigner])
|
||||
else
|
||||
content.gsub!(/({ifassigner})(.*)({endassigner})/, '')
|
||||
end
|
||||
# 合并请求里程碑修改
|
||||
if change_params[:milestone].present?
|
||||
milestone = issue&.version&.name || '未选择里程碑'
|
||||
content.sub!('{ifmilestone}', '')
|
||||
content.sub!('{endmilestone}', '')
|
||||
content.gsub!('{milestone1}', milestone)
|
||||
content.gsub!('{milestone2}', change_params[:milestone])
|
||||
else
|
||||
content.gsub!(/({ifmilestone})(.*)({endmilestone})/, '')
|
||||
end
|
||||
# 合并请求标签修改
|
||||
if change_params[:tag].present?
|
||||
tag = issue&.issue_tags.distinct.pluck(:name).join(",")
|
||||
tag = '未选择标签' if tag == ''
|
||||
content.sub!('{iftag}', '')
|
||||
content.sub!('{endtag}', '')
|
||||
content.gsub!('{tag1}', tag)
|
||||
content.gsub!('{tag2}', change_params[:tag])
|
||||
else
|
||||
content.gsub!(/({iftag})(.*)({endtag})()/, '')
|
||||
end
|
||||
# 合并请求优先级修改
|
||||
if change_params[:priority].present?
|
||||
priority = issue&.priority&.name
|
||||
content.sub!('{ifpriority}', '')
|
||||
content.sub!('{endpriority}', '')
|
||||
content.gsub!('{priority1}', priority)
|
||||
content.gsub!('{priority2}', change_params[:priority])
|
||||
else
|
||||
content.gsub!(/({ifpriority})(.*)({endpriority})/, '')
|
||||
end
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::PullRequestChanged.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,16 @@
|
|||
|
||||
# 我创建或负责的合并请求被关闭
|
||||
class MessageTemplate::PullRequestClosed < MessageTemplate
|
||||
|
||||
# MessageTemplate::PullRequestClosed.get_message_content(User.where(login: 'yystopf'), User.last, PullRequest.last)
|
||||
def self.get_message_content(receivers, operator, pull_request)
|
||||
project = pull_request&.project
|
||||
owner = project&.owner
|
||||
content = sys_notice.gsub('{title}', pull_request&.title)
|
||||
url = notification_url
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::PullRequestClosed.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,14 @@
|
|||
# notification_url :string(255)
|
||||
#
|
||||
|
||||
# 我创建或负责的合并请求有新的评论
|
||||
# TODO 我创建或负责的合并请求有新的评论
|
||||
class MessageTemplate::PullRequestJournal < MessageTemplate
|
||||
|
||||
# MessageTemplate::PullRequestJournal.get_message_content(User.where(login: 'yystopf'))
|
||||
def self.get_message_content(receivers)
|
||||
return receivers_string(receivers), content, url
|
||||
rescue => e
|
||||
Rails.logger.info("MessageTemplate::PullRequestJournal.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,4 +13,16 @@
|
|||
|
||||
# 我创建或负责的合并请求被合并
|
||||
class MessageTemplate::PullRequestMerged < MessageTemplate
|
||||
|
||||
# MessageTemplate::PullRequestMerged.get_message_content(User.where(login: 'yystopf'), User.last, PullRequest.last)
|
||||
def self.get_message_content(receivers, operator, pull_request)
|
||||
project = pull_request&.project
|
||||
owner = project&.owner
|
||||
content = sys_notice.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::PullRequestMerged.get_message_content [ERROR] #{e}")
|
||||
return '', '', ''
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue