mirror of
https://github.com/discourse/discourse.git
synced 2025-03-26 02:06:41 +08:00
Merge pull request #2497 from BenLubar/benlubar-import-id-on-imported-posts
set import_id on imported posts
This commit is contained in:
commit
4e1f76d3b9
@ -242,7 +242,7 @@ class ImportScripts::Base
|
|||||||
skipped += 1 # already imported this post
|
skipped += 1 # already imported this post
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
new_post = create_post(params)
|
new_post = create_post(params, import_id)
|
||||||
@posts[import_id] = new_post.id
|
@posts[import_id] = new_post.id
|
||||||
@topic_lookup[new_post.id] = {post_number: new_post.post_number, topic_id: new_post.topic_id}
|
@topic_lookup[new_post.id] = {post_number: new_post.post_number, topic_id: new_post.topic_id}
|
||||||
|
|
||||||
@ -263,9 +263,11 @@ class ImportScripts::Base
|
|||||||
return [created, skipped]
|
return [created, skipped]
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_post(opts)
|
def create_post(opts, import_id)
|
||||||
user = User.find(opts[:user_id])
|
user = User.find(opts[:user_id])
|
||||||
opts = opts.merge(skip_validations: true)
|
opts = opts.merge(skip_validations: true)
|
||||||
|
opts[:custom_fields] ||= {}
|
||||||
|
opts[:custom_fields]['import_id'] = import_id
|
||||||
|
|
||||||
if @bbcode_to_md
|
if @bbcode_to_md
|
||||||
opts[:raw] = opts[:raw].bbcode_to_md rescue opts[:raw]
|
opts[:raw] = opts[:raw].bbcode_to_md rescue opts[:raw]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user