Skip to content

Commit

Permalink
Fetch only non blocked pesons
Browse files Browse the repository at this point in the history
  • Loading branch information
tclaus committed Jun 15, 2021
1 parent dc4483a commit e14f182
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
8 changes: 3 additions & 5 deletions Gemfile
Expand Up @@ -251,7 +251,9 @@ group :development do
gem "rubocop", "0.93.1", require: false
gem "rubocop-rails", "2.9.1", require: false


# Debugging
gem "pry"
gem "pry-byebug"

# test coverage
gem "simplecov", "0.21.2", require: false
Expand Down Expand Up @@ -303,8 +305,4 @@ group :development, :test do

# For `assigns` in controller specs
gem "rails-controller-testing", "1.0.4"

# Debugging
gem "pry"
gem "pry-byebug"
end
6 changes: 4 additions & 2 deletions config/initializers/diaspora_federation.rb
Expand Up @@ -15,7 +15,7 @@
config.define_callbacks do
on :fetch_person_for_webfinger do |diaspora_id|
person = Person.where(diaspora_handle: diaspora_id, closed_account: false).where.not(owner: nil).first
if person
unless person.nil? || person.closed_account?
DiasporaFederation::Discovery::WebFinger.new(
{
acct_uri: "acct:#{person.diaspora_handle}",
Expand All @@ -39,7 +39,7 @@

on :fetch_person_for_hcard do |guid|
person = Person.where(guid: guid, closed_account: false).where.not(owner: nil).take
if person
unless person.nil? || person.closed_account?
DiasporaFederation::Discovery::HCard.new(
guid: person.guid,
nickname: person.username,
Expand Down Expand Up @@ -111,13 +111,15 @@
when DiasporaFederation::Entities::Retraction
Diaspora::Federation::Receive.retraction(entity, recipient_id)
else
# TODO: Check for person.closed_account? when merging with #8228 'Block Pod'
persisted = Diaspora::Federation::Receive.perform(entity)
Workers::ReceiveLocal.perform_async(persisted.class.to_s, persisted.id, [recipient_id].compact) if persisted
end
end

on :fetch_public_entity do |entity_type, guid|
entity = Diaspora::Federation::Mappings.model_class_for(entity_type).all_public.find_by(guid: guid)
# TODO: Check for person.closed_account? when merging with #8228 'Block Pod'
case entity
when Post
Diaspora::Federation::Entities.post(entity)
Expand Down
1 change: 0 additions & 1 deletion spec/federation_callbacks_spec.rb
Expand Up @@ -364,7 +364,6 @@
it "receives a entity" do
received = Fabricate(:status_message_entity, author: remote_person.diaspora_handle)
persisted = FactoryBot.create(:status_message)
byebug
expect(Diaspora::Federation::Receive).to receive(:perform).with(received).and_return(persisted)
expect(Workers::ReceiveLocal).to receive(:perform_async).with(persisted.class.to_s, persisted.id, [])

Expand Down

0 comments on commit e14f182

Please sign in to comment.