Merge branch 'master' of github.com:diaspora/diaspora

This commit is contained in:
maxwell 2010-11-02 17:52:22 -07:00
commit 8c350282d3
4 changed files with 11 additions and 6 deletions

View file

@ -8,7 +8,7 @@
$(document).ready(function(){
function debug(str){ $("#debug").append("<p>" + str); };
ws = new WebSocket("ws://#{request.host}:#{APP_CONFIG[:socket_port]}/#{CGI::escape(current_user.id.to_s)}");
ws = new WebSocket("ws://#{request.host}:#{APP_CONFIG[:socket_port]}/");
//Attach onmessage to websocket
ws.onmessage = function(evt) {

View file

@ -15,7 +15,7 @@ module Diaspora
def self.push_to_user(uid, data)
Rails.logger.debug "Websocketing to #{uid}"
@channels[uid.to_s][0].push(data) if @channels[uid.to_s]
@channels[uid][0].push(data) if @channels[uid]
end
def self.subscribe(uid, ws)

View file

@ -48,11 +48,15 @@ begin
:debug =>APP_CONFIG[:socket_debug]) do |ws|
ws.onopen {
sid = Diaspora::WebSocket.subscribe(ws.request['Path'].gsub('/',''), ws)
encoded_cookie = ws.request["Cookie"].gsub("_diaspora_session=","")
cookie = Marshal.load(encoded_cookie.unpack("m*").first)
user_id = cookie["warden.user.user.key"].last
sid = Diaspora::WebSocket.subscribe(user_id, ws)
ws.onmessage { |msg| SocketsController.new.incoming(msg) }
ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) }
ws.onclose { Diaspora::WebSocket.unsubscribe(user_id, sid) }
}
end
PID_FILE = APP_CONFIG[:socket_pidfile]

View file

@ -47,14 +47,15 @@ describe Person do
@person.diaspora_handle.include?(APP_CONFIG[:terse_pod_url]).should be false
end
end
describe 'validation' do
it 'is unique' do
person_two = Factory.build(:person, :url => @person.diaspora_handle)
person_two = Factory.build(:person, :diaspora_handle => @person.diaspora_handle)
person_two.valid?.should be_false
end
it 'is case insensitive' do
person_two = Factory.build(:person, :url => @person.diaspora_handle.upcase)
person_two = Factory.build(:person, :url => @person.url.upcase)
person_two.valid?.should be_false
end
end