FIX: Improve error messages if user cannot send PM emails (#12547)
This commit is contained in:
parent
21b4fef175
commit
52a5c7e438
|
@ -7,7 +7,7 @@
|
||||||
topicId=topicId
|
topicId=topicId
|
||||||
filterPlaceholder="composer.users_placeholder"
|
filterPlaceholder="composer.users_placeholder"
|
||||||
includeMessageableGroups=true
|
includeMessageableGroups=true
|
||||||
allowEmails=true
|
allowEmails=currentUser.can_send_private_email_messages
|
||||||
autoWrap=true
|
autoWrap=true
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -568,6 +568,7 @@ en:
|
||||||
cant_send_pm: "Sorry, you cannot send a personal message to that user."
|
cant_send_pm: "Sorry, you cannot send a personal message to that user."
|
||||||
no_user_selected: "You must select a valid user."
|
no_user_selected: "You must select a valid user."
|
||||||
reply_by_email_disabled: "Reply by email has been disabled."
|
reply_by_email_disabled: "Reply by email has been disabled."
|
||||||
|
send_to_email_disabled: "Sorry, you cannot send personal messages to email."
|
||||||
target_user_not_found: "One of the users you are sending this message to could not be found."
|
target_user_not_found: "One of the users you are sending this message to could not be found."
|
||||||
unable_to_update: "There was an error updating that topic."
|
unable_to_update: "There was an error updating that topic."
|
||||||
unable_to_tag: "There was an error tagging the topic."
|
unable_to_tag: "There was an error tagging the topic."
|
||||||
|
|
|
@ -193,7 +193,7 @@ class TopicCreator
|
||||||
end
|
end
|
||||||
|
|
||||||
if @opts[:target_emails].present? && !@guardian.can_send_private_messages_to_email? then
|
if @opts[:target_emails].present? && !@guardian.can_send_private_messages_to_email? then
|
||||||
rollback_with!(topic, :reply_by_email_disabled)
|
rollback_with!(topic, :send_to_email_disabled)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_users(topic, @opts[:target_usernames])
|
add_users(topic, @opts[:target_usernames])
|
||||||
|
|
|
@ -245,6 +245,17 @@ describe TopicCreator do
|
||||||
end.to raise_error(ActiveRecord::Rollback)
|
end.to raise_error(ActiveRecord::Rollback)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'to emails' do
|
||||||
|
it 'works for staff' do
|
||||||
|
expect(TopicCreator.create(admin, Guardian.new(admin), pm_valid_attrs.merge(target_emails: 'test@example.com'))).to be_valid
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'does not work for non-staff' do
|
||||||
|
user.update!(trust_level: TrustLevel[4])
|
||||||
|
expect { TopicCreator.create(user, Guardian.new(user), pm_valid_attrs.merge(target_emails: 'test@example.com')) }.to raise_error(ActiveRecord::Rollback)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'setting timestamps' do
|
context 'setting timestamps' do
|
||||||
|
|
Loading…
Reference in New Issue