mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-25 17:26:43 +00:00
Update SettingsController, add photo_reblogs_only setting
This commit is contained in:
parent
74a6b169d3
commit
dccec7d5a9
1 changed files with 19 additions and 11 deletions
|
@ -231,43 +231,51 @@ class SettingsController extends Controller
|
||||||
public function timelineSettings(Request $request)
|
public function timelineSettings(Request $request)
|
||||||
{
|
{
|
||||||
$uid = $request->user()->id;
|
$uid = $request->user()->id;
|
||||||
$pid = $request->user()->profile_id;
|
$pid = $request->user()->profile_id;
|
||||||
$top = Redis::zscore('pf:tl:top', $pid) != false;
|
$top = Redis::zscore('pf:tl:top', $pid) != false;
|
||||||
$replies = Redis::zscore('pf:tl:replies', $pid) != false;
|
$replies = Redis::zscore('pf:tl:replies', $pid) != false;
|
||||||
$userSettings = UserSetting::firstOrCreate([
|
$userSettings = UserSetting::firstOrCreate([
|
||||||
'user_id' => $uid
|
'user_id' => $uid
|
||||||
]);
|
]);
|
||||||
if(!$userSettings || !$userSettings->other) {
|
if(!$userSettings || !$userSettings->other) {
|
||||||
$userSettings = [
|
$userSettings = [
|
||||||
'enable_reblogs' => false,
|
'enable_reblogs' => false,
|
||||||
|
'photo_reblogs_only' => false
|
||||||
];
|
];
|
||||||
} else {
|
} else {
|
||||||
$userSettings = $userSettings->other;
|
$userSettings = array_merge([
|
||||||
|
'enable_reblogs' => false,
|
||||||
|
'photo_reblogs_only' => false
|
||||||
|
],
|
||||||
|
$userSettings->other);
|
||||||
}
|
}
|
||||||
return view('settings.timeline', compact('top', 'replies', 'userSettings'));
|
return view('settings.timeline', compact('top', 'replies', 'userSettings'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateTimelineSettings(Request $request)
|
public function updateTimelineSettings(Request $request)
|
||||||
{
|
{
|
||||||
$pid = $request->user()->profile_id;
|
$pid = $request->user()->profile_id;
|
||||||
$uid = $request->user()->id;
|
$uid = $request->user()->id;
|
||||||
$this->validate($request, [
|
$this->validate($request, [
|
||||||
'enable_reblogs' => 'sometimes'
|
'enable_reblogs' => 'sometimes',
|
||||||
|
'photo_reblogs_only' => 'sometimes'
|
||||||
]);
|
]);
|
||||||
Redis::zrem('pf:tl:top', $pid);
|
Redis::zrem('pf:tl:top', $pid);
|
||||||
Redis::zrem('pf:tl:replies', $pid);
|
Redis::zrem('pf:tl:replies', $pid);
|
||||||
$userSettings = UserSetting::firstOrCreate([
|
$userSettings = UserSetting::firstOrCreate([
|
||||||
'user_id' => $uid
|
'user_id' => $uid
|
||||||
]);
|
]);
|
||||||
if($userSettings->other) {
|
if($userSettings->other) {
|
||||||
$other = $userSettings->other;
|
$other = $userSettings->other;
|
||||||
$other['enable_reblogs'] = $request->has('enable_reblogs');
|
$other['enable_reblogs'] = $request->has('enable_reblogs');
|
||||||
|
$other['photo_reblogs_only'] = $request->has('photo_reblogs_only');
|
||||||
} else {
|
} else {
|
||||||
$other['enable_reblogs'] = $request->has('enable_reblogs');
|
$other['enable_reblogs'] = $request->has('enable_reblogs');
|
||||||
|
$other['photo_reblogs_only'] = $request->has('photo_reblogs_only');
|
||||||
}
|
}
|
||||||
$userSettings->other = $other;
|
$userSettings->other = $other;
|
||||||
$userSettings->save();
|
$userSettings->save();
|
||||||
return redirect(route('settings'))->with('status', 'Timeline settings successfully updated!');
|
return redirect(route('settings'))->with('status', 'Timeline settings successfully updated!');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mediaSettings(Request $request)
|
public function mediaSettings(Request $request)
|
||||||
|
|
Loading…
Reference in a new issue