Don't raise when the public key of a person is "broken"
Breaking a public key of a person can be used to "block" receiving posts from this person on the pod. So we should handle that case better and not just trigger many retries for something that will fail again. closes #7448
This commit is contained in:
parent
7d9c6c85bd
commit
02b4d3f347
4 changed files with 17 additions and 2 deletions
|
|
@ -7,6 +7,7 @@
|
|||
* Make photo upload button hover text translatable [#7429](https://github.com/diaspora/diaspora/pull/7429)
|
||||
* Fix first comment in mobile view with french locale [#7441](https://github.com/diaspora/diaspora/pull/7441)
|
||||
* Use post page title and post author in atom feed [#7420](https://github.com/diaspora/diaspora/pull/7420)
|
||||
* Handle broken public keys when receiving posts [#7448](https://github.com/diaspora/diaspora/pull/7448)
|
||||
|
||||
## Features
|
||||
|
||||
|
|
|
|||
|
|
@ -229,6 +229,8 @@ class Person < ActiveRecord::Base
|
|||
|
||||
def public_key
|
||||
OpenSSL::PKey::RSA.new(serialized_public_key)
|
||||
rescue OpenSSL::PKey::RSAError
|
||||
nil
|
||||
end
|
||||
|
||||
def exported_key
|
||||
|
|
|
|||
|
|
@ -72,8 +72,7 @@ DiasporaFederation.configure do |config|
|
|||
end
|
||||
|
||||
on :fetch_public_key do |diaspora_id|
|
||||
key = Person.find_or_fetch_by_identifier(diaspora_id).serialized_public_key
|
||||
OpenSSL::PKey::RSA.new(key) unless key.nil?
|
||||
Person.find_or_fetch_by_identifier(diaspora_id).public_key
|
||||
end
|
||||
|
||||
on :fetch_related_entity do |entity_type, guid|
|
||||
|
|
|
|||
|
|
@ -479,6 +479,19 @@ describe Person, :type => :model do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#public_key" do
|
||||
it "returns the public key for the person" do
|
||||
key = @person.public_key
|
||||
expect(key).to be_a(OpenSSL::PKey::RSA)
|
||||
expect(key.to_s).to eq(@person.serialized_public_key)
|
||||
end
|
||||
|
||||
it "handles broken keys and returns nil" do
|
||||
@person.update_attributes(serialized_public_key: "broken")
|
||||
expect(@person.public_key).to be_nil
|
||||
end
|
||||
end
|
||||
|
||||
context 'people finders for webfinger' do
|
||||
let(:user) { FactoryGirl.create(:user) }
|
||||
let(:person) { FactoryGirl.create(:person) }
|
||||
|
|
|
|||
Loading…
Reference in a new issue