mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-03 13:46:26 +08:00
22 lines
739 B
Ruby
22 lines
739 B
Ruby
# frozen_string_literal: true
|
|
|
|
Fabricator(:reaction_user, class_name: "DiscourseReactions::ReactionUser") do
|
|
transient :skip_post_action
|
|
reaction { |attrs| attrs[:reaction] }
|
|
user { |attrs| attrs[:user] || Fabricate(:user) }
|
|
post { |attrs| attrs[:post] || Fabricate(:post) }
|
|
|
|
after_create do |reaction_user, transients|
|
|
if DiscourseReactions::Reaction.reactions_counting_as_like.include?(
|
|
reaction_user.reaction.reaction_value,
|
|
) && !transients[:skip_post_action]
|
|
Fabricate(
|
|
:post_action,
|
|
user: reaction_user.user,
|
|
post: reaction_user.post,
|
|
post_action_type_id: PostActionType::LIKE_POST_ACTION_ID,
|
|
created_at: reaction_user.created_at,
|
|
)
|
|
end
|
|
end
|
|
end
|