-
Notifications
You must be signed in to change notification settings - Fork 47
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
✨ Add GDPR-Export for user #2444
Open
HerrLevin
wants to merge
22
commits into
develop
Choose a base branch
from
dev-lb/gdpr-export
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
68bc1bf
Add basic gdpr export without any ui
HerrLevin d23f3ce
Move statuses to end + fix mentions
HerrLevin bf8cbe4
Autoformatter
HerrLevin 9104b43
Add Database Notification
HerrLevin 0c42682
Remove useless comment
HerrLevin dfa69da
Merge branch 'refs/heads/develop' into dev-lb/gdpr-export
MrKrisKrisu 6ceb677
fix composer errors
MrKrisKrisu 9fda849
Merge branch 'develop' into dev-lb/gdpr-export
HerrLevin c2cb84a
composer fix
HerrLevin 2c7913f
Move UserPersonalData to custom class
HerrLevin 321a09d
Add reports to GdprDataService
HerrLevin 44673e9
remove blocked_by
HerrLevin 3256bf0
Add trusted_users, remove muted_by
HerrLevin 0648d25
Add frontend to gdpr request
HerrLevin d0182fc
Limit to 7 days + cleanup
HerrLevin a5ba02b
soft-launching
HerrLevin 71eb46b
Merge branch 'develop' into dev-lb/gdpr-export
MrKrisKrisu 690a105
rename `data` -> `userModel`
MrKrisKrisu f28056e
use only
MrKrisKrisu 94f8b1e
add attributes from user model
MrKrisKrisu dff7f2f
use only
MrKrisKrisu f0e7b10
add todo
MrKrisKrisu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use romanzipp\QueueMonitor\Traits\IsMonitored; | ||
use Spatie\PersonalDataExport\ExportsPersonalData; | ||
use Spatie\PersonalDataExport\Jobs\CreatePersonalDataExportJob; | ||
|
||
class MonitoredPersonalDataExportJob extends CreatePersonalDataExportJob | ||
{ | ||
|
||
use IsMonitored; | ||
|
||
public $timeout = 30 * 60; | ||
|
||
|
||
protected function ensureValidUser(ExportsPersonalData $user) { | ||
// Do nothing since we are not enforcing the user to have an email property | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace App\Notifications; | ||
|
||
use Carbon\Carbon; | ||
use Spatie\PersonalDataExport\Notifications\PersonalDataExportedNotification as MainPersonalDataExportedNotification; | ||
|
||
class PersonalDataExportedNotification extends MainPersonalDataExportedNotification implements BaseNotification | ||
{ | ||
|
||
public function via($notifiable): array { | ||
return ['mail', 'database']; | ||
} | ||
|
||
public static function getLead(array $data): string { | ||
return __('notifications.personalDataExported.lead'); | ||
} | ||
|
||
public static function getNotice(array $data): ?string { | ||
$date = Carbon::parse($data['deletionDatetime']); | ||
return __('notifications.personalDataExported.notice', [ | ||
'date' => userTime($date, __('datetime-format')), | ||
]); | ||
} | ||
|
||
public static function getLink(array $data): ?string { | ||
return route('personal-data-exports', $data['zipFilename']); | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'zipFilename' => $this->zipFilename, | ||
'deletionDatetime' => $this->deletionDatetime, | ||
]; | ||
} | ||
} |
87 changes: 87 additions & 0 deletions
87
app/Services/PersonalDataSelection/UserGdprDataService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?php | ||
|
||
namespace App\Services\PersonalDataSelection; | ||
|
||
use App\Http\Controllers\Backend\User\TokenController; | ||
use App\Models\Event; | ||
use App\Models\EventSuggestion; | ||
use App\Models\Mention; | ||
use App\Models\User; | ||
use App\Models\WebhookCreationRequest; | ||
use Illuminate\Support\Facades\DB; | ||
use Spatie\PersonalDataExport\PersonalDataSelection; | ||
|
||
class UserGdprDataService | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gerade noch festgestellt: Wenn man die .zip herunterlädt fehlt die Dateiendung. Die Datei heißt einfach nur wie der User. Da sollten wir nochmal schauen. |
||
{ | ||
public function __invoke(PersonalDataSelection $personalDataSelection, User $data): void { | ||
$this->addUserPersonalData($personalDataSelection, $data); | ||
} | ||
|
||
private function addUserPersonalData(PersonalDataSelection $personalDataSelection, User $userModel): void { | ||
$userData = $userModel->only([ | ||
'name', 'username', 'home_id', 'private_profile', 'default_status_visibility', | ||
'default_status_sensitivity', 'prevent_index', 'privacy_hide_days', 'language', | ||
'timezone', 'friend_checkin', 'likes_enabled', 'points_enabled', 'mapprovider', | ||
'email', 'email_verified_at', 'privacy_ack_at', | ||
'last_login', 'created_at', 'updated_at' | ||
]); | ||
|
||
$webhooks = $userModel->webhooks()->with('events')->get(); | ||
$webhooks = $webhooks->map(function($webhook) { | ||
return $webhook->only([ | ||
'oauth_client_id', 'created_at', 'updated_at' | ||
]); | ||
}); | ||
|
||
|
||
if ($userModel->avatar && file_exists(public_path('/uploads/avatars/' . $userModel->avatar))) { | ||
$personalDataSelection | ||
->addFile(public_path('/uploads/avatars/' . $userModel->avatar)); | ||
} | ||
|
||
$personalDataSelection | ||
->add('user.json', $userData) | ||
->add('notifications.json', $userModel->notifications()->get()->toJson()) //TODO: columns definieren | ||
->add('likes.json', $userModel->likes()->get()->toJson()) //TODO: columns definieren | ||
->add('social_profile.json', $userModel->socialProfile()->with('mastodonserver')->get()) //TODO: columns definieren | ||
->add('event_suggestions.json', EventSuggestion::where('user_id', $userModel->id)->get()->toJson()) //TODO: columns definieren | ||
->add('events.json', Event::where('approved_by', $userModel->id)->get()->toJson()) //TODO: columns definieren | ||
->add('webhooks.json', $webhooks) | ||
->add( | ||
'webhook_creation_requests.json', | ||
WebhookCreationRequest::where('user_id', $userModel->id)->get()->toJson() //TODO: columns definieren | ||
) | ||
->add('tokens.json', TokenController::index($userModel)->toJson()) //TODO: columns definieren | ||
->add('ics_tokens.json', $userModel->icsTokens()->get()->toJson()) //TODO: columns definieren | ||
->add( | ||
'password_resets.json', | ||
DB::table('password_resets')->select(['email', 'created_at'])->where('email', $userModel->email)->get() //TODO: columns definieren | ||
) | ||
->add('apps.json', $userModel->oAuthClients()->get()->toJson()) //TODO: columns definieren | ||
->add('follows.json', DB::table('follows')->where('user_id', $userModel->id)->get()) //TODO: columns definieren | ||
->add('followings.json', DB::table('follows')->where('follow_id', $userModel->id)->get()) //TODO: columns definieren | ||
->add('blocks.json', DB::table('user_blocks')->where('user_id', $userModel->id)->get()) //TODO: columns definieren | ||
->add('mutes.json', DB::table('user_mutes')->where('user_id', $userModel->id)->get()) //TODO: columns definieren | ||
->add('follow_requests.json', DB::table('follow_requests')->where('user_id', $userModel->id)->get()) //TODO: columns definieren | ||
->add('follows_requests.json', DB::table('follow_requests')->where('follow_id', $userModel->id)->get()) //TODO: columns definieren | ||
->add('sessions.json', $userModel->sessions()->get()->toJson()) //TODO: columns definieren | ||
->add('home.json', $userModel->home()->get()->toJson()) //TODO: columns definieren | ||
->add('hafas_trips.json', DB::table('hafas_trips')->where('user_id', $userModel->id)->get()) //TODO: columns definieren | ||
->add('mentions.json', Mention::where('mentioned_id', $userModel->id)->get()->toJson()) //TODO: columns definieren | ||
->add('roles.json', $userModel->roles()->get()->toJson()) //TODO: columns definieren | ||
->add( | ||
'activity_log.json', | ||
DB::table('activity_log')->where('causer_type', get_class($userModel))->where('causer_id', $userModel->id)->get() //TODO: columns definieren | ||
) | ||
->add('permissions.json', $userModel->permissions()->get()->toJson()) //TODO: columns definieren | ||
->add('statuses.json', $userModel->statuses()->with('tags')->get()) //TODO: columns definieren | ||
->add( | ||
'reports.json', | ||
DB::table('reports') | ||
->select('subject_type', 'subject_id', 'reason', 'description', 'reporter_id') | ||
->where('reporter_id', $userModel->id) | ||
->get() //TODO: columns definieren | ||
) | ||
->add('trusted_users.json', DB::table('trusted_users')->where('user_id', $userModel->id)->get()); //TODO: columns definieren | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Könnte man ggfs. mit dem Laravel Ratelimiter lösen.