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

View contributions publicly when peer-to-peer is on #810

Merged
merged 5 commits into from
Jan 8, 2021

Conversation

h-m-m
Copy link
Collaborator

@h-m-m h-m-m commented Dec 4, 2020

Why

This is one of the required steps of the peer-to-peer matchmaking workflow. This makes the list of available contributions generally public if the peer-to-peer setting is on.

Next Steps

The next step after this will be to change what the "Respond" button does for people who aren't logged in. I'd prefer to keep that next step in a separate PR, but can add it on to here if people would rather keep them together.

Also, the permission logic here should be refactored out to a Pundit object once we're bringing those in. @maebeale talked about adding features later that allow users to mark their contributions as "for admin eyes only" or something similar. Implementation of those features would be a good time to refactor here.

Pre-Merge Checklist

  • All new features have been described in the pull request
  • Security & accessibility have been considered
  • All outstanding questions and concerns have been resolved
  • Any next steps that seem like good ideas have been created as issues for future discussion & implementation
  • High quality tests have been added, or an explanation has been given why the features cannot be tested
  • New features have been documented, and the code is understandable and well commented
  • Entry added to CHANGELOG.md if appropriate

What

  • moved the code that generates the urls for the response buttons out of the presenter and into the controller
  • updated controller before actions for authentication to include the new logic
  • refactored tests to describe the new behavior
  • TODO: changed the ContributionsController#respond action because the view for that page currently has a lot of stuff in it that we don't want publicly-facing

Accessibility

I expect this change will have no net effect on accessibility excepting any of the security concerns below.

Security

There is a security risk here of inadvertently allowing information to be public.

  • It is possible that someone will try submit some form of spam, advertising, or inappropriate promotion if info from the contribution forms is automatically made public like this
  • It is very likely that some user will not understand what information on the forms they fill will or won't be made public
  • It is possible take information that a user wants to and expects will stay private and make it public later. This can happen if an admin changes to p2p mode without notifying users
  • an admin could also reveal info by changing the setting by accident

I feel like it's acceptable to continue with this work, understanding that the above security concerns are things we can address once we confirm mutual aid groups are happy with the basic functionality

Copy link
Collaborator

@solebared solebared left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Agree the next chunk can be in a separate PR though maybe they need to be merged together?

Couple of comments in line, nothing majory.
💪🏾


def contribution_blueprint_options
options = { respond_path: ->(id) { respond_contribution_path(id)} }
options[:view_path] = ->(id) { contribution_path(id) } if SystemSetting.current_settings&.peer_to_peer?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 62 above references @system_setting. Can we do that here as well?

before do
sign_in user unless scenario =~ /logged out/
allow_any_instance_of(SystemSetting).to receive(:peer_to_peer?).and_return(true) if scenario =~ /p2p is enabled/
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, i don't love repeating buckets of examples across multiple contexts.

There are of course circumstances when that's appropriate, eg for cross-cutting concerns. But in many cases, it can quickly become difficult to know which examples really care about being tested in all contexts and which just happened to be lumped in out of convenience. This then can hinder future refactoring.

In this case, iirc the key thing to test between the three contexts is whether /contributions is accessible. I'd probably make that clear in a separate describe 'access' or similar block where that's the only thing being asserted. The examples below deal with details of the page which i don't think need to be re-run across contexts that are about authorization.

All that said, this is just my gut feeling -- i'm certainly fine with leaving it as is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the tests as you've suggested

Copy link
Collaborator

@maebeale maebeale left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@svileshina svileshina self-requested a review January 8, 2021 00:15
@h-m-m h-m-m marked this pull request as ready for review January 8, 2021 01:07
Howard M. Miller and others added 4 commits January 7, 2021 20:08
@h-m-m
Copy link
Collaborator Author

h-m-m commented Jan 8, 2021

Discussed with @maebeale and @svileshina, and I think we're okay with merging this in now, and then putting the "TODO: changed the ContributionsController#respond action because the view for that page currently has a lot of stuff in it that we don't want publicly-facing" part in a separate PR

As long as we don't cut a release before fixing that part of things, we're good

@h-m-m h-m-m merged commit 8597d73 into main Jan 8, 2021
@h-m-m h-m-m deleted the p2p-contribution-changes branch January 8, 2021 01:26
@maebeale
Copy link
Collaborator

maebeale commented Jan 8, 2021

WOO HOOOOOO!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants