From 25d628fca314aebb25e3976f006cc96629a3d780 Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Wed, 24 Jul 2019 13:01:12 -0500 Subject: revert the current unfinished chat implementation --- app/models/account.rb | 10 ---------- app/models/chat_account.rb | 17 ----------------- app/models/status.rb | 9 ++------- app/models/tag.rb | 9 ++------- 4 files changed, 4 insertions(+), 41 deletions(-) delete mode 100644 app/models/chat_account.rb (limited to 'app/models') diff --git a/app/models/account.rb b/app/models/account.rb index 068b5e7a0..efa6b8fbd 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -48,7 +48,6 @@ # adult_content :boolean default(FALSE), not null # silenced_at :datetime # suspended_at :datetime -# supports_chat :boolean default(FALSE), not null # gently :boolean default(FALSE), not null # kobold :boolean default(FALSE), not null # froze :boolean @@ -75,9 +74,6 @@ class Account < ApplicationRecord LOCAL_DOMAINS = ENV.fetch('LOCAL_DOMAINS', '').chomp.split(/\.?\s+/).freeze - has_many :chat_accounts, dependent: :destroy, inverse_of: :account - has_many :chat_tags, through: :chat_accounts, source: :tag - validates :username, presence: true # Remote user validations @@ -559,7 +555,6 @@ class Account < ApplicationRecord before_create :generate_keys before_create :set_domain_from_inbox_url - before_create :set_chat_support before_validation :prepare_contents, if: :local? before_validation :prepare_username, on: :create before_destroy :clean_feed_manager @@ -582,11 +577,6 @@ class Account < ApplicationRecord nil end - def set_chat_support - return unless local? - self.supports_chat = true - end - def generate_keys return unless local? && !Rails.env.test? diff --git a/app/models/chat_account.rb b/app/models/chat_account.rb deleted file mode 100644 index 41589a395..000000000 --- a/app/models/chat_account.rb +++ /dev/null @@ -1,17 +0,0 @@ -# == Schema Information -# -# Table name: chat_accounts -# -# id :bigint(8) not null, primary key -# account_id :bigint(8) not null -# tag_id :bigint(8) not null -# created_at :datetime not null -# updated_at :datetime not null -# - -class ChatAccount < ApplicationRecord - belongs_to :account, inverse_of: :chat_accounts - belongs_to :tag, inverse_of: :chat_accounts - - validates :account_id, uniqueness: { scope: :tag_id } -end diff --git a/app/models/status.rb b/app/models/status.rb index 946958758..a8c53d930 100644 --- a/app/models/status.rb +++ b/app/models/status.rb @@ -52,7 +52,7 @@ class Status < ApplicationRecord update_index('statuses#status', :proper) if Chewy.enabled? - enum visibility: [:public, :unlisted, :private, :direct, :limited, :local, :chat], _suffix: :visibility + enum visibility: [:public, :unlisted, :private, :direct, :limited, :local], _suffix: :visibility belongs_to :application, class_name: 'Doorkeeper::Application', optional: true @@ -104,7 +104,7 @@ class Status < ApplicationRecord scope :reblogs, -> { where('statuses.reblog_of_id IS NOT NULL') } # all reblogs scope :with_public_visibility, -> { where(visibility: :public) } scope :public_local_visibility, -> { where(visibility: [:public, :local]) } - scope :public_browsable, -> { where(visibility: [:public, :unlisted, :local, :chat]) } + scope :public_browsable, -> { where(visibility: [:public, :unlisted, :local]) } scope :tagged_with, ->(tag) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag }) } scope :excluding_silenced_accounts, -> { left_outer_joins(:account).where(accounts: { silenced_at: nil }) } scope :including_silenced_accounts, -> { left_outer_joins(:account).where.not(accounts: { silenced_at: nil }) } @@ -262,11 +262,6 @@ class Status < ApplicationRecord @emojis = CustomEmoji.from_text(fields.join(' '), account.domain) end - def chat_tags - return @chat_tags if defined?(@chat_tags) - @chat_tags = tags.only_chat - end - def delete_after destructing_status&.delete_after end diff --git a/app/models/tag.rb b/app/models/tag.rb index 858f674c3..87894a7b2 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -10,7 +10,6 @@ # local :boolean default(FALSE), not null # private :boolean default(FALSE), not null # unlisted :boolean default(FALSE), not null -# chat :boolean default(FALSE), not null # class Tag < ApplicationRecord @@ -19,8 +18,6 @@ class Tag < ApplicationRecord has_and_belongs_to_many :sample_accounts, -> { searchable.discoverable.popular.limit(3) }, class_name: 'Account' has_many :featured_tags, dependent: :destroy, inverse_of: :tag - has_many :chat_accounts, dependent: :destroy, inverse_of: :tag - has_many :chatters, through: :chat_accounts, source: :account has_one :account_tag_stat, dependent: :destroy @@ -37,7 +34,6 @@ class Tag < ApplicationRecord scope :only_global, -> { where(local: false, unlisted: false) } scope :only_private, -> { where(private: true) } scope :only_unlisted, -> { where(unlisted: true) } - scope :only_chat, -> { where(chat: true) } scope :only_public, -> { where(unlisted: false) } delegate :accounts_count, @@ -109,9 +105,8 @@ class Tag < ApplicationRecord def set_scope self.private = true if name.in?(%w(self .self)) || name.starts_with?('self.', '.self.') self.unlisted = true if self.private || name.starts_with?('.') - self.chat = true if name.starts_with?('chat.', '.chat') self.local = true if self.private || - name.in?(%w(local .local chat.local .chat.local)) || - name.starts_with?('local.', '.local', 'chat.local.' '.chat.local') + name.in?(%w(local .local)) || + name.starts_with?('local.', '.local') end end -- cgit