about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--Gemfile2
-rw-r--r--Gemfile.lock4
-rw-r--r--app/models/concerns/account_associations.rb9
-rw-r--r--app/models/destructing_status.rb15
-rw-r--r--app/models/publishing_delay.rb14
-rw-r--r--app/models/queued_boost.rb15
-rw-r--r--app/models/status.rb3
-rw-r--r--app/models/user.rb4
-rw-r--r--db/migrate/20200731163700_create_destructing_statuses.rb11
-rw-r--r--db/migrate/20200731205913_create_queued_boosts.rb10
-rw-r--r--db/migrate/20200731211100_create_publishing_delays.rb10
-rw-r--r--db/schema.rb29
12 files changed, 124 insertions, 2 deletions
diff --git a/Gemfile b/Gemfile
index 4b74a1f73..a72bf5453 100644
--- a/Gemfile
+++ b/Gemfile
@@ -163,3 +163,5 @@ gem 'concurrent-ruby', require: false
 gem 'connection_pool', require: false
 
 gem "reek", "~> 6.0", :group => :development
+
+gem "w3c_validators", "~> 1.3"
diff --git a/Gemfile.lock b/Gemfile.lock
index c7c1372ef..bc90e6530 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -634,6 +634,9 @@ GEM
     unf_ext (0.0.7.7)
     unicode-display_width (1.7.0)
     uniform_notifier (1.13.0)
+    w3c_validators (1.3.5)
+      json (>= 1.8)
+      nokogiri (~> 1.6)
     warden (1.2.8)
       rack (>= 2.0.6)
     webmock (3.8.3)
@@ -785,6 +788,7 @@ DEPENDENCIES
   tty-prompt (~> 0.22)
   twitter-text (~> 1.14)
   tzinfo-data (~> 1.2020)
+  w3c_validators (~> 1.3)
   webmock (~> 3.8)
   webpacker (~> 5.1)
   webpush
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
diff --git a/db/migrate/20200731163700_create_destructing_statuses.rb b/db/migrate/20200731163700_create_destructing_statuses.rb
new file mode 100644
index 000000000..4923eb393
--- /dev/null
+++ b/db/migrate/20200731163700_create_destructing_statuses.rb
@@ -0,0 +1,11 @@
+class CreateDestructingStatuses < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    create_table :destructing_statuses do |t|
+      t.references :status, null: false, unique: true, foreign_key: { on_delete: :cascade }
+      t.datetime :after, null: false, index: { algorithm: :concurrently }
+      t.boolean :defederate_only, null: false, default: false
+    end
+  end
+end
diff --git a/db/migrate/20200731205913_create_queued_boosts.rb b/db/migrate/20200731205913_create_queued_boosts.rb
new file mode 100644
index 000000000..33ddbb966
--- /dev/null
+++ b/db/migrate/20200731205913_create_queued_boosts.rb
@@ -0,0 +1,10 @@
+class CreateQueuedBoosts < ActiveRecord::Migration[5.2]
+  def change
+    create_table :queued_boosts do |t|
+      t.references :account, null: false, foreign_key: { on_delete: :cascade }
+      t.references :status, null: false, foreign_key: { on_delete: :cascade }
+    end
+
+    add_index :queued_boosts, [:account_id, :status_id], unique: true
+  end
+end
diff --git a/db/migrate/20200731211100_create_publishing_delays.rb b/db/migrate/20200731211100_create_publishing_delays.rb
new file mode 100644
index 000000000..9561ca0b2
--- /dev/null
+++ b/db/migrate/20200731211100_create_publishing_delays.rb
@@ -0,0 +1,10 @@
+class CreatePublishingDelays < ActiveRecord::Migration[5.2]
+  disable_ddl_transaction!
+
+  def change
+    create_table :publishing_delays do |t|
+      t.references :status, null: false, unique: true, foreign_key: { on_delete: :cascade }
+      t.datetime :after, index: { algorithm: :concurrently }
+    end
+  end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 06d012600..5e0bf0b13 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -10,7 +10,7 @@
 #
 # It's strongly recommended that you check this file into your version control system.
 
-ActiveRecord::Schema.define(version: 2020_07_31_135033) do
+ActiveRecord::Schema.define(version: 2020_07_31_211100) do
 
   # These are extensions that must be enabled in order to support this database
   enable_extension "plpgsql"
@@ -347,6 +347,14 @@ ActiveRecord::Schema.define(version: 2020_07_31_135033) do
     t.index ["account_id"], name: "index_custom_filters_on_account_id"
   end
 
+  create_table "destructing_statuses", force: :cascade do |t|
+    t.bigint "status_id", null: false
+    t.datetime "after", null: false
+    t.boolean "defederate_only", default: false, null: false
+    t.index ["after"], name: "index_destructing_statuses_on_after"
+    t.index ["status_id"], name: "index_destructing_statuses_on_status_id"
+  end
+
   create_table "devices", force: :cascade do |t|
     t.bigint "access_token_id"
     t.bigint "account_id"
@@ -703,6 +711,21 @@ ActiveRecord::Schema.define(version: 2020_07_31_135033) do
     t.index ["status_id", "preview_card_id"], name: "index_preview_cards_statuses_on_status_id_and_preview_card_id"
   end
 
+  create_table "publishing_delays", force: :cascade do |t|
+    t.bigint "status_id", null: false
+    t.datetime "after"
+    t.index ["after"], name: "index_publishing_delays_on_after"
+    t.index ["status_id"], name: "index_publishing_delays_on_status_id"
+  end
+
+  create_table "queued_boosts", force: :cascade do |t|
+    t.bigint "account_id", null: false
+    t.bigint "status_id", null: false
+    t.index ["account_id", "status_id"], name: "index_queued_boosts_on_account_id_and_status_id", unique: true
+    t.index ["account_id"], name: "index_queued_boosts_on_account_id"
+    t.index ["status_id"], name: "index_queued_boosts_on_status_id"
+  end
+
   create_table "relays", force: :cascade do |t|
     t.string "inbox_url", default: "", null: false
     t.string "follow_activity_id"
@@ -1011,6 +1034,7 @@ ActiveRecord::Schema.define(version: 2020_07_31_135033) do
   add_foreign_key "conversation_mutes", "conversations", on_delete: :cascade
   add_foreign_key "conversations", "accounts"
   add_foreign_key "custom_filters", "accounts", on_delete: :cascade
+  add_foreign_key "destructing_statuses", "statuses", on_delete: :cascade
   add_foreign_key "devices", "accounts", on_delete: :cascade
   add_foreign_key "devices", "oauth_access_tokens", column: "access_token_id", on_delete: :cascade
   add_foreign_key "email_domain_blocks", "email_domain_blocks", column: "parent_id", on_delete: :cascade
@@ -1053,6 +1077,9 @@ ActiveRecord::Schema.define(version: 2020_07_31_135033) do
   add_foreign_key "poll_votes", "polls", on_delete: :cascade
   add_foreign_key "polls", "accounts", on_delete: :cascade
   add_foreign_key "polls", "statuses", on_delete: :cascade
+  add_foreign_key "publishing_delays", "statuses", on_delete: :cascade
+  add_foreign_key "queued_boosts", "accounts", on_delete: :cascade
+  add_foreign_key "queued_boosts", "statuses", on_delete: :cascade
   add_foreign_key "report_notes", "accounts", on_delete: :cascade
   add_foreign_key "report_notes", "reports", on_delete: :cascade
   add_foreign_key "reports", "accounts", column: "action_taken_by_account_id", name: "fk_bca45b75fd", on_delete: :nullify