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

Close; Anonymise; Erase #7611

Merged
merged 7 commits into from
Mar 17, 2023
Merged

Close; Anonymise; Erase #7611

merged 7 commits into from
Mar 17, 2023

Conversation

garethrees
Copy link
Member

@garethrees garethrees commented Feb 27, 2023

Add some task-specific methods for better composability and future ability to add a UI button for each action to give us more control over how we handle various user requests.

A precursor to:

For use in other specs.

Had to change `after_initialize` to `before_validation` so that records
built via FactoryBot were valid. This also affects normal records:

    data = load_file_fixture('parrot.jpg')
    a = ProfilePhoto.new(data: data, user: User.first)
    a.valid?
    # => true

    data = load_file_fixture('parrot.jpg')
    a = ProfilePhoto.new(user: User.first)
    a.data = data
    a.valid?
    # => false

With this change, both examples now return `true`.
Tweak the spec such that it'll be easier to add forthcoming examples.
@mysociety-pusher mysociety-pusher force-pushed the close-anonymise-erase branch 2 times, most recently from f756b50 to 4ad05e1 Compare March 2, 2023 12:34
@garethrees garethrees marked this pull request as ready for review March 2, 2023 12:35
@garethrees garethrees requested a review from gbp March 2, 2023 13:09
Copy link
Member

@gbp gbp 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. Left some minor comments.

app/models/user.rb Outdated Show resolved Hide resolved
spec/models/user_spec.rb Show resolved Hide resolved
spec/models/user_spec.rb Show resolved Hide resolved
spec/models/user_spec.rb Show resolved Hide resolved
Closing your account should stop all communications from the app. This
is likely not completely true in practice [1] as some messages may
ignore this flag, but this sets the intent.

[1] #4603
Add a version of `#close` that raises on failure, and define `#close` in
terms of `#close!` as per convention.
Method to only erase PII account data to enable forthcoming composition
of various close / anonymise / erase options.
Simple method to handle anonymisation via CensorRule if the user has any
content to anonymise.
Compose from new task-specific methods to make clearer.

Had to tweak the censor rule creation since closing currently appends
"(Account suspended)", which then gets added to the censor rule `text`.
We only want to redact the raw attribute content.

Drop `User#redact_name!` since we now have `anonymise!` to do the same
thing.

Fixes #5600 as the use of
`#erase!` for this method now clears the profile photo.
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