change 'mute' to 'ignore' for now; fix specs; repopulate cache upon
contact removal
This commit is contained in:
parent
5df6bc1adf
commit
07f713f46c
11 changed files with 60 additions and 25 deletions
|
|
@ -3,8 +3,8 @@ module StreamElementHelper
|
||||||
if user_signed_in? && current_user.person.id != author.id
|
if user_signed_in? && current_user.person.id != author.id
|
||||||
link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}),
|
link_to image_tag('deletelabel.png'), blocks_path(:block => {:person_id => author.id}),
|
||||||
:class => 'block_user delete',
|
:class => 'block_user delete',
|
||||||
:confirm => t('are_you_sure'),
|
:confirm => t('.ignore_user_description'),
|
||||||
:title => t('.block_user', :name => author.first_name),
|
:title => t('.ignore_user', :name => author.first_name),
|
||||||
:method => :post
|
:method => :post
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,8 @@ class Contact < ActiveRecord::Base
|
||||||
|
|
||||||
validates_uniqueness_of :person_id, :scope => :user_id
|
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
|
# contact.sharing is true when contact.person is sharing with contact.user
|
||||||
scope :sharing, lambda {
|
scope :sharing, lambda {
|
||||||
|
|
@ -42,6 +43,13 @@ class Contact < ActiveRecord::Base
|
||||||
:type => "Notifications::StartedSharing").delete_all
|
:type => "Notifications::StartedSharing").delete_all
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def repopulate_cache!
|
||||||
|
if RedisCache.configured?
|
||||||
|
cache = RedisCache.new(self.user)
|
||||||
|
cache.repopulate!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def dispatch_request
|
def dispatch_request
|
||||||
request = self.generate_request
|
request = self.generate_request
|
||||||
Postzord::Dispatcher.build(self.user, request).post
|
Postzord::Dispatcher.build(self.user, request).post
|
||||||
|
|
|
||||||
|
|
@ -12,13 +12,12 @@
|
||||||
|
|
||||||
.span-12.prepend-5.last
|
.span-12.prepend-5.last
|
||||||
%h3
|
%h3
|
||||||
= t('.blocked_users')
|
= t('.ignored_users')
|
||||||
|
|
||||||
- @blocks.each do |block|
|
- @blocks.each do |block|
|
||||||
= block.person.name
|
= block.person.name
|
||||||
\-
|
\-
|
||||||
= link_to t('.unblock'), block_path(block),
|
= link_to t('.stop_ignoring'), block_path(block),
|
||||||
:confirm => t('are_you_sure'),
|
|
||||||
:method => :delete
|
:method => :delete
|
||||||
%br
|
%br
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -725,11 +725,11 @@ en:
|
||||||
|
|
||||||
blocks:
|
blocks:
|
||||||
create:
|
create:
|
||||||
success: "Alright, you won't see them again. #niceblock!"
|
success: "Alright, you won't see that user in your stream again. #silencio!"
|
||||||
failure: "I couldn't block that user. #evasion"
|
failure: "I couldn't ignore that user. #evasion"
|
||||||
destroy:
|
destroy:
|
||||||
success: "User unblocked! #combobreaker"
|
success: "Let's see what they have to say! #sayhello"
|
||||||
failure: "I couldn't unblock that user. #evasion"
|
failure: "I couldn't stop ignoring that user. #evasion"
|
||||||
|
|
||||||
shared:
|
shared:
|
||||||
aspect_dropdown:
|
aspect_dropdown:
|
||||||
|
|
@ -793,7 +793,8 @@ en:
|
||||||
connect_to_comment: "Connect to this user to comment on their post"
|
connect_to_comment: "Connect to this user to comment on their post"
|
||||||
currently_unavailable: 'commenting currently unavailable'
|
currently_unavailable: 'commenting currently unavailable'
|
||||||
via: "via %{link}"
|
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"
|
hide_and_mute: "Hide and mute post"
|
||||||
like: "Like"
|
like: "Like"
|
||||||
unlike: "Unlike"
|
unlike: "Unlike"
|
||||||
|
|
@ -932,8 +933,8 @@ en:
|
||||||
|
|
||||||
privacy_settings:
|
privacy_settings:
|
||||||
title: "Privacy Settings"
|
title: "Privacy Settings"
|
||||||
blocked_users: "Blocked Users"
|
ignored_users: "Ignored Users"
|
||||||
unblock: "Unblock"
|
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."
|
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:
|
getting_started:
|
||||||
|
|
|
||||||
|
|
@ -4,10 +4,10 @@
|
||||||
|
|
||||||
class RedisCache
|
class RedisCache
|
||||||
|
|
||||||
SUPPORTED_CACHES = [:created_at] #['updated_at',
|
SUPPORTED_CACHES = [:created_at]
|
||||||
CACHE_LIMIT = 100
|
CACHE_LIMIT = 100
|
||||||
|
|
||||||
def initialize(user, order_field)
|
def initialize(user, order_field=:created_at)
|
||||||
@user = user
|
@user = user
|
||||||
@order_field = order_field.to_s
|
@order_field = order_field.to_s
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ module Diaspora
|
||||||
end
|
end
|
||||||
|
|
||||||
def shareables_from(klass, person)
|
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
|
con = Contact.arel_table
|
||||||
p = klass.arel_table
|
p = klass.arel_table
|
||||||
shareable_ids = []
|
shareable_ids = []
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,8 @@ form
|
||||||
:padding
|
:padding
|
||||||
:top 45px
|
:top 45px
|
||||||
:bottom 8px
|
:bottom 8px
|
||||||
|
:left 12px
|
||||||
|
:right 12px
|
||||||
|
|
||||||
#flash_notice
|
#flash_notice
|
||||||
.message
|
.message
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ require File.join(Rails.root, 'spec', 'shared_behaviors', 'stream')
|
||||||
|
|
||||||
describe Stream::Public do
|
describe Stream::Public do
|
||||||
before do
|
before do
|
||||||
@stream = Stream::Public.new(stub)
|
@stream = Stream::Public.new(alice)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'shared behaviors' do
|
describe 'shared behaviors' do
|
||||||
|
|
|
||||||
|
|
@ -174,4 +174,29 @@ describe Contact do
|
||||||
end
|
end
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@ describe Diaspora::UserModules::Connecting do
|
||||||
it 'calls remove contact' do
|
it 'calls remove contact' do
|
||||||
contact = bob.contact_for(alice.person)
|
contact = bob.contact_for(alice.person)
|
||||||
|
|
||||||
bob.should_receive(:remove_contact).with(contact)
|
bob.should_receive(:remove_contact).with(contact, {})
|
||||||
bob.disconnect contact
|
bob.disconnect(contact)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'dispatches a retraction' do
|
it 'dispatches a retraction' do
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue