UX: better rejection message when reply via email is too short

This commit is contained in:
OsamaSayegh
2018-08-02 22:43:53 +03:00
parent 3dbaaf0d74
commit a157dfd418
5 changed files with 69 additions and 2 deletions

View File

@ -31,6 +31,7 @@ module Email
class TopicNotFoundError < ProcessingError; end
class TopicClosedError < ProcessingError; end
class InvalidPost < ProcessingError; end
class TooShortPost < ProcessingError; end
class InvalidPostAction < ProcessingError; end
class UnsubscribeNotAllowed < ProcessingError; end
class EmailNotAllowed < ProcessingError; end
@ -932,7 +933,14 @@ module Email
user = options.delete(:user)
result = NewPostManager.new(user, options).perform
raise InvalidPost, result.errors.full_messages.join("\n") if result.errors.any?
errors = result.errors.full_messages
if errors.any? do |message|
message.include?(I18n.t("activerecord.attributes.post.raw").strip) &&
message.include?(I18n.t("errors.messages.too_short", count: SiteSetting.min_post_length).strip)
end
raise TooShortPost
end
raise InvalidPost, errors.join("\n") if result.errors.any?
if result.post
@incoming_email.update_columns(topic_id: result.post.topic_id, post_id: result.post.id)