Skip to content

Commit

Permalink
Merge branch 'develop' into 0valt/1459/draft-discard
Browse files Browse the repository at this point in the history
  • Loading branch information
Oaphi authored Dec 3, 2024
2 parents bd00424 + 51048bf commit e265b8c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ gem 'jquery-rails', '~> 4.5.0'
gem 'mysql2', '~> 0.5.4'
gem 'puma', '~> 5.6'
gem 'rails', '~> 7.0.8'
gem 'rails-html-sanitizer', '~> 1.4'
gem 'rails-html-sanitizer', '~> 1.6'
gem 'redis', '~> 4.8'
gem 'rotp', '~> 6.2'
gem 'sass-rails', '~> 6.0'
Expand Down
10 changes: 5 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ GEM
listen (3.7.1)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.22.0)
loofah (2.23.1)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
mail (2.8.1)
Expand Down Expand Up @@ -212,7 +212,7 @@ GEM
net-smtp (0.4.0)
net-protocol
nio4r (2.7.3)
nokogiri (1.16.7-x86_64-linux)
nokogiri (1.16.8-x86_64-linux)
racc (~> 1.4)
omniauth (2.1.0)
hashie (>= 3.4.6)
Expand Down Expand Up @@ -263,9 +263,9 @@ GEM
activesupport (>= 5.0.0)
minitest
nokogiri (>= 1.6)
rails-html-sanitizer (1.6.0)
rails-html-sanitizer (1.6.1)
loofah (~> 2.21)
nokogiri (~> 1.14)
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
railties (7.0.8.5)
actionpack (= 7.0.8.5)
activesupport (= 7.0.8.5)
Expand Down Expand Up @@ -426,7 +426,7 @@ DEPENDENCIES
rack-mini-profiler (~> 3.0)
rails (~> 7.0.8)
rails-controller-testing (~> 1.0)
rails-html-sanitizer (~> 1.4)
rails-html-sanitizer (~> 1.6)
redis (~> 4.8)
reverse_markdown (~> 2.1)
rmagick (~> 5.3)
Expand Down
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 e265b8c

Please sign in to comment.