diff --git a/app/models/contact.rb b/app/models/contact.rb index f449352a6..f064ad929 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -61,7 +61,7 @@ class Contact < ActiveRecord::Base end def generate_request - Diaspora::Federated::Request.diaspora_initialize(:from => self.user.person, + Request.diaspora_initialize(:from => self.user.person, :to => self.person, :into => aspects.first) end diff --git a/app/models/notification.rb b/app/models/notification.rb index 3bdf26f1c..a60d8cdb9 100644 --- a/app/models/notification.rb +++ b/app/models/notification.rb @@ -83,7 +83,7 @@ private n = notification_type.new(:target => target, :recipient_id => recipient.id) n.actors = n.actors | [actor] - n.unread = false if target.is_a? Diaspora::Federated::Request + n.unread = false if target.is_a? Request n.save! n end diff --git a/app/models/user.rb b/app/models/user.rb index fa9cb9e17..521bf057b 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -297,11 +297,11 @@ class User < ActiveRecord::Base ######### Posts and Such ############### def retract(target, opts={}) if target.respond_to?(:relayable?) && target.relayable? - retraction = Diaspora::Federated::RelayableRetraction.build(self, target) + retraction = RelayableRetraction.build(self, target) elsif target.is_a? Post - retraction = Diaspora::Federated::SignedRetraction.build(self, target) + retraction = SignedRetraction.build(self, target) else - retraction = Diaspora::Federated::Retraction.for(target) + retraction = Retraction.for(target) end if target.is_a?(Post) diff --git a/app/models/user/connecting.rb b/app/models/user/connecting.rb index 245219303..e90133330 100644 --- a/app/models/user/connecting.rb +++ b/app/models/user/connecting.rb @@ -56,7 +56,7 @@ module User::Connecting def disconnect(bad_contact, opts={}) person = bad_contact.person Rails.logger.info("event=disconnect user=#{diaspora_handle} target=#{person.diaspora_handle}") - retraction = Diaspora::Federated::Retraction.for(self) + retraction = Retraction.for(self) retraction.subscribers = [person]#HAX Postzord::Dispatcher.build(self, retraction).post diff --git a/features/support/paths.rb b/features/support/paths.rb index fa1bf1abb..b3553e141 100644 --- a/features/support/paths.rb +++ b/features/support/paths.rb @@ -22,7 +22,7 @@ module NavigationHelpers when /^my acceptance form page$/ invite_code_path(InvitationCode.first) when /^the requestors profile$/ - person_path(Diaspora::Federated::Request.where(:recipient_id => @me.person.id).first.sender) + person_path(Request.where(:recipient_id => @me.person.id).first.sender) when /^"([^\"]*)"'s page$/ person_path(User.find_by_email($1).person) when /^my account settings page$/ diff --git a/lib/diaspora/federated/relayable_retraction.rb b/lib/diaspora/federated/relayable_retraction.rb index 174f672a7..ab7be6528 100644 --- a/lib/diaspora/federated/relayable_retraction.rb +++ b/lib/diaspora/federated/relayable_retraction.rb @@ -1,67 +1,63 @@ # Copyright (c) 2010-2011, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -module Diaspora - module Federated - class RelayableRetraction < SignedRetraction - xml_name :relayable_retraction - xml_attr :parent_author_signature +class RelayableRetraction < SignedRetraction + xml_name :relayable_retraction + xml_attr :parent_author_signature - attr_accessor :parent_author_signature + attr_accessor :parent_author_signature - delegate :parent, :parent_author, to: :target, allow_nil: true + delegate :parent, :parent_author, to: :target, allow_nil: true - def signable_accessors - super - ['parent_author_signature'] - end + def signable_accessors + super - ['parent_author_signature'] + end - # @param sender [User] - # @param target [Object] - def self.build(sender, target) - retraction = super - retraction.parent_author_signature = retraction.sign_with_key(sender.encryption_key) if defined?(target.parent) && sender.person == target.parent.author - retraction - end + # @param sender [User] + # @param target [Object] + def self.build(sender, target) + retraction = super + retraction.parent_author_signature = retraction.sign_with_key(sender.encryption_key) if defined?(target.parent) && sender.person == target.parent.author + retraction + end - def diaspora_handle - self.sender_handle - end + def diaspora_handle + self.sender_handle + end - def relayable? - true - end + def relayable? + true + end - def perform receiving_user - Rails.logger.debug "Performing relayable retraction for #{target_guid}" - if not self.parent_author_signature.nil? or self.parent.author.remote? - # Don't destroy a relayable unless the top-level owner has received it, otherwise it may not get relayed - self.target.destroy - Rails.logger.info("event=relayable_retraction status =complete target_type=#{self.target_type} guid =#{self.target_guid}") - end - end - - def receive(recipient, sender) - if self.target.nil? - Rails.logger.info("event=retraction status=abort reason='no post found' sender=#{sender.diaspora_handle} target_guid=#{target_guid}") - return - elsif self.parent.author == recipient.person && self.target_author_signature_valid? - #this is a retraction from the downstream object creator, and the recipient is the upstream owner - self.parent_author_signature = self.sign_with_key(recipient.encryption_key) - Postzord::Dispatcher.build(recipient, self).post - self.perform(recipient) - elsif self.parent_author_signature_valid? - #this is a retraction from the upstream owner - self.perform(recipient) - else - Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{recipient.diaspora_handle} sender=#{self.parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{self.parent.id}") - return - end - self - end - - def parent_author_signature_valid? - verify_signature(self.parent_author_signature, self.parent.author) - end + def perform receiving_user + Rails.logger.debug "Performing relayable retraction for #{target_guid}" + if not self.parent_author_signature.nil? or self.parent.author.remote? + # Don't destroy a relayable unless the top-level owner has received it, otherwise it may not get relayed + self.target.destroy + Rails.logger.info("event=relayable_retraction status =complete target_type=#{self.target_type} guid =#{self.target_guid}") end end + + def receive(recipient, sender) + if self.target.nil? + Rails.logger.info("event=retraction status=abort reason='no post found' sender=#{sender.diaspora_handle} target_guid=#{target_guid}") + return + elsif self.parent.author == recipient.person && self.target_author_signature_valid? + #this is a retraction from the downstream object creator, and the recipient is the upstream owner + self.parent_author_signature = self.sign_with_key(recipient.encryption_key) + Postzord::Dispatcher.build(recipient, self).post + self.perform(recipient) + elsif self.parent_author_signature_valid? + #this is a retraction from the upstream owner + self.perform(recipient) + else + Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{recipient.diaspora_handle} sender=#{self.parent.author.diaspora_handle} payload_type=#{self.class} parent_id=#{self.parent.id}") + return + end + self + end + + def parent_author_signature_valid? + verify_signature(self.parent_author_signature, self.parent.author) + end end diff --git a/lib/diaspora/federated/request.rb b/lib/diaspora/federated/request.rb index 9439575ef..0b0f446b3 100644 --- a/lib/diaspora/federated/request.rb +++ b/lib/diaspora/federated/request.rb @@ -2,104 +2,101 @@ # t # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -module Diaspora - module Federated - class Request - include Base - include ActiveModel::Validations - attr_accessor :sender, :recipient, :aspect +class Request + include Diaspora::Federated::Base + include ActiveModel::Validations - xml_accessor :sender_handle - xml_accessor :recipient_handle + attr_accessor :sender, :recipient, :aspect - validates :sender, :presence => true - validates :recipient, :presence => true + xml_accessor :sender_handle + xml_accessor :recipient_handle - validate :not_already_connected - validate :not_friending_yourself + validates :sender, :presence => true + validates :recipient, :presence => true - # Initalize variables - # @note we should be using ActiveModel::Serialization for this - # @return [Request] - def self.diaspora_initialize(opts = {}) - req = self.new - req.sender = opts[:from] - req.recipient = opts[:to] - req.aspect = opts[:into] - req - end + validate :not_already_connected + validate :not_friending_yourself - # Alias of sender_handle - # @return [String] - def diaspora_handle - sender_handle - end + # Initalize variables + # @note we should be using ActiveModel::Serialization for this + # @return [Request] + def self.diaspora_initialize(opts = {}) + req = self.new + req.sender = opts[:from] + req.recipient = opts[:to] + req.aspect = opts[:into] + req + end - # @note Used for XML marshalling - # @return [String] - def sender_handle - sender.diaspora_handle - end - def sender_handle= sender_handle - self.sender = Person.where(:diaspora_handle => sender_handle).first - end + # Alias of sender_handle + # @return [String] + def diaspora_handle + sender_handle + end - # @note Used for XML marshalling - # @return [String] - def recipient_handle - recipient.diaspora_handle - end - def recipient_handle= recipient_handle - self.recipient = Person.where(:diaspora_handle => recipient_handle).first - end + # @note Used for XML marshalling + # @return [String] + def sender_handle + sender.diaspora_handle + end + def sender_handle= sender_handle + self.sender = Person.where(:diaspora_handle => sender_handle).first + end - # Defines the abstract interface used in sending a corresponding [Notification] given the [Request] - # @param user [User] - # @param person [Person] - # @return [Notifications::StartedSharing] - def notification_type(user, person) - Notifications::StartedSharing - end + # @note Used for XML marshalling + # @return [String] + def recipient_handle + recipient.diaspora_handle + end + def recipient_handle= recipient_handle + self.recipient = Person.where(:diaspora_handle => recipient_handle).first + end - # Defines the abstract interface used in sending the [Request] - # @param user [User] - # @return [Array] The recipient of the request - def subscribers(user) - [self.recipient] - end + # Defines the abstract interface used in sending a corresponding [Notification] given the [Request] + # @param user [User] + # @param person [Person] + # @return [Notifications::StartedSharing] + def notification_type(user, person) + Notifications::StartedSharing + end - # Finds or initializes a corresponding [Contact], and will set Contact#sharing to true - # Follows back if user setting is set so - # @note A [Contact] may already exist if the [Request]'s recipient is sharing with the sender - # @return [Request] - def receive(user, person) - Rails.logger.info("event=receive payload_type=request sender=#{self.sender} to=#{self.recipient}") + # Defines the abstract interface used in sending the [Request] + # @param user [User] + # @return [Array] The recipient of the request + def subscribers(user) + [self.recipient] + end - contact = user.contacts.find_or_initialize_by_person_id(self.sender.id) - contact.sharing = true - contact.save - - user.share_with(person, user.auto_follow_back_aspect) if user.auto_follow_back && !contact.receiving + # Finds or initializes a corresponding [Contact], and will set Contact#sharing to true + # Follows back if user setting is set so + # @note A [Contact] may already exist if the [Request]'s recipient is sharing with the sender + # @return [Request] + def receive(user, person) + Rails.logger.info("event=receive payload_type=request sender=#{self.sender} to=#{self.recipient}") - self - end + contact = user.contacts.find_or_initialize_by_person_id(self.sender.id) + contact.sharing = true + contact.save + + user.share_with(person, user.auto_follow_back_aspect) if user.auto_follow_back && !contact.receiving - private + self + end - # Checks if a [Contact] does not already exist between the requesting [User] and receiving [Person] - def not_already_connected - if sender && recipient && Contact.where(:user_id => self.recipient.owner_id, :person_id => self.sender.id).exists? - errors[:base] << 'You have already connected to this person' - end - end + private - # Checks to see that the requesting [User] is not sending a request to himself - def not_friending_yourself - if self.recipient == self.sender - errors[:base] << 'You can not friend yourself' - end - end + # Checks if a [Contact] does not already exist between the requesting [User] and receiving [Person] + def not_already_connected + if sender && recipient && Contact.where(:user_id => self.recipient.owner_id, :person_id => self.sender.id).exists? + errors[:base] << 'You have already connected to this person' + end + end + + # Checks to see that the requesting [User] is not sending a request to himself + def not_friending_yourself + if self.recipient == self.sender + errors[:base] << 'You can not friend yourself' end end end diff --git a/lib/diaspora/federated/retraction.rb b/lib/diaspora/federated/retraction.rb index caa64846d..e1798ed94 100644 --- a/lib/diaspora/federated/retraction.rb +++ b/lib/diaspora/federated/retraction.rb @@ -1,67 +1,63 @@ # Copyright (c) 2010-2011, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -module Diaspora - module Federated - class Retraction - include Base +class Retraction + include Diaspora::Federated::Base - xml_accessor :post_guid - xml_accessor :diaspora_handle - xml_accessor :type + xml_accessor :post_guid + xml_accessor :diaspora_handle + xml_accessor :type - attr_accessor :person, :object, :subscribers + attr_accessor :person, :object, :subscribers - def subscribers(user) - unless self.type == 'Person' - @subscribers ||= self.object.subscribers(user) - @subscribers -= self.object.resharers unless self.object.is_a?(Photo) - @subscribers - else - raise 'HAX: you must set the subscribers manaully before unfriending' if @subscribers.nil? - @subscribers - end - end - - def self.for(object) - retraction = self.new - if object.is_a? User - retraction.post_guid = object.person.guid - retraction.type = object.person.class.to_s - else - retraction.post_guid = object.guid - retraction.type = object.class.to_s - retraction.object = object - end - retraction.diaspora_handle = object.diaspora_handle - retraction - end - - def target - @target ||= self.type.constantize.where(:guid => post_guid).first - end - - def perform receiving_user - Rails.logger.debug "Performing retraction for #{post_guid}" - - self.target.destroy if self.target - Rails.logger.info("event=retraction status=complete type=#{self.type} guid=#{self.post_guid}") - end - - def receive(user, person) - if self.type == 'Person' - unless self.person.guid.to_s == self.post_guid.to_s - Rails.logger.info("event=receive status=abort reason='sender is not the person he is trying to retract' recipient=#{self.diaspora_handle} sender=#{self.person.diaspora_handle} payload_type=#{self.class} retraction_type=person") - return - end - user.disconnected_by(self.target) - elsif self.target.nil? || self.target.author != self.person - Rails.logger.info("event=retraction status=abort reason='no post found authored by retractor' sender=#{person.diaspora_handle} post_guid=#{post_guid}") - else - self.perform(user) - end - self - end + def subscribers(user) + unless self.type == 'Person' + @subscribers ||= self.object.subscribers(user) + @subscribers -= self.object.resharers unless self.object.is_a?(Photo) + @subscribers + else + raise 'HAX: you must set the subscribers manaully before unfriending' if @subscribers.nil? + @subscribers end end + + def self.for(object) + retraction = self.new + if object.is_a? User + retraction.post_guid = object.person.guid + retraction.type = object.person.class.to_s + else + retraction.post_guid = object.guid + retraction.type = object.class.to_s + retraction.object = object + end + retraction.diaspora_handle = object.diaspora_handle + retraction + end + + def target + @target ||= self.type.constantize.where(:guid => post_guid).first + end + + def perform receiving_user + Rails.logger.debug "Performing retraction for #{post_guid}" + + self.target.destroy if self.target + Rails.logger.info("event=retraction status=complete type=#{self.type} guid=#{self.post_guid}") + end + + def receive(user, person) + if self.type == 'Person' + unless self.person.guid.to_s == self.post_guid.to_s + Rails.logger.info("event=receive status=abort reason='sender is not the person he is trying to retract' recipient=#{self.diaspora_handle} sender=#{self.person.diaspora_handle} payload_type=#{self.class} retraction_type=person") + return + end + user.disconnected_by(self.target) + elsif self.target.nil? || self.target.author != self.person + Rails.logger.info("event=retraction status=abort reason='no post found authored by retractor' sender=#{person.diaspora_handle} post_guid=#{post_guid}") + else + self.perform(user) + end + self + end end \ No newline at end of file diff --git a/lib/diaspora/federated/signed_retraction.rb b/lib/diaspora/federated/signed_retraction.rb index 6cf13e6a9..67a6812c1 100644 --- a/lib/diaspora/federated/signed_retraction.rb +++ b/lib/diaspora/federated/signed_retraction.rb @@ -1,108 +1,105 @@ # Copyright (c) 2010-2011, Diaspora Inc. This file is # licensed under the Affero General Public License version 3 or later. See # the COPYRIGHT file. -module Diaspora - module Federated - class SignedRetraction - include Base - - include Diaspora::Encryptable - xml_name :signed_retraction - xml_attr :target_guid - xml_attr :target_type - xml_attr :sender_handle - xml_attr :target_author_signature +class SignedRetraction + include Diaspora::Federated::Base + + include Diaspora::Encryptable - attr_accessor :target_guid, - :target_type, - :target_author_signature, - :sender + xml_name :signed_retraction + xml_attr :target_guid + xml_attr :target_type + xml_attr :sender_handle + xml_attr :target_author_signature - #NOTE(fix this hack -- go through the app and make sure we only call RelayableRetraction in a unified way) - def author - if sender.is_a?(User) - sender.person - else - sender - end - end + attr_accessor :target_guid, + :target_type, + :target_author_signature, + :sender - def signable_accessors - accessors = self.class.roxml_attrs.collect do |definition| - definition.accessor - end - accessors - ['target_author_signature', 'sender_handle'] - end - - def sender_handle= new_sender_handle - @sender = Person.where(:diaspora_handle => new_sender_handle).first - end - - def sender_handle - @sender.diaspora_handle - end - - def diaspora_handle - self.sender_handle - end - - def subscribers(user) - self.target.subscribers(user) - end - - def self.build(sender, target) - retraction = self.new - retraction.sender = sender - retraction.target = target - retraction.target_author_signature = retraction.sign_with_key(sender.encryption_key) if sender.person == target.author - retraction - end - - def target - @target ||= self.target_type.constantize.where(:guid => target_guid).first - end - - def guid - target_guid - end - def target= new_target - @target = new_target - @target_type = new_target.class.to_s - @target_guid = new_target.guid - end - - def perform receiving_user - Rails.logger.debug "Performing retraction for #{target_guid}" - if reshare = Reshare.where(:author_id => receiving_user.person.id, :root_guid => target_guid).first - onward_retraction = self.dup - onward_retraction.sender = receiving_user.person - Postzord::Dispatcher.build(receiving_user, onward_retraction).post - end - if target - self.target.destroy - end - Rails.logger.info("event=retraction status =complete target_type=#{self.target_type} guid =#{self.target_guid}") - end - - def receive(recipient, sender) - if self.target.nil? - Rails.logger.info("event=retraction status=abort reason='no post found' sender=#{sender.diaspora_handle} target_guid=#{target_guid}") - return - elsif self.target_author_signature_valid? - #this is a retraction from the upstream owner - self.perform(recipient) - else - Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{recipient.diaspora_handle} sender=#{self.sender_handle} payload_type=#{self.class}") - return - end - self - end - - def target_author_signature_valid? - verify_signature(self.target_author_signature, self.target.author) - end + #NOTE(fix this hack -- go through the app and make sure we only call RelayableRetraction in a unified way) + def author + if sender.is_a?(User) + sender.person + else + sender end end + + def signable_accessors + accessors = self.class.roxml_attrs.collect do |definition| + definition.accessor + end + accessors - ['target_author_signature', 'sender_handle'] + end + + def sender_handle= new_sender_handle + @sender = Person.where(:diaspora_handle => new_sender_handle).first + end + + def sender_handle + @sender.diaspora_handle + end + + def diaspora_handle + self.sender_handle + end + + def subscribers(user) + self.target.subscribers(user) + end + + def self.build(sender, target) + retraction = self.new + retraction.sender = sender + retraction.target = target + retraction.target_author_signature = retraction.sign_with_key(sender.encryption_key) if sender.person == target.author + retraction + end + + def target + @target ||= self.target_type.constantize.where(:guid => target_guid).first + end + + def guid + target_guid + end + def target= new_target + @target = new_target + @target_type = new_target.class.to_s + @target_guid = new_target.guid + end + + def perform receiving_user + Rails.logger.debug "Performing retraction for #{target_guid}" + if reshare = Reshare.where(:author_id => receiving_user.person.id, :root_guid => target_guid).first + onward_retraction = self.dup + onward_retraction.sender = receiving_user.person + Postzord::Dispatcher.build(receiving_user, onward_retraction).post + end + if target + self.target.destroy + end + Rails.logger.info("event=retraction status =complete target_type=#{self.target_type} guid =#{self.target_guid}") + end + + def receive(recipient, sender) + if self.target.nil? + Rails.logger.info("event=retraction status=abort reason='no post found' sender=#{sender.diaspora_handle} target_guid=#{target_guid}") + return + elsif self.target_author_signature_valid? + #this is a retraction from the upstream owner + self.perform(recipient) + else + Rails.logger.info("event=receive status=abort reason='object signature not valid' recipient=#{recipient.diaspora_handle} sender=#{self.sender_handle} payload_type=#{self.class}") + return + end + self + end + + def target_author_signature_valid? + verify_signature(self.target_author_signature, self.target.author) + end end diff --git a/lib/postzord/dispatcher.rb b/lib/postzord/dispatcher.rb index 13374f8d6..01ead3da0 100644 --- a/lib/postzord/dispatcher.rb +++ b/lib/postzord/dispatcher.rb @@ -149,7 +149,7 @@ class Postzord::Dispatcher if @object.instance_of?(StatusMessage) Workers::PostToService.perform_async(service.id, @object.id, url) end - if @object.instance_of?(Diaspora::Federated::SignedRetraction) + if @object.instance_of?(SignedRetraction) Workers::DeletePostFromService.perform_async(service.id, @object.target.id) end end diff --git a/lib/postzord/receiver/private.rb b/lib/postzord/receiver/private.rb index 1f268a5cb..f2d560e50 100644 --- a/lib/postzord/receiver/private.rb +++ b/lib/postzord/receiver/private.rb @@ -99,7 +99,7 @@ class Postzord::Receiver::Private < Postzord::Receiver end def contact_required_unless_request - unless @object.is_a?(Diaspora::Federated::Request) || @user.contact_for(@sender) + unless @object.is_a?(Request) || @user.contact_for(@sender) FEDERATION_LOGGER.error("event=receive status=abort reason='sender not connected to recipient' recipient=#{@user_person.diaspora_handle} sender=#{@sender.diaspora_handle}") return true end @@ -107,7 +107,7 @@ class Postzord::Receiver::Private < Postzord::Receiver def assign_sender_handle_if_request #special casey - if @object.is_a?(Diaspora::Federated::Request) + if @object.is_a?(Request) @object.sender_handle = @sender.diaspora_handle end end diff --git a/lib/postzord/receiver/public.rb b/lib/postzord/receiver/public.rb index 326aa125e..ae8cdb869 100644 --- a/lib/postzord/receiver/public.rb +++ b/lib/postzord/receiver/public.rb @@ -30,7 +30,7 @@ class Postzord::Receiver::Public < Postzord::Receiver receive_relayable elsif @object.is_a?(AccountDeletion) #nothing - elsif @object.is_a?(Diaspora::Federated::SignedRetraction) # feels like a hack + elsif @object.is_a?(SignedRetraction) # feels like a hack self.recipient_user_ids.each do |user_id| user = User.where(id: user_id).first @object.perform user if user diff --git a/spec/integration/attack_vectors_spec.rb b/spec/integration/attack_vectors_spec.rb index 3088132e5..398297428 100644 --- a/spec/integration/attack_vectors_spec.rb +++ b/spec/integration/attack_vectors_spec.rb @@ -47,7 +47,7 @@ def expect_error(partial_message, &block)# DOES NOT REQUIRE ERROR!! end def bogus_retraction(&block) - ret = Diaspora::Federated::Retraction.new + ret = Retraction.new yield ret ret end diff --git a/spec/integration/receiving_spec.rb b/spec/integration/receiving_spec.rb index b3135cd83..bc9b3c765 100644 --- a/spec/integration/receiving_spec.rb +++ b/spec/integration/receiving_spec.rb @@ -317,7 +317,7 @@ describe 'a user receives a post' do let(:zord) { Postzord::Receiver::Private.new(alice, person: bob.person) } it 'should accept retractions' do - retraction = Diaspora::Federated::Retraction.for(message) + retraction = Retraction.for(message) xml = retraction.to_diaspora_xml expect { @@ -327,7 +327,7 @@ describe 'a user receives a post' do it 'should accept relayable retractions' do comment = bob.comment! message, "and dogs" - retraction = Diaspora::Federated::RelayableRetraction.build(bob, comment) + retraction = RelayableRetraction.build(bob, comment) xml = retraction.to_diaspora_xml expect { @@ -337,7 +337,7 @@ describe 'a user receives a post' do it 'should accept signed retractions for public posts' do message = bob.post(:status_message, text: "cats", public: true) - retraction = Diaspora::Federated::SignedRetraction.build(bob, message) + retraction = SignedRetraction.build(bob, message) salmon = Postzord::Dispatcher::Public.salmon bob, retraction.to_diaspora_xml xml = salmon.xml_for alice.person zord = Postzord::Receiver::Public.new xml diff --git a/spec/lib/diaspora/federated/relayable_retraction_spec.rb b/spec/lib/diaspora/federated/relayable_retraction_spec.rb index edf957089..6a2d2659f 100644 --- a/spec/lib/diaspora/federated/relayable_retraction_spec.rb +++ b/spec/lib/diaspora/federated/relayable_retraction_spec.rb @@ -6,7 +6,7 @@ require 'spec_helper' require Rails.root.join("spec", "shared_behaviors", "relayable") # require Rails.root.join('lib', 'diaspora', 'federated', 'messages') -describe Diaspora::Federated::RelayableRetraction do +describe RelayableRetraction do before do @local_luke, @local_leia, @remote_raphael = set_up_friends @remote_parent = FactoryGirl.build(:status_message, :author => @remote_raphael) diff --git a/spec/lib/diaspora/federated/request_spec.rb b/spec/lib/diaspora/federated/request_spec.rb index ba031b57f..a0d77a237 100644 --- a/spec/lib/diaspora/federated/request_spec.rb +++ b/spec/lib/diaspora/federated/request_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' -describe Diaspora::Federated::Request do +describe Request do before do @aspect = alice.aspects.first end diff --git a/spec/lib/diaspora/federated/retraction_spec.rb b/spec/lib/diaspora/federated/retraction_spec.rb index 86f0514f4..a7aadcdd9 100644 --- a/spec/lib/diaspora/federated/retraction_spec.rb +++ b/spec/lib/diaspora/federated/retraction_spec.rb @@ -5,7 +5,7 @@ require 'spec_helper' # require Rails.root.join('lib', 'diaspora', 'federated', 'messages') -describe Diaspora::Federated::Retraction do +describe Retraction do before do @aspect = alice.aspects.first alice.contacts.create(:person => eve.person, :aspects => [@aspect]) diff --git a/spec/lib/diaspora/federated/signed_retraction_spec.rb b/spec/lib/diaspora/federated/signed_retraction_spec.rb index bb98348f2..06caf4699 100644 --- a/spec/lib/diaspora/federated/signed_retraction_spec.rb +++ b/spec/lib/diaspora/federated/signed_retraction_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' # require Rails.root.join('lib', 'diaspora', 'federated', 'messages') -describe Diaspora::Federated::SignedRetraction do +describe SignedRetraction do before do @post = FactoryGirl.create(:status_message, :author => bob.person, :public => true) @resharer = FactoryGirl.create(:user) diff --git a/spec/lib/postzord/dispatcher_spec.rb b/spec/lib/postzord/dispatcher_spec.rb index fb9eba054..d5fc319e8 100644 --- a/spec/lib/postzord/dispatcher_spec.rb +++ b/spec/lib/postzord/dispatcher_spec.rb @@ -262,7 +262,7 @@ describe Postzord::Dispatcher do end it 'returns false for a relayable_retraction' do - f = Diaspora::Federated::RelayableRetraction.new + f = RelayableRetraction.new f.target = FactoryGirl.create(:status_message, :public => true) Postzord::Dispatcher.object_should_be_processed_as_public?(f).should be_false end @@ -312,7 +312,7 @@ describe Postzord::Dispatcher do end it 'queues a job to delete if given retraction' do - retraction = Diaspora::Federated::SignedRetraction.build(alice, FactoryGirl.create(:status_message)) + retraction = SignedRetraction.build(alice, FactoryGirl.create(:status_message)) mailman = Postzord::Dispatcher.build(alice, retraction, :url => "http://joindiaspora.com/p/123", :services => [@service]) Workers::DeletePostFromService.should_receive(:perform_async).with(anything, anything) diff --git a/spec/models/notification_spec.rb b/spec/models/notification_spec.rb index 5dd0edcb2..779cdb7c6 100644 --- a/spec/models/notification_spec.rb +++ b/spec/models/notification_spec.rb @@ -65,7 +65,7 @@ describe Notification do describe '.notify' do context 'with a request' do before do - @request = Diaspora::Federated::Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect) + @request = Request.diaspora_initialize(:from => @user.person, :to => @user2.person, :into => @aspect) end it 'calls Notification.create if the object has a notification_type' do diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b23551307..60c1e157c 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -800,7 +800,7 @@ describe User do context "posts" do before do - Diaspora::Federated::SignedRetraction.stub(:build).and_return(@retraction) + SignedRetraction.stub(:build).and_return(@retraction) @retraction.stub(:perform) end diff --git a/spec/shared_behaviors/relayable.rb b/spec/shared_behaviors/relayable.rb index 43a9d741c..f3afeee10 100644 --- a/spec/shared_behaviors/relayable.rb +++ b/spec/shared_behaviors/relayable.rb @@ -34,7 +34,7 @@ describe Diaspora::Relayable do it "sends a retraction for the object" do pending 'need to figure out how to test this' - Diaspora::Federated::RelayableRetraction.should_receive(:build) + RelayableRetraction.should_receive(:build) Postzord::Dispatcher.should_receive(:build) @relayable.valid? end