Module: NewsmastMastodon::Concerns::DraftStatusService

Extended by:
ActiveSupport::Concern
Defined in:
app/services/newsmast_mastodon/concerns/draft_status_service.rb

Instance Method Summary collapse

Instance Method Details

#call(account, options = {}) ⇒ Status

Post a text status update, fetch and notify remote users mentioned

Parameters:

  • account (Account)

    Account from which to post

  • options (Hash) (defaults to: {})
  • [String] (Hash)

    a customizable set of options

  • [Status] (Hash)

    a customizable set of options

  • [Boolean] (Hash)

    a customizable set of options

  • [Hash] (Hash)

    a customizable set of options

  • [Enumerable] (Hash)

    a customizable set of options

  • [Doorkeeper::Application] (Hash)

    a customizable set of options

Returns:

  • (Status)


29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/services/newsmast_mastodon/concerns/draft_status_service.rb', line 29

def call(, options = {})
  @account     = 
  @options     = options
  @text        = @options[:text] || ''
  @in_reply_to = @options[:thread]
  @quoted_status = @options[:quoted_status]

  return idempotency_duplicate if idempotency_given? && idempotency_duplicate?

  validate_media!
  preprocess_attributes!

  if scheduled?
    schedule_status!
  elsif drafted?
    draft_status!
  else
    process_status!
  end

  redis.setex(idempotency_key, 3_600, @status.id) if idempotency_given?

  unless scheduled? || drafted?
    postprocess_status!
    bump_potential_friendship!
  end

  @status
rescue => e
  if defined?(Antispam::SilentlyDrop) && e.is_a?(Antispam::SilentlyDrop)
    e.status
  else
    raise
  end
end