remove all references to the websocket. bang bang.
This commit is contained in:
parent
2243778c17
commit
0e5bb81d66
26 changed files with 34 additions and 406 deletions
9
Gemfile
9
Gemfile
|
|
@ -22,16 +22,10 @@ gem 'omniauth-twitter'
|
|||
|
||||
gem 'twitter', '2.0.2'
|
||||
|
||||
# backups
|
||||
|
||||
# mail
|
||||
|
||||
gem 'messagebus_ruby_api', '1.0.1'
|
||||
|
||||
|
||||
# web sockets
|
||||
gem 'em-synchrony', :platforms => :ruby_19
|
||||
gem 'em-websocket'
|
||||
|
||||
group :production do # we don't install these on travis to speed up test runs
|
||||
# chef
|
||||
gem 'chef', '~> 0.10.4', :require => false
|
||||
|
|
@ -116,6 +110,7 @@ gem 'client_side_validations'
|
|||
|
||||
gem 'faraday'
|
||||
gem 'faraday-stack'
|
||||
gem 'em-synchrony', :platforms => :ruby_19
|
||||
|
||||
# jazzy jasmine
|
||||
|
||||
|
|
|
|||
|
|
@ -154,9 +154,6 @@ GEM
|
|||
diff-lcs (1.1.3)
|
||||
em-synchrony (0.2.0)
|
||||
eventmachine (>= 0.12.9)
|
||||
em-websocket (0.3.6)
|
||||
addressable (>= 2.1.1)
|
||||
eventmachine (>= 0.12.9)
|
||||
erubis (2.6.6)
|
||||
abstract (>= 1.0.0)
|
||||
eventmachine (0.12.10)
|
||||
|
|
@ -465,7 +462,6 @@ DEPENDENCIES
|
|||
devise_invitable (= 0.5.0)
|
||||
diaspora-client!
|
||||
em-synchrony
|
||||
em-websocket
|
||||
factory_girl_rails
|
||||
faraday
|
||||
faraday-stack
|
||||
|
|
|
|||
|
|
@ -169,6 +169,7 @@ class PeopleController < ApplicationController
|
|||
@contact = current_user.contact_for(@person) || Contact.new
|
||||
render :partial => 'aspect_membership_dropdown', :locals => {:contact => @contact, :person => @person, :hang => 'left'}
|
||||
end
|
||||
Webfinger.new(account, opts)
|
||||
end
|
||||
|
||||
def diaspora_id?(query)
|
||||
|
|
@ -177,7 +178,7 @@ class PeopleController < ApplicationController
|
|||
|
||||
private
|
||||
def webfinger(account, opts = {})
|
||||
Resque.enqueue(Jobs::SocketWebfinger, current_user.id, account, opts)
|
||||
Webfinger.new(account, opts)
|
||||
end
|
||||
|
||||
def remote_profile_with_no_user_session?
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
|
||||
scope :all_contacts_of_person, lambda {|x| where(:person_id => x.id)}
|
||||
|
||||
|
||||
# contact.sharing is true when contact.person is sharing with contact.user
|
||||
scope :sharing, lambda {
|
||||
where(:sharing => true)
|
||||
|
|
@ -69,7 +69,6 @@ class Contact < ActiveRecord::Base
|
|||
|
||||
def receive_shareable(shareable)
|
||||
ShareVisibility.create!(:shareable_id => shareable.id, :shareable_type => shareable.class.base_class.to_s, :contact_id => self.id)
|
||||
Diaspora::Websocket.to(self.user, :aspect_ids => self.aspect_ids).socket(shareable)
|
||||
end
|
||||
|
||||
def contacts
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
module Diaspora
|
||||
class Websocket
|
||||
|
||||
def initialize(*args)
|
||||
end
|
||||
|
||||
def self.to(*args)
|
||||
w = Websocket.new(*args)
|
||||
w
|
||||
end
|
||||
|
||||
def send(object)
|
||||
end
|
||||
|
||||
def retract(object)
|
||||
end
|
||||
|
||||
alias :socket :send
|
||||
alias :unsocket :retract
|
||||
end
|
||||
end
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
# 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 Jobs
|
||||
class SocketWebfinger < Base
|
||||
|
||||
@queue = :socket_webfinger
|
||||
|
||||
def self.perform(user_id, account, opts={})
|
||||
finger = Webfinger.new(account)
|
||||
begin
|
||||
result = finger.fetch
|
||||
Diaspora::Websocket.to(user_id).socket(opts)
|
||||
rescue
|
||||
Diaspora::Websocket.to(user_id).socket(
|
||||
{:class => 'people',
|
||||
:status => 'fail',
|
||||
:query => account,
|
||||
:response => I18n.t('people.webfinger.fail', :handle => account)})
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -15,7 +15,7 @@ class Notification < ActiveRecord::Base
|
|||
def self.notify(recipient, target, actor)
|
||||
if target.respond_to? :notification_type
|
||||
if note_type = target.notification_type(recipient, actor)
|
||||
if(target.is_a? Comment) || (target.is_a? Like)
|
||||
if(target.is_a? Comment) || (target.is_a? Like)
|
||||
n = note_type.concatenate_or_create(recipient, target.parent, actor, note_type)
|
||||
elsif(target.is_a? Reshare)
|
||||
n = note_type.concatenate_or_create(recipient, target.root, actor, note_type)
|
||||
|
|
@ -24,7 +24,6 @@ class Notification < ActiveRecord::Base
|
|||
end
|
||||
if n
|
||||
n.email_the_user(target, actor)
|
||||
Diaspora::Websocket.to(recipient, :actor => actor).socket(n)
|
||||
n
|
||||
else
|
||||
nil
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ class Retraction
|
|||
|
||||
def perform receiving_user
|
||||
Rails.logger.debug "Performing retraction for #{post_guid}"
|
||||
Diaspora::Websocket.to(receiving_user).retract(self.target)
|
||||
|
||||
self.target.destroy if self.target
|
||||
Rails.logger.info("event=retraction status=complete type=#{self.type} guid=#{self.post_guid}")
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ class SignedRetraction
|
|||
Postzord::Dispatcher.build(receiving_user, onward_retraction).post
|
||||
end
|
||||
if target
|
||||
Diaspora::Websocket.to(receiving_user).retract(self.target)
|
||||
self.target.destroy
|
||||
end
|
||||
Rails.logger.info("event=retraction status =complete target_type=#{self.target_type} guid =#{self.target_guid}")
|
||||
|
|
|
|||
|
|
@ -77,12 +77,12 @@ class User < ActiveRecord::Base
|
|||
identifier = invitation.identifier
|
||||
|
||||
if service == 'email'
|
||||
existing_user = User.where(:email => identifier).first
|
||||
existing_user = User.where(:email => identifier).first
|
||||
else
|
||||
existing_user = User.joins(:services).where(:services => {:type => "Services::#{service.titleize}", :uid => identifier}).first
|
||||
end
|
||||
|
||||
if existing_user.nil?
|
||||
|
||||
if existing_user.nil?
|
||||
i = Invitation.where(:service => service, :identifier => identifier).first
|
||||
existing_user = i.recipient if i
|
||||
end
|
||||
|
|
@ -219,8 +219,6 @@ class User < ActiveRecord::Base
|
|||
def add_to_streams(post, aspects_to_insert)
|
||||
inserted_aspect_ids = aspects_to_insert.map{|x| x.id}
|
||||
|
||||
Diaspora::Websocket.to(self, :aspect_ids => inserted_aspect_ids ).socket(post)
|
||||
|
||||
aspects_to_insert.each do |aspect|
|
||||
aspect << post
|
||||
end
|
||||
|
|
@ -348,7 +346,7 @@ class User < ActiveRecord::Base
|
|||
self.invitation_token = nil
|
||||
self.password = opts[:password]
|
||||
self.password_confirmation = opts[:password_confirmation]
|
||||
|
||||
|
||||
self.save
|
||||
return unless self.errors.empty?
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
-# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
-# licensed under the Affero General Public License version 3 or later. See
|
||||
-# the COPYRIGHT file.
|
||||
|
||||
-if AppConfig.single_process_mode?
|
||||
:javascript
|
||||
var websocket_enabled = false
|
||||
- else
|
||||
:javascript
|
||||
var websocket_enabled = true
|
||||
WebSocket.__swfLocation = "#{javascript_path 'vendor/WebSocketMain.swf'}";
|
||||
$(document).ready(function(){
|
||||
WSR.initialize("#{(AppConfig[:socket_secure])?'wss':'ws'}://#{request.host}:#{AppConfig[:socket_port]}/");
|
||||
});
|
||||
|
|
@ -3,9 +3,6 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
module Diaspora
|
||||
|
||||
autoload :Parser
|
||||
autoload :Webhooks
|
||||
autoload :Websocket
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module Diaspora
|
|||
|
||||
validates_associated :parent
|
||||
validates :author, :presence => true
|
||||
|
||||
|
||||
delegate :public?, :to => :parent
|
||||
end
|
||||
end
|
||||
|
|
@ -67,10 +67,8 @@ module Diaspora
|
|||
Postzord::Dispatcher.build(user, comment_or_like).post
|
||||
end
|
||||
|
||||
Diaspora::Websocket.to(user).socket(comment_or_like)
|
||||
|
||||
if comment_or_like.after_receive(user, person)
|
||||
comment_or_like
|
||||
comment_or_like
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class Postzord::Dispatcher
|
|||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# @return [Object]
|
||||
def post(opts={})
|
||||
|
|
@ -52,7 +52,7 @@ class Postzord::Dispatcher
|
|||
remote_people, local_people = @subscribers.partition{ |person| person.owner_id.nil? }
|
||||
|
||||
if @object.respond_to?(:relayable?) && @sender.owns?(@object.parent)
|
||||
self.socket_and_notify_local_users(local_people)
|
||||
self.notify_local_users(local_people)
|
||||
else
|
||||
self.deliver_to_local(local_people)
|
||||
end
|
||||
|
|
@ -83,10 +83,10 @@ class Postzord::Dispatcher
|
|||
# @param remote_people [Array<Person>] Recipients of the post on other pods
|
||||
# @return [void]
|
||||
def queue_remote_delivery_job(remote_people)
|
||||
Resque.enqueue(Jobs::HttpMulti,
|
||||
@sender.id,
|
||||
Base64.encode64s(@object.to_diaspora_xml),
|
||||
remote_people.map{|p| p.id},
|
||||
Resque.enqueue(Jobs::HttpMulti,
|
||||
@sender.id,
|
||||
Base64.encode64s(@object.to_diaspora_xml),
|
||||
remote_people.map{|p| p.id},
|
||||
self.class.to_s)
|
||||
end
|
||||
|
||||
|
|
@ -129,11 +129,9 @@ class Postzord::Dispatcher
|
|||
end
|
||||
|
||||
# @param local_people [Array<People>]
|
||||
def socket_and_notify_local_users(local_people)
|
||||
def notify_local_users(local_people)
|
||||
local_users = fetch_local_users(local_people)
|
||||
self.notify_users(local_users)
|
||||
local_users << @sender if @object.author.local?
|
||||
self.socket_to_users(local_users)
|
||||
end
|
||||
|
||||
# @param services [Array<User>]
|
||||
|
|
@ -149,11 +147,5 @@ class Postzord::Dispatcher
|
|||
def object_is_related_to_diaspora_hq?
|
||||
(@object.author.diaspora_handle == 'diasporahq@joindiaspora.com' || (@object.respond_to?(:relayable?) && @object.parent.author.diaspora_handle == 'diasporahq@joindiaspora.com'))
|
||||
end
|
||||
|
||||
# @param services [Array<User>]
|
||||
def socket_to_users(users)
|
||||
return unless users.present?
|
||||
Diaspora::Websocket.to(users).socket(@object)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ class Postzord::Receiver::LocalBatch < Postzord::Receiver
|
|||
notify_mentioned_users if @object.respond_to?(:mentions)
|
||||
|
||||
# 09/27/11 this is slow
|
||||
socket_to_users
|
||||
notify_users
|
||||
|
||||
true
|
||||
|
|
@ -65,13 +64,6 @@ class Postzord::Receiver::LocalBatch < Postzord::Receiver
|
|||
end
|
||||
|
||||
#NOTE(these methods should be in their own module, included in this class)
|
||||
|
||||
# Issue websocket requests to all specified recipients
|
||||
# @return [void]
|
||||
def socket_to_users
|
||||
Diaspora::Websocket.to(@users).socket(@object)
|
||||
end
|
||||
|
||||
# Notify users of the new object
|
||||
# return [void]
|
||||
def notify_users
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
#
|
||||
# Start diaspora websocket and main services
|
||||
# Start diaspora main services
|
||||
#
|
||||
|
||||
# ensure right directory
|
||||
|
|
@ -80,13 +80,6 @@ if [ -n "$services" ]; then
|
|||
exit 64
|
||||
fi
|
||||
|
||||
services=$( chk_service $SOCKET_PORT )
|
||||
if [ -n "$services" ]; then
|
||||
echo "FATAL: Error: websocket port $SOCKET_PORT is already in use. Exiting" >&2
|
||||
echo " $services"
|
||||
exit 64
|
||||
fi
|
||||
|
||||
# Force AGPL
|
||||
if [ -w public -a ! -e public/source.tar.gz ]; then
|
||||
branch=$( git branch | awk '/^[*]/ {print $2}')
|
||||
|
|
@ -111,10 +104,7 @@ fi
|
|||
# Start Diaspora
|
||||
|
||||
if [ "$(bundle exec ruby ./script/get_config.rb 'single_process_mode?')" != "true" ]; then
|
||||
|
||||
QUEUE=* bundle exec rake resque:work&
|
||||
|
||||
#bundle exec ruby ./script/websocket_server.rb&
|
||||
fi
|
||||
|
||||
if [ "$(./script/get_config.rb enable_thin script_server)" = "true" ]; then
|
||||
|
|
|
|||
|
|
@ -1,118 +0,0 @@
|
|||
# Copyright (c) 2010-2011, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3 or later. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require File.join(File.dirname(__FILE__), '..', 'config', 'environment')
|
||||
require File.join(File.dirname(__FILE__), '..','lib', 'diaspora', 'web_socket')
|
||||
|
||||
at_exit do
|
||||
begin
|
||||
File.delete(PID_FILE)
|
||||
rescue
|
||||
puts 'Cannot remove pidfile: ' + (PID_FILE ? PID_FILE : "NIL")
|
||||
end
|
||||
end
|
||||
|
||||
def write_pidfile
|
||||
begin
|
||||
f = File.open(PID_FILE, "w")
|
||||
f.write(Process.pid)
|
||||
f.close
|
||||
rescue => e
|
||||
puts "Can't write to pidfile!"
|
||||
puts e.inspect
|
||||
end
|
||||
end
|
||||
|
||||
def debug_pp thing
|
||||
pp thing if AppConfig[:socket_debug] || ENV['SOCKET_DEBUG']
|
||||
end
|
||||
|
||||
def process_message
|
||||
if Diaspora::WebSocket.length > 0
|
||||
message = JSON::parse(Diaspora::WebSocket.next)
|
||||
if message
|
||||
Diaspora::WebSocket.push_to_user(message['uid'], message['data'])
|
||||
end
|
||||
EM.next_tick{ process_message}
|
||||
else
|
||||
EM::Timer.new(1){process_message}
|
||||
end
|
||||
end
|
||||
|
||||
$cookie_parser = Rack::Builder.new do
|
||||
use ActionDispatch::Cookies
|
||||
use ActionDispatch::Session::CookieStore, :key => "_diaspora_session"
|
||||
use Warden::Manager do |warden|
|
||||
warden.default_scope = :user
|
||||
warden.failure_app = Proc.new {|env| [0, {}, nil]}
|
||||
end
|
||||
|
||||
run Proc.new {|env| [0, {}, env['warden'].user]}
|
||||
end
|
||||
|
||||
def get_user_from_request(request)
|
||||
user = $cookie_parser.call(request.merge(
|
||||
{"HTTP_COOKIE" => request['cookie'],
|
||||
"action_dispatch.secret_token" => Rails.application.config.secret_token}
|
||||
))[2]
|
||||
raise ArgumentError, "user not authenticated" unless user
|
||||
user
|
||||
end
|
||||
|
||||
begin
|
||||
EM.run {
|
||||
Diaspora::WebSocket.initialize_channels
|
||||
|
||||
socket_params = { :host => AppConfig[:socket_host],
|
||||
:port => AppConfig[:socket_port],
|
||||
:debug =>AppConfig[:socket_debug] }
|
||||
|
||||
if AppConfig[:socket_secure] && AppConfig[:socket_private_key_location] && AppConfig[:socket_cert_chain_location]
|
||||
socket_params[:secure] = true;
|
||||
socket_params[:tls_options] = {
|
||||
:private_key_file => AppConfig[:socket_private_key_location],
|
||||
:cert_chain_file => AppConfig[:socket_cert_chain_location]
|
||||
}
|
||||
end
|
||||
|
||||
EventMachine::WebSocket.start( socket_params ) do |ws|
|
||||
|
||||
ws.onopen {
|
||||
begin
|
||||
debug_pp ws.request
|
||||
|
||||
user = get_user_from_request(ws.request)
|
||||
user_id = user.id
|
||||
|
||||
debug_pp "In WSS, suscribing user: #{user.name} with id: #{user_id}"
|
||||
sid = Diaspora::WebSocket.subscribe(user_id, ws)
|
||||
|
||||
ws.onmessage { |msg| SocketsController.new.incoming(msg) }
|
||||
|
||||
ws.onclose {
|
||||
begin
|
||||
debug_pp "In WSS, unsuscribing user: #{user.name} with id: #{user_id}"
|
||||
Diaspora::WebSocket.unsubscribe(user_id, sid)
|
||||
rescue
|
||||
debug_pp "Could not unsubscribe socket for #{user_id}"
|
||||
end
|
||||
}
|
||||
rescue ArgumentError => e
|
||||
raise e unless e.message.include?("not authenticated")
|
||||
debug_pp "Could not open socket for request with cookie: #{ws.request["cookie"]}"
|
||||
debug_pp "Looks like the cookie is invalid or the user isn't signed in"
|
||||
end
|
||||
}
|
||||
end
|
||||
PID_FILE = (AppConfig[:socket_pidfile] ? AppConfig[:socket_pidfile] : 'tmp/diaspora-ws.pid')
|
||||
write_pidfile
|
||||
puts "Websocket server started."
|
||||
process_message
|
||||
}
|
||||
rescue RuntimeError => e
|
||||
raise e unless e.message.include?("no acceptor")
|
||||
puts "Are you sure the websocket server isn't already running?"
|
||||
puts "Just start thin with bundle exec thin start."
|
||||
Process.exit
|
||||
end
|
||||
|
|
@ -387,8 +387,8 @@ describe PeopleController do
|
|||
end
|
||||
|
||||
describe '#webfinger' do
|
||||
it 'enqueues a webfinger job' do
|
||||
Resque.should_receive(:enqueue).with(Jobs::SocketWebfinger, @user.id, @user.diaspora_handle, anything).once
|
||||
it 'calls Webfinger.new' do
|
||||
Webfinger.should_receive(:new).with(@user.diaspora_handle, anything).once
|
||||
get :retrieve_remote, :diaspora_handle => @user.diaspora_handle
|
||||
end
|
||||
end
|
||||
|
|
|
|||
23
spec/fixtures/config/old_style_app.yml
vendored
23
spec/fixtures/config/old_style_app.yml
vendored
|
|
@ -14,26 +14,6 @@ default:
|
|||
# Enable extensive logging to log/{development,test,production}.log
|
||||
debug: false
|
||||
|
||||
# Websocket server setup, see script/websocket_server.rb
|
||||
# Enable extensive logging to websocket server.
|
||||
socket_debug : false
|
||||
|
||||
# Websocket host, leave as 0.0.0.0 unless you know what you are doing
|
||||
socket_host: 0.0.0.0
|
||||
|
||||
# File containing pid of running script/websocket_server.rb
|
||||
socket_pidfile: "log/diaspora-wsd.pid"
|
||||
|
||||
# Websocket port, should normally be 8080 or 8081.
|
||||
socket_port: 8080
|
||||
socket_collection_name: 'websocket'
|
||||
|
||||
# Secure websocket confguration (wss://)
|
||||
# requires SSL cert and key
|
||||
socket_secure: false
|
||||
socket_cert_chain_location: '/full/path/to/cert_chain.crt'
|
||||
socket_private_key_location: '/full/path/to/file.key'
|
||||
|
||||
# Diaspora is only tested against this default pubsub server.
|
||||
pubsub_server: 'https://pubsubhubbub.appspot.com/'
|
||||
|
||||
|
|
@ -113,7 +93,6 @@ production:
|
|||
# Do not touch unless you know what you're doing
|
||||
test:
|
||||
pod_url: "http://example.org/"
|
||||
socket_port: 8081
|
||||
enable_splunk_logging: false
|
||||
|
||||
|
||||
|
|
@ -126,4 +105,4 @@ script_server:
|
|||
default_thin_args: "-p $THIN_PORT -e $RAILS_ENV"
|
||||
|
||||
# Possibilties are development, production
|
||||
rails_env: "development"
|
||||
rails_env: "development"
|
||||
|
|
|
|||
|
|
@ -19,16 +19,6 @@ describe 'a user receives a post' do
|
|||
@contact = alice.contact_for(bob.person)
|
||||
end
|
||||
|
||||
it 'streams only one message to the everyone aspect when a multi-aspected contacts posts' do
|
||||
contact = alice.contact_for(bob.person)
|
||||
alice.add_contact_to_aspect(contact, alice.aspects.create(:name => "villains"))
|
||||
status = bob.build_post(:status_message, :text => "Users do things", :to => @bobs_aspect.id)
|
||||
Diaspora::Websocket.stub!(:is_connected?).and_return(true)
|
||||
Diaspora::Websocket.should_receive(:to).exactly(:once).and_return(stub.as_null_object)
|
||||
zord = Postzord::Receiver::Private.new(alice, :object => status, :person => bob.person)
|
||||
zord.receive_object
|
||||
end
|
||||
|
||||
it 'should be able to parse and store a status message from xml' do
|
||||
status_message = bob.post :status_message, :text => 'store this!', :to => @bobs_aspect.id
|
||||
|
||||
|
|
@ -55,7 +45,6 @@ describe 'a user receives a post' do
|
|||
fantasy_resque do
|
||||
sm = bob.build_post(:status_message, :text => "hi")
|
||||
sm.save!
|
||||
sm.stub!(:socket_to_user)
|
||||
bob.aspects.reload
|
||||
bob.add_to_streams(sm, [@bobs_aspect])
|
||||
bob.dispatch_post(sm, :to => @bobs_aspect)
|
||||
|
|
@ -70,7 +59,6 @@ describe 'a user receives a post' do
|
|||
Notification.should_receive(:notify).with(eve, anything(), bob.person)
|
||||
|
||||
@sm = bob.build_post(:status_message, :text => "@{#{alice.name}; #{alice.diaspora_handle}} stuff @{#{eve.name}; #{eve.diaspora_handle}}")
|
||||
@sm.stub!(:socket_to_user)
|
||||
bob.add_to_streams(@sm, [bob.aspects.first])
|
||||
@sm.save
|
||||
|
||||
|
|
@ -88,7 +76,6 @@ describe 'a user receives a post' do
|
|||
Notification.should_receive(:notify).with(alice, anything(), @remote_person)
|
||||
|
||||
@sm = Factory.build(:status_message, :text => "hello @{#{alice.name}; #{alice.diaspora_handle}}", :diaspora_handle => @remote_person.diaspora_handle, :author => @remote_person)
|
||||
@sm.stub!(:socket_to_user)
|
||||
@sm.save
|
||||
|
||||
zord = Postzord::Receiver::Private.new(alice, :object => @sm, :person => bob.person)
|
||||
|
|
@ -99,7 +86,6 @@ describe 'a user receives a post' do
|
|||
Notification.should_not_receive(:notify).with(alice, anything(), eve.person)
|
||||
|
||||
@sm = eve.build_post(:status_message, :text => "should not notify @{#{alice.name}; #{alice.diaspora_handle}}")
|
||||
@sm.stub!(:socket_to_user)
|
||||
eve.add_to_streams(@sm, [eve.aspects.first])
|
||||
@sm.save
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ describe Postzord::Dispatcher do
|
|||
zord.xml.should == @sm.to_diaspora_xml
|
||||
end
|
||||
|
||||
context 'setting @subscribers' do
|
||||
context 'setting @subscribers' do
|
||||
it 'sets @subscribers from object' do
|
||||
@sm.should_receive(:subscribers).and_return(@subscribers)
|
||||
zord = Postzord::Dispatcher.build(alice, @sm)
|
||||
|
|
@ -90,18 +90,17 @@ describe Postzord::Dispatcher do
|
|||
before do
|
||||
@mailman = Postzord::Dispatcher.build(@local_leia, @comment)
|
||||
end
|
||||
|
||||
it 'calls deliver_to_local with local_luke' do
|
||||
@mailman.should_receive(:deliver_to_local).with([@local_luke.person])
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls deliver_to_remote with nobody' do
|
||||
@mailman.should_receive(:deliver_to_remote).with([])
|
||||
@mailman.post
|
||||
end
|
||||
it 'does not call socket_to_users' do
|
||||
@mailman.should_not_receive(:socket_to_users)
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'does not call notify_users' do
|
||||
@mailman.should_not_receive(:notify_users)
|
||||
@mailman.post
|
||||
|
|
@ -111,18 +110,17 @@ describe Postzord::Dispatcher do
|
|||
before do
|
||||
@mailman = Postzord::Dispatcher.build(@local_luke, @comment)
|
||||
end
|
||||
|
||||
it 'does not call deliver_to_local' do
|
||||
@mailman.should_not_receive(:deliver_to_local)
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls deliver_to_remote with remote raphael' do
|
||||
@mailman.should_receive(:deliver_to_remote).with([@remote_raphael])
|
||||
@mailman.post
|
||||
end
|
||||
it 'calls socket_to_users' do
|
||||
@mailman.should_receive(:socket_to_users).with([@local_leia, @local_luke])
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls notify_users' do
|
||||
@mailman.should_receive(:notify_users).with([@local_leia])
|
||||
@mailman.post
|
||||
|
|
@ -147,11 +145,6 @@ describe Postzord::Dispatcher do
|
|||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls socket_to_users' do
|
||||
@mailman.should_receive(:socket_to_users).with([@local_leia])
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls notify_users' do
|
||||
@mailman.should_receive(:notify_users).with([@local_leia])
|
||||
@mailman.post
|
||||
|
|
@ -175,11 +168,6 @@ describe Postzord::Dispatcher do
|
|||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls socket_to_users' do
|
||||
@mailman.should_receive(:socket_to_users).with([@local_leia, @local_luke])
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'calls notify_users' do
|
||||
@mailman.should_receive(:notify_users).with([@local_leia])
|
||||
@mailman.post
|
||||
|
|
@ -205,11 +193,6 @@ describe Postzord::Dispatcher do
|
|||
@mailman.post
|
||||
end
|
||||
|
||||
it 'does not call socket_to_users' do
|
||||
@mailman.should_not_receive(:socket_to_users)
|
||||
@mailman.post
|
||||
end
|
||||
|
||||
it 'does not call notify_users' do
|
||||
@mailman.should_not_receive(:notify_users)
|
||||
@mailman.post
|
||||
|
|
@ -328,15 +311,10 @@ describe Postzord::Dispatcher do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#socket_and_notify_local_users' do
|
||||
describe '#and_notify_local_users' do
|
||||
it 'calls notifiy_users' do
|
||||
@zord.should_receive(:notify_users).with([bob])
|
||||
@zord.send(:socket_and_notify_local_users, [bob.person])
|
||||
end
|
||||
|
||||
it 'calls socket_to_users with the object author' do
|
||||
@zord.should_receive(:socket_to_users).with([bob, @zord.sender])
|
||||
@zord.send(:socket_and_notify_local_users, [bob.person])
|
||||
@zord.send(:notify_local_users, [bob.person])
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -346,13 +324,6 @@ describe Postzord::Dispatcher do
|
|||
@zord.send(:notify_users, [bob])
|
||||
end
|
||||
end
|
||||
|
||||
describe '#socket_to_users' do
|
||||
it 'calls socket_to_user given users' do
|
||||
Diaspora::Websocket.should_receive(:to).and_return(stub.as_null_object)
|
||||
@zord.send(:socket_to_users, [bob])
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
require 'spec_helper'
|
||||
require 'spec_helper'
|
||||
require File.join(Rails.root, 'lib','postzord', 'receiver', 'local_batch')
|
||||
|
||||
describe Postzord::Receiver::LocalBatch do
|
||||
before do
|
||||
@object = Factory(:status_message, :author => alice.person)
|
||||
@ids = [bob.id.to_s]
|
||||
@ids = [bob.id.to_s]
|
||||
end
|
||||
|
||||
let(:receiver) { Postzord::Receiver::LocalBatch.new(@object, @ids) }
|
||||
|
|
@ -41,13 +41,6 @@ describe Postzord::Receiver::LocalBatch do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#socket_to_users' do
|
||||
it 'sockets to users' do
|
||||
Diaspora::Websocket.should_receive(:to).with(receiver.users).and_return(stub.as_null_object)
|
||||
receiver.socket_to_users
|
||||
end
|
||||
end
|
||||
|
||||
describe '#notify_mentioned_users' do
|
||||
it 'calls notify person for a mentioned person' do
|
||||
sm = Factory(:status_message,
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Jobs::SocketWebfinger do
|
||||
before do
|
||||
@user = alice
|
||||
@account = "tom@tom.joindiaspora.com"
|
||||
end
|
||||
it 'Makes a Webfinger object' do
|
||||
Webfinger.should_receive(:new).with(@account)
|
||||
Jobs::SocketWebfinger.perform(@user.id, @account)
|
||||
end
|
||||
it 'Queries the target account' do
|
||||
finger = mock()
|
||||
Webfinger.stub(:new).and_return(finger)
|
||||
|
||||
finger.should_receive(:fetch).and_return(Factory.create(:person))
|
||||
Jobs::SocketWebfinger.perform(@user.id, @account)
|
||||
end
|
||||
it 'Sockets the resulting person on success' do
|
||||
finger = mock()
|
||||
Webfinger.stub(:new).and_return(finger)
|
||||
person = Factory.create(:person)
|
||||
finger.stub(:fetch).and_return(person)
|
||||
|
||||
Diaspora::Websocket.should_receive(:to).with(@user.id).and_return(stub.as_null_object)
|
||||
Jobs::SocketWebfinger.perform(@user.id, @account)
|
||||
end
|
||||
it 'Passes opts through on success' do
|
||||
finger = mock()
|
||||
Webfinger.stub(:new).and_return(finger)
|
||||
person = Factory.create(:person)
|
||||
finger.stub(:fetch).and_return(person)
|
||||
|
||||
opts = {:symbol => true}
|
||||
|
||||
Diaspora::Websocket.should_receive(:to).with(@user.id).and_return(stub.as_null_object)
|
||||
Jobs::SocketWebfinger.perform(@user.id, @account, opts)
|
||||
end
|
||||
it 'sockets failure message on failure' do
|
||||
finger = mock()
|
||||
Webfinger.stub(:new).and_return(finger)
|
||||
finger.stub(:fetch).and_raise(Webfinger::WebfingerFailedError)
|
||||
|
||||
opts = {:class => 'people', :status => 'fail', :query => @account, :response => I18n.t('people.webfinger.fail', :handle => @account )}.to_json
|
||||
Diaspora::Websocket.should_receive(:to).with(@user.id).and_return(stub.as_null_object)
|
||||
|
||||
Jobs::SocketWebfinger.perform(@user.id, @account)
|
||||
|
||||
end
|
||||
end
|
||||
|
|
@ -72,19 +72,6 @@ describe Notification do
|
|||
Notification.notify(@user, @request, @person)
|
||||
end
|
||||
|
||||
it 'sockets to the recipient' do
|
||||
opts = {:target_id => @request.sender.id,
|
||||
:target_type => "Request",
|
||||
:actors => [@person],
|
||||
:recipient_id => @user.id}
|
||||
|
||||
n = @request.notification_type(@user, @person).create(opts)
|
||||
Notification.stub!(:make_notification).and_return n
|
||||
|
||||
Diaspora::Websocket.should_receive(:to).once.and_return(stub.as_null_object)
|
||||
Notification.notify(@user, @request, @person)
|
||||
end
|
||||
|
||||
describe '#emails_the_user' do
|
||||
it 'calls mail' do
|
||||
opts = {
|
||||
|
|
|
|||
|
|
@ -31,13 +31,6 @@ describe User do
|
|||
@aspect.reload.post_ids.should include @post.id
|
||||
@aspect1.reload.post_ids.should include @post.id
|
||||
end
|
||||
|
||||
it 'sockets the post to the poster' do
|
||||
socket_stub = mock()
|
||||
socket_stub.should_receive(:socket).with(@post)
|
||||
Diaspora::Websocket.should_receive(:to).with(alice, instance_of(Hash)).and_return(socket_stub)
|
||||
alice.add_to_streams(@post, @aspects)
|
||||
end
|
||||
end
|
||||
|
||||
describe '#aspects_from_ids' do
|
||||
|
|
|
|||
|
|
@ -61,13 +61,6 @@ describe Diaspora::Relayable do
|
|||
@object_by_recipient.receive(@local_luke, @local_leia.person)
|
||||
end
|
||||
|
||||
it 'sockets to the user if the object supports it' do
|
||||
if @object_by_recipient.respond_to?(:socket_to_user)
|
||||
@object_by_recipient.should_receive(:socket_to_user).exactly(3).times
|
||||
@object_by_recipient.receive(@local_luke, @local_leia.person)
|
||||
end
|
||||
end
|
||||
|
||||
it 'calls after_receive callback' do
|
||||
@object_by_recipient.should_receive(:after_receive)
|
||||
@object_by_recipient.class.stub(:where).and_return([@object_by_recipient])
|
||||
|
|
|
|||
Loading…
Reference in a new issue