From 6e812ca714f18de070ef9b8e10a203a68acdef59 Mon Sep 17 00:00:00 2001 From: BrokenEagle Date: Mon, 30 Oct 2017 16:38:06 -0700 Subject: [PATCH] Moved adding post to new pool until after post save --- app/models/post.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/models/post.rb b/app/models/post.rb index 89dd791f9..7135f1ceb 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -765,7 +765,9 @@ class Post < ApplicationRecord end def apply_casesensitive_metatags(tags) - casesensitive_metatags, tags = tags.partition {|x| x =~ /\A(?:source|newpool):/i} + casesensitive_metatags, tags = tags.partition {|x| x =~ /\A(?:source):/i} + #Reuse the following metatags after the post has been saved + casesensitive_metatags += tags.select {|x| x =~ /\A(?:newpool):/i} if casesensitive_metatags.length > 0 case casesensitive_metatags[-1] when /^source:none$/i @@ -782,7 +784,6 @@ class Post < ApplicationRecord if pool.nil? pool = Pool.create(:name => $1, :description => "This pool was automatically generated") end - add_pool!(pool) if pool end end return tags @@ -791,7 +792,7 @@ class Post < ApplicationRecord def filter_metatags(tags) @pre_metatags, tags = tags.partition {|x| x =~ /\A(?:rating|parent|-parent|-?locked):/i} tags = apply_categorization_metatags(tags) - @post_metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|fav|-fav|child|-favgroup|favgroup|upvote|downvote):/i} + @post_metatags, tags = tags.partition {|x| x =~ /\A(?:-pool|pool|newpool|fav|-fav|child|-favgroup|favgroup|upvote|downvote):/i} apply_pre_metatags return tags end @@ -828,6 +829,10 @@ class Post < ApplicationRecord pool = Pool.find_by_name($1) add_pool!(pool) if pool + when /^newpool:(.+)$/i + pool = Pool.find_by_name($1) + add_pool!(pool) if pool + when /^fav:(.+)$/i add_favorite!(CurrentUser.user)