FIX: Don't allow other flag actions after notify_moderator has happened.

https://meta.discourse.org/t/receiving-sorry-an-error-has-occurred-during-flagging-step-of-discobot-tutorial/77233/5
This commit is contained in:
Guo Xiang Tan
2018-02-28 11:22:51 +08:00
parent e997cc7b77
commit 902c5d11cf
4 changed files with 43 additions and 16 deletions

View File

@@ -364,7 +364,7 @@ SQL
end
def is_flag?
!!PostActionType.flag_types[post_action_type_id]
!!PostActionType.notify_flag_types[post_action_type_id]
end
def is_private_message?
@@ -396,7 +396,7 @@ SQL
end
before_create do
post_action_type_ids = is_flag? ? PostActionType.flag_types_without_custom.values : post_action_type_id
post_action_type_ids = is_flag? ? PostActionType.notify_flag_types.values : post_action_type_id
raise AlreadyActed if PostAction.where(user_id: user_id)
.where(post_id: post_id)
.where(post_action_type_id: post_action_type_ids)