fix: send message job need open notice menu
This commit is contained in:
parent
21af31f23c
commit
1b87a7a733
|
@ -111,8 +111,8 @@ class IssuesController < ApplicationController
|
|||
Issues::CreateForm.new({subject:issue_params[:subject]}).validate!
|
||||
@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)
|
||||
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('ProjectIssue', current_user.id, @issue&.id) if Site.has_notice_menu?
|
||||
if params[:attachment_ids].present?
|
||||
params[:attachment_ids].each do |id|
|
||||
attachment = Attachment.select(:id, :container_id, :container_type)&.find_by_id(id)
|
||||
|
@ -206,8 +206,8 @@ class IssuesController < ApplicationController
|
|||
Issues::UpdateForm.new({subject:issue_params[:subject]}).validate!
|
||||
if @issue.update_attributes(issue_params)
|
||||
if @issue&.pull_request.present?
|
||||
SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @issue&.pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value))
|
||||
SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @issue&.pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present?
|
||||
SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @issue&.pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value)) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @issue&.pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present? && Site.has_notice_menu?
|
||||
else
|
||||
previous_changes = @issue.previous_changes.slice(:status_id, :assigned_to_id, :tracker_id, :priority_id, :fixed_version_id, :done_ratio, :issue_tags_value, :branch_name)
|
||||
if @issue.previous_changes[:start_date].present?
|
||||
|
@ -216,6 +216,7 @@ class IssuesController < ApplicationController
|
|||
if @issue.previous_changes[:due_date].present?
|
||||
previous_changes.merge!(due_date: [@issue.previous_changes[:due_date][0].to_s, @issue.previous_changes[:due_date][1].to_s])
|
||||
end
|
||||
<<<<<<< HEAD
|
||||
if @issue.previous_changes[:status_id].present? && @issue.previous_changes[:status_id][1] == 5
|
||||
@issue.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE)
|
||||
end
|
||||
|
@ -224,6 +225,10 @@ class IssuesController < ApplicationController
|
|||
end
|
||||
SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, @issue&.id, previous_changes)
|
||||
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) if @issue.previous_changes[:assigned_to_id].present?
|
||||
=======
|
||||
SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, @issue&.id, previous_changes) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @issue&.id) if @issue.previous_changes[:assigned_to_id].present? && Site.has_notice_menu?
|
||||
>>>>>>> 356cafdd (fix: send message job need open notice menu)
|
||||
end
|
||||
if params[:status_id].to_i == 5 #任务由非关闭状态到关闭状态时
|
||||
@issue.issue_times.update_all(end_time: Time.now)
|
||||
|
@ -276,7 +281,7 @@ class IssuesController < ApplicationController
|
|||
status_id = @issue.status_id
|
||||
token = @issue.token
|
||||
login = @issue.user.try(:login)
|
||||
SendTemplateMessageJob.perform_later('IssueDeleted', current_user.id, @issue&.subject, @issue.assigned_to_id, @issue.author_id)
|
||||
SendTemplateMessageJob.perform_later('IssueDeleted', current_user.id, @issue&.subject, @issue.assigned_to_id, @issue.author_id) if Site.has_notice_menu?
|
||||
if @issue.destroy
|
||||
if issue_type == "2" && status_id != 5
|
||||
post_to_chain("add", token, login)
|
||||
|
@ -299,7 +304,7 @@ class IssuesController < ApplicationController
|
|||
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)
|
||||
SendTemplateMessageJob.perform_later('IssueDeleted', current_user.id, i&.subject, i.assigned_to_id, i.author_id) if Site.has_notice_menu?
|
||||
end
|
||||
if issues.destroy_all
|
||||
normal_status(0, "删除成功")
|
||||
|
@ -344,6 +349,7 @@ class IssuesController < ApplicationController
|
|||
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
|
||||
<<<<<<< HEAD
|
||||
if i.previous_changes[:status_id].present? && i.previous_changes[:status_id][1] == 5
|
||||
i.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: ProjectTrend::CLOSE)
|
||||
end
|
||||
|
@ -352,6 +358,10 @@ class IssuesController < ApplicationController
|
|||
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?
|
||||
=======
|
||||
SendTemplateMessageJob.perform_later('IssueChanged', current_user.id, i&.id, previous_changes) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, i&.id) if i.previous_changes[:assigned_to_id].present? && Site.has_notice_menu?
|
||||
>>>>>>> 356cafdd (fix: send message job need open notice menu)
|
||||
end
|
||||
normal_status(0, "批量更新成功")
|
||||
else
|
||||
|
@ -366,8 +376,8 @@ class IssuesController < ApplicationController
|
|||
@new_issue = @issue.dup
|
||||
@new_issue.author_id = current_user.id
|
||||
if @new_issue.save
|
||||
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @new_issue&.id)
|
||||
SendTemplateMessageJob.perform_later('ProjectIssue', current_user.id, @new_issue&.id)
|
||||
SendTemplateMessageJob.perform_later('IssueAssigned', current_user.id, @new_issue&.id) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('ProjectIssue', current_user.id, @new_issue&.id) if Site.has_notice_menu?
|
||||
issue_tags = @issue.issue_tags.pluck(:id)
|
||||
if issue_tags.present?
|
||||
issue_tags.each do |tag|
|
||||
|
|
|
@ -9,8 +9,8 @@ class MembersController < ApplicationController
|
|||
|
||||
def create
|
||||
interactor = Projects::AddMemberInteractor.call(@project.owner, @project, @user)
|
||||
SendTemplateMessageJob.perform_later('ProjectJoined', current_user.id, @user.id, @project.id)
|
||||
SendTemplateMessageJob.perform_later('ProjectMemberJoined', current_user.id, @user.id, @project.id)
|
||||
SendTemplateMessageJob.perform_later('ProjectJoined', current_user.id, @user.id, @project.id) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('ProjectMemberJoined', current_user.id, @user.id, @project.id) if Site.has_notice_menu?
|
||||
render_response(interactor)
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
|
@ -30,8 +30,8 @@ class MembersController < ApplicationController
|
|||
|
||||
def remove
|
||||
interactor = Projects::DeleteMemberInteractor.call(@project.owner, @project, @user)
|
||||
SendTemplateMessageJob.perform_later('ProjectLeft', current_user.id, @user.id, @project.id)
|
||||
SendTemplateMessageJob.perform_later('ProjectMemberLeft', current_user.id, @user.id, @project.id)
|
||||
SendTemplateMessageJob.perform_later('ProjectLeft', current_user.id, @user.id, @project.id) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('ProjectMemberLeft', current_user.id, @user.id, @project.id) if Site.has_notice_menu?
|
||||
render_response(interactor)
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
|
@ -40,7 +40,7 @@ class MembersController < ApplicationController
|
|||
|
||||
def change_role
|
||||
interactor = Projects::ChangeMemberRoleInteractor.call(@project.owner, @project, @user, params[:role])
|
||||
SendTemplateMessageJob.perform_later('ProjectRole', current_user.id, @user.id, @project.id, message_role_name)
|
||||
SendTemplateMessageJob.perform_later('ProjectRole', current_user.id, @user.id, @project.id, message_role_name) if Site.has_notice_menu?
|
||||
render_response(interactor)
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
|
|
|
@ -18,7 +18,7 @@ class Organizations::TeamUsersController < Organizations::BaseController
|
|||
ActiveRecord::Base.transaction do
|
||||
@team_user = TeamUser.build(@organization.id, @operate_user.id, @team.id)
|
||||
@organization_user = OrganizationUser.build(@organization.id, @operate_user.id)
|
||||
SendTemplateMessageJob.perform_later('OrganizationRole', @operate_user.id, @organization.id, @team.authorize_name)
|
||||
SendTemplateMessageJob.perform_later('OrganizationRole', @operate_user.id, @organization.id, @team.authorize_name) if Site.has_notice_menu?
|
||||
Gitea::Organization::TeamUser::CreateService.call(@organization.gitea_token, @team.gtid, @operate_user.login)
|
||||
end
|
||||
rescue Exception => e
|
||||
|
|
|
@ -7,7 +7,7 @@ class Projects::ProjectUnitsController < Projects::BaseController
|
|||
if current_user.admin? || @project.manager?(current_user)
|
||||
ActiveRecord::Base.transaction do
|
||||
before_units, after_units = ProjectUnit.update_by_unit_types!(@project, unit_types)
|
||||
SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, {navbar: true}) unless before_units.eql?(after_units)
|
||||
SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, {navbar: true}) unless before_units.eql?(after_units) if Site.has_notice_menu?
|
||||
render_ok
|
||||
end
|
||||
else
|
||||
|
|
|
@ -145,7 +145,7 @@ class ProjectsController < ApplicationController
|
|||
gitea_repo = Gitea::Repository::UpdateService.call(@owner, @project&.repository&.identifier, gitea_params)
|
||||
@project.repository.update_attributes({hidden: gitea_repo["private"], identifier: gitea_repo["name"]})
|
||||
end
|
||||
SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, @project.previous_changes.slice(:name, :description, :project_category_id, :project_language_id, :is_public))
|
||||
SendTemplateMessageJob.perform_later('ProjectSettingChanged', current_user.id, @project&.id, @project.previous_changes.slice(:name, :description, :project_category_id, :project_language_id, :is_public)) if Site.has_notice_menu?
|
||||
end
|
||||
rescue Exception => e
|
||||
uid_logger_error(e.message)
|
||||
|
|
|
@ -59,8 +59,8 @@ class PullRequestsController < ApplicationController
|
|||
@pull_request, @gitea_pull_request = PullRequests::CreateService.call(current_user, @owner, @project, params)
|
||||
if @gitea_pull_request[:status] == :success
|
||||
@pull_request.bind_gitea_pull_request!(@gitea_pull_request[:body]["number"], @gitea_pull_request[:body]["id"])
|
||||
SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id)
|
||||
SendTemplateMessageJob.perform_later('ProjectPullRequest', current_user.id, @pull_request&.id)
|
||||
SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('ProjectPullRequest', current_user.id, @pull_request&.id) if Site.has_notice_menu?
|
||||
else
|
||||
render_error("create pull request error: #{@gitea_pull_request[:status]}")
|
||||
raise ActiveRecord::Rollback
|
||||
|
@ -118,8 +118,8 @@ class PullRequestsController < ApplicationController
|
|||
normal_status(-1, e.message)
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value))
|
||||
SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present?
|
||||
SendTemplateMessageJob.perform_later('PullRequestChanged', current_user.id, @pull_request&.id, @issue.previous_changes.slice(:assigned_to_id, :priority_id, :fixed_version_id, :issue_tags_value)) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('PullRequestAssigned', current_user.id, @pull_request&.id ) if @issue.previous_changes[:assigned_to_id].present? && Site.has_notice_menu?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -131,7 +131,7 @@ class PullRequestsController < ApplicationController
|
|||
colsed = PullRequests::CloseService.call(@owner, @repository, @pull_request, current_user)
|
||||
if colsed === true
|
||||
@pull_request.project_trends.create!(user: current_user, project: @project,action_type: ProjectTrend::CLOSE)
|
||||
SendTemplateMessageJob.perform_later('PullRequestClosed', current_user.id, @pull_request.id)
|
||||
SendTemplateMessageJob.perform_later('PullRequestClosed', current_user.id, @pull_request.id) if Site.has_notice_menu?
|
||||
normal_status(1, "已拒绝")
|
||||
else
|
||||
normal_status(-1, '合并失败')
|
||||
|
@ -175,7 +175,7 @@ class PullRequestsController < ApplicationController
|
|||
# @pull_request.project_trend_status!
|
||||
@pull_request.project_trends.create!(user: current_user, project: @project,action_type: ProjectTrend::MERGE)
|
||||
@issue&.custom_journal_detail("merge", "", "该合并请求已被合并", current_user&.id)
|
||||
SendTemplateMessageJob.perform_later('PullRequestMerged', current_user.id, @pull_request.id)
|
||||
SendTemplateMessageJob.perform_later('PullRequestMerged', current_user.id, @pull_request.id) if Site.has_notice_menu?
|
||||
normal_status(1, "合并成功")
|
||||
else
|
||||
normal_status(-1, result.message)
|
||||
|
|
|
@ -18,16 +18,16 @@ class Users::MessagesController < Users::BaseController
|
|||
Notice::Write::CreateAtmeForm.new(atme_params).validate!
|
||||
case atme_params[:atmeable_type]
|
||||
when 'Issue'
|
||||
SendTemplateMessageJob.perform_now('IssueAtme', @receivers, current_user.id, atme_params[:atmeable_id])
|
||||
SendTemplateMessageJob.perform_now('IssueAtme', @receivers, current_user.id, atme_params[:atmeable_id]) if Site.has_notice_menu?
|
||||
when 'PullRequest'
|
||||
SendTemplateMessageJob.perform_now('PullRequestAtme', @receivers, current_user.id, atme_params[:atmeable_id])
|
||||
SendTemplateMessageJob.perform_now('PullRequestAtme', @receivers, current_user.id, atme_params[:atmeable_id]) if Site.has_notice_menu?
|
||||
when 'Journal'
|
||||
journal = Journal.find_by_id(atme_params[:atmeable_id])
|
||||
if journal.present?
|
||||
if journal&.issue&.pull_request.present?
|
||||
SendTemplateMessageJob.perform_now('PullRequestAtme', @receivers, current_user.id, atme_params[:atmeable_id])
|
||||
SendTemplateMessageJob.perform_now('PullRequestAtme', @receivers, current_user.id, atme_params[:atmeable_id]) if Site.has_notice_menu?
|
||||
else
|
||||
SendTemplateMessageJob.perform_now('IssueAtme', @receivers, current_user.id, atme_params[:atmeable_id])
|
||||
SendTemplateMessageJob.perform_now('IssueAtme', @receivers, current_user.id, atme_params[:atmeable_id]) if Site.has_notice_menu?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -3,8 +3,8 @@ class DelayExpiredIssueJob < ApplicationJob
|
|||
|
||||
def perform
|
||||
Issue.where(due_date: Date.today + 1.days).find_each do |issue|
|
||||
SendTemplateMessageJob.perform_later('IssueAssignerExpire', issue.id)
|
||||
SendTemplateMessageJob.perform_later('IssueCreatorExpire', issue.id)
|
||||
SendTemplateMessageJob.perform_later('IssueAssignerExpire', issue.id) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('IssueCreatorExpire', issue.id) if Site.has_notice_menu?
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -36,10 +36,10 @@ class OrganizationUser < ApplicationRecord
|
|||
end
|
||||
|
||||
def send_create_message_to_notice_system
|
||||
SendTemplateMessageJob.perform_later('OrganizationJoined', self.user_id, self.organization_id)
|
||||
SendTemplateMessageJob.perform_later('OrganizationJoined', self.user_id, self.organization_id) if Site.has_notice_menu?
|
||||
end
|
||||
|
||||
def send_destroy_message_to_notice_system
|
||||
SendTemplateMessageJob.perform_later('OrganizationLeft', self.user_id, self.organization_id)
|
||||
SendTemplateMessageJob.perform_later('OrganizationLeft', self.user_id, self.organization_id) if Site.has_notice_menu?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -26,6 +26,10 @@ class Site < ApplicationRecord
|
|||
set_common_menu!
|
||||
end
|
||||
|
||||
def self.has_notice_menu?
|
||||
self.common.where(key: 'notice').present?
|
||||
end
|
||||
|
||||
private
|
||||
def self.set_add_menu!
|
||||
adds= [
|
||||
|
|
|
@ -37,7 +37,7 @@ class Watcher < ApplicationRecord
|
|||
end
|
||||
|
||||
def send_create_message_to_notice_system
|
||||
SendTemplateMessageJob.perform_later('FollowTip', self.id) if self.watchable.is_a?(User)
|
||||
SendTemplateMessageJob.perform_later('FollowTip', self.id) if self.watchable.is_a?(User) if Site.has_notice_menu?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -53,8 +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)
|
||||
SendTemplateMessageJob.perform_later('ProjectJoined', @user.id, @applied_project.user_id, @project.id) if Site.has_notice_menu?
|
||||
SendTemplateMessageJob.perform_later('ProjectMemberJoined', @user.id, @applied_project.user_id, @project.id) if Site.has_notice_menu?
|
||||
end
|
||||
|
||||
def send_apply_message
|
||||
|
|
Loading…
Reference in New Issue