Merge branch 'origin/master' into sync/upstream
Conflicts: app/javascript/mastodon/components/status_list.js app/javascript/mastodon/features/notifications/index.js app/javascript/mastodon/features/ui/components/modal_root.js app/javascript/mastodon/features/ui/components/onboarding_modal.js app/javascript/mastodon/features/ui/index.js app/javascript/styles/about.scss app/javascript/styles/accounts.scss app/javascript/styles/components.scss app/presenters/instance_presenter.rb app/services/post_status_service.rb app/services/reblog_service.rb app/views/about/more.html.haml app/views/about/show.html.haml app/views/accounts/_header.html.haml config/webpack/loaders/babel.js spec/controllers/api/v1/accounts/credentials_controller_spec.rb
This commit is contained in:
@@ -77,6 +77,10 @@ class Account < ApplicationRecord
|
||||
has_many :mentions, inverse_of: :account, dependent: :destroy
|
||||
has_many :notifications, inverse_of: :account, dependent: :destroy
|
||||
|
||||
# Pinned statuses
|
||||
has_many :status_pins, inverse_of: :account, dependent: :destroy
|
||||
has_many :pinned_statuses, -> { reorder('status_pins.created_at DESC') }, through: :status_pins, class_name: 'Status', source: :status
|
||||
|
||||
# Media
|
||||
has_many :media_attachments, dependent: :destroy
|
||||
|
||||
@@ -91,7 +95,7 @@ class Account < ApplicationRecord
|
||||
scope :local, -> { where(domain: nil) }
|
||||
scope :without_followers, -> { where(followers_count: 0) }
|
||||
scope :with_followers, -> { where('followers_count > 0') }
|
||||
scope :expiring, ->(time) { where(subscription_expires_at: nil).or(where('subscription_expires_at < ?', time)).remote.with_followers }
|
||||
scope :expiring, ->(time) { remote.where.not(subscription_expires_at: nil).where('subscription_expires_at < ?', time) }
|
||||
scope :partitioned, -> { order('row_number() over (partition by domain)') }
|
||||
scope :silenced, -> { where(silenced: true) }
|
||||
scope :suspended, -> { where(suspended: true) }
|
||||
@@ -105,6 +109,7 @@ class Account < ApplicationRecord
|
||||
:current_sign_in_ip,
|
||||
:current_sign_in_at,
|
||||
:confirmed?,
|
||||
:admin?,
|
||||
:locale,
|
||||
to: :user,
|
||||
prefix: true,
|
||||
@@ -133,11 +138,11 @@ class Account < ApplicationRecord
|
||||
end
|
||||
|
||||
def keypair
|
||||
OpenSSL::PKey::RSA.new(private_key || public_key)
|
||||
@keypair ||= OpenSSL::PKey::RSA.new(private_key || public_key)
|
||||
end
|
||||
|
||||
def subscription(webhook_url)
|
||||
OStatus2::Subscription.new(remote_url, secret: secret, lease_seconds: 30.days.seconds, webhook: webhook_url, hub: hub_url)
|
||||
@subscription ||= OStatus2::Subscription.new(remote_url, secret: secret, webhook: webhook_url, hub: hub_url)
|
||||
end
|
||||
|
||||
def save_with_optional_media!
|
||||
@@ -171,6 +176,10 @@ class Account < ApplicationRecord
|
||||
reorder(nil).pluck('distinct accounts.domain')
|
||||
end
|
||||
|
||||
def inboxes
|
||||
reorder(nil).where(protocol: :activitypub).pluck("distinct coalesce(nullif(accounts.shared_inbox_url, ''), accounts.inbox_url)")
|
||||
end
|
||||
|
||||
def triadic_closures(account, limit: 5, offset: 0)
|
||||
sql = <<-SQL.squish
|
||||
WITH first_degree AS (
|
||||
@@ -263,7 +272,7 @@ class Account < ApplicationRecord
|
||||
def generate_keys
|
||||
return unless local?
|
||||
|
||||
keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 1024 : 2048)
|
||||
keypair = OpenSSL::PKey::RSA.new(Rails.env.test? ? 512 : 2048)
|
||||
self.private_key = keypair.to_pem
|
||||
self.public_key = keypair.public_key.to_pem
|
||||
end
|
||||
|
Reference in New Issue
Block a user