Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/autofollow any user #4278

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,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

Expand Down
4 changes: 2 additions & 2 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,8 @@ def seed_aspects
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('[email protected]').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
Expand Down
9 changes: 6 additions & 3 deletions config/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ defaults:
settings:
pod_name: 'Diaspora*'
enable_registrations: true
follow_diasporahq: true
autofollow_on_join: true
autofollow_on_join_user: '[email protected]'
invitations:
open: true
count: 25
Expand Down Expand Up @@ -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:
Expand All @@ -132,7 +134,8 @@ test:
assets:
serve: true
settings:
follow_diasporahq: false
autofollow_on_join: false
autofollow_on_join_user: ''
invitations:
open: true
services:
Expand Down
12 changes: 8 additions & 4 deletions config/diaspora.yml.example
Original file line number Diff line number Diff line change
Expand Up @@ -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
## [email protected] 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: '[email protected]'

## Settings about invitations
invitations: ## Section
Expand Down
19 changes: 11 additions & 8 deletions spec/models/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -864,34 +864,37 @@
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
end

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)

Expand Down