1
0
Fork 0
forked from mirror/pixelfed
pixelfed/app/Http/Controllers/SettingsController.php

135 lines
3.4 KiB
PHP
Raw Normal View History

2018-05-26 22:53:21 +00:00
<?php
namespace App\Http\Controllers;
2018-08-28 03:07:36 +00:00
use App\AccountLog;
use App\Following;
use App\UserFilter;
2018-08-28 03:07:36 +00:00
use Auth;
use DB;
use Cache;
2018-11-08 04:34:31 +00:00
use Purify;
2018-08-28 03:07:36 +00:00
use Illuminate\Http\Request;
2018-09-17 01:47:19 +00:00
use App\Http\Controllers\Settings\{
HomeSettings,
PrivacySettings,
SecuritySettings
};
2018-05-26 22:53:21 +00:00
class SettingsController extends Controller
{
2018-09-17 01:47:19 +00:00
use HomeSettings,
PrivacySettings,
SecuritySettings;
2018-05-26 22:53:21 +00:00
public function __construct()
{
2018-08-10 03:17:24 +00:00
$this->middleware('auth');
2018-05-26 22:53:21 +00:00
}
public function accessibility()
{
2018-08-28 03:07:36 +00:00
$settings = Auth::user()->settings;
return view('settings.accessibility', compact('settings'));
}
public function accessibilityStore(Request $request)
{
2018-08-28 03:07:36 +00:00
$settings = Auth::user()->settings;
$fields = [
'compose_media_descriptions',
'reduce_motion',
'optimize_screen_reader',
'high_contrast_mode',
2018-08-28 03:07:36 +00:00
'video_autoplay',
];
2018-08-28 03:07:36 +00:00
foreach ($fields as $field) {
$form = $request->input($field);
if ($form == 'on') {
$settings->{$field} = true;
} else {
$settings->{$field} = false;
}
$settings->save();
}
return redirect(route('settings.accessibility'))->with('status', 'Settings successfully updated!');
}
2018-05-26 22:53:21 +00:00
public function notifications()
{
2018-08-28 03:07:36 +00:00
return view('settings.notifications');
2018-05-26 22:53:21 +00:00
}
public function applications()
{
2018-08-28 03:07:36 +00:00
return view('settings.applications');
2018-05-26 22:53:21 +00:00
}
public function dataExport()
{
2018-08-28 03:07:36 +00:00
return view('settings.dataexport');
2018-05-26 22:53:21 +00:00
}
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');
}
2018-05-26 22:53:21 +00:00
public function dataImport()
{
2018-08-28 03:07:36 +00:00
return view('settings.import.home');
2018-05-26 22:53:21 +00:00
}
public function dataImportInstagram()
{
2018-08-28 03:07:36 +00:00
return view('settings.import.instagram.home');
2018-05-26 22:53:21 +00:00
}
public function developers()
{
2018-08-28 03:07:36 +00:00
return view('settings.developers');
2018-05-26 22:53:21 +00:00
}
}
2018-08-31 04:29:38 +00:00