Skip to content

Commit

Permalink
Merge pull request #1458 from codidact/0valt/1457/draft-tags
Browse files Browse the repository at this point in the history
Fix empty ephemeral tags in post drafts if the draft is saved with no tags
  • Loading branch information
ArtOfCode- authored Dec 3, 2024
2 parents ffa4b0a + d0f9d5d commit 0d7d397
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/controllers/posts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,9 @@ def save_draft
key_name = [:body, :saved_at].include?(key) ? base_key : "#{base_key}.#{key}"

if key == :tags
RequestContext.redis.sadd(key_name, params[key])
if params[key].present?
RequestContext.redis.sadd(key_name, params[key])
end
else
RequestContext.redis.set(key_name, params[key])
end
Expand Down
4 changes: 4 additions & 0 deletions config/schedule.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
runner 'scripts/run_spam_cleanup.rb'
end

every 1.day, at: '02:20' do
runner 'scripts/cleanup_drafts.rb'
end

every 6.hours do
runner 'scripts/recalc_abilities.rb'
end
5 changes: 5 additions & 0 deletions scripts/cleanup_drafts.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
redis = RequestContext.redis

redis.scan_each(:match => "saved_post.*.*.tags") do |key|
redis.srem?(key, '')
end

0 comments on commit 0d7d397

Please sign in to comment.