Remove subscription_expires_at leftover from OStatus (#15857)
This commit is contained in:
parent
f2ca6c7a17
commit
5cc45d22d3
|
@ -27,7 +27,6 @@
|
||||||
# header_file_size :integer
|
# header_file_size :integer
|
||||||
# header_updated_at :datetime
|
# header_updated_at :datetime
|
||||||
# avatar_remote_url :string
|
# avatar_remote_url :string
|
||||||
# subscription_expires_at :datetime
|
|
||||||
# locked :boolean default(FALSE), not null
|
# locked :boolean default(FALSE), not null
|
||||||
# header_remote_url :string default(""), not null
|
# header_remote_url :string default(""), not null
|
||||||
# last_webfingered_at :datetime
|
# last_webfingered_at :datetime
|
||||||
|
@ -55,6 +54,8 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
class Account < ApplicationRecord
|
class Account < ApplicationRecord
|
||||||
|
self.ignored_columns = %w(subscription_expires_at)
|
||||||
|
|
||||||
USERNAME_RE = /[a-z0-9_]+([a-z0-9_\.-]+[a-z0-9_]+)?/i
|
USERNAME_RE = /[a-z0-9_]+([a-z0-9_\.-]+[a-z0-9_]+)?/i
|
||||||
MENTION_RE = /(?<=^|[^\/[:word:]])@((#{USERNAME_RE})(?:@[[:word:]\.\-]+[a-z0-9]+)?)/i
|
MENTION_RE = /(?<=^|[^\/[:word:]])@((#{USERNAME_RE})(?:@[[:word:]\.\-]+[a-z0-9]+)?)/i
|
||||||
|
|
||||||
|
@ -93,7 +94,6 @@ class Account < ApplicationRecord
|
||||||
|
|
||||||
scope :remote, -> { where.not(domain: nil) }
|
scope :remote, -> { where.not(domain: nil) }
|
||||||
scope :local, -> { where(domain: nil) }
|
scope :local, -> { where(domain: nil) }
|
||||||
scope :expiring, ->(time) { remote.where.not(subscription_expires_at: nil).where('subscription_expires_at < ?', time) }
|
|
||||||
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }
|
scope :partitioned, -> { order(Arel.sql('row_number() over (partition by domain)')) }
|
||||||
scope :silenced, -> { where.not(silenced_at: nil) }
|
scope :silenced, -> { where.not(silenced_at: nil) }
|
||||||
scope :suspended, -> { where.not(suspended_at: nil) }
|
scope :suspended, -> { where.not(suspended_at: nil) }
|
||||||
|
@ -190,10 +190,6 @@ class Account < ApplicationRecord
|
||||||
"acct:#{local_username_and_domain}"
|
"acct:#{local_username_and_domain}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def subscribed?
|
|
||||||
subscription_expires_at.present?
|
|
||||||
end
|
|
||||||
|
|
||||||
def searchable?
|
def searchable?
|
||||||
!(suspended? || moved?)
|
!(suspended? || moved?)
|
||||||
end
|
end
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
class RemoveSubscriptionExpiresAtFromAccounts < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
safety_assured do
|
||||||
|
remove_column :accounts, :subscription_expires_at, :datetime, null: true, default: nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2021_02_21_045109) do
|
ActiveRecord::Schema.define(version: 2021_03_08_133107) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -166,7 +166,6 @@ ActiveRecord::Schema.define(version: 2021_02_21_045109) do
|
||||||
t.integer "header_file_size"
|
t.integer "header_file_size"
|
||||||
t.datetime "header_updated_at"
|
t.datetime "header_updated_at"
|
||||||
t.string "avatar_remote_url"
|
t.string "avatar_remote_url"
|
||||||
t.datetime "subscription_expires_at"
|
|
||||||
t.boolean "locked", default: false, null: false
|
t.boolean "locked", default: false, null: false
|
||||||
t.string "header_remote_url", default: "", null: false
|
t.string "header_remote_url", default: "", null: false
|
||||||
t.datetime "last_webfingered_at"
|
t.datetime "last_webfingered_at"
|
||||||
|
|
|
@ -134,18 +134,6 @@ RSpec.describe Account, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#subscribed?' do
|
|
||||||
it 'returns false when no subscription expiration information is present' do
|
|
||||||
account = Fabricate(:account, subscription_expires_at: nil)
|
|
||||||
expect(account.subscribed?).to be false
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'returns true when subscription expiration has been set' do
|
|
||||||
account = Fabricate(:account, subscription_expires_at: 30.days.from_now)
|
|
||||||
expect(account.subscribed?).to be true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#possibly_stale?' do
|
describe '#possibly_stale?' do
|
||||||
let(:account) { Fabricate(:account, last_webfingered_at: last_webfingered_at) }
|
let(:account) { Fabricate(:account, last_webfingered_at: last_webfingered_at) }
|
||||||
|
|
||||||
|
@ -707,21 +695,6 @@ RSpec.describe Account, type: :model do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'expiring' do
|
|
||||||
it 'returns remote accounts with followers whose subscription expiration date is past or not given' do
|
|
||||||
local = Fabricate(:account, domain: nil)
|
|
||||||
matches = [
|
|
||||||
{ domain: 'remote', subscription_expires_at: '2000-01-01T00:00:00Z' },
|
|
||||||
].map(&method(:Fabricate).curry(2).call(:account))
|
|
||||||
matches.each(&local.method(:follow!))
|
|
||||||
Fabricate(:account, domain: 'remote', subscription_expires_at: nil)
|
|
||||||
local.follow!(Fabricate(:account, domain: 'remote', subscription_expires_at: '2000-01-03T00:00:00Z'))
|
|
||||||
local.follow!(Fabricate(:account, domain: nil, subscription_expires_at: nil))
|
|
||||||
|
|
||||||
expect(Account.expiring('2000-01-02T00:00:00Z').recent).to eq matches.reverse
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'remote' do
|
describe 'remote' do
|
||||||
it 'returns an array of accounts who have a domain' do
|
it 'returns an array of accounts who have a domain' do
|
||||||
account_1 = Fabricate(:account, domain: nil)
|
account_1 = Fabricate(:account, domain: nil)
|
||||||
|
|
Loading…
Reference in a new issue