Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `app/controllers/home_controller.rb`: Upstream made it so `/web` is available to non-logged-in users and `/` redirects to `/web` instead of `/about`. Kept our version since glitch-soc's WebUI doesn't have what's needed yet and I think /about is still a much better landing page anyway. - `app/models/form/admin_settings.rb`: Upstream added new settings, and glitch-soc had an extra setting. Not really a conflict. Added upstream's new settings. - `app/serializers/initial_state_serializer.rb`: Upstream added a new `server` initial state object. Not really a conflict. Merged upstream's changes. - `app/views/admin/settings/edit.html.haml`: Upstream added new settings. Not really a conflict. Merged upstream's changes. - `app/workers/scheduler/feed_cleanup_scheduler.rb`: Upstream refactored that part and removed the file. Ported our relevant changes into `app/lib/vacuum/feeds_vacuum.rb` - `config/settings.yml`: Upstream added new settings. Not a real conflict. Added upstream's new settings.
This commit is contained in:
@@ -262,6 +262,10 @@ class Account < ApplicationRecord
|
||||
update!(memorial: true)
|
||||
end
|
||||
|
||||
def trendable
|
||||
boolean_with_default('trendable', Setting.trendable_by_default)
|
||||
end
|
||||
|
||||
def sign?
|
||||
true
|
||||
end
|
||||
|
@@ -9,6 +9,7 @@ module AccountInteractions
|
||||
mapping[follow.target_account_id] = {
|
||||
reblogs: follow.show_reblogs?,
|
||||
notify: follow.notify?,
|
||||
languages: follow.languages,
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -38,6 +39,7 @@ module AccountInteractions
|
||||
mapping[follow_request.target_account_id] = {
|
||||
reblogs: follow_request.show_reblogs?,
|
||||
notify: follow_request.notify?,
|
||||
languages: follow_request.languages,
|
||||
}
|
||||
end
|
||||
end
|
||||
@@ -100,12 +102,13 @@ module AccountInteractions
|
||||
has_many :announcement_mutes, dependent: :destroy
|
||||
end
|
||||
|
||||
def follow!(other_account, reblogs: nil, notify: nil, uri: nil, rate_limit: false, bypass_limit: false)
|
||||
rel = active_relationships.create_with(show_reblogs: reblogs.nil? ? true : reblogs, notify: notify.nil? ? false : notify, uri: uri, rate_limit: rate_limit, bypass_follow_limit: bypass_limit)
|
||||
def follow!(other_account, reblogs: nil, notify: nil, languages: nil, uri: nil, rate_limit: false, bypass_limit: false)
|
||||
rel = active_relationships.create_with(show_reblogs: reblogs.nil? ? true : reblogs, notify: notify.nil? ? false : notify, languages: languages, uri: uri, rate_limit: rate_limit, bypass_follow_limit: bypass_limit)
|
||||
.find_or_create_by!(target_account: other_account)
|
||||
|
||||
rel.show_reblogs = reblogs unless reblogs.nil?
|
||||
rel.notify = notify unless notify.nil?
|
||||
rel.show_reblogs = reblogs unless reblogs.nil?
|
||||
rel.notify = notify unless notify.nil?
|
||||
rel.languages = languages unless languages.nil?
|
||||
|
||||
rel.save! if rel.changed?
|
||||
|
||||
@@ -114,12 +117,13 @@ module AccountInteractions
|
||||
rel
|
||||
end
|
||||
|
||||
def request_follow!(other_account, reblogs: nil, notify: nil, uri: nil, rate_limit: false, bypass_limit: false)
|
||||
rel = follow_requests.create_with(show_reblogs: reblogs.nil? ? true : reblogs, notify: notify.nil? ? false : notify, uri: uri, rate_limit: rate_limit, bypass_follow_limit: bypass_limit)
|
||||
def request_follow!(other_account, reblogs: nil, notify: nil, languages: nil, uri: nil, rate_limit: false, bypass_limit: false)
|
||||
rel = follow_requests.create_with(show_reblogs: reblogs.nil? ? true : reblogs, notify: notify.nil? ? false : notify, uri: uri, languages: languages, rate_limit: rate_limit, bypass_follow_limit: bypass_limit)
|
||||
.find_or_create_by!(target_account: other_account)
|
||||
|
||||
rel.show_reblogs = reblogs unless reblogs.nil?
|
||||
rel.notify = notify unless notify.nil?
|
||||
rel.show_reblogs = reblogs unless reblogs.nil?
|
||||
rel.notify = notify unless notify.nil?
|
||||
rel.languages = languages unless languages.nil?
|
||||
|
||||
rel.save! if rel.changed?
|
||||
|
||||
@@ -288,8 +292,7 @@ module AccountInteractions
|
||||
|
||||
private
|
||||
|
||||
def remove_potential_friendship(other_account, mutual = false)
|
||||
def remove_potential_friendship(other_account)
|
||||
PotentialFriendshipTracker.remove(id, other_account.id)
|
||||
PotentialFriendshipTracker.remove(other_account.id, id) if mutual
|
||||
end
|
||||
end
|
||||
|
25
app/models/content_retention_policy.rb
Normal file
25
app/models/content_retention_policy.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class ContentRetentionPolicy
|
||||
def self.current
|
||||
new
|
||||
end
|
||||
|
||||
def media_cache_retention_period
|
||||
retention_period Setting.media_cache_retention_period
|
||||
end
|
||||
|
||||
def content_cache_retention_period
|
||||
retention_period Setting.content_cache_retention_period
|
||||
end
|
||||
|
||||
def backups_retention_period
|
||||
retention_period Setting.backups_retention_period
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def retention_period(value)
|
||||
value.days if value.is_a?(Integer) && value.positive?
|
||||
end
|
||||
end
|
@@ -30,9 +30,9 @@ class Export
|
||||
end
|
||||
|
||||
def to_following_accounts_csv
|
||||
CSV.generate(headers: ['Account address', 'Show boosts'], write_headers: true) do |csv|
|
||||
CSV.generate(headers: ['Account address', 'Show boosts', 'Notify on new posts', 'Languages'], write_headers: true) do |csv|
|
||||
account.active_relationships.includes(:target_account).reorder(id: :desc).each do |follow|
|
||||
csv << [acct(follow.target_account), follow.show_reblogs]
|
||||
csv << [acct(follow.target_account), follow.show_reblogs, follow.notify, follow.languages&.join(', ')]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -11,6 +11,7 @@
|
||||
# show_reblogs :boolean default(TRUE), not null
|
||||
# uri :string
|
||||
# notify :boolean default(FALSE), not null
|
||||
# languages :string is an Array
|
||||
#
|
||||
|
||||
class Follow < ApplicationRecord
|
||||
@@ -27,6 +28,7 @@ class Follow < ApplicationRecord
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||
validates :languages, language: true
|
||||
|
||||
scope :recent, -> { reorder(id: :desc) }
|
||||
|
||||
@@ -35,7 +37,7 @@ class Follow < ApplicationRecord
|
||||
end
|
||||
|
||||
def revoke_request!
|
||||
FollowRequest.create!(account: account, target_account: target_account, show_reblogs: show_reblogs, notify: notify, uri: uri)
|
||||
FollowRequest.create!(account: account, target_account: target_account, show_reblogs: show_reblogs, notify: notify, languages: languages, uri: uri)
|
||||
destroy!
|
||||
end
|
||||
|
||||
|
@@ -11,6 +11,7 @@
|
||||
# show_reblogs :boolean default(TRUE), not null
|
||||
# uri :string
|
||||
# notify :boolean default(FALSE), not null
|
||||
# languages :string is an Array
|
||||
#
|
||||
|
||||
class FollowRequest < ApplicationRecord
|
||||
@@ -27,9 +28,10 @@ class FollowRequest < ApplicationRecord
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||
validates :languages, language: true
|
||||
|
||||
def authorize!
|
||||
account.follow!(target_account, reblogs: show_reblogs, notify: notify, uri: uri, bypass_limit: true)
|
||||
account.follow!(target_account, reblogs: show_reblogs, notify: notify, languages: languages, uri: uri, bypass_limit: true)
|
||||
MergeWorker.perform_async(target_account.id, account.id) if account.local?
|
||||
destroy!
|
||||
end
|
||||
|
@@ -40,6 +40,9 @@ class Form::AdminSettings
|
||||
outgoing_spoilers
|
||||
require_invite_text
|
||||
captcha_enabled
|
||||
media_cache_retention_period
|
||||
content_cache_retention_period
|
||||
backups_retention_period
|
||||
).freeze
|
||||
|
||||
BOOLEAN_KEYS = %i(
|
||||
@@ -81,6 +84,7 @@ class Form::AdminSettings
|
||||
validates :bootstrap_timeline_accounts, existing_username: { multiple: true }
|
||||
validates :show_domain_blocks, inclusion: { in: %w(disabled users all) }
|
||||
validates :show_domain_blocks_rationale, inclusion: { in: %w(disabled users all) }
|
||||
validates :media_cache_retention_period, :content_cache_retention_period, :backups_retention_period, numericality: { only_integer: true }, allow_blank: true
|
||||
|
||||
def initialize(_attributes = {})
|
||||
super
|
||||
|
@@ -282,7 +282,7 @@ class User < ApplicationRecord
|
||||
end
|
||||
|
||||
def preferred_posting_language
|
||||
valid_locale_cascade(settings.default_language, locale)
|
||||
valid_locale_cascade(settings.default_language, locale, I18n.locale)
|
||||
end
|
||||
|
||||
def setting_default_privacy
|
||||
|
Reference in New Issue
Block a user