about summary refs log tree commit diff
path: root/app/models/concerns/streamable.rb
blob: 910736dac6ac362976cb3f03192076b3961d5e21 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# frozen_string_literal: true

module Streamable
  extend ActiveSupport::Concern

  included do
    has_one :stream_entry, as: :activity

    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

    def needs_stream_entry?
      account.local?
    end

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