mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 19:00:32 -06:00
UX: better error message when inviting user to a topic
This commit is contained in:
parent
3d5dfab54e
commit
41a0f9b7fd
@ -582,6 +582,8 @@ class Topic < ActiveRecord::Base
|
|||||||
if private_message?
|
if private_message?
|
||||||
# If the user exists, add them to the message.
|
# If the user exists, add them to the message.
|
||||||
user = User.find_by_username_or_email(username_or_email)
|
user = User.find_by_username_or_email(username_or_email)
|
||||||
|
raise StandardError.new I18n.t("topic_invite_user_exists") if user.present? && topic_allowed_users.where(user_id: user.id).exists?
|
||||||
|
|
||||||
if user && topic_allowed_users.create!(user_id: user.id)
|
if user && topic_allowed_users.create!(user_id: user.id)
|
||||||
# Create a small action message
|
# Create a small action message
|
||||||
add_small_action(invited_by, "invited_user", user.username)
|
add_small_action(invited_by, "invited_user", user.username)
|
||||||
@ -605,6 +607,8 @@ class Topic < ActiveRecord::Base
|
|||||||
else
|
else
|
||||||
# invite existing member to a topic
|
# invite existing member to a topic
|
||||||
user = User.find_by_username(username_or_email)
|
user = User.find_by_username(username_or_email)
|
||||||
|
raise StandardError.new I18n.t("topic_invite_user_exists") if user.present? && topic_allowed_users.where(user_id: user.id).exists?
|
||||||
|
|
||||||
if user && topic_allowed_users.create!(user_id: user.id)
|
if user && topic_allowed_users.create!(user_id: user.id)
|
||||||
# rate limit topic invite
|
# rate limit topic invite
|
||||||
RateLimiter.new(invited_by, "topic-invitations-per-day", SiteSetting.max_topic_invitations_per_day, 1.day.to_i).performed!
|
RateLimiter.new(invited_by, "topic-invitations-per-day", SiteSetting.max_topic_invitations_per_day, 1.day.to_i).performed!
|
||||||
|
@ -138,6 +138,8 @@ en:
|
|||||||
reading_time: "Reading time"
|
reading_time: "Reading time"
|
||||||
likes: "Likes"
|
likes: "Likes"
|
||||||
|
|
||||||
|
topic_invite_user_exists: "Sorry, that user has already been invited. You may only invite a user to a topic once."
|
||||||
|
|
||||||
too_many_replies:
|
too_many_replies:
|
||||||
one: "We're sorry, but new users are temporarily limited to 1 reply in the same topic."
|
one: "We're sorry, but new users are temporarily limited to 1 reply in the same topic."
|
||||||
other: "We're sorry, but new users are temporarily limited to %{count} replies in the same topic."
|
other: "We're sorry, but new users are temporarily limited to %{count} replies in the same topic."
|
||||||
|
Loading…
Reference in New Issue
Block a user