mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
fix and add some message feature
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user