Browse Source

When posting a status or reblogging one, ping hubs about the feed update

closed-social-glitch-2
Eugen Rochko 8 years ago
parent
commit
8fada4fae2
4 changed files with 11 additions and 0 deletions
  1. +5
    -0
      app/models/account.rb
  2. +1
    -0
      app/services/post_status_service.rb
  3. +1
    -0
      app/services/reblog_service.rb
  4. +4
    -0
      spec/models/account_spec.rb

+ 5
- 0
app/models/account.rb View 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

+ 1
- 0
app/services/post_status_service.rb View 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

+ 1
- 0
app/services/reblog_service.rb View 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

+ 4
- 0
spec/models/account_spec.rb View 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

Loading…
Cancel
Save