From 1c647b0b060981e9421c8cbcc78be8744d1b07d9 Mon Sep 17 00:00:00 2001 From: Fosco Marotto Date: Sun, 24 Jan 2021 13:50:51 -0500 Subject: [PATCH] [reset] cleanup --- .../api/v1/statuses/favourites_controller.rb | 10 ++++++++- .../api/v1/statuses/reblogs_controller.rb | 10 ++++++++- app/lib/sorting_query_builder.rb | 4 ---- app/models/home_feed.rb | 21 ++++++------------- app/services/favourite_service.rb | 8 ++++++- app/services/reblog_service.rb | 8 ++++++- config/routes.rb | 10 ++++++--- 7 files changed, 45 insertions(+), 26 deletions(-) diff --git a/app/controllers/api/v1/statuses/favourites_controller.rb b/app/controllers/api/v1/statuses/favourites_controller.rb index 96582d6d..3bc2cc49 100644 --- a/app/controllers/api/v1/statuses/favourites_controller.rb +++ b/app/controllers/api/v1/statuses/favourites_controller.rb @@ -34,6 +34,14 @@ class Api::V1::Statuses::FavouritesController < Api::BaseController end def requested_status - Status.find(params[:status_id]) + rs = nil + begin + rs = Status.find(params[:status_id]) + rescue ActiveRecord::RecordNotFound + Status.connection.stick_to_master! + rs = Status.find(params[:status_id]) + end + return rs unless rs.nil? + raise ActiveRecord::RecordNotFound end end diff --git a/app/controllers/api/v1/statuses/reblogs_controller.rb b/app/controllers/api/v1/statuses/reblogs_controller.rb index 9e17dfd9..a05ada84 100644 --- a/app/controllers/api/v1/statuses/reblogs_controller.rb +++ b/app/controllers/api/v1/statuses/reblogs_controller.rb @@ -31,7 +31,15 @@ class Api::V1::Statuses::ReblogsController < Api::BaseController private def status_for_reblog - Status.find params[:status_id] + rs = nil + begin + rs = Status.find(params[:status_id]) + rescue ActiveRecord::RecordNotFound + Status.connection.stick_to_master! + rs = Status.find(params[:status_id]) + end + return rs unless rs.nil? + raise ActiveRecord::RecordNotFound end def status_for_destroy diff --git a/app/lib/sorting_query_builder.rb b/app/lib/sorting_query_builder.rb index 3d8fd76e..d2927437 100644 --- a/app/lib/sorting_query_builder.rb +++ b/app/lib/sorting_query_builder.rb @@ -80,10 +80,6 @@ class SortingQueryBuilder < BaseService query += " ) q - left join custom_filters cf - on cf.account_id = #{account_id} - and q.text like '%' || cf.phrase || '%' - where cf.id is null " return Status.find_by_sql query end diff --git a/app/models/home_feed.rb b/app/models/home_feed.rb index b5a7bc75..c506dfd8 100644 --- a/app/models/home_feed.rb +++ b/app/models/home_feed.rb @@ -8,11 +8,7 @@ class HomeFeed < Feed end def get(limit = 20, max_id = nil, since_id = nil, min_id = nil) - # if redis.exists?("account:#{@account.id}:regeneration") from_database(limit, max_id, since_id, min_id) - # else - # super - # end end private @@ -33,7 +29,12 @@ class HomeFeed < Feed and s.reply is false and ( s.account_id = #{@id} - or s.account_id in (select target_account_id from follows where account_id = #{@id}) + or s.account_id in ( + select ff.target_account_id + from follows ff + join accounts af + on ff.target_account_id = af.id + where ff.account_id = #{@id}) ) and s.account_id not in (select target_account_id from mutes where account_id = #{@id}) and (reblog.id is null or reblog.account_id not in (select target_account_id from mutes where account_id = #{@id})) @@ -43,16 +44,6 @@ class HomeFeed < Feed order by s.created_at desc limit #{limit} ) st - left join statuses rb - on st.reblog_of_id = rb.id - left join custom_filters cf - on cf.account_id = #{@id} and ( - st.text like '%' || cf.phrase || '%' - or rb.text like '%' || cf.phrase || '%') - where cf.id is null or st.account_id = #{@id} " - # .reject { |status| FeedManager.instance.filter?(:home, status, @account.id) } - # Status.as_home_timeline(@account) - # .paginate_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id) end end diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index c9928150..0c4edaf3 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -10,7 +10,13 @@ class FavouriteService < BaseService def call(account, status) authorize_with account, status, :favourite? - favourite = Favourite.find_by(account: account, status: status) + favourite = nil + begin + favourite = Favourite.find_by(account: account, status: status) + rescue ActiveRecord::RecordNotFound + Favourite.connection.stick_to_master! + favourite = Favourite.find_by(account: account, status: status) + end return favourite unless favourite.nil? diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb index 067c0b75..f330af5d 100644 --- a/app/services/reblog_service.rb +++ b/app/services/reblog_service.rb @@ -13,7 +13,13 @@ class ReblogService < BaseService authorize_with account, reblogged_status, :reblog? - reblog = account.statuses.find_by(reblog: reblogged_status) + reblog = nil + begin + reblog = account.statuses.find_by(reblog: reblogged_status) + rescue ActiveRecord::RecordNotFound + account.statuses.connection.stick_to_master! + reblog = account.statuses.find_by(reblog: reblogged_status) + end return reblog unless reblog.nil? diff --git a/config/routes.rb b/config/routes.rb index 1e913d40..905be549 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -16,6 +16,10 @@ Rails.application.routes.draw do mount PgHero::Engine, at: 'pghero', as: :pghero end + Doorkeeper::AccessToken.connection.stick_to_master! + Doorkeeper::AccessGrant.connection.stick_to_master! + SessionActivation.connection.stick_to_master! + use_doorkeeper do controllers authorizations: 'oauth/authorizations', authorized_applications: 'oauth/authorized_applications', @@ -225,9 +229,9 @@ Rails.application.routes.draw do end namespace :chat_conversation_accounts do - # + # end - + resources :chat_conversation_accounts, only: :show do member do post :messenger_block_relationships @@ -365,7 +369,7 @@ Rails.application.routes.draw do resource :removed_accounts, only: [:show, :create, :destroy], controller: 'groups/removed_accounts' resource :password, only: [:create], controller: 'groups/password' resource :join_requests, only: [:show], controller: 'groups/requests' - + post '/join_requests/respond', to: 'groups/requests#respond_to_request' resource :pin, only: [:show, :create], controller: 'groups/pins'