Skip to content

Commit

Permalink
🐛 Mastodon link is not automatically invalidated after unlinking prof…
Browse files Browse the repository at this point in the history
…ile (#2268)
  • Loading branch information
HerrLevin authored Jan 13, 2024
1 parent c88585b commit 10809e1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ public function getProfileUrl(): ?string {
}

private function getData(): ?array {
return Cache::remember(CacheKey::getMastodonProfileInformationKey($this->user), 60 * 60 /* 1 hour */, function() {
return Cache::remember(CacheKey::getMastodonProfileInformationKey($this->user), 3600, function () {
return $this->fetchProfileInformation();
});
}

public function forgetData(): void {
Cache::forget(CacheKey::getMastodonProfileInformationKey($this->user));
}

private function fetchProfileInformation(): ?array {
if ($this->user?->socialProfile?->mastodon_token && $this->user->socialProfile?->mastodon_id) {
try {
Expand Down
4 changes: 4 additions & 0 deletions app/Http/Controllers/Frontend/Social/SocialController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Controllers\Frontend\Social;

use App\Http\Controllers\Backend\Social\MastodonProfileDetails;
use App\Http\Controllers\Controller;
use Illuminate\Contracts\Foundation\Application;
use Illuminate\Contracts\Routing\ResponseFactory;
Expand Down Expand Up @@ -42,6 +43,9 @@ public function destroyProvider(Request $request): Response|Application|Response
'mastodon_server' => null,
'mastodon_token' => null
]);

$mastodonProfileDetails = new MastodonProfileDetails($user);
$mastodonProfileDetails->forgetData();
}
return response(__('controller.social.deleted'), 200);
}
Expand Down

0 comments on commit 10809e1

Please sign in to comment.