mirror of
https://github.com/discourse/discourse.git
synced 2025-05-21 18:12:32 +08:00
FEATURE: New 'Reviewable' model to make reviewable items generic
Includes support for flags, reviewable users and queued posts, with REST API backwards compatibility. Co-Authored-By: romanrizzi <romanalejandro@gmail.com> Co-Authored-By: jjaffeux <j.jaffeux@gmail.com>
This commit is contained in:
@ -596,12 +596,9 @@ class ImportScripts::Base
|
||||
skipped += 1
|
||||
puts "Skipping bookmark for user id #{params[:user_id]} and post id #{params[:post_id]}"
|
||||
else
|
||||
begin
|
||||
PostAction.act(user, post, PostActionType.types[:bookmark])
|
||||
created += 1
|
||||
rescue PostAction::AlreadyActed
|
||||
skipped += 1
|
||||
end
|
||||
result = PostActionCreator.create(user, post, :bookmark)
|
||||
created += 1 if result.success?
|
||||
skipped += 1 if result.failed?
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -398,7 +398,7 @@ class ImportScripts::DiscuzX < ImportScripts::Base
|
||||
end
|
||||
elsif (m['status'] & 2) >> 1 == 1 # waiting for approve
|
||||
mapped[:post_create_action] = lambda do |action_post|
|
||||
PostAction.act(Discourse.system_user, action_post, 6, take_action: false)
|
||||
PostActionCreator.notify_user(Discourse.system_user, action_post)
|
||||
end
|
||||
end
|
||||
skip ? nil : mapped
|
||||
|
@ -184,8 +184,7 @@ class ImportScripts::JiveApi < ImportScripts::Base
|
||||
break if likes["error"]
|
||||
likes["list"].each do |like|
|
||||
next unless user_id = user_id_from_imported_user_id(like["id"])
|
||||
next if PostAction.exists?(user_id: user_id, post_id: post_id, post_action_type_id: PostActionType.types[:like])
|
||||
PostAction.act(User.find(user_id), Post.find(post_id), PostActionType.types[:like])
|
||||
PostActionCreator.like(User.find(user_id), Post.find(post_id))
|
||||
end
|
||||
|
||||
break if likes["list"].size < USER_COUNT || likes.dig("links", "next").blank?
|
||||
@ -287,8 +286,7 @@ class ImportScripts::JiveApi < ImportScripts::Base
|
||||
favorites["list"].each do |favorite|
|
||||
next unless user_id = user_id_from_imported_user_id(favorite["author"]["id"])
|
||||
next unless post_id = post_id_from_imported_post_id(favorite["favoriteObject"]["id"])
|
||||
next if PostAction.exists?(user_id: user_id, post_id: post_id, post_action_type_id: PostActionType.types[:bookmark])
|
||||
PostAction.act(User.find(user_id), Post.find(post_id), PostActionType.types[:bookmark])
|
||||
PostActionCreator.create(User.find(user_id), Post.find(post_id), :bookmark)
|
||||
end
|
||||
|
||||
break if favorites["list"].size < POST_COUNT || favorites.dig("links", "next").blank?
|
||||
|
@ -410,11 +410,7 @@ class ImportScripts::NodeBB < ImportScripts::Base
|
||||
post["upvoted_by"].each do |upvoter_id|
|
||||
user = User.new
|
||||
user.id = user_id_from_imported_user_id(upvoter_id) || Discourse::SYSTEM_USER_ID
|
||||
|
||||
begin
|
||||
PostAction.act(user, p, PostActionType.types[:like])
|
||||
rescue PostAction::AlreadyActed
|
||||
end
|
||||
PostActionCreator.like(user, p)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
@ -310,7 +310,7 @@ EOM
|
||||
post = Post.find_by(id: post_id_from_imported_post_id("thread-#{like['postid']}"))
|
||||
user = User.find_by(id: user_id_from_imported_user_id(like["userid"]))
|
||||
begin
|
||||
PostAction.act(user, post, 2) if user && post
|
||||
PostActionCreator.like(user, post) if user && post
|
||||
rescue => e
|
||||
puts "error acting on post #{e}"
|
||||
end
|
||||
|
@ -165,8 +165,6 @@ class ImportScripts::StackOverflow < ImportScripts::Base
|
||||
end
|
||||
end
|
||||
|
||||
LIKE ||= PostActionType.types[:like]
|
||||
|
||||
def import_likes
|
||||
puts "", "Importing post likes..."
|
||||
|
||||
@ -196,7 +194,7 @@ class ImportScripts::StackOverflow < ImportScripts::Base
|
||||
next unless post_id = post_id_from_imported_post_id(l["PostId"])
|
||||
next unless user = User.find_by(id: user_id)
|
||||
next unless post = Post.find_by(id: post_id)
|
||||
PostAction.act(user, post, LIKE) rescue nil
|
||||
PostActionCreator.like(user, post) rescue nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -229,7 +227,7 @@ class ImportScripts::StackOverflow < ImportScripts::Base
|
||||
next unless post_id = post_id_from_imported_post_id(l["PostCommentId"])
|
||||
next unless user = User.find_by(id: user_id)
|
||||
next unless post = Post.find_by(id: post_id)
|
||||
PostAction.act(user, post, LIKE) rescue nil
|
||||
PostActionCreator.like(user, post) rescue nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user