Module: SocialStream::Ostatus::Models::Contact

Extended by:
ActiveSupport::Concern
Defined in:
lib/social_stream/ostatus/models/contact.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#unset_follow_action_with_salmon(relation) ⇒ Object

Send Salmon notification

FIXME DRY with activity.rb



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
# File 'lib/social_stream/ostatus/models/contact.rb', line 31

def unset_follow_action_with_salmon(relation)
  unset_follow_action_without_salmon(relation)

  return if sender.subject_type == "RemoteSubject" ||
              receiver.subject_type != "RemoteSubject"

  title = I18n.t "activity.stream.title.unfollow",
                 author: sender_subject.name,
                 activity_object: receiver_subject.name

  entry =
    Proudhon::Entry.new id: "tag:#{ SocialStream::Ostatus.activity_feed_host },2005:contact-destroy-#{ id }",
                        title: title,
                        content: title,
                        verb: 'http://ostatus.org/schema/1.0/unfollow',
                        author: Proudhon::Author.new(name: sender.name,
                                                     uri: sender.webfinger_uri)
  salmon = entry.to_salmon

  if SocialStream::Ostatus.debug_requests
    logger.info entry.to_xml
  end

  # FIXME: Rails 4 queues
  Thread.new do
    salmon.deliver receiver_subject.salmon_url, sender.rsa_key

    ActiveRecord::Base.connection.close
  end
end