parent
30cc330747
commit
d74e20a790
7 changed files with 64 additions and 11 deletions
|
|
@ -41,6 +41,7 @@
|
|||
* Add a button to follow/unfollow tags to the mobile interface [#5941](https://github.com/diaspora/diaspora/pull/5941)
|
||||
* Add a "Manage followed tags" page to mass unfollow tags in the mobile interface [#5945](https://github.com/diaspora/diaspora/pull/5945)
|
||||
* Add popover/tooltip about email visibility to registration/settings page [#5956](https://github.com/diaspora/diaspora/pull/5956)
|
||||
* Fetch person posts on sharing request [#5960](https://github.com/diaspora/diaspora/pull/5960)
|
||||
|
||||
# 0.5.0.1
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ module Workers
|
|||
person = Webfinger.new(account).fetch
|
||||
|
||||
# also, schedule to fetch a few public posts from that person
|
||||
Workers::FetchPublicPosts.perform_async(person.diaspora_handle) unless person.nil?
|
||||
Diaspora::Fetcher::Public.queue_for(person) unless person.nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ class Request
|
|||
|
||||
user.share_with(person, user.auto_follow_back_aspect) if user.auto_follow_back && !contact.receiving
|
||||
|
||||
# also, schedule to fetch a few public posts from that person
|
||||
Diaspora::Fetcher::Public.queue_for(person)
|
||||
|
||||
self
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ module Diaspora; module Fetcher; class Public
|
|||
Status_Failed = 5
|
||||
Status_Unfetchable = 6
|
||||
|
||||
def self.queue_for(person)
|
||||
Workers::FetchPublicPosts.perform_async(person.diaspora_handle) unless person.fetch_status > Status_Initial
|
||||
end
|
||||
|
||||
# perform all actions necessary to fetch the public posts of a person
|
||||
# with the given diaspora_id
|
||||
def fetch! diaspora_id
|
||||
|
|
|
|||
|
|
@ -92,43 +92,50 @@ describe Request do
|
|||
:into => eve.aspects.first).receive(alice, eve.person)
|
||||
expect(alice.contact_for(eve.person)).to be_sharing
|
||||
end
|
||||
|
||||
|
||||
it 'shares back if auto_following is enabled' do
|
||||
alice.auto_follow_back = true
|
||||
alice.auto_follow_back_aspect = alice.aspects.first
|
||||
alice.save
|
||||
|
||||
|
||||
described_class.diaspora_initialize(:from => eve.person, :to => alice.person,
|
||||
:into => eve.aspects.first).receive(alice, eve.person)
|
||||
|
||||
|
||||
expect(eve.contact_for( alice.person )).to be_sharing
|
||||
end
|
||||
|
||||
|
||||
it 'shares not back if auto_following is not enabled' do
|
||||
alice.auto_follow_back = false
|
||||
alice.auto_follow_back_aspect = alice.aspects.first
|
||||
alice.save
|
||||
|
||||
|
||||
described_class.diaspora_initialize(:from => eve.person, :to => alice.person,
|
||||
:into => eve.aspects.first).receive(alice, eve.person)
|
||||
|
||||
|
||||
expect(eve.contact_for(alice.person)).to be_nil
|
||||
end
|
||||
|
||||
|
||||
it 'shares not back if already sharing' do
|
||||
alice.auto_follow_back = true
|
||||
alice.auto_follow_back_aspect = alice.aspects.first
|
||||
alice.save
|
||||
|
||||
|
||||
contact = FactoryGirl.build:contact, :user => alice, :person => eve.person,
|
||||
:receiving => true, :sharing => false
|
||||
contact.save
|
||||
|
||||
|
||||
expect(alice).not_to receive(:share_with)
|
||||
|
||||
|
||||
described_class.diaspora_initialize(:from => eve.person, :to => alice.person,
|
||||
:into => eve.aspects.first).receive(alice, eve.person)
|
||||
end
|
||||
|
||||
it "queue a job to fetch public posts" do
|
||||
expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times
|
||||
|
||||
described_class.diaspora_initialize(from: eve.person, to: alice.person,
|
||||
into: eve.aspects.first).receive(alice, eve.person)
|
||||
end
|
||||
end
|
||||
|
||||
context 'xml' do
|
||||
|
|
|
|||
|
|
@ -25,6 +25,24 @@ describe Diaspora::Fetcher::Public do
|
|||
}).to_return(:body => @fixture)
|
||||
end
|
||||
|
||||
describe "#queue_for" do
|
||||
it "queues a new job" do
|
||||
@person.fetch_status = Diaspora::Fetcher::Public::Status_Initial
|
||||
|
||||
expect(Workers::FetchPublicPosts).to receive(:perform_async).with(@person.diaspora_handle)
|
||||
|
||||
Diaspora::Fetcher::Public.queue_for(@person)
|
||||
end
|
||||
|
||||
it "queues no job if the status is not initial" do
|
||||
@person.fetch_status = Diaspora::Fetcher::Public::Status_Done
|
||||
|
||||
expect(Workers::FetchPublicPosts).not_to receive(:perform_async).with(@person.diaspora_handle)
|
||||
|
||||
Diaspora::Fetcher::Public.queue_for(@person)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#retrieve_posts" do
|
||||
before do
|
||||
person = @person
|
||||
|
|
|
|||
20
spec/workers/fetch_webfinger_spec.rb
Normal file
20
spec/workers/fetch_webfinger_spec.rb
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
require "spec_helper"
|
||||
|
||||
describe Workers::FetchWebfinger do
|
||||
it "should webfinger and queue a job to fetch public posts" do
|
||||
@person = FactoryGirl.create(:person)
|
||||
allow(Webfinger).to receive(:new).and_return(double(fetch: @person))
|
||||
|
||||
expect(Diaspora::Fetcher::Public).to receive(:queue_for).exactly(1).times
|
||||
|
||||
Workers::FetchWebfinger.new.perform(@person.diaspora_handle)
|
||||
end
|
||||
|
||||
it "should webfinger and queue no job to fetch public posts if the person is not found" do
|
||||
allow(Webfinger).to receive(:new).and_return(double(fetch: nil))
|
||||
|
||||
expect(Diaspora::Fetcher::Public).not_to receive(:queue_for)
|
||||
|
||||
Workers::FetchWebfinger.new.perform("unknown-person@example.net")
|
||||
end
|
||||
end
|
||||
Loading…
Reference in a new issue