about summary refs log blame commit diff
path: root/app/models/concerns/streamable.rb
blob: 7c9edb8ef8f6f89cd5f40d842a2d89497d69b081 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
                             




                                        
                                                                                            
       
     
 

           
 

             
 

            
 

                 
 

            
 

             
 


                         
     
# frozen_string_literal: true

module Streamable
  extend ActiveSupport::Concern

  included do
    has_one :stream_entry, as: :activity

    after_create do
      account.stream_entries.create!(activity: self, hidden: hidden?) if needs_stream_entry?
    end
  end

  def title
    super
  end

  def content
    title
  end

  def target
    super
  end

  def object_type
    :activity
  end

  def thread
    super
  end

  def hidden?
    false
  end

  private

  def needs_stream_entry?
    account.local?
  end
end