mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 00:06:46 +08:00
FEATURE: new 'should_add_email_attachments' plugin modifier
That can be used by plugins to control whether email attachments should be sent. Internal ref - t/132149
This commit is contained in:
@ -360,6 +360,8 @@ module Email
|
|||||||
|
|
||||||
email_size = 0
|
email_size = 0
|
||||||
posts.each do |post|
|
posts.each do |post|
|
||||||
|
next unless DiscoursePluginRegistry.apply_modifier(:should_add_email_attachments, post)
|
||||||
|
|
||||||
post.uploads.each do |original_upload|
|
post.uploads.each do |original_upload|
|
||||||
optimized_1X = original_upload.optimized_images.first
|
optimized_1X = original_upload.optimized_images.first
|
||||||
|
|
||||||
|
@ -561,6 +561,20 @@ RSpec.describe Email::Sender do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "with a plugin" do
|
||||||
|
before { DiscoursePluginRegistry.clear_modifiers! }
|
||||||
|
after { DiscoursePluginRegistry.clear_modifiers! }
|
||||||
|
|
||||||
|
it "allows plugins to control whether attachments are included" do
|
||||||
|
SiteSetting.email_total_attachment_size_limit_kb = 10_000
|
||||||
|
|
||||||
|
Plugin::Instance.new.register_modifier(:should_add_email_attachments) { false }
|
||||||
|
|
||||||
|
Email::Sender.new(message, :valid_type).send
|
||||||
|
expect(message.attachments.size).to eq(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
it "adds only non-image uploads as attachments to the email" do
|
it "adds only non-image uploads as attachments to the email" do
|
||||||
SiteSetting.email_total_attachment_size_limit_kb = 10_000
|
SiteSetting.email_total_attachment_size_limit_kb = 10_000
|
||||||
Email::Sender.new(message, :valid_type).send
|
Email::Sender.new(message, :valid_type).send
|
||||||
|
Reference in New Issue
Block a user