|
|
@ -1,4 +1,5 @@ |
|
|
|
# frozen_string_literal: true |
|
|
|
# frozen_string_literal: true |
|
|
|
|
|
|
|
|
|
|
|
# == Schema Information |
|
|
|
# == Schema Information |
|
|
|
# |
|
|
|
# |
|
|
|
# Table name: stream_entries |
|
|
|
# Table name: stream_entries |
|
|
@ -26,6 +27,10 @@ class StreamEntry < ApplicationRecord |
|
|
|
default_scope { where(activity_type: 'Status') } |
|
|
|
default_scope { where(activity_type: 'Status') } |
|
|
|
scope :with_includes, -> { includes(:account, status: STATUS_INCLUDES) } |
|
|
|
scope :with_includes, -> { includes(:account, status: STATUS_INCLUDES) } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delegate :target, :title, :content, :thread, |
|
|
|
|
|
|
|
to: :status, |
|
|
|
|
|
|
|
allow_nil: true |
|
|
|
|
|
|
|
|
|
|
|
def object_type |
|
|
|
def object_type |
|
|
|
orphaned? || targeted? ? :activity : status.object_type |
|
|
|
orphaned? || targeted? ? :activity : status.object_type |
|
|
|
end |
|
|
|
end |
|
|
@ -38,26 +43,10 @@ class StreamEntry < ApplicationRecord |
|
|
|
[:follow, :request_friend, :authorize, :reject, :unfollow, :block, :unblock, :share, :favorite].include? verb |
|
|
|
[:follow, :request_friend, :authorize, :reject, :unfollow, :block, :unblock, :share, :favorite].include? verb |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def target |
|
|
|
|
|
|
|
orphaned? ? nil : status.target |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def title |
|
|
|
|
|
|
|
orphaned? ? nil : status.title |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def content |
|
|
|
|
|
|
|
orphaned? ? nil : status.content |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def threaded? |
|
|
|
def threaded? |
|
|
|
(verb == :favorite || object_type == :comment) && !thread.nil? |
|
|
|
(verb == :favorite || object_type == :comment) && !thread.nil? |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def thread |
|
|
|
|
|
|
|
orphaned? ? nil : status.thread |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def mentions |
|
|
|
def mentions |
|
|
|
orphaned? ? [] : status.mentions.map(&:account) |
|
|
|
orphaned? ? [] : status.mentions.map(&:account) |
|
|
|
end |
|
|
|
end |
|
|
|