Browse Source

fix: atme sender info

tags/v4.0.0
yystopf 4 years ago
parent
commit
222e5c1050
2 changed files with 16 additions and 7 deletions
  1. +2
    -2
      app/jobs/send_template_message_job.rb
  2. +14
    -5
      app/views/users/messages/_message.json.jbuilder

+ 2
- 2
app/jobs/send_template_message_job.rb View File

@@ -38,7 +38,7 @@ class SendTemplateMessageJob < ApplicationJob
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)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, issue_id: issue.id}, 2, operator_id)
when 'IssueChanged'
operator_id, issue_id, change_params = args[0], args[1], args[2]
operator = User.find_by_id(operator_id)
@@ -236,7 +236,7 @@ class SendTemplateMessageJob < ApplicationJob
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)
Notice::Write::CreateService.call(receivers_string, content, notification_url, source, {operator_id: operator.id, pull_request_id: pull_request.id}, 2, operator_id)
when 'PullRequestChanged'
operator_id, pull_request_id, change_params = args[0], args[1], args[2]
operator = User.find_by_id(operator_id)


+ 14
- 5
app/views/users/messages/_message.json.jbuilder View File

@@ -14,11 +14,20 @@ when 1
when 2
json.type "atme"
json.sender do
sender = User.find_by_id(message["sender"])
if sender.present?
json.partial! '/users/user_simple', locals: {user: sender}
else
json.nil
sender = $redis_cache.hgetall("v2-owner-common:#{message["sender"]}")
if sender.blank?
sender = User.find_by_id(message["sender"]) || User.find_by_id(JSON.parse(message['extra'])['operator_id'])
if sender.present?
json.partial! '/users/user_simple', locals: {user: sender}
else
json.nil
end
else
json.id message["sender"]
json.type sender['type']
json.name sender['name']
json.login sender['login']
json.image_url sender['avatar_url']
end
end
end

Loading…
Cancel
Save