diff --git a/Changelog.md b/Changelog.md index 3d558b969..77376c5d0 100644 --- a/Changelog.md +++ b/Changelog.md @@ -19,6 +19,7 @@ * Fix Facebox icons 404s when called from Backbone * Fix deleting a post from Facebook [#4290](https://github.com/diaspora/diaspora/pull/4290) * Display notices a little bit longer to help on sign up errors [#4274](https://github.com/diaspora/diaspora/issues/4274) +* Fix user contact sharing/receiving [#4163](https://github.com/diaspora/diaspora/issues/4163) ## Features * Admin: add option to find users under 13 (COPPA) [#4252](https://github.com/diaspora/diaspora/pull/4252) @@ -32,7 +33,7 @@ ## Refactor -* Refactored config/ directory [#4145](https://github.com/diaspora/diaspora/pull/4145). +* Refactored config/ directory [#4144](https://github.com/diaspora/diaspora/pull/4145). * Drop misleading fallback donation form. [Proposal](https://www.loomio.org/discussions/1045?proposal=2722) * Update Typhoeus to 0.6.3 and refactor HydraWrapper. [#4162](https://github.com/diaspora/diaspora/pull/4162) * Bump recomended Ruby version to 1.9.3-p448, see [Ruby news](http://www.ruby-lang.org/en/news/2013/06/27/hostname-check-bypassing-vulnerability-in-openssl-client-cve-2013-4073/). diff --git a/app/models/user/connecting.rb b/app/models/user/connecting.rb index 94e2698f7..e90133330 100644 --- a/app/models/user/connecting.rb +++ b/app/models/user/connecting.rb @@ -41,11 +41,13 @@ module User::Connecting nil end - def remove_contact(contact, opts={:force => false}) + def remove_contact(contact, opts={:force => false, :retracted => false}) posts = contact.posts.all if !contact.mutual? || opts[:force] contact.destroy + elsif opts[:retracted] + contact.update_attributes(:sharing => false) else contact.update_attributes(:receiving => false) end @@ -65,7 +67,7 @@ module User::Connecting def disconnected_by(person) Rails.logger.info("event=disconnected_by user=#{diaspora_handle} target=#{person.diaspora_handle}") if contact = self.contact_for(person) - remove_contact(contact) + remove_contact(contact, :retracted => true) end end end diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index ad063674f..6f8250d2f 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -36,10 +36,16 @@ describe User::Connecting do describe '#disconnected_by' do it 'calls remove contact' do - bob.should_receive(:remove_contact).with(bob.contact_for(alice.person)) + bob.should_receive(:remove_contact).with(bob.contact_for(alice.person), :retracted => true) bob.disconnected_by(alice.person) end + it 'removes contact sharing flag' do + bob.contacts.find_by_person_id(alice.person.id).should be_sharing + bob.disconnected_by(alice.person) + bob.contacts.find_by_person_id(alice.person.id).should_not be_sharing + end + it 'removes notitications' do alice.share_with(eve.person, alice.aspects.first) Notifications::StartedSharing.where(:recipient_id => eve.id).first.should_not be_nil