mirror of
https://github.com/discourse/discourse.git
synced 2025-02-24 23:14:10 +08:00

This commit contains a couple of improvements for this rake task. * We no longer limit the uploads to only ones with Post upload references, it doesn't matter what the secure uploads are linked to, they should all be un-secured * We now only get distinct uploads from the initial query, multiple upload references on the same upload caused double ups and confusing counts for the task * We now also disable the secure_uploads_pm_only site setting at the same time
39 lines
1.0 KiB
Ruby
39 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
Fabricator(:draft) do
|
|
user { Fabricate(:user) }
|
|
transient :category_id
|
|
transient :topic
|
|
transient :post
|
|
transient :archetype
|
|
transient :tags
|
|
draft_key do |transients|
|
|
topic = transients[:topic] || transients[:post]&.topic
|
|
|
|
return "#{Draft::EXISTING_TOPIC}_#{topic.id}" if topic
|
|
|
|
if transients[:archetype] == "regular"
|
|
Draft::NEW_TOPIC
|
|
else
|
|
Draft::NEW_PRIVATE_MESSAGE
|
|
end
|
|
end
|
|
owner { SecureRandom.hex(10) }
|
|
revisions { sequence(:revisions) { |n| n } }
|
|
sequence { sequence(:sequence) { |n| n } }
|
|
data do |transients|
|
|
topic = transients[:topic] || transients[:post]&.topic
|
|
|
|
{
|
|
reply: "This is my really long draft",
|
|
action: topic.present? ? "reply" : "createTopic",
|
|
categoryId: transients[:category_id] || topic&.category_id,
|
|
tags: transients[:tags],
|
|
archetypeId: transients[:archetype],
|
|
metaData: nil,
|
|
composerTime: SecureRandom.random_number(10_000),
|
|
typingTime: SecureRandom.random_number(10_000),
|
|
}
|
|
end
|
|
end
|