Progress
This commit is contained in:
@@ -50,6 +50,7 @@
|
||||
# is_verified :boolean default(FALSE), not null
|
||||
# is_donor :boolean default(FALSE), not null
|
||||
# is_investor :boolean default(FALSE), not null
|
||||
# is_flagged_as_spam :boolean default(FALSE), not null
|
||||
#
|
||||
|
||||
class Account < ApplicationRecord
|
||||
@@ -91,7 +92,7 @@ class Account < ApplicationRecord
|
||||
scope :recent, -> { reorder(id: :desc) }
|
||||
scope :bots, -> { where(actor_type: %w(Application Service)) }
|
||||
scope :alphabetic, -> { order(domain: :asc, username: :asc) }
|
||||
scope :by_domain_accounts, -> { group(:domain).select(:domain, 'COUNT(*) AS accounts_count').order('accounts_count desc') }
|
||||
scope :by_domain_accounts, -> { group(:id).select(:domain, 'COUNT(*) AS accounts_count').order('accounts_count desc') }
|
||||
scope :matches_username, ->(value) { where(arel_table[:username].matches("#{value}%")) }
|
||||
scope :matches_display_name, ->(value) { where(arel_table[:display_name].matches("#{value}%")) }
|
||||
scope :matches_domain, ->(value) { where(arel_table[:domain].matches("%#{value}%")) }
|
||||
@@ -148,6 +149,14 @@ class Account < ApplicationRecord
|
||||
Follow.where(target_account_id: id).count
|
||||
end
|
||||
|
||||
def chat_conversation_accounts_count
|
||||
ChatConversationAccount.where(account_id: id).count
|
||||
end
|
||||
|
||||
def chat_messages_count
|
||||
ChatMessage.where(from_account_id: id).count
|
||||
end
|
||||
|
||||
def silenced?
|
||||
silenced_at.present?
|
||||
end
|
||||
|
||||
@@ -101,7 +101,7 @@ class AccountConversation < ApplicationRecord
|
||||
end
|
||||
|
||||
def subscribed_to_timeline?
|
||||
Redis.current.exists("subscribed:#{streaming_channel}")
|
||||
Redis.current.exists?("subscribed:#{streaming_channel}")
|
||||
end
|
||||
|
||||
def streaming_channel
|
||||
|
||||
@@ -17,15 +17,26 @@
|
||||
#
|
||||
|
||||
# : todo : expires
|
||||
# : todo : max per account
|
||||
class ChatConversationAccount < ApplicationRecord
|
||||
include Paginable
|
||||
|
||||
PER_ACCOUNT_APPROVED_LIMIT = 100
|
||||
|
||||
EXPIRATION_POLICY_MAP = {
|
||||
none: nil,
|
||||
five_minutes: '1',
|
||||
sixty_minutes: '2',
|
||||
six_hours: '3',
|
||||
one_day: '4',
|
||||
three_days: '5',
|
||||
one_week: '6',
|
||||
}.freeze
|
||||
|
||||
belongs_to :account
|
||||
belongs_to :chat_conversation
|
||||
belongs_to :last_chat_message, class_name: 'ChatMessage', optional: true
|
||||
|
||||
# before_validation :set_last_chat_message
|
||||
|
||||
def participant_accounts
|
||||
if participant_account_ids.empty?
|
||||
[account]
|
||||
@@ -35,10 +46,4 @@ class ChatConversationAccount < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_last_chat_message
|
||||
self.last_chat_message_id = nil # : todo :
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class HomeFeed < Feed
|
||||
end
|
||||
|
||||
def get(limit, max_id = nil, since_id = nil, min_id = nil)
|
||||
if redis.exists("account:#{@account.id}:regeneration")
|
||||
if redis.exists?("account:#{@account.id}:regeneration")
|
||||
from_database(limit, max_id, since_id, min_id)
|
||||
else
|
||||
super
|
||||
@@ -18,6 +18,7 @@ class HomeFeed < Feed
|
||||
private
|
||||
|
||||
def from_database(limit, max_id, since_id, min_id)
|
||||
puts "tilly from_database"
|
||||
Status.as_home_timeline(@account)
|
||||
.paginate_by_id(limit, max_id: max_id, since_id: since_id, min_id: min_id)
|
||||
.reject { |status| FeedManager.instance.filter?(:home, status, @account.id) }
|
||||
|
||||
@@ -18,9 +18,13 @@ class LinkBlock < ApplicationRecord
|
||||
return false if text.nil?
|
||||
return false if text.length < 1
|
||||
|
||||
urls = text.scan(FetchLinkCardService::URL_PATTERN).map { |array| Addressable::URI.parse(array[0]).normalize }
|
||||
urls = text.scan(FetchLinkCardService::URL_PATTERN).map {|array|
|
||||
Addressable::URI.parse(array[0]).normalize
|
||||
}
|
||||
url = urls.first
|
||||
link_for_fetch = TagManager.instance.normalize_link(url)
|
||||
where(link: link_for_fetch).exists?
|
||||
link_for_fetch = link_for_fetch.chomp("/")
|
||||
|
||||
where("LOWER(link) LIKE LOWER(?)", "%#{link_for_fetch}%").exists?
|
||||
end
|
||||
end
|
||||
@@ -3,22 +3,23 @@
|
||||
#
|
||||
# Table name: media_attachments
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# status_id :bigint(8)
|
||||
# file_file_name :string
|
||||
# file_content_type :string
|
||||
# file_file_size :integer
|
||||
# file_updated_at :datetime
|
||||
# remote_url :string default(""), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# shortcode :string
|
||||
# type :integer default("image"), not null
|
||||
# file_meta :json
|
||||
# account_id :bigint(8)
|
||||
# description :text
|
||||
# scheduled_status_id :bigint(8)
|
||||
# blurhash :string
|
||||
# id :bigint(8) not null, primary key
|
||||
# status_id :bigint(8)
|
||||
# file_file_name :string
|
||||
# file_content_type :string
|
||||
# file_file_size :integer
|
||||
# file_updated_at :datetime
|
||||
# remote_url :string default(""), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# shortcode :string
|
||||
# type :integer default("image"), not null
|
||||
# file_meta :json
|
||||
# account_id :bigint(8)
|
||||
# description :text
|
||||
# scheduled_status_id :bigint(8)
|
||||
# blurhash :string
|
||||
# media_attachment_album_id :bigint(8)
|
||||
#
|
||||
|
||||
class MediaAttachment < ApplicationRecord
|
||||
|
||||
25
app/models/media_attachment_album.rb
Normal file
25
app/models/media_attachment_album.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
# frozen_string_literal: true
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: media_attachment_albums
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# title :text default(""), not null
|
||||
# description :text
|
||||
# account_id :integer not null
|
||||
# visibility :integer default("public"), not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# cover_id :bigint(8)
|
||||
#
|
||||
|
||||
class MediaAttachmentAlbum < ApplicationRecord
|
||||
|
||||
enum visibility: [
|
||||
:public,
|
||||
:private,
|
||||
], _suffix: :visibility
|
||||
|
||||
belongs_to :account
|
||||
|
||||
end
|
||||
@@ -290,13 +290,13 @@ class Status < ApplicationRecord
|
||||
end
|
||||
|
||||
def as_home_timeline(account)
|
||||
query = where('created_at > ?', 5.days.ago)
|
||||
query = where('created_at > ?', 10.days.ago)
|
||||
query.where(visibility: [:public, :unlisted, :private])
|
||||
query.where(account: [account] + account.following).without_replies
|
||||
end
|
||||
|
||||
def as_group_timeline(group)
|
||||
query = where('created_at > ?', 5.days.ago)
|
||||
query = where('created_at > ?', 10.days.ago)
|
||||
query.where(group: group).without_replies
|
||||
end
|
||||
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
#
|
||||
# Table name: status_bookmarks
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint(8) not null
|
||||
# status_id :bigint(8) not null
|
||||
# id :bigint(8) not null, primary key
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
# account_id :bigint(8) not null
|
||||
# status_id :bigint(8) not null
|
||||
# status_bookmark_collection_id :bigint(8)
|
||||
#
|
||||
|
||||
class StatusBookmark < ApplicationRecord
|
||||
|
||||
19
app/models/status_bookmark_collection.rb
Normal file
19
app/models/status_bookmark_collection.rb
Normal file
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
# == Schema Information
|
||||
#
|
||||
# Table name: status_bookmark_collections
|
||||
#
|
||||
# id :bigint(8) not null, primary key
|
||||
# title :text default(""), not null
|
||||
# account_id :integer not null
|
||||
# created_at :datetime not null
|
||||
# updated_at :datetime not null
|
||||
#
|
||||
|
||||
class StatusBookmarkCollection < ApplicationRecord
|
||||
|
||||
PER_ACCOUNT_LIMIT = 100
|
||||
|
||||
belongs_to :account
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user