Add: #518 コンテンツキャッシュについて、リアクションのあった投稿は削除しないオプション (#535)

* Add: #518 コンテンツキャッシュについて、リアクションのあった投稿は削除しないオプション

* Fix: 新規登録のテストが特定時刻で落ちる問題
This commit is contained in:
KMY(雪あすか) 2024-02-13 08:56:55 +09:00 committed by GitHub
parent ba776d3677
commit f2fb829e63
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 118 additions and 5 deletions

View file

@ -26,7 +26,7 @@ class ActivityPub::Activity::Like < ActivityPub::Activity
def process_favourite
return if @account.favourited?(@original_status)
favourite = @original_status.favourites.create!(account: @account)
favourite = @original_status.favourites.create!(account: @account, uri: @json['id'])
LocalNotificationWorker.perform_async(@original_status.account_id, favourite.id, 'Favourite', 'favourite')
Trends.statuses.register(@original_status)

View file

@ -32,9 +32,24 @@ class Vacuum::StatusesVacuum
end
def statuses_scope
Status.unscoped.kept
.joins(:account).merge(Account.remote)
.where('statuses.id < ?', retention_period_as_id)
scope = Status.unscoped.kept
.joins(:account).merge(Account.remote)
.where('statuses.id < ?', retention_period_as_id)
if Setting.delete_content_cache_without_reaction
scope = scope.where.not(id: favourited_statuses)
.where.not(id: bookmarked_statuses)
end
scope
end
def favourited_statuses
Favourite.local.select(:status_id)
end
def bookmarked_statuses
Bookmark.select(:status_id)
end
def retention_period_as_id

View file

@ -22,6 +22,8 @@ class EmojiReaction < ApplicationRecord
update_index('statuses', :status)
scope :local, -> { where(uri: nil) }
belongs_to :account, inverse_of: :emoji_reactions
belongs_to :status, inverse_of: :emoji_reactions
belongs_to :custom_emoji, optional: true

View file

@ -9,6 +9,7 @@
# updated_at :datetime not null
# account_id :bigint(8) not null
# status_id :bigint(8) not null
# uri :string
#
class Favourite < ApplicationRecord
@ -16,6 +17,8 @@ class Favourite < ApplicationRecord
update_index('statuses', :status)
scope :local, -> { where(uri: nil) }
belongs_to :account, inverse_of: :favourites
belongs_to :status, inverse_of: :favourites

View file

@ -41,6 +41,7 @@ class Form::AdminSettings
media_cache_retention_period
content_cache_retention_period
backups_retention_period
delete_content_cache_without_reaction
status_page_url
captcha_enabled
ng_words
@ -98,6 +99,7 @@ class Form::AdminSettings
unlocked_friend
stranger_mention_from_local_ng
enable_local_timeline
delete_content_cache_without_reaction
).freeze
UPLOAD_KEYS = %i(

View file

@ -12,7 +12,12 @@
.fields-group
= f.input :media_cache_retention_period, wrapper: :with_block_label, input_html: { pattern: '[0-9]+' }
.fields-group
= f.input :content_cache_retention_period, wrapper: :with_block_label, input_html: { pattern: '[0-9]+' }, hint: false, warning_hint: t('simple_form.hints.form_admin_settings.content_cache_retention_period')
= f.input :delete_content_cache_without_reaction, as: :boolean, wrapper: :with_label, kmyblue: true, hint: false
.fields-group
= f.input :backups_retention_period, wrapper: :with_block_label, input_html: { pattern: '[0-9]+' }
.actions