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
Make autofollow_on_join_user
configuration a list
#8430
base: develop
Are you sure you want to change the base?
Make autofollow_on_join_user
configuration a list
#8430
Conversation
abrahamparayil
commented
Jun 15, 2023
- Fixes: Make 'autofollow_on_join_user' configuration a list #4986
@denschub @SuperTux88 I am unable to run the specs locally. I am getting the following error:
Couldn't find any documentation for running tests either could you folks help me out here? Thanks! |
Welcome to this project, @abrahamparayil! :)
Have a look at this wiki page which explains the generics. If you still run into issues, head over to our Discourse and create a new thread in the "Development" section, so we can debug and help there without adding too much "not related to this PR" comments here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good progress! A few more tests, a deprecation warning on boot time for the old setting and a changelog entry describing how to migrate the setting and then this looks good to me 😇
app/models/user.rb
Outdated
autofollow_accounts.push(autofollow_user) if autofollow_user.present? | ||
|
||
begin | ||
autofollow_accounts.uniq.each { |user_id| follow_account(user_id, aq) } if autofollow_accounts.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
autofollow_accounts.uniq.each { |user_id| follow_account(user_id, aq) } if autofollow_accounts.present? | |
autofollow_accounts.uniq.each { |user_id| follow_account(user_id, aq) } |
Array.wrap
will ensure it's an array already, the #push
call above would already fail if it's not and each
on an empty array is a noop. So I think we can do without the if
condition :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved here: 25ae7a9.
app/models/user.rb
Outdated
|
||
begin | ||
autofollow_accounts.uniq.each { |user_id| follow_account(user_id, aq) } if autofollow_accounts.present? | ||
rescue DiasporaFederation::Discovery::DiscoveryError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we fold the rescue
into the loop (or follow_account
that is) perhaps? That is wouldn't we want to attempt to follow the remaining users regardless of anyone failing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved here: 25ae7a9.
@denschub All tests are failing with the following error:
Am I missing something here? 😅 @jhass I there a specific place (as a convention) to add boot time warnings within the project? |
@abrahamparayil Sorry for the late reply. I think config/load_config.rb would be a good place for this one. |
@jhass No worries. I've added the warning. :) |
- New: | ||
```toml | ||
autofollow_on_join_accounts = "hq@pod.diaspora.software" | ||
OR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this line a comment, so it doesn't show up as TOML-syntax error.
OR | |
# OR |
if AppConfig.settings.autofollow_on_join? | ||
autofollow_user = AppConfig.settings.autofollow_on_join_user | ||
autofollow_accounts = Array.wrap(AppConfig.settings.autofollow_on_join_accounts) | ||
autofollow_accounts.push(autofollow_user) if autofollow_user.present? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if just adding the old autofollow_on_join_user
to the new default value of autofollow_on_join_accounts
is the correct thing to do. For podmins who didn't configure anything, nothing chnages, but podmins who manually set another account, it silently adds the HQ-account to the list (as it's the default value for the new setting), until they manually migrate their config to the new autofollow_on_join_accounts
and decide if they want to include the HQ-account now (in addition to their account), or if they still want to keep it with only one account.
My expectations would have been, that if the old autofollow_on_join_user
is set, it still behaves as it was before, so just following that one user. And only if the new autofollow_on_join_accounts
is the only option used, it follows multiple users.
But maybe the behavior is fine, as this will be released in a major version with a big changelog entry, so we can expect podmins to read that and react accordingly if they don't want the HQ-Account to be added by default? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with breaking things in major releases. It's not our fault if people don't read changelogs, and in this case, this seems like a worthy change.
expect(Person).to | ||
receive(:find_or_fetch_by_identifier).with(person.diaspora_handle).and_return(person) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This syntax (with receive
on a separate line) breaks the tests (as it should be a parameter for to
) , it needs to be like this:
expect(Person).to | |
receive(:find_or_fetch_by_identifier).with(person.diaspora_handle).and_return(person) | |
expect(Person).to receive(:find_or_fetch_by_identifier) | |
.with(person.diaspora_handle).and_return(person) |
expect(Person).to | ||
receive(:find_or_fetch_by_identifier).with(person.diaspora_handle).and_return(person) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above:
expect(Person).to | |
receive(:find_or_fetch_by_identifier).with(person.diaspora_handle).and_return(person) | |
expect(Person).to receive(:find_or_fetch_by_identifier) | |
.with(person.diaspora_handle).and_return(person) |
expect(Person).to | ||
receive(:find_or_fetch_by_identifier).with(person.diaspora_handle).and_return(person) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is broken, as it expects the behavior I described above. It wants that only the autofollow_on_join_user
(person
) is followed, but since autofollow_on_join_accounts
has a default value of the HQ account, it also tries to follow that one, which isn't expected by this test. So either change the behavior that when autofollow_on_join_user
is set, it ignores the value of autofollow_on_join_accounts
(which always has a default value set), or change the test, to also expect the default value of autofollow_on_join_accounts
.
Also there is a syntax error with the receive
on it's own line.