Merge pull request #2746 from pixelfed/staging

Staging
This commit is contained in:
daniel 2021-05-01 16:17:20 -06:00 committed by GitHub
commit 67f7a75bd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 472 additions and 453 deletions

View file

@ -76,6 +76,12 @@
- Updated StoryController, optimize photo size by resizing to 9:16 aspect. ([e66ed9a2](https://github.com/pixelfed/pixelfed/commit/e66ed9a2)) - Updated StoryController, optimize photo size by resizing to 9:16 aspect. ([e66ed9a2](https://github.com/pixelfed/pixelfed/commit/e66ed9a2))
- Updated StoryCompose crop logic. ([2ead622c](https://github.com/pixelfed/pixelfed/commit/2ead622c)) - Updated StoryCompose crop logic. ([2ead622c](https://github.com/pixelfed/pixelfed/commit/2ead622c))
- Updated StatusController, allow license edits without 24 hour limit. ([c799a01a](https://github.com/pixelfed/pixelfed/commit/c799a01a)) - Updated StatusController, allow license edits without 24 hour limit. ([c799a01a](https://github.com/pixelfed/pixelfed/commit/c799a01a))
- Updated Settings, remove reports page. ([9cf962ff](https://github.com/pixelfed/pixelfed/commit/9cf962ff))
- Updated ProfileService, use account transformer. ([391b1287](https://github.com/pixelfed/pixelfed/commit/391b1287))
- Updated LikeController, hide like counts. ([ea687240](https://github.com/pixelfed/pixelfed/commit/ea687240))
- Updated StatusTransformers, add liked_by attribute. ([372bacb0](https://github.com/pixelfed/pixelfed/commit/372bacb0))
- Updated PostComponent, change like logic. ([0a35f5d6](https://github.com/pixelfed/pixelfed/commit/0a35f5d6))
- Updated Timeline component, change like logic. ([7bcbf96b](https://github.com/pixelfed/pixelfed/commit/7bcbf96b))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10) ## [v0.10.10 (2021-01-28)](https://github.com/pixelfed/pixelfed/compare/v0.10.9...v0.10.10)

View file

@ -13,60 +13,60 @@ use App\Services\StatusService;
class LikeController extends Controller class LikeController extends Controller
{ {
public function __construct() public function __construct()
{ {
$this->middleware('auth'); $this->middleware('auth');
} }
public function store(Request $request) public function store(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'item' => 'required|integer|min:1', 'item' => 'required|integer|min:1',
]); ]);
$user = Auth::user(); $user = Auth::user();
$profile = $user->profile; $profile = $user->profile;
$status = Status::findOrFail($request->input('item')); $status = Status::findOrFail($request->input('item'));
$count = $status->likes()->count(); $count = $status->likes()->count();
if ($status->likes()->whereProfileId($profile->id)->count() !== 0) { if ($status->likes()->whereProfileId($profile->id)->count() !== 0) {
$like = Like::whereProfileId($profile->id)->whereStatusId($status->id)->firstOrFail(); $like = Like::whereProfileId($profile->id)->whereStatusId($status->id)->firstOrFail();
$like->forceDelete(); $like->forceDelete();
$count--; $count--;
$status->likes_count = $count; $status->likes_count = $count;
$status->save(); $status->save();
} else { } else {
$like = Like::firstOrCreate([ $like = Like::firstOrCreate([
'profile_id' => $user->profile_id, 'profile_id' => $user->profile_id,
'status_id' => $status->id 'status_id' => $status->id
]); ]);
if($like->wasRecentlyCreated == true) { if($like->wasRecentlyCreated == true) {
$count++; $count++;
$status->likes_count = $count; $status->likes_count = $count;
$like->status_profile_id = $status->profile_id; $like->status_profile_id = $status->profile_id;
$like->is_comment = in_array($status->type, [ $like->is_comment = in_array($status->type, [
'photo', 'photo',
'photo:album', 'photo:album',
'video', 'video',
'video:album', 'video:album',
'photo:video:album' 'photo:video:album'
]) == false; ]) == false;
$like->save(); $like->save();
$status->save(); $status->save();
LikePipeline::dispatch($like); LikePipeline::dispatch($like);
} }
} }
Cache::forget('status:'.$status->id.':likedby:userid:'.$user->id); Cache::forget('status:'.$status->id.':likedby:userid:'.$user->id);
StatusService::del($status->id); StatusService::del($status->id);
if ($request->ajax()) { if ($request->ajax()) {
$response = ['code' => 200, 'msg' => 'Like saved', 'count' => $count]; $response = ['code' => 200, 'msg' => 'Like saved', 'count' => 0];
} else { } else {
$response = redirect($status->url()); $response = redirect($status->url());
} }
return $response; return $response;
} }
} }

View file

@ -12,223 +12,216 @@ use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use App\Http\Controllers\Settings\{ use App\Http\Controllers\Settings\{
ExportSettings, ExportSettings,
LabsSettings, LabsSettings,
HomeSettings, HomeSettings,
PrivacySettings, PrivacySettings,
RelationshipSettings, RelationshipSettings,
SecuritySettings SecuritySettings
}; };
use App\Jobs\DeletePipeline\DeleteAccountPipeline; use App\Jobs\DeletePipeline\DeleteAccountPipeline;
class SettingsController extends Controller class SettingsController extends Controller
{ {
use ExportSettings, use ExportSettings,
LabsSettings, LabsSettings,
HomeSettings, HomeSettings,
PrivacySettings, PrivacySettings,
RelationshipSettings, RelationshipSettings,
SecuritySettings; SecuritySettings;
public function __construct() public function __construct()
{ {
$this->middleware('auth'); $this->middleware('auth');
} }
public function accessibility() public function accessibility()
{ {
$settings = Auth::user()->settings; $settings = Auth::user()->settings;
return view('settings.accessibility', compact('settings')); return view('settings.accessibility', compact('settings'));
} }
public function accessibilityStore(Request $request) public function accessibilityStore(Request $request)
{ {
$settings = Auth::user()->settings; $settings = Auth::user()->settings;
$fields = [ $fields = [
'compose_media_descriptions', 'compose_media_descriptions',
'reduce_motion', 'reduce_motion',
'optimize_screen_reader', 'optimize_screen_reader',
'high_contrast_mode', 'high_contrast_mode',
'video_autoplay', 'video_autoplay',
]; ];
foreach ($fields as $field) { foreach ($fields as $field) {
$form = $request->input($field); $form = $request->input($field);
if ($form == 'on') { if ($form == 'on') {
$settings->{$field} = true; $settings->{$field} = true;
} else { } else {
$settings->{$field} = false; $settings->{$field} = false;
} }
$settings->save(); $settings->save();
} }
return redirect(route('settings.accessibility'))->with('status', 'Settings successfully updated!'); return redirect(route('settings.accessibility'))->with('status', 'Settings successfully updated!');
} }
public function notifications() public function notifications()
{ {
return view('settings.notifications'); return view('settings.notifications');
} }
public function applications() public function applications()
{ {
return view('settings.applications'); return view('settings.applications');
} }
public function dataImport() public function dataImport()
{ {
abort_if(!config('pixelfed.import.instagram.enabled'), 404); abort_if(!config('pixelfed.import.instagram.enabled'), 404);
return view('settings.import.home'); return view('settings.import.home');
} }
public function dataImportInstagram() public function dataImportInstagram()
{ {
abort_if(!config('pixelfed.import.instagram.enabled'), 404); abort_if(!config('pixelfed.import.instagram.enabled'), 404);
return view('settings.import.instagram.home'); return view('settings.import.instagram.home');
} }
public function developers() public function developers()
{ {
return view('settings.developers'); return view('settings.developers');
} }
public function removeAccountTemporary(Request $request) public function removeAccountTemporary(Request $request)
{ {
$user = Auth::user(); $user = Auth::user();
abort_if(!config('pixelfed.account_deletion'), 403); abort_if(!config('pixelfed.account_deletion'), 403);
abort_if($user->is_admin, 403); abort_if($user->is_admin, 403);
return view('settings.remove.temporary'); return view('settings.remove.temporary');
} }
public function removeAccountTemporarySubmit(Request $request) public function removeAccountTemporarySubmit(Request $request)
{ {
$user = Auth::user(); $user = Auth::user();
abort_if(!config('pixelfed.account_deletion'), 403); abort_if(!config('pixelfed.account_deletion'), 403);
abort_if($user->is_admin, 403); abort_if($user->is_admin, 403);
$profile = $user->profile; $profile = $user->profile;
$user->status = 'disabled'; $user->status = 'disabled';
$profile->status = 'disabled'; $profile->status = 'disabled';
$user->save(); $user->save();
$profile->save(); $profile->save();
Auth::logout(); Auth::logout();
Cache::forget('profiles:private'); Cache::forget('profiles:private');
return redirect('/'); return redirect('/');
} }
public function removeAccountPermanent(Request $request) public function removeAccountPermanent(Request $request)
{ {
$user = Auth::user(); $user = Auth::user();
abort_if($user->is_admin, 403); abort_if($user->is_admin, 403);
return view('settings.remove.permanent'); return view('settings.remove.permanent');
} }
public function removeAccountPermanentSubmit(Request $request) public function removeAccountPermanentSubmit(Request $request)
{ {
if(config('pixelfed.account_deletion') == false) { if(config('pixelfed.account_deletion') == false) {
abort(404); abort(404);
} }
$user = Auth::user(); $user = Auth::user();
abort_if(!config('pixelfed.account_deletion'), 403); abort_if(!config('pixelfed.account_deletion'), 403);
abort_if($user->is_admin, 403); abort_if($user->is_admin, 403);
$profile = $user->profile; $profile = $user->profile;
$ts = Carbon::now()->addMonth(); $ts = Carbon::now()->addMonth();
$user->status = 'delete'; $user->status = 'delete';
$profile->status = 'delete'; $profile->status = 'delete';
$user->delete_after = $ts; $user->delete_after = $ts;
$profile->delete_after = $ts; $profile->delete_after = $ts;
$user->save(); $user->save();
$profile->save(); $profile->save();
Cache::forget('profiles:private'); Cache::forget('profiles:private');
Auth::logout(); Auth::logout();
DeleteAccountPipeline::dispatch($user)->onQueue('high'); DeleteAccountPipeline::dispatch($user)->onQueue('high');
return redirect('/'); return redirect('/');
} }
public function requestFullExport(Request $request) public function requestFullExport(Request $request)
{ {
$user = Auth::user(); $user = Auth::user();
return view('settings.export.show'); return view('settings.export.show');
} }
public function reportsHome(Request $request) public function metroDarkMode(Request $request)
{ {
$profile = Auth::user()->profile; $this->validate($request, [
$reports = Report::whereProfileId($profile->id)->orderByDesc('created_at')->paginate(10); 'mode' => 'required|string|in:light,dark'
return view('settings.reports', compact('reports')); ]);
}
public function metroDarkMode(Request $request) $mode = $request->input('mode');
{
$this->validate($request, [
'mode' => 'required|string|in:light,dark'
]);
$mode = $request->input('mode');
if($mode == 'dark') { if($mode == 'dark') {
$cookie = Cookie::make('dark-mode', true, 43800); $cookie = Cookie::make('dark-mode', true, 43800);
} else { } else {
$cookie = Cookie::forget('dark-mode'); $cookie = Cookie::forget('dark-mode');
} }
return response()->json([200])->cookie($cookie); return response()->json([200])->cookie($cookie);
} }
public function sponsor() public function sponsor()
{ {
$default = [ $default = [
'patreon' => null, 'patreon' => null,
'liberapay' => null, 'liberapay' => null,
'opencollective' => null 'opencollective' => null
]; ];
$sponsors = ProfileSponsor::whereProfileId(Auth::user()->profile->id)->first(); $sponsors = ProfileSponsor::whereProfileId(Auth::user()->profile->id)->first();
$sponsors = $sponsors ? json_decode($sponsors->sponsors, true) : $default; $sponsors = $sponsors ? json_decode($sponsors->sponsors, true) : $default;
return view('settings.sponsor', compact('sponsors')); return view('settings.sponsor', compact('sponsors'));
} }
public function sponsorStore(Request $request) public function sponsorStore(Request $request)
{ {
$this->validate($request, [ $this->validate($request, [
'patreon' => 'nullable|string', 'patreon' => 'nullable|string',
'liberapay' => 'nullable|string', 'liberapay' => 'nullable|string',
'opencollective' => 'nullable|string' 'opencollective' => 'nullable|string'
]); ]);
$patreon = Str::startsWith($request->input('patreon'), 'https://') ? $patreon = Str::startsWith($request->input('patreon'), 'https://') ?
substr($request->input('patreon'), 8) : substr($request->input('patreon'), 8) :
$request->input('patreon'); $request->input('patreon');
$liberapay = Str::startsWith($request->input('liberapay'), 'https://') ? $liberapay = Str::startsWith($request->input('liberapay'), 'https://') ?
substr($request->input('liberapay'), 8) : substr($request->input('liberapay'), 8) :
$request->input('liberapay'); $request->input('liberapay');
$opencollective = Str::startsWith($request->input('opencollective'), 'https://') ?
substr($request->input('opencollective'), 8) :
$request->input('opencollective');
$patreon = Str::startsWith($patreon, 'patreon.com/') ? e($patreon) : null; $opencollective = Str::startsWith($request->input('opencollective'), 'https://') ?
$liberapay = Str::startsWith($liberapay, 'liberapay.com/') ? e($liberapay) : null; substr($request->input('opencollective'), 8) :
$opencollective = Str::startsWith($opencollective, 'opencollective.com/') ? e($opencollective) : null; $request->input('opencollective');
if(empty($patreon) && empty($liberapay) && empty($opencollective)) { $patreon = Str::startsWith($patreon, 'patreon.com/') ? e($patreon) : null;
return redirect(route('settings'))->with('error', 'An error occured. Please try again later.');; $liberapay = Str::startsWith($liberapay, 'liberapay.com/') ? e($liberapay) : null;
} $opencollective = Str::startsWith($opencollective, 'opencollective.com/') ? e($opencollective) : null;
$res = [ if(empty($patreon) && empty($liberapay) && empty($opencollective)) {
'patreon' => $patreon, return redirect(route('settings'))->with('error', 'An error occured. Please try again later.');;
'liberapay' => $liberapay, }
'opencollective' => $opencollective
];
$sponsors = ProfileSponsor::firstOrCreate([ $res = [
'profile_id' => Auth::user()->profile_id ?? Auth::user()->profile->id 'patreon' => $patreon,
]); 'liberapay' => $liberapay,
$sponsors->sponsors = json_encode($res); 'opencollective' => $opencollective
$sponsors->save(); ];
$sponsors = $res;
return redirect(route('settings'))->with('status', 'Sponsor settings successfully updated!');; $sponsors = ProfileSponsor::firstOrCreate([
} 'profile_id' => Auth::user()->profile_id ?? Auth::user()->profile->id
]);
$sponsors->sponsors = json_encode($res);
$sponsors->save();
$sponsors = $res;
return redirect(route('settings'))->with('status', 'Sponsor settings successfully updated!');;
}
} }

View file

@ -0,0 +1,65 @@
<?php
namespace App\Services;
use App\Util\ActivityPub\Helpers;
use Illuminate\Support\Facades\Redis;
use App\Like;
class LikeService {
const CACHE_KEY = 'pf:services:likes:ids:';
public static function getUser($profile_id)
{
return self::get($profile_id);
}
protected static function get($profile_id)
{
$key = self::CACHE_KEY . $profile_id;
if(Redis::zcard($key) == 0) {
self::warmCache($profile_id);
} else {
return Redis::zrevrange($key, 0, 40);
}
}
protected static function set($profile_id, $status_id)
{
$key = self::CACHE_KEY . $profile_id;
Redis::zadd($key, $status_id, $status_id);
}
public static function warmCache($profile_id)
{
Like::select('id', 'profile_id', 'status_id')
->whereProfileId($profile_id)
->latest()
->get()
->each(function($like) use ($profile_id) {
self::set($profile_id, $like->status_id);
});
}
public static function liked($profileId, $statusId)
{
$key = self::CACHE_KEY . $profileId;
return (bool) Redis::zrank($key, $statusId);
}
public static function likedBy($status)
{
if(!$status->likes_count) {
return [
'username' => null,
'others' => false
];
}
$id = Like::whereStatusId($status->id)->first()->profile_id;
return [
'username' => ProfileService::get($id)['username'],
'others' => $status->likes_count >= 5,
];
}
}

View file

@ -57,7 +57,7 @@ class MediaTagService
protected function idToUsername($id) protected function idToUsername($id)
{ {
$profile = ProfileService::build()->profileId($id); $profile = ProfileService::get($id);
if(!$profile) { if(!$profile) {
return 'unavailable'; return 'unavailable';
@ -65,8 +65,8 @@ class MediaTagService
return [ return [
'id' => (string) $id, 'id' => (string) $id,
'username' => $profile->username, 'username' => $profile['username'],
'avatar' => $profile->avatarUrl() 'avatar' => $profile['avatar']
]; ];
} }
@ -98,4 +98,4 @@ class MediaTagService
Cache::forget($key); Cache::forget($key);
return true; return true;
} }
} }

View file

@ -4,41 +4,29 @@ namespace App\Services;
use Cache; use Cache;
use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Redis;
use App\Transformer\Api\AccountTransformer;
use App\{ use League\Fractal;
Follower, use League\Fractal\Serializer\ArraySerializer;
Profile use League\Fractal\Pagination\IlluminatePaginatorAdapter;
}; use App\Profile;
class ProfileService { class ProfileService {
protected $profile; public static function get($id)
protected $profile_prefix;
public static function build()
{ {
return new self(); $key = 'profile:model:' . $id;
} $ttl = now()->addHours(4);
$res = Cache::remember($key, $ttl, function() use($id) {
public function profile(Profile $profile) $profile = Profile::find($id);
{ if(!$profile) {
$this->profile = $profile; return false;
$this->profile_prefix = 'profile:model:'.$profile->id; }
return $this; $fractal = new Fractal\Manager();
} $fractal->setSerializer(new ArraySerializer());
$resource = new Fractal\Resource\Item($profile, new AccountTransformer());
public function profileId($id) return $fractal->createData($resource)->toArray();
{
return Cache::rememberForever('profile:model:'.$id, function() use($id) {
return Profile::findOrFail($id);
}); });
return $res;
} }
public function get() }
{
return Cache::rememberForever($this->profile_prefix, function() {
return $this->profile;
});
}
}

View file

@ -6,74 +6,79 @@ use App\Status;
use League\Fractal; use League\Fractal;
use Cache; use Cache;
use App\Services\HashidService; use App\Services\HashidService;
use App\Services\LikeService;
use App\Services\MediaTagService; use App\Services\MediaTagService;
use App\Services\StatusLabelService;
use App\Services\ProfileService;
class StatusStatelessTransformer extends Fractal\TransformerAbstract class StatusStatelessTransformer extends Fractal\TransformerAbstract
{ {
protected $defaultIncludes = [ protected $defaultIncludes = [
'account', 'account',
'media_attachments', 'media_attachments',
]; ];
public function transform(Status $status) public function transform(Status $status)
{ {
$taggedPeople = MediaTagService::get($status->id); $taggedPeople = MediaTagService::get($status->id);
return [ return [
'_v' => 1, '_v' => 1,
'id' => (string) $status->id, 'id' => (string) $status->id,
'shortcode' => HashidService::encode($status->id), 'shortcode' => HashidService::encode($status->id),
'uri' => $status->url(), 'uri' => $status->url(),
'url' => $status->url(), 'url' => $status->url(),
'in_reply_to_id' => $status->in_reply_to_id, 'in_reply_to_id' => $status->in_reply_to_id,
'in_reply_to_account_id' => $status->in_reply_to_profile_id, 'in_reply_to_account_id' => $status->in_reply_to_profile_id,
'reblog' => null, 'reblog' => null,
'content' => $status->rendered ?? $status->caption, 'content' => $status->rendered ?? $status->caption,
'content_text' => $status->caption, 'content_text' => $status->caption,
'created_at' => $status->created_at->format('c'), 'created_at' => $status->created_at->format('c'),
'emojis' => [], 'emojis' => [],
'reblogs_count' => $status->reblogs_count ?? 0, 'reblogs_count' => 0,
'favourites_count' => $status->likes_count ?? 0, 'favourites_count' => 0,
'reblogged' => null, 'reblogged' => null,
'favourited' => null, 'favourited' => null,
'muted' => null, 'muted' => null,
'sensitive' => (bool) $status->is_nsfw, 'sensitive' => (bool) $status->is_nsfw,
'spoiler_text' => $status->cw_summary ?? '', 'spoiler_text' => $status->cw_summary ?? '',
'visibility' => $status->visibility ?? $status->scope, 'visibility' => $status->visibility ?? $status->scope,
'application' => [ 'application' => [
'name' => 'web', 'name' => 'web',
'website' => null 'website' => null
], ],
'language' => null, 'language' => null,
'pinned' => null, 'pinned' => null,
'mentions' => [], 'mentions' => [],
'tags' => [], 'tags' => [],
'pf_type' => $status->type ?? $status->setType(), 'pf_type' => $status->type ?? $status->setType(),
'reply_count' => (int) $status->reply_count, 'reply_count' => (int) $status->reply_count,
'comments_disabled' => $status->comments_disabled ? true : false, 'comments_disabled' => $status->comments_disabled ? true : false,
'thread' => false, 'thread' => false,
'replies' => [], 'replies' => [],
'parent' => [], 'parent' => [],
'place' => $status->place, 'place' => $status->place,
'local' => (bool) $status->local, 'local' => (bool) $status->local,
'taggedPeople' => $taggedPeople 'taggedPeople' => $taggedPeople,
]; 'label' => StatusLabelService::get($status),
} 'liked_by' => LikeService::likedBy($status)
];
}
public function includeAccount(Status $status) public function includeAccount(Status $status)
{ {
$account = $status->profile; $account = $status->profile;
return $this->item($account, new AccountTransformer()); return $this->item($account, new AccountTransformer());
} }
public function includeMediaAttachments(Status $status) public function includeMediaAttachments(Status $status)
{ {
return Cache::remember('status:transformer:media:attachments:'.$status->id, now()->addMinutes(3), function() use($status) { return Cache::remember('status:transformer:media:attachments:'.$status->id, now()->addMinutes(3), function() use($status) {
if(in_array($status->type, ['photo', 'video', 'video:album', 'photo:album', 'loop', 'photo:video:album'])) { if(in_array($status->type, ['photo', 'video', 'video:album', 'photo:album', 'loop', 'photo:video:album'])) {
$media = $status->media()->orderBy('order')->get(); $media = $status->media()->orderBy('order')->get();
return $this->collection($media, new MediaTransformer()); return $this->collection($media, new MediaTransformer());
} }
}); });
} }
} }

View file

@ -2,81 +2,85 @@
namespace App\Transformer\Api; namespace App\Transformer\Api;
use App\Like;
use App\Status; use App\Status;
use League\Fractal; use League\Fractal;
use Cache; use Cache;
use App\Services\HashidService; use App\Services\HashidService;
use App\Services\LikeService;
use App\Services\MediaTagService; use App\Services\MediaTagService;
use App\Services\StatusLabelService; use App\Services\StatusLabelService;
use App\Services\ProfileService;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class StatusTransformer extends Fractal\TransformerAbstract class StatusTransformer extends Fractal\TransformerAbstract
{ {
protected $defaultIncludes = [ protected $defaultIncludes = [
'account', 'account',
'media_attachments', 'media_attachments',
]; ];
public function transform(Status $status) public function transform(Status $status)
{ {
$taggedPeople = MediaTagService::get($status->id); $taggedPeople = MediaTagService::get($status->id);
return [
'_v' => 1,
'id' => (string) $status->id,
'shortcode' => HashidService::encode($status->id),
'uri' => $status->url(),
'url' => $status->url(),
'in_reply_to_id' => (string) $status->in_reply_to_id,
'in_reply_to_account_id' => (string) $status->in_reply_to_profile_id,
'reblog' => null,
'content' => $status->rendered ?? $status->caption,
'content_text' => $status->caption,
'created_at' => $status->created_at->format('c'),
'emojis' => [],
'reblogs_count' => $status->reblogs_count ?? 0,
'favourites_count' => $status->likes_count ?? 0,
'reblogged' => $status->shared(),
'favourited' => $status->liked(),
'muted' => null,
'sensitive' => (bool) $status->is_nsfw,
'spoiler_text' => $status->cw_summary ?? '',
'visibility' => $status->visibility ?? $status->scope,
'application' => [
'name' => 'web',
'website' => null
],
'language' => null,
'pinned' => null,
'mentions' => [],
'tags' => [],
'pf_type' => $status->type ?? $status->setType(),
'reply_count' => (int) $status->reply_count,
'comments_disabled' => $status->comments_disabled ? true : false,
'thread' => false,
'replies' => [],
'parent' => [],
'place' => $status->place,
'local' => (bool) $status->local,
'taggedPeople' => $taggedPeople,
'label' => StatusLabelService::get($status)
];
}
public function includeAccount(Status $status) return [
{ '_v' => 1,
$account = $status->profile; 'id' => (string) $status->id,
'shortcode' => HashidService::encode($status->id),
'uri' => $status->url(),
'url' => $status->url(),
'in_reply_to_id' => (string) $status->in_reply_to_id,
'in_reply_to_account_id' => (string) $status->in_reply_to_profile_id,
'reblog' => null,
'content' => $status->rendered ?? $status->caption,
'content_text' => $status->caption,
'created_at' => $status->created_at->format('c'),
'emojis' => [],
'reblogs_count' => 0,
'favourites_count' => 0,
'reblogged' => $status->shared(),
'favourited' => $status->liked(),
'muted' => null,
'sensitive' => (bool) $status->is_nsfw,
'spoiler_text' => $status->cw_summary ?? '',
'visibility' => $status->visibility ?? $status->scope,
'application' => [
'name' => 'web',
'website' => null
],
'language' => null,
'pinned' => null,
'mentions' => [],
'tags' => [],
'pf_type' => $status->type ?? $status->setType(),
'reply_count' => (int) $status->reply_count,
'comments_disabled' => $status->comments_disabled ? true : false,
'thread' => false,
'replies' => [],
'parent' => [],
'place' => $status->place,
'local' => (bool) $status->local,
'taggedPeople' => $taggedPeople,
'label' => StatusLabelService::get($status),
'liked_by' => LikeService::likedBy($status)
];
}
return $this->item($account, new AccountTransformer()); public function includeAccount(Status $status)
} {
$account = $status->profile;
public function includeMediaAttachments(Status $status) return $this->item($account, new AccountTransformer());
{ }
return Cache::remember('status:transformer:media:attachments:'.$status->id, now()->addMinutes(14), function() use($status) {
if(in_array($status->type, ['photo', 'video', 'video:album', 'photo:album', 'loop', 'photo:video:album'])) { public function includeMediaAttachments(Status $status)
$media = $status->media()->orderBy('order')->get(); {
return $this->collection($media, new MediaTransformer()); return Cache::remember('status:transformer:media:attachments:'.$status->id, now()->addMinutes(14), function() use($status) {
} if(in_array($status->type, ['photo', 'video', 'video:album', 'photo:album', 'loop', 'photo:video:album'])) {
}); $media = $status->media()->orderBy('order')->get();
} return $this->collection($media, new MediaTransformer());
}
});
}
} }

BIN
public/js/status.js vendored

Binary file not shown.

BIN
public/js/timeline.js vendored

Binary file not shown.

Binary file not shown.

View file

@ -220,13 +220,15 @@
<h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.bookmarked ? 'fas fa-bookmark text-warning m-0 mr-3 cursor-pointer' : 'far fa-bookmark m-0 mr-3 cursor-pointer']" title="Bookmark" v-on:click="bookmarkStatus"></h3> <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.bookmarked ? 'fas fa-bookmark text-warning m-0 mr-3 cursor-pointer' : 'far fa-bookmark m-0 mr-3 cursor-pointer']" title="Bookmark" v-on:click="bookmarkStatus"></h3>
<h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'fas fa-retweet m-0 text-primary cursor-pointer' : 'fas fa-retweet m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus"></h3> <h3 v-if="status.visibility == 'public'" v-bind:class="[reactions.shared ? 'fas fa-retweet m-0 text-primary cursor-pointer' : 'fas fa-retweet m-0 share-btn cursor-pointer']" title="Share" v-on:click="shareStatus"></h3>
</div> </div>
<div class="reaction-counts font-weight-bold mb-0"> <div class="reaction-counts mb-0">
<span style="cursor:pointer;" v-on:click="likesModal"> <div v-if="status.liked_by.username && status.liked_by.username !== user.username" class="likes mb-1">
<span class="like-count">{{status.favourites_count || 0}}</span> likes <span class="like-count">Liked by
</span> <a class="font-weight-bold text-dark" :href="'/'+status.liked_by.username">{{status.liked_by.username}}</a>
<span v-if="status.visibility == 'public'" class="float-right" style="cursor:pointer;" v-on:click="sharesModal"> <span v-if="status.liked_by.others == true">
<span class="share-count pl-4">{{status.reblogs_count || 0}}</span> shares and <span class="font-weight-bold text-dark cursor-pointer" @click="likesModal">others</span>
</span> </span>
</span>
</div>
</div> </div>
<div class="timestamp pt-2 d-flex align-items-bottom justify-content-between"> <div class="timestamp pt-2 d-flex align-items-bottom justify-content-between">
<a v-bind:href="statusUrl" class="small text-muted" :title="status.created_at"> <a v-bind:href="statusUrl" class="small text-muted" :title="status.created_at">
@ -978,9 +980,6 @@ export default {
window.location.href = '/login?next=' + encodeURIComponent('/p/' + this.status.shortcode); window.location.href = '/login?next=' + encodeURIComponent('/p/' + this.status.shortcode);
return; return;
} }
if(this.status.favourites_count == 0) {
return;
}
if(this.likes.length) { if(this.likes.length) {
this.$refs.likesModal.show(); this.$refs.likesModal.show();
return; return;

View file

@ -224,8 +224,13 @@
</span> </span>
</div> </div>
<div class="likes font-weight-bold" v-if="expLc(status) == true"> <div v-if="status.liked_by.username && status.liked_by.username !== profile.username" class="likes mb-1">
<span class="like-count">{{status.favourites_count}}</span> {{status.favourites_count == 1 ? 'like' : 'likes'}} <span class="like-count">Liked by
<a class="font-weight-bold text-dark" :href="'/'+status.liked_by.username">{{status.liked_by.username}}</a>
<span v-if="status.liked_by.others == true">
and <span class="font-weight-bold">others</span>
</span>
</span>
</div> </div>
<div v-if="status.pf_type != 'text'" class="caption"> <div v-if="status.pf_type != 'text'" class="caption">
<p v-if="!status.sensitive" class="mb-2 read-more" style="overflow: hidden;"> <p v-if="!status.sensitive" class="mb-2 read-more" style="overflow: hidden;">

View file

@ -16,7 +16,7 @@
@endif @endif
<li class="nav-item pl-3 {{request()->is('settings/notifications')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('settings/notifications')?'active':''}}">
<a class="nav-link font-weight-light text-muted" href="{{route('settings.notifications')}}">Notifications</a> <a class="nav-link font-weight-light text-muted" href="{{route('settings.notifications')}}">Notifications</a>
</li> </li>
<li class="nav-item pl-3 {{request()->is('settings/password')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('settings/password')?'active':''}}">
<a class="nav-link font-weight-light text-muted" href="{{route('settings.password')}}">Password</a> <a class="nav-link font-weight-light text-muted" href="{{route('settings.password')}}">Password</a>
</li> </li>
@ -26,16 +26,9 @@
<li class="nav-item pl-3 {{request()->is('settings/relationships*')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('settings/relationships*')?'active':''}}">
<a class="nav-link font-weight-light text-muted" href="{{route('settings.relationships')}}">Relationships</a> <a class="nav-link font-weight-light text-muted" href="{{route('settings.relationships')}}">Relationships</a>
</li> </li>
<li class="nav-item pl-3 {{request()->is('settings/reports*')?'active':''}}">
<a class="nav-link font-weight-light text-muted" href="{{route('settings.reports')}}">Reports</a>
</li>
<li class="nav-item pl-3 {{request()->is('settings/security*')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('settings/security*')?'active':''}}">
<a class="nav-link font-weight-light text-muted" href="{{route('settings.security')}}">Security</a> <a class="nav-link font-weight-light text-muted" href="{{route('settings.security')}}">Security</a>
</li> </li>
{{-- <li class="nav-item pl-3 {{request()->is('settings/sponsor*')?'active':''}}">
<a class="nav-link font-weight-light text-muted" href="{{route('settings.sponsor')}}">Sponsor</a>
</li> --}}
<li class="nav-item"> <li class="nav-item">
<hr> <hr>
</li> </li>
@ -47,7 +40,7 @@
<li class="nav-item pl-3 {{request()->is('settings/data-export')?'active':''}}"> <li class="nav-item pl-3 {{request()->is('settings/data-export')?'active':''}}">
<a class="nav-link font-weight-light text-muted" href="{{route('settings.dataexport')}}">Data Export</a> <a class="nav-link font-weight-light text-muted" href="{{route('settings.dataexport')}}">Data Export</a>
</li> </li>
@if(config('pixelfed.oauth_enabled') == true) @if(config('pixelfed.oauth_enabled') == true)
<li class="nav-item"> <li class="nav-item">
<hr> <hr>
@ -67,4 +60,4 @@
<a class="nav-link font-weight-light text-muted" href="{{route('settings.labs')}}">Labs</a> <a class="nav-link font-weight-light text-muted" href="{{route('settings.labs')}}">Labs</a>
</li> </li>
</ul> </ul>
</div> </div>

View file

@ -1,38 +0,0 @@
@extends('settings.template')
@section('section')
<div class="title">
<h3 class="font-weight-bold">Reports</h3>
</div>
<hr>
<p class="lead">A list of reports you have made. </p>
<table class="table table-responsive">
<thead class="bg-light">
<th scope="col">ID</th>
<th scope="col">Type</th>
<th scope="col">Reported</th>
<th scope="col">Status</th>
<th scope="col">Created</th>
</tr>
</thead>
<tbody>
@foreach($reports as $report)
<tr>
<td class="font-weight-bold">{{$report->id}}</td>
<td class="font-weight-bold">{{$report->type}}</td>
<td class="font-weight-bold"><a href="{{$report->reported()->url()}}">{{str_limit($report->reported()->url(), 30)}}</a></td>
@if(!$report->admin_seen)
<td><span class="text-danger font-weight-bold">Unresolved</span></td>
@else
<td><span class="text-success font-weight-bold">Resolved</span></td>
@endif
<td class="font-weight-bold">{{$report->created_at->diffForHumans(null, true, true)}}</td>
</tr>
@endforeach
</tbody>
</table>
<div class="d-flex justify-content-center mt-5 small">
{{$reports->links()}}
</div>
@endsection

View file

@ -351,7 +351,6 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
Route::post('privacy/blocked-instances/unblock', 'SettingsController@blockedInstanceUnblock')->name('settings.privacy.blocked-instances.unblock'); Route::post('privacy/blocked-instances/unblock', 'SettingsController@blockedInstanceUnblock')->name('settings.privacy.blocked-instances.unblock');
Route::get('privacy/blocked-keywords', 'SettingsController@blockedKeywords')->name('settings.privacy.blocked-keywords'); Route::get('privacy/blocked-keywords', 'SettingsController@blockedKeywords')->name('settings.privacy.blocked-keywords');
Route::post('privacy/account', 'SettingsController@privateAccountOptions')->name('settings.privacy.account'); Route::post('privacy/account', 'SettingsController@privateAccountOptions')->name('settings.privacy.account');
Route::get('reports', 'SettingsController@reportsHome')->name('settings.reports');
Route::group(['prefix' => 'remove', 'middleware' => 'dangerzone'], function() { Route::group(['prefix' => 'remove', 'middleware' => 'dangerzone'], function() {
Route::get('request/temporary', 'SettingsController@removeAccountTemporary')->name('settings.remove.temporary'); Route::get('request/temporary', 'SettingsController@removeAccountTemporary')->name('settings.remove.temporary');
Route::post('request/temporary', 'SettingsController@removeAccountTemporarySubmit'); Route::post('request/temporary', 'SettingsController@removeAccountTemporarySubmit');