mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 13:31:18 +08:00
DEV: Enable unless
cops
We discussed the use of `unless` internally and decided to enforce available rules from rubocop to restrict its most problematic uses.
This commit is contained in:

committed by
Loïc Guitaut

parent
87de3c2319
commit
f7c57fbc19
@ -335,7 +335,15 @@ class ImportScripts::XenForo < ImportScripts::Base
|
||||
created_at: Time.zone.at(post["message_date"].to_i),
|
||||
import_mode: true,
|
||||
}
|
||||
unless post["topic_id"] > 0
|
||||
if post["topic_id"] <= 0
|
||||
topic_id = post["topic_id"]
|
||||
if t = topic_lookup_from_imported_post_id("pm_#{topic_id}")
|
||||
msg[:topic_id] = t[:topic_id]
|
||||
else
|
||||
puts "Topic ID #{topic_id} not found, skipping post #{post["message_id"]} from #{post["user_id"]}"
|
||||
next
|
||||
end
|
||||
else
|
||||
msg[:title] = post["title"]
|
||||
msg[:archetype] = Archetype.private_message
|
||||
to_user_array = PHP.unserialize(post["recipients"])
|
||||
@ -344,14 +352,6 @@ class ImportScripts::XenForo < ImportScripts::Base
|
||||
usernames = User.where(id: [discourse_user_ids]).pluck(:username)
|
||||
msg[:target_usernames] = usernames.join(",")
|
||||
end
|
||||
else
|
||||
topic_id = post["topic_id"]
|
||||
if t = topic_lookup_from_imported_post_id("pm_#{topic_id}")
|
||||
msg[:topic_id] = t[:topic_id]
|
||||
else
|
||||
puts "Topic ID #{topic_id} not found, skipping post #{post["message_id"]} from #{post["user_id"]}"
|
||||
next
|
||||
end
|
||||
end
|
||||
msg
|
||||
else
|
||||
|
Reference in New Issue
Block a user