Wrong rejection email is being sent

Sorry, I traced it.

Turns out that this particular user is @-mentioned in a post, and got an email, and so was compelled to reply.

But this code:

disallows the post and then sent over a very cryptic error message.

Perhaps this error message really needs to be changed to something like You don't have permission to post your reply in this topic.

EDIT: Something like this:

topic = Topic.unscoped.where(id: manager.args[:topic_id]).first

unless !topic.blank? && !topic.trashed?
  result = NewPostResult.new(:created_post, false)
  result.errors[:base] << I18n.t(:topic_not_found)
  return result
end

unless manager.user.guardian.can_create_post_on_topic?(topic)
  result = NewPostResult.new(:created_post, false)
  result.errors[:base] << I18n.t(:no_permission_to_post_in_topic)
  return result
end
5 个赞