From dce1531ba6c800238e8b503c5fda5f29b8858528 Mon Sep 17 00:00:00 2001 From: Ruxton Date: Wed, 3 Jul 2013 10:43:28 +0800 Subject: [PATCH] Changed follow_diasporahq to be configurable to auto follow any user on join. Fixing example config file Updated changelog --- Changelog.md | 1 + app/models/user.rb | 4 ++-- config/defaults.yml | 9 ++++++--- config/diaspora.yml.example | 12 ++++++++---- spec/models/user_spec.rb | 19 +++++++++++-------- 5 files changed, 28 insertions(+), 17 deletions(-) diff --git a/Changelog.md b/Changelog.md index f6c9fe534..4f96202ce 100644 --- a/Changelog.md +++ b/Changelog.md @@ -14,6 +14,7 @@ * Admin: add option to find users under 13 (COPPA) [#4252](https://github.com/diaspora/diaspora/pull/4252) * Show the user if a contact is sharing with them when viewing their profile page [#2948](https://github.com/diaspora/diaspora/issues/2948) * Made Unicorn timeout configurable and increased the default to 90 seconds +* Follow DiasporaHQ upon account creation is now configurable to another account [#4278](https://github.com/diaspora/diaspora/pull/4278) # 0.1.1.0 diff --git a/app/models/user.rb b/app/models/user.rb index faca1f6af..a53bfe488 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -391,8 +391,8 @@ class User < ActiveRecord::Base self.aspects.create(:name => I18n.t('aspects.seed.work')) aq = self.aspects.create(:name => I18n.t('aspects.seed.acquaintances')) - if AppConfig.settings.follow_diasporahq? - default_account = Webfinger.new('diasporahq@joindiaspora.com').fetch + if AppConfig.settings.autofollow_on_join? + default_account = Webfinger.new(AppConfig.settings.autofollow_on_join_user).fetch self.share_with(default_account, aq) if default_account end aq diff --git a/config/defaults.yml b/config/defaults.yml index e9f56a4da..7454595bf 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -53,7 +53,8 @@ defaults: settings: pod_name: 'Diaspora*' enable_registrations: true - follow_diasporahq: true + autofollow_on_join: true + autofollow_on_join_user: 'diasporahq@joindiaspora.com' invitations: open: true count: 25 @@ -121,7 +122,8 @@ development: server: unicorn_worker: 1 settings: - follow_diasporahq: false + autofollow_on_join: false + autofollow_on_join_user: '' production: i_am_a_dummy: # Remove if you add an actual override test: @@ -132,7 +134,8 @@ test: assets: serve: true settings: - follow_diasporahq: false + autofollow_on_join: false + autofollow_on_join_user: '' invitations: open: true services: diff --git a/config/diaspora.yml.example b/config/diaspora.yml.example index 1b681ad0e..1ca7c1afd 100644 --- a/config/diaspora.yml.example +++ b/config/diaspora.yml.example @@ -205,12 +205,16 @@ configuration: ## Section ## the first registration (you). #enable_registrations: true - ## Set this to false if you don't want your users to follow the - ## diasporahq@joindiaspora.com account on account creation. + ## Users will automatically follow a specified account on creation + ## Set this to false if you don't want your users to automatically + ## follow an account upon creation. + #autfollow_on_join: true + ## The diasporahq account helps users start with some activity in ## their stream and get news about Diaspora, but if you don't want - ## your server to contact joindiaspora.com, set this to false: - #follow_diasporahq: false + ## your server to contact joindiaspora.com, you can change account + ## below or set autofollow_on_join to false + #autofollow_on_join_user: 'diasporahq@joindiaspora.com' ## Settings about invitations invitations: ## Section diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 58fcbc142..d0ac01f5a 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -864,26 +864,29 @@ describe User do end end - describe "diasporahq sharing" do + describe "autofollow sharing" do let(:user) { FactoryGirl.create(:user) } before(:each) do - @old_followhq_value = AppConfig.settings.follow_diasporahq? + @old_autofollow_value = AppConfig.settings.autofollow_on_join? + @old_autofollow_user = AppConfig.settings.autofollow_on_join_user end after(:each) do - AppConfig.settings.follow_diasporahq = @old_followhq_value + AppConfig.settings.autofollow_on_join = @old_followhq_value + AppConfig.settings.autofollow_on_join_user = @old_autofollow_user end - context "with sharing with diasporahq enabled" do - it "should start sharing with the diasporahq account" do - AppConfig.settings.follow_diasporahq = true + context "with autofollow sharing enabled" do + it "should start sharing with autofollow account" do + AppConfig.settings.autofollow_on_join = true + AppConfig.settings.autofollow_on_join_user = 'one' wf_mock = mock wf_mock.should_receive(:fetch) - Webfinger.should_receive(:new).and_return(wf_mock) + Webfinger.should_receive(:new).with('one').and_return(wf_mock) user.seed_aspects end @@ -891,7 +894,7 @@ describe User do context "with sharing with diasporahq enabled" do it "should not start sharing with the diasporahq account" do - AppConfig.settings.follow_diasporahq = false + AppConfig.settings.autofollow_on_join = false Webfinger.should_not_receive(:new)