diff --git a/app/helpers/stream_element_helper.rb b/app/helpers/stream_element_helper.rb index 4ccdbe791..5c4ee610e 100644 --- a/app/helpers/stream_element_helper.rb +++ b/app/helpers/stream_element_helper.rb @@ -3,8 +3,8 @@ module StreamElementHelper if user_signed_in? && current_user.person.id != author.id link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}), :class => 'block_user delete', - :confirm => t('are_you_sure'), - :title => t('.block_user', :name => author.first_name), + :confirm => t('.ignore_user_description'), + :title => t('.ignore_user', :name => author.first_name), :method => :post end end diff --git a/app/helpers/stream_helper.rb b/app/helpers/stream_helper.rb index a91515420..bfd573616 100644 --- a/app/helpers/stream_helper.rb +++ b/app/helpers/stream_helper.rb @@ -10,15 +10,15 @@ module StreamHelper "/apps/1?#{{:max_time => @posts.last.created_at.to_i}.to_param}" elsif controller.instance_of?(PeopleController) person_path(@person, :max_time => time_for_scroll(opts[:ajax_stream], @stream)) - elsif controller.instance_of?(TagFollowingsController) + elsif controller.instance_of?(TagFollowingsController) tag_followings_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) - elsif controller.instance_of?(CommunitySpotlightController) + elsif controller.instance_of?(CommunitySpotlightController) spotlight_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) - elsif controller.instance_of?(MentionsController) + elsif controller.instance_of?(MentionsController) mentions_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) - elsif controller.instance_of?(MultisController) + elsif controller.instance_of?(MultisController) multi_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) - elsif controller.instance_of?(PostsController) + elsif controller.instance_of?(PostsController) public_stream_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :sort_order => session[:sort_order]) elsif controller.instance_of?(AspectsController) aspects_path(:max_time => time_for_scroll(opts[:ajax_stream], @stream), :a_ids => @stream.aspect_ids, :sort_order => session[:sort_order]) diff --git a/app/models/contact.rb b/app/models/contact.rb index ba7358911..b1e961207 100644 --- a/app/models/contact.rb +++ b/app/models/contact.rb @@ -19,7 +19,8 @@ class Contact < ActiveRecord::Base validates_uniqueness_of :person_id, :scope => :user_id - before_destroy :destroy_notifications + before_destroy :destroy_notifications, + :repopulate_cache! # contact.sharing is true when contact.person is sharing with contact.user scope :sharing, lambda { @@ -39,7 +40,14 @@ class Contact < ActiveRecord::Base Notification.where(:target_type => "Person", :target_id => person_id, :recipient_id => user_id, - :type => "Notifications::StartedSharing").delete_all + :type => "Notifications::StartedSharing").delete_all + end + + def repopulate_cache! + if RedisCache.configured? + cache = RedisCache.new(self.user) + cache.repopulate! + end end def dispatch_request diff --git a/app/views/users/privacy_settings.html.haml b/app/views/users/privacy_settings.html.haml index 1a70cbc6c..7fd59f8a0 100644 --- a/app/views/users/privacy_settings.html.haml +++ b/app/views/users/privacy_settings.html.haml @@ -12,13 +12,12 @@ .span-12.prepend-5.last %h3 - = t('.blocked_users') + = t('.ignored_users') - @blocks.each do |block| = block.person.name \- - = link_to t('.unblock'), block_path(block), - :confirm => t('are_you_sure'), + = link_to t('.stop_ignoring'), block_path(block), :method => :delete %br diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index e63b623cc..594d24a6a 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -725,11 +725,11 @@ en: blocks: create: - success: "Alright, you won't see them again. #niceblock!" - failure: "I couldn't block that user. #evasion" + success: "Alright, you won't see that user in your stream again. #silencio!" + failure: "I couldn't ignore that user. #evasion" destroy: - success: "User unblocked! #combobreaker" - failure: "I couldn't unblock that user. #evasion" + success: "Let's see what they have to say! #sayhello" + failure: "I couldn't stop ignoring that user. #evasion" shared: aspect_dropdown: @@ -793,7 +793,8 @@ en: connect_to_comment: "Connect to this user to comment on their post" currently_unavailable: 'commenting currently unavailable' via: "via %{link}" - block_user: "Block %{name}" + ignore_user: "Ignore %{name}" + ignore_user_description: "Ignore and remove user from all aspects?" hide_and_mute: "Hide and mute post" like: "Like" unlike: "Unlike" @@ -932,8 +933,8 @@ en: privacy_settings: title: "Privacy Settings" - blocked_users: "Blocked Users" - unblock: "Unblock" + ignored_users: "Ignored Users" + stop_ignoring: "Stop ignoring" destroy: "Your account has been locked. It may take 20 minutes for us to finish closing your account. Thank you for trying Diaspora." getting_started: diff --git a/lib/diaspora/redis_cache.rb b/lib/diaspora/redis_cache.rb index 0d980d71f..60b8a4c33 100644 --- a/lib/diaspora/redis_cache.rb +++ b/lib/diaspora/redis_cache.rb @@ -4,10 +4,10 @@ class RedisCache - SUPPORTED_CACHES = [:created_at] #['updated_at', + SUPPORTED_CACHES = [:created_at] CACHE_LIMIT = 100 - def initialize(user, order_field) + def initialize(user, order_field=:created_at) @user = user @order_field = order_field.to_s end diff --git a/lib/diaspora/user/querying.rb b/lib/diaspora/user/querying.rb index c9b76bf6e..d6a83a637 100644 --- a/lib/diaspora/user/querying.rb +++ b/lib/diaspora/user/querying.rb @@ -141,7 +141,7 @@ module Diaspora end def shareables_from(klass, person) - return self.person.send(klass.table_name).where(:pending => false).order("created_at DESC") if person == self.person + return self.person.send(klass.table_name).where(:pending => false).order("#{klass.table_name}.created_at DESC") if person == self.person con = Contact.arel_table p = klass.arel_table shareable_ids = [] diff --git a/public/stylesheets/sass/application.sass b/public/stylesheets/sass/application.sass index 9020c1548..3da4106b7 100644 --- a/public/stylesheets/sass/application.sass +++ b/public/stylesheets/sass/application.sass @@ -96,6 +96,8 @@ form :padding :top 45px :bottom 8px + :left 12px + :right 12px #flash_notice .message diff --git a/spec/lib/stream/public_spec.rb b/spec/lib/stream/public_spec.rb index 9f0fdacf1..cb09c3962 100644 --- a/spec/lib/stream/public_spec.rb +++ b/spec/lib/stream/public_spec.rb @@ -3,7 +3,7 @@ require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream') describe Stream::Public do before do - @stream = Stream::Public.new(stub) + @stream = Stream::Public.new(alice) end describe 'shared behaviors' do diff --git a/spec/models/contact_spec.rb b/spec/models/contact_spec.rb index 2bf82f661..26cce4b53 100644 --- a/spec/models/contact_spec.rb +++ b/spec/models/contact_spec.rb @@ -174,4 +174,29 @@ describe Contact do end end end + + describe "#repopulate_cache" do + before do + @contact = bob.contact_for(alice.person) + end + + it "repopulates the cache if the cache exists" do + cache = stub(:repopulate!) + RedisCache.stub(:configured? => true, :new => cache) + + cache.should_receive(:repopulate!) + @contact.repopulate_cache! + end + + it "does not touch the cache if it is not configured" do + RedisCache.stub(:configured?).and_return(false) + RedisCache.should_not_receive(:new) + @contact.repopulate_cache! + end + + it "gets called on destroy" do + @contact.should_receive(:repopulate_cache!) + @contact.destroy + end + end end diff --git a/spec/models/user/connecting_spec.rb b/spec/models/user/connecting_spec.rb index c5cf3da1a..78d86934b 100644 --- a/spec/models/user/connecting_spec.rb +++ b/spec/models/user/connecting_spec.rb @@ -52,8 +52,8 @@ describe Diaspora::UserModules::Connecting do it 'calls remove contact' do contact = bob.contact_for(alice.person) - bob.should_receive(:remove_contact).with(contact) - bob.disconnect contact + bob.should_receive(:remove_contact).with(contact, {}) + bob.disconnect(contact) end it 'dispatches a retraction' do