From 870ebfe74e9b91249bad6cfaf2b3a5a650d19c2a Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Sun, 29 Nov 2020 11:44:10 -0600 Subject: Simply Tavern curation checks --- app/controllers/api/v1/statuses/bookmarks_controller.rb | 5 ++--- app/models/status.rb | 10 ++++++++-- app/services/favourite_service.rb | 5 ++--- app/services/reblog_service.rb | 5 ++--- 4 files changed, 14 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/controllers/api/v1/statuses/bookmarks_controller.rb b/app/controllers/api/v1/statuses/bookmarks_controller.rb index 1bf698a78..d7f3d8475 100644 --- a/app/controllers/api/v1/statuses/bookmarks_controller.rb +++ b/app/controllers/api/v1/statuses/bookmarks_controller.rb @@ -9,7 +9,7 @@ class Api::V1::Statuses::BookmarksController < Api::BaseController def create current_account.bookmarks.find_or_create_by!(account: current_account, status: @status) - curate! unless @status.curated? || !@status.published? + curate! render json: @status, serializer: REST::StatusSerializer end @@ -40,7 +40,6 @@ class Api::V1::Statuses::BookmarksController < Api::BaseController end def curate! - @status.curate! - DistributionWorker.perform_async(@status.id) + DistributionWorker.perform_async(@status.id) if @status.curate! end end diff --git a/app/models/status.rb b/app/models/status.rb index 67b975813..2e83e258b 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -309,11 +309,17 @@ class Status < ApplicationRecord end def curate! - update_column(:curated, true) if public_visibility? && !curated + return false unless !curated? && published? && public_visibility? + + update_column(:curated, true) + true end def uncurate! - update_column(:curated, false) if curated + return false unless curated? + + update_column(:curated, false) + true end def notify=(value) diff --git a/app/services/favourite_service.rb b/app/services/favourite_service.rb index f3e89746b..0b2923165 100644 --- a/app/services/favourite_service.rb +++ b/app/services/favourite_service.rb @@ -16,7 +16,7 @@ class FavouriteService < BaseService return favourite unless favourite.nil? favourite = Favourite.create!(account: account, status: status) - curate!(status) unless status.curated? || !status.published? + curate!(status) create_notification(favourite) bump_potential_friendship(account, status) @@ -47,7 +47,6 @@ class FavouriteService < BaseService end def curate!(status) - status.curate! - DistributionWorker.perform_async(status.id) + DistributionWorker.perform_async(status.id) if status.curate! end end diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb index b694bc500..500c743ce 100644 --- a/app/services/reblog_service.rb +++ b/app/services/reblog_service.rb @@ -29,7 +29,7 @@ class ReblogService < BaseService end reblog = account.statuses.create!(reblog: reblogged_status, text: '', visibility: visibility, rate_limit: options[:with_rate_limit], sensitive: true, spoiler_text: options[:spoiler_text] || '', published: true) - curate!(reblogged_status) unless reblogged_status.curated? || !reblogged_status.published? + curate!(reblogged_status) DistributionWorker.perform_async(reblog.id) ActivityPub::DistributionWorker.perform_async(reblog.id) unless reblogged_status.local_only? || reblogged_status.account.private? @@ -65,7 +65,6 @@ class ReblogService < BaseService end def curate!(status) - status.curate! - DistributionWorker.perform_async(status.id) + DistributionWorker.perform_async(status.id) if status.curate! end end -- cgit