-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
293 additions
and
40 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
app/Services/PersonalDataSelection/Exporters/AppsExporter.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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class AppsExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'apps.json'; | ||
protected string $relation = 'oAuthClients'; | ||
// todo: columns | ||
} |
36 changes: 36 additions & 0 deletions
36
app/Services/PersonalDataSelection/Exporters/Base/RelationExportable.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,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters\Base; | ||
|
||
trait RelationExportable | ||
{ | ||
protected function exportData(): string|array { | ||
|
||
$relation = $this->user->{$this->relation}(); | ||
|
||
if (!empty($this->whereColumn)) { | ||
$condition = $this->whereCondition ?? 'id'; | ||
|
||
$relation->where( | ||
$this->whereColumn, | ||
$this->user->{$condition} | ||
); | ||
} | ||
|
||
if (!empty($this->with)) { | ||
$relation->with($this->with); | ||
} | ||
|
||
if (!empty($this->columns)) { | ||
return $relation->only($this->columns); | ||
} | ||
|
||
return $relation->get()->toJson(); | ||
} | ||
|
||
protected function onExportValidation(): bool { | ||
return !empty($this->relation); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Services/PersonalDataSelection/Exporters/HomeExporter.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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class HomeExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'home.json'; | ||
protected string $relation = 'home'; | ||
// todo: columns | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Services/PersonalDataSelection/Exporters/IcsTokenExporter.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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class IcsTokenExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'ics_tokens.json'; | ||
protected string $relation = 'icsTokens'; | ||
// todo: columns | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Services/PersonalDataSelection/Exporters/LikesExporter.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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class LikesExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'likes.json'; | ||
protected string $relation = 'likes'; | ||
// todo: columns | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Services/PersonalDataSelection/Exporters/NotificationsExporter.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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class NotificationsExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'notifications.json'; | ||
protected string $relation = 'notifications'; | ||
// todo: columns | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Services/PersonalDataSelection/Exporters/PermissionExporter.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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class PermissionExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'permissions.json'; | ||
protected string $relation = 'permissions'; | ||
// todo: columns | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Services/PersonalDataSelection/Exporters/RoleExporter.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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class RoleExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'roles.json'; | ||
protected string $relation = 'roles'; | ||
// todo: columns | ||
} |
17 changes: 17 additions & 0 deletions
17
app/Services/PersonalDataSelection/Exporters/SessionExporter.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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class SessionExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'sessions.json'; | ||
protected string $relation = 'sessions'; | ||
// todo: columns | ||
} |
18 changes: 18 additions & 0 deletions
18
app/Services/PersonalDataSelection/Exporters/SocialProfileExporter.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,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class SocialProfileExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'social_profiles.json'; | ||
protected string $relation = 'socialProfile'; | ||
protected string $with = 'mastodonserver'; | ||
// todo: columns | ||
} |
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
17 changes: 17 additions & 0 deletions
17
app/Services/PersonalDataSelection/Exporters/TokenExporter.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,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
use App\Services\PersonalDataSelection\Exporters\Base\RelationExportable; | ||
|
||
class TokenExporter extends AbstractExporter | ||
{ | ||
use RelationExportable; | ||
|
||
protected string $fileName = 'tokens.json'; | ||
protected string $relation = 'tokens'; | ||
// todo: columns | ||
} |
27 changes: 27 additions & 0 deletions
27
app/Services/PersonalDataSelection/Exporters/UserDataExporter.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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
|
||
class UserDataExporter extends AbstractExporter | ||
{ | ||
protected string $fileName = 'user.json'; | ||
protected array $columns = [ | ||
'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' | ||
]; | ||
|
||
protected function exportData(): array|string { | ||
return $this->user->only($this->columns); | ||
} | ||
|
||
protected function onExportValidation(): bool { | ||
return true; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/Services/PersonalDataSelection/Exporters/WebhookExporter.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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Services\PersonalDataSelection\Exporters; | ||
|
||
use App\Services\PersonalDataSelection\Exporters\Base\AbstractExporter; | ||
|
||
class WebhookExporter extends AbstractExporter | ||
{ | ||
protected string $fileName = 'webhooks.json'; | ||
|
||
protected function exportData(): array|string { | ||
$webhooks = $this->user->webhooks()->with('events')->get(); | ||
$webhooks = $webhooks->map(function($webhook) { | ||
return $webhook->only([ | ||
'oauth_client_id', 'created_at', 'updated_at' | ||
]); | ||
}); | ||
|
||
return $webhooks->toJson(); | ||
} | ||
|
||
protected function onExportValidation(): bool { | ||
return true; | ||
} | ||
} |
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