From 21f70c643df1ee04c629d384f28122adbc7fec77 Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 16:15:10 -0700 Subject: [PATCH 1/3] DG IZ; moved update_profile from Person into User. removed notify_people methods. temporarily broke album pushing --- app/models/album.rb | 2 +- app/models/person.rb | 9 ------ app/models/user.rb | 30 +++++++++++++------ app/views/layouts/application.html.haml | 2 -- lib/diaspora/webhooks.rb | 10 ------- .../fancybox/jquery.fancybox-1.3.1.js | 2 +- public/javascripts/satisfaction-display.js | 10 ------- public/javascripts/satisfaction.js | 3 -- public/javascripts/view.js | 2 +- spec/lib/web_hooks_spec.rb | 13 -------- spec/models/comments_spec.rb | 2 +- spec/models/user_spec.rb | 2 +- 12 files changed, 26 insertions(+), 61 deletions(-) delete mode 100644 public/javascripts/satisfaction-display.js delete mode 100644 public/javascripts/satisfaction.js diff --git a/app/models/album.rb b/app/models/album.rb index b30cb5c45..cadb7c807 100644 --- a/app/models/album.rb +++ b/app/models/album.rb @@ -18,7 +18,7 @@ class Album validates_presence_of :name, :person before_destroy :destroy_photos - after_save :notify_people + before_destroy :propagate_retraction def self.instantiate params diff --git a/app/models/person.rb b/app/models/person.rb index 26236a5b8..32d68cab8 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -55,15 +55,6 @@ class Person encryption_key.public_key.export end - ##profile - def update_profile(params) - if self.update_attributes(params) - self.profile.notify_people! - true - else - false - end - end def owns?(post) self.id == post.person.id diff --git a/app/models/user.rb b/app/models/user.rb index ead632e74..3b269f135 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -49,19 +49,21 @@ class User post = model_class.instantiate(options) post.creator_signature = post.sign_with_key(encryption_key) post.save - post.notify_people + + + if group_id + group = self.groups.find_by_id(group_id) + group.posts << post + group.save + post.push_to( group.people.all ) + else + post.push_to( self.friends.all ) + end post.socket_to_uid(id) if post.respond_to?(:socket_to_uid) self.raw_visible_posts << post self.save - - if group_id - group = self.groups.find_by_id(group_id) - group.posts << post - group.save - end - post end @@ -104,10 +106,20 @@ class User post.unsocket_from_uid(self.id) if post.respond_to? :unsocket_from_uid retraction = Retraction.for(post) retraction.creator_signature = retraction.sign_with_key( encryption_key ) - retraction.notify_people + retraction.push_to( self.friends.all ) retraction end + ########### Profile ###################### + def update_profile(params) + if self.person.update_attributes(params) + self.profile.push_to( self.friends.all ) + true + else + false + end + end + ######### Friend Requesting ########### def send_friend_request_to(friend_url, group_id) unless self.friends.detect{ |x| x.receive_url == friend_url} diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 62d0c4eb1..006872e5b 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -24,8 +24,6 @@ = csrf_meta_tag = yield(:head) - /= javascript_include_tag 'satisfaction' , 'satisfaction-display' - = javascript_include_tag 'jquery.html5_upload' %body diff --git a/lib/diaspora/webhooks.rb b/lib/diaspora/webhooks.rb index dba3968e2..d0d555a2a 100644 --- a/lib/diaspora/webhooks.rb +++ b/lib/diaspora/webhooks.rb @@ -6,16 +6,6 @@ module Diaspora @@queue = MessageHandler.new - def notify_people - unless self.person.owner.nil? - push_to(people_with_permissions) - end - end - - def notify_people! - push_to(people_with_permissions) - end - def push_to(recipients) unless recipients.empty? recipients.map!{|x| x = x.receive_url } diff --git a/public/javascripts/fancybox/jquery.fancybox-1.3.1.js b/public/javascripts/fancybox/jquery.fancybox-1.3.1.js index 688f93aa3..2209ceadc 100644 --- a/public/javascripts/fancybox/jquery.fancybox-1.3.1.js +++ b/public/javascripts/fancybox/jquery.fancybox-1.3.1.js @@ -1074,4 +1074,4 @@ fancybox_init(); }); -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/public/javascripts/satisfaction-display.js b/public/javascripts/satisfaction-display.js deleted file mode 100644 index e72e66809..000000000 --- a/public/javascripts/satisfaction-display.js +++ /dev/null @@ -1,10 +0,0 @@ - var feedback_widget_options = {}; - - feedback_widget_options.display = "overlay"; - feedback_widget_options.company = "diaspora"; - feedback_widget_options.placement = "right"; - feedback_widget_options.color = "#222"; - feedback_widget_options.style = "idea"; - - - var feedback_widget = new GSFN.feedback_widget(feedback_widget_options); diff --git a/public/javascripts/satisfaction.js b/public/javascripts/satisfaction.js deleted file mode 100644 index b8efb5890..000000000 --- a/public/javascripts/satisfaction.js +++ /dev/null @@ -1,3 +0,0 @@ - var is_ssl = ("https:" == document.location.protocol); - var asset_host = is_ssl ? "https://s3.amazonaws.com/getsatisfaction.com/" : "http://s3.amazonaws.com/getsatisfaction.com/"; - document.write(unescape("%3Cscript src='" + asset_host + "javascripts/feedback-v2.js' type='text/javascript'%3E%3C/script%3E")); diff --git a/public/javascripts/view.js b/public/javascripts/view.js index 6648c1714..aa87fda21 100644 --- a/public/javascripts/view.js +++ b/public/javascripts/view.js @@ -85,7 +85,7 @@ $(document).ready(function(){ $("#add_album_button").fancybox(); $("#add_group_button").fancybox(); - $("#add_request_button").fancybox(); + $("#add_request_button").fancybox({ 'titleShow': false }); $("#add_photo_button").fancybox(); //pane_toggler_button("photo"); diff --git a/spec/lib/web_hooks_spec.rb b/spec/lib/web_hooks_spec.rb index 63739f636..5996a6e3a 100644 --- a/spec/lib/web_hooks_spec.rb +++ b/spec/lib/web_hooks_spec.rb @@ -17,20 +17,7 @@ describe Diaspora do end it "should add the following methods to Post on inclusion" do - @post.respond_to?(:notify_people).should be true @post.respond_to?(:to_diaspora_xml).should be true - @post.respond_to?(:people_with_permissions).should be true - end - - it "should retrieve all valid person endpoints" do - @user.friends << Factory.create(:person, :url => "http://www.bob.com/") - @user.friends << Factory.create(:person, :url => "http://www.alice.com/") - @user.friends << Factory.create(:person, :url => "http://www.jane.com/") - @user.save - - @post.person.owner.reload - - @post.people_with_permissions.should == @user.friends end it "should send an owners post to their people" do diff --git a/spec/models/comments_spec.rb b/spec/models/comments_spec.rb index 6d6aa7c3c..a9066f6d0 100644 --- a/spec/models/comments_spec.rb +++ b/spec/models/comments_spec.rb @@ -52,7 +52,7 @@ describe Comment do end it 'should send a user comment on his own post to lots of people' do - allowed_urls = @user_status.people_with_permissions.map{|x| x = x.receive_url} + allowed_urls = @user.friends.map!{ |x| x = x.receive_url } message_queue.should_receive(:add_post_request).with(allowed_urls, anything) @user.comment "yo", :on => @user_status end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 6ecbb3c3c..146547edb 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -28,7 +28,7 @@ describe User do message_queue.should_receive(:process) - @user.person.update_profile(updated_profile).should == true + @user.update_profile(updated_profile).should == true @user.profile.image_url.should == "http://clown.com" end end From 5de9362933a1694a7e11959dc00950e1acd37858 Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 16:27:08 -0700 Subject: [PATCH 2/3] DG IZ setting group id to nil and changing the deploy script for renaming of the repo --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 291246750..5d91f1206 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base if current_user @groups = current_user.groups @friends = current_user.friends - @group = params[:group] ? current_user.group_by_id(params[:group]) : current_user.groups.first + @group = params[:group] ? current_user.group_by_id(params[:group]) : nil end end From 516a667ce4a7e5d195fea3062141f931490e2539 Mon Sep 17 00:00:00 2001 From: ilya Date: Wed, 18 Aug 2010 16:35:11 -0700 Subject: [PATCH 3/3] going back to showing the first group on the index page --- app/controllers/application_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5d91f1206..291246750 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -19,7 +19,7 @@ class ApplicationController < ActionController::Base if current_user @groups = current_user.groups @friends = current_user.friends - @group = params[:group] ? current_user.group_by_id(params[:group]) : nil + @group = params[:group] ? current_user.group_by_id(params[:group]) : current_user.groups.first end end