module SocialStream::Ostatus::Models::Contact

Public Instance Methods

unset_follow_action_with_salmon(relation) click to toggle source

Send Salmon notification

FIXME DRY with activity.rb

# 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