mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-14 02:24:31 +00:00
Update SettingsController, add export endpoints
This commit is contained in:
parent
431845dac4
commit
0691961af0
1 changed files with 47 additions and 1 deletions
|
@ -3,9 +3,11 @@
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\AccountLog;
|
use App\AccountLog;
|
||||||
|
use App\Following;
|
||||||
|
use App\UserFilter;
|
||||||
use Auth;
|
use Auth;
|
||||||
use DB;
|
use DB;
|
||||||
|
use Cache;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Settings\{
|
use App\Http\Controllers\Settings\{
|
||||||
HomeSettings,
|
HomeSettings,
|
||||||
|
@ -69,6 +71,50 @@ class SettingsController extends Controller
|
||||||
return view('settings.dataexport');
|
return view('settings.dataexport');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function exportFollowing()
|
||||||
|
{
|
||||||
|
$data = Cache::remember('account:export:profile:following:'.Auth::user()->profile->id, 1440, function() {
|
||||||
|
return Auth::user()->profile->following()->get()->map(function($i) {
|
||||||
|
return $i->url();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return response()->streamDownload(function () use($data) {
|
||||||
|
echo $data;
|
||||||
|
}, 'following.json');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exportFollowers()
|
||||||
|
{
|
||||||
|
$data = Cache::remember('account:export:profile:followers:'.Auth::user()->profile->id, 1440, function() {
|
||||||
|
return Auth::user()->profile->followers()->get()->map(function($i) {
|
||||||
|
return $i->url();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return response()->streamDownload(function () use($data) {
|
||||||
|
echo $data;
|
||||||
|
}, 'followers.json');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function exportMuteBlockList()
|
||||||
|
{
|
||||||
|
$profile = Auth::user()->profile;
|
||||||
|
$exists = UserFilter::select('id')
|
||||||
|
->whereUserId($profile->id)
|
||||||
|
->exists();
|
||||||
|
if(!$exists) {
|
||||||
|
return redirect()->back();
|
||||||
|
}
|
||||||
|
$data = Cache::remember('account:export:profile:muteblocklist:'.Auth::user()->profile->id, 1440, function() use($profile) {
|
||||||
|
return json_encode([
|
||||||
|
'muted' => $profile->mutedProfileUrls(),
|
||||||
|
'blocked' => $profile->blockedProfileUrls()
|
||||||
|
], JSON_PRETTY_PRINT);
|
||||||
|
});
|
||||||
|
return response()->streamDownload(function () use($data) {
|
||||||
|
echo $data;
|
||||||
|
}, 'muted-and-blocked-accounts.json');
|
||||||
|
}
|
||||||
|
|
||||||
public function dataImport()
|
public function dataImport()
|
||||||
{
|
{
|
||||||
return view('settings.import.home');
|
return view('settings.import.home');
|
||||||
|
|
Loading…
Reference in a new issue