Remove namespacing from federation libs recently migrated from app/models/

This commit is contained in:
Oliver Azevedo Barnes 2013-08-13 18:23:05 -05:00
parent 1c9d65e94c
commit 7214dc184d
22 changed files with 301 additions and 315 deletions

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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$/

View file

@ -1,8 +1,6 @@
# 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
@ -63,5 +61,3 @@ module Diaspora
verify_signature(self.parent_author_signature, self.parent.author)
end
end
end
end

View file

@ -2,10 +2,9 @@
# 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 Diaspora::Federated::Base
include ActiveModel::Validations
attr_accessor :sender, :recipient, :aspect
@ -101,5 +100,3 @@ module Diaspora
end
end
end
end
end

View file

@ -1,10 +1,8 @@
# 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
include Diaspora::Federated::Base
xml_accessor :post_guid
xml_accessor :diaspora_handle
@ -63,5 +61,3 @@ module Diaspora
self
end
end
end
end

View file

@ -1,10 +1,9 @@
# 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::Federated::Base
include Diaspora::Encryptable
@ -103,6 +102,4 @@ module Diaspora
verify_signature(self.target_author_signature, self.target.author)
end
end
end
end

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -4,7 +4,7 @@
require 'spec_helper'
describe Diaspora::Federated::Request do
describe Request do
before do
@aspect = alice.aspects.first
end

View file

@ -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])

View file

@ -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)

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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