mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 17:46:05 -05:00
link email logs to the post that generate the email notification when available
This commit is contained in:
parent
81c6fb318b
commit
bf96025507
5 changed files with 31 additions and 8 deletions
|
@ -30,7 +30,13 @@
|
|||
</td>
|
||||
<td><a href='mailto:{{unbound l.to_address}}'>{{l.to_address}}</a></td>
|
||||
<td>{{l.email_type}}</td>
|
||||
<td>{{l.reply_key}}</td>
|
||||
<td>
|
||||
{{#if l.post_url}}
|
||||
<a href="{{l.post_url}}">{{l.reply_key}}</a>
|
||||
{{else}}
|
||||
{{l.reply_key}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr><td colspan="5">{{i18n 'admin.email.logs.none'}}</td></tr>
|
||||
|
|
|
@ -30,7 +30,13 @@
|
|||
</td>
|
||||
<td><a href='mailto:{{unbound l.to_address}}'>{{l.to_address}}</a></td>
|
||||
<td>{{l.email_type}}</td>
|
||||
<td>{{l.skipped_reason}}</td>
|
||||
<td>
|
||||
{{#if l.post_url}}
|
||||
<a href="{{l.post_url}}">{{l.skipped_reason}}</a>
|
||||
{{else}}
|
||||
{{l.skipped_reason}}
|
||||
{{/if}}
|
||||
</td>
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr><td colspan="5">{{i18n 'admin.email.logs.none'}}</td></tr>
|
||||
|
|
|
@ -67,7 +67,7 @@ class Admin::EmailController < Admin::AdminController
|
|||
private
|
||||
|
||||
def filter_email_logs(email_logs, params)
|
||||
email_logs = email_logs.includes(:user)
|
||||
email_logs = email_logs.includes(:user, { post: :topic })
|
||||
.references(:user)
|
||||
.order(created_at: :desc)
|
||||
.offset(params[:offset] || 0)
|
||||
|
|
|
@ -15,7 +15,7 @@ module Jobs
|
|||
user = User.find_by(id: args[:user_id])
|
||||
to_address = args[:to_address].presence || user.try(:email).presence || "no_email_found"
|
||||
|
||||
set_skip_context(type, args[:user_id], to_address)
|
||||
set_skip_context(type, args[:user_id], to_address, args[:post_id])
|
||||
|
||||
return skip(I18n.t("email_log.no_user", user_id: args[:user_id])) unless user
|
||||
|
||||
|
@ -44,8 +44,8 @@ module Jobs
|
|||
end
|
||||
end
|
||||
|
||||
def set_skip_context(type, user_id, to_address)
|
||||
@skip_context = { type: type, user_id: user_id, to_address: to_address }
|
||||
def set_skip_context(type, user_id, to_address, post_id)
|
||||
@skip_context = { type: type, user_id: user_id, to_address: to_address, post_id: post_id }
|
||||
end
|
||||
|
||||
NOTIFICATIONS_SENT_BY_MAILING_LIST ||= Set.new %w{posted replied mentioned group_mentioned quoted}
|
||||
|
@ -54,7 +54,7 @@ module Jobs
|
|||
notification_type=nil, notification_data_hash=nil,
|
||||
email_token=nil, to_address=nil)
|
||||
|
||||
set_skip_context(type, user.id, to_address || user.email)
|
||||
set_skip_context(type, user.id, to_address || user.email, post.try(:id))
|
||||
|
||||
return skip_message(I18n.t("email_log.anonymous_user")) if user.anonymous?
|
||||
return skip_message(I18n.t("email_log.suspended_not_pm")) if user.suspended? && type != :user_private_message
|
||||
|
@ -142,6 +142,7 @@ module Jobs
|
|||
email_type: @skip_context[:type],
|
||||
to_address: @skip_context[:to_address],
|
||||
user_id: @skip_context[:user_id],
|
||||
post_id: @skip_context[:post_id],
|
||||
skipped: true,
|
||||
skipped_reason: "[UserEmail] #{reason}",
|
||||
)
|
||||
|
|
|
@ -7,11 +7,21 @@ class EmailLogSerializer < ApplicationSerializer
|
|||
:user_id,
|
||||
:created_at,
|
||||
:skipped,
|
||||
:skipped_reason
|
||||
:skipped_reason,
|
||||
:post_url
|
||||
|
||||
has_one :user, serializer: BasicUserSerializer, embed: :objects
|
||||
|
||||
def include_skipped_reason?
|
||||
object.skipped
|
||||
end
|
||||
|
||||
def post_url
|
||||
object.post.url
|
||||
end
|
||||
|
||||
def include_post_url?
|
||||
object.post.present?
|
||||
end
|
||||
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue