From 52b500e482180b20bb988c09c07c39a492512c31 Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Fri, 31 Jul 2020 21:39:29 -0500 Subject: [Feature, Database] Add migrations and models for queued boosts, delayed publishing, and self-destructing posts --- app/models/concerns/account_associations.rb | 9 +++++++++ app/models/destructing_status.rb | 15 +++++++++++++++ app/models/publishing_delay.rb | 14 ++++++++++++++ app/models/queued_boost.rb | 15 +++++++++++++++ app/models/status.rb | 3 +++ app/models/user.rb | 4 +++- 6 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 app/models/destructing_status.rb create mode 100644 app/models/publishing_delay.rb create mode 100644 app/models/queued_boost.rb (limited to 'app/models') diff --git a/app/models/concerns/account_associations.rb b/app/models/concerns/account_associations.rb index 5a54f2208..14f64cb71 100644 --- a/app/models/concerns/account_associations.rb +++ b/app/models/concerns/account_associations.rb @@ -69,5 +69,14 @@ module AccountAssociations # Custom metadata has_one :metadata, class_name: 'AccountMetadata', inverse_of: :account, dependent: :destroy + + # Delayed posts + has_many :publishing_delays, inverse_of: :account, dependent: :destroy + + # Self-destructing posts + has_many :destructing_statuses, inverse_of: :account, dependent: :destroy + + # Queued boosts + has_many :queued_boosts, inverse_of: :account, dependent: :destroy end end diff --git a/app/models/destructing_status.rb b/app/models/destructing_status.rb new file mode 100644 index 000000000..70bfc28d2 --- /dev/null +++ b/app/models/destructing_status.rb @@ -0,0 +1,15 @@ +# == Schema Information +# +# Table name: destructing_statuses +# +# id :bigint(8) not null, primary key +# status_id :bigint(8) not null +# after :datetime not null +# defederate_only :boolean default(FALSE), not null +# + +class DestructingStatus < ApplicationRecord + belongs_to :status, inverse_of: :destruct + + validates :status_id, uniqueness: true +end diff --git a/app/models/publishing_delay.rb b/app/models/publishing_delay.rb new file mode 100644 index 000000000..7b4d4c214 --- /dev/null +++ b/app/models/publishing_delay.rb @@ -0,0 +1,14 @@ +# == Schema Information +# +# Table name: publishing_delays +# +# id :bigint(8) not null, primary key +# status_id :bigint(8) not null +# after :datetime +# + +class PublishingDelay < ApplicationRecord + belongs_to :status, inverse_of: :destruct + + validates :status_id, uniqueness: true +end diff --git a/app/models/queued_boost.rb b/app/models/queued_boost.rb new file mode 100644 index 000000000..6eca3725f --- /dev/null +++ b/app/models/queued_boost.rb @@ -0,0 +1,15 @@ +# == Schema Information +# +# Table name: queued_boosts +# +# id :bigint(8) not null, primary key +# account_id :bigint(8) not null +# status_id :bigint(8) not null +# + +class QueuedBoost < ApplicationRecord + belongs_to :account, inverse_of: :queued_boosts + belongs_to :status, inverse_of: :queued_boosts + + validates :account_id, uniqueness: { scope: :status_id } +end diff --git a/app/models/status.rb b/app/models/status.rb index 7016476c0..5c58917bc 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -77,6 +77,9 @@ class Status < ApplicationRecord has_many :mutes, class_name: 'StatusMute', inverse_of: :status, dependent: :destroy belongs_to :conversation_mute, primary_key: 'conversation_id', foreign_key: 'conversation_id', inverse_of: :conversation, dependent: :destroy, optional: true has_many :domain_permissions, class_name: 'StatusDomainPermission', inverse_of: :status, dependent: :destroy + has_one :publishing_delay, inverse_of: :status, dependent: :destroy + has_one :destruct, class_name: 'DestructingStatus', inverse_of: :status, dependent: :destroy + has_many :queued_boosts, inverse_of: :status, dependent: :destroy has_and_belongs_to_many :tags has_and_belongs_to_many :preview_cards diff --git a/app/models/user.rb b/app/models/user.rb index 129cb822d..0ed133079 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -114,7 +114,9 @@ class User < ApplicationRecord :expand_spoilers, :default_language, :aggregate_reblogs, :show_application, :advanced_layout, :use_blurhash, :use_pending_items, :trends, :crop_images, :default_content_type, :system_emoji_font, - :manual_publish, :style_dashed_nest, :style_underline_a, + :manual_publish, :style_dashed_nest, :style_underline_a, :style_css_profile, + :style_css_profile_errors, :style_css_webapp, :style_css_webapp_errors, + :publish_in, to: :settings, prefix: :setting, allow_nil: false attr_reader :invite_code, :sign_in_token_attempt -- cgit