]> cat aescling's git repositories - mastodon.git/commitdiff
When posting a status or reblogging one, ping hubs about the feed update
authorEugen Rochko <eugen@zeonfederated.com>
Sun, 28 Feb 2016 13:33:13 +0000 (14:33 +0100)
committerEugen Rochko <eugen@zeonfederated.com>
Sun, 28 Feb 2016 13:33:13 +0000 (14:33 +0100)
app/models/account.rb
app/services/post_status_service.rb
app/services/reblog_service.rb
spec/models/account_spec.rb

index f1ac6fdd76d7883e09b049e81bcb587df7f5a0f3..e9fc03a1003b6ff08cc61d66869189e4edb49d3e 100644 (file)
@@ -65,6 +65,11 @@ class Account < ActiveRecord::Base
     @subscription ||= OStatus2::Subscription.new(self.remote_url, secret: self.secret, token: self.verify_token, webhook: webhook_url, hub: self.hub_url)
   end
 
+  def ping!(atom_url, hubs)
+    return unless local?
+    OStatus2::Publication.new(atom_url, hubs).publish
+  end
+
   def avatar_remote_url=(url)
     self.avatar = URI.parse(url)
     @avatar_remote_url = url
index 17cc8e32313d2b5626396b9d7dba954ff5c29622..64519a4003d155184733107cf6a1f326e8802226 100644 (file)
@@ -7,6 +7,7 @@ class PostStatusService < BaseService
   def call(account, text, in_reply_to = nil)
     status = account.statuses.create!(text: text, thread: in_reply_to)
     process_mentions_service.(status)
+    account.ping!(atom_user_stream_url(id: account.id), HUB_URL)
     status
   end
 
index 000ed8ee673338e4658013ce1af105f5c3b2eb51..66b7634fb085e020abda8e1124cd6b997178a355 100644 (file)
@@ -5,6 +5,7 @@ class ReblogService < BaseService
   # @return [Status]
   def call(account, reblogged_status)
     reblog = account.statuses.create!(reblog: reblogged_status, text: '')
+    account.ping!(atom_user_stream_url(id: account.id), HUB_URL)
     return reblog if reblogged_status.local?
     send_interaction_service.(reblog.stream_entry, reblogged_status.account)
     reblog
index a5f24a990538521dc42fd33c17a96b58039139ce..562989335a21d2c0a0fc4916012153e20c8418c1 100644 (file)
@@ -107,4 +107,8 @@ RSpec.describe Account, type: :model do
       expect(subject.content).to eql subject.note
     end
   end
+
+  describe '#ping!' do
+    pending
+  end
 end