mirror of
https://github.com/discourse/discourse.git
synced 2024-12-13 02:43:38 +08:00
30990006a9
This reduces chances of errors where consumers of strings mutate inputs and reduces memory usage of the app. Test suite passes now, but there may be some stuff left, so we will run a few sites on a branch prior to merging
31 lines
785 B
Ruby
31 lines
785 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Skippable
|
|
extend ActiveSupport::Concern
|
|
|
|
def create_skipped_email_log(email_type:,
|
|
to_address:,
|
|
user_id:,
|
|
post_id:,
|
|
reason_type:)
|
|
|
|
attributes = {
|
|
email_type: email_type,
|
|
to_address: to_address,
|
|
user_id: user_id,
|
|
post_id: post_id,
|
|
reason_type: reason_type
|
|
}
|
|
|
|
if reason_type == SkippedEmailLog.reason_types[:exceeded_emails_limit]
|
|
exists = SkippedEmailLog.exists?({
|
|
created_at: (Time.zone.now.beginning_of_day..Time.zone.now.end_of_day)
|
|
}.merge!(attributes.except(:post_id)))
|
|
|
|
return if exists
|
|
end
|
|
|
|
SkippedEmailLog.create!(attributes)
|
|
end
|
|
end
|