mirror of
https://github.com/discourse/discourse.git
synced 2024-11-30 06:04:09 +08:00
FEATURE: Add cooked post to user archive exports (#18979)
This change allows easily accessible secure media URLs to be available in the exported data.
This commit is contained in:
parent
0b367216ae
commit
c7ccb17433
|
@ -26,7 +26,7 @@ module Jobs
|
||||||
)
|
)
|
||||||
|
|
||||||
HEADER_ATTRS_FOR ||= HashWithIndifferentAccess.new(
|
HEADER_ATTRS_FOR ||= HashWithIndifferentAccess.new(
|
||||||
user_archive: ['topic_title', 'categories', 'is_pm', 'post', 'like_count', 'reply_count', 'url', 'created_at'],
|
user_archive: ['topic_title', 'categories', 'is_pm', 'post_raw', 'post_cooked', 'like_count', 'reply_count', 'url', 'created_at'],
|
||||||
user_archive_profile: ['location', 'website', 'bio', 'views'],
|
user_archive_profile: ['location', 'website', 'bio', 'views'],
|
||||||
auth_tokens: ['id', 'auth_token_hash', 'prev_auth_token_hash', 'auth_token_seen', 'client_ip', 'user_agent', 'seen_at', 'rotated_at', 'created_at', 'updated_at'],
|
auth_tokens: ['id', 'auth_token_hash', 'prev_auth_token_hash', 'auth_token_seen', 'client_ip', 'user_agent', 'seen_at', 'rotated_at', 'created_at', 'updated_at'],
|
||||||
auth_token_logs: ['id', 'action', 'user_auth_token_id', 'client_ip', 'auth_token_hash', 'created_at', 'path', 'user_agent'],
|
auth_token_logs: ['id', 'action', 'user_auth_token_id', 'client_ip', 'auth_token_hash', 'created_at', 'path', 'user_agent'],
|
||||||
|
@ -134,7 +134,7 @@ module Jobs
|
||||||
|
|
||||||
Post.includes(topic: :category)
|
Post.includes(topic: :category)
|
||||||
.where(user_id: @current_user.id)
|
.where(user_id: @current_user.id)
|
||||||
.select(:topic_id, :post_number, :raw, :like_count, :reply_count, :created_at)
|
.select(:topic_id, :post_number, :raw, :cooked, :like_count, :reply_count, :created_at)
|
||||||
.order(:created_at)
|
.order(:created_at)
|
||||||
.with_deleted
|
.with_deleted
|
||||||
.each do |user_archive|
|
.each do |user_archive|
|
||||||
|
@ -441,7 +441,15 @@ module Jobs
|
||||||
is_pm = topic_data.archetype == "private_message" ? I18n.t("csv_export.boolean_yes") : I18n.t("csv_export.boolean_no")
|
is_pm = topic_data.archetype == "private_message" ? I18n.t("csv_export.boolean_yes") : I18n.t("csv_export.boolean_no")
|
||||||
url = "#{Discourse.base_url}/t/#{topic_data.slug}/#{topic_data.id}/#{user_archive['post_number']}"
|
url = "#{Discourse.base_url}/t/#{topic_data.slug}/#{topic_data.id}/#{user_archive['post_number']}"
|
||||||
|
|
||||||
topic_hash = { "post" => user_archive['raw'], "topic_title" => topic_data.title, "categories" => categories, "is_pm" => is_pm, "url" => url }
|
topic_hash = {
|
||||||
|
"post_raw" => user_archive['raw'],
|
||||||
|
"post_cooked" => user_archive["cooked"],
|
||||||
|
"topic_title" => topic_data.title,
|
||||||
|
"categories" => categories,
|
||||||
|
"is_pm" => is_pm,
|
||||||
|
"url" => url
|
||||||
|
}
|
||||||
|
|
||||||
user_archive.merge!(topic_hash)
|
user_archive.merge!(topic_hash)
|
||||||
|
|
||||||
HEADER_ATTRS_FOR['user_archive'].each do |attr|
|
HEADER_ATTRS_FOR['user_archive'].each do |attr|
|
||||||
|
|
|
@ -146,9 +146,13 @@ RSpec.describe Jobs::ExportUserArchive do
|
||||||
expect(post2["is_pm"]).to eq(I18n.t("csv_export.boolean_no"))
|
expect(post2["is_pm"]).to eq(I18n.t("csv_export.boolean_no"))
|
||||||
expect(post3["is_pm"]).to eq(I18n.t("csv_export.boolean_yes"))
|
expect(post3["is_pm"]).to eq(I18n.t("csv_export.boolean_yes"))
|
||||||
|
|
||||||
expect(post1["post"]).to eq(normal_post.raw)
|
expect(post1["post_raw"]).to eq(normal_post.raw)
|
||||||
expect(post2["post"]).to eq(subsubpost.raw)
|
expect(post2["post_raw"]).to eq(subsubpost.raw)
|
||||||
expect(post3["post"]).to eq(message_post.raw)
|
expect(post3["post_raw"]).to eq(message_post.raw)
|
||||||
|
|
||||||
|
expect(post1["post_cooked"]).to eq(normal_post.cooked)
|
||||||
|
expect(post2["post_cooked"]).to eq(subsubpost.cooked)
|
||||||
|
expect(post3["post_cooked"]).to eq(message_post.cooked)
|
||||||
|
|
||||||
expect(post1['like_count']).to eq(1)
|
expect(post1['like_count']).to eq(1)
|
||||||
expect(post2['like_count']).to eq(0)
|
expect(post2['like_count']).to eq(0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user