mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Add SMTP group ID to EmailLog (#13381)
Adds a new `smtp_group_id` column to `EmailLog` which is filled in if the mail `from_address` matches a group's `email_username`. This is for easier debugging, so we know which emails have been sent via group SMTP.
This commit is contained in:
@@ -337,6 +337,36 @@ describe Email::Sender do
|
||||
expect(email_log.to_address).to eq('eviltrout@test.domain')
|
||||
expect(email_log.user_id).to be_blank
|
||||
end
|
||||
|
||||
context 'when the email is sent using group SMTP credentials' do
|
||||
let(:reply) { Fabricate(:post, topic: post.topic, reply_to_user: post.user, reply_to_post_number: post.post_number) }
|
||||
let(:notification) { Fabricate(:posted_notification, user: post.user, post: reply) }
|
||||
let(:message) do
|
||||
UserNotifications.user_private_message(
|
||||
post.user,
|
||||
post: reply,
|
||||
notification_type: notification.notification_type,
|
||||
notification_data_hash: notification.data_hash
|
||||
)
|
||||
end
|
||||
let(:group) { Fabricate(:smtp_group) }
|
||||
|
||||
before do
|
||||
SiteSetting.enable_smtp = true
|
||||
end
|
||||
|
||||
it 'adds the group id to the email log' do
|
||||
TopicAllowedGroup.create(topic: post.topic, group: group)
|
||||
|
||||
email_sender.send
|
||||
|
||||
expect(email_log).to be_present
|
||||
expect(email_log.email_type).to eq('valid_type')
|
||||
expect(email_log.to_address).to eq(post.user.email)
|
||||
expect(email_log.user_id).to be_blank
|
||||
expect(email_log.smtp_group_id).to eq(group.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "email log with a post id and topic id" do
|
||||
|
||||
Reference in New Issue
Block a user