Log the following information in email headers: * X-Danbooru-User: the user's name and ID. * X-Danbooru-IP: the user's IP. * X-Danbooru-Session: the users' session ID. * X-Danbooru-URL: the page that triggered the email. * X-Danbooru-Job-Id: the ID of the background job that sent the email. * X-Danbooru-Enqueued-At: when the email was queued as a background job. * X-Danbooru-Dmail: for Dmail notifications, the link to the Dmail. * X-Request-Id: the request ID of the HTTP request that triggered the email. Also make it so we log an event in the APM when we send an email.
41 lines
1.3 KiB
Ruby
41 lines
1.3 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
# The base class for all background jobs on Danbooru.
|
|
#
|
|
# @see https://guides.rubyonrails.org/active_job_basics.html
|
|
# @see https://github.com/bensheldon/good_job
|
|
class ApplicationJob < ActiveJob::Base
|
|
class JobTimeoutError < StandardError; end
|
|
|
|
queue_as :default
|
|
queue_with_priority 0
|
|
|
|
around_perform do |_job, block|
|
|
CurrentUser.scoped(User.system) do
|
|
ApplicationRecord.without_timeout do
|
|
Timeout.timeout(24.hours, JobTimeoutError) do
|
|
block.call
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
discard_on ActiveJob::DeserializationError do |_job, error|
|
|
DanbooruLogger.log(error)
|
|
end
|
|
|
|
# A list of all available job types. Used by the /jobs search form.
|
|
def self.job_classes
|
|
[
|
|
AmcheckDatabaseJob, BigqueryExportAllJob, DeleteFavoritesJob,
|
|
DmailInactiveApproversJob, IqdbAddPostJob, IqdbRemovePostJob,
|
|
PopulateSavedSearchJob, PruneApproversJob, PruneBansJob,
|
|
PruneBulkUpdateRequestsJob, PrunePostDisapprovalsJob, PrunePostsJob,
|
|
PruneRateLimitsJob, ProcessUploadJob, RegeneratePostCountsJob,
|
|
RegeneratePostJob, RetireTagRelationshipsJob, VacuumDatabaseJob,
|
|
DiscordNotificationJob, BigqueryExportJob, ProcessBulkUpdateRequestJob,
|
|
PruneJobsJob, MailDeliveryJob
|
|
]
|
|
end
|
|
end
|