Merge branch 'pixelfed:dev' into dev

This commit is contained in:
Norbert Tretkowski 2024-05-07 13:11:36 +02:00 committed by GitHub
commit 8f3ba930ce
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
28 changed files with 2175 additions and 1658 deletions

View file

@ -67,7 +67,7 @@ ADMIN_DOMAIN="${APP_DOMAIN}"
# @default "false" # @default "false"
# @see https://docs.pixelfed.org/technical-documentation/config/#config_cache # @see https://docs.pixelfed.org/technical-documentation/config/#config_cache
# @dottie/validate required,boolean # @dottie/validate required,boolean
ENABLE_CONFIG_CACHE="false" ENABLE_CONFIG_CACHE="true"
# Enable/disable new local account registrations. # Enable/disable new local account registrations.
# #

View file

@ -8,6 +8,7 @@ OPEN_REGISTRATION="false"
ENFORCE_EMAIL_VERIFICATION="false" ENFORCE_EMAIL_VERIFICATION="false"
PF_MAX_USERS="1000" PF_MAX_USERS="1000"
OAUTH_ENABLED="true" OAUTH_ENABLED="true"
ENABLE_CONFIG_CACHE=true
# Media Configuration # Media Configuration
PF_OPTIMIZE_IMAGES="true" PF_OPTIMIZE_IMAGES="true"

View file

@ -1,6 +1,19 @@
# Release Notes # Release Notes
## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.11.13...dev) ## [Unreleased](https://github.com/pixelfed/pixelfed/compare/v0.12.1...dev)
### Updates
- Update DirectMessageController, add 72 hour delay for new accounts before they can send a DM ([61d105fd](https://github.com/pixelfed/pixelfed/commit/61d105fd))
- Update AdminCuratedRegisterController, increase message length from 1000 to 3000 ([9a5e3471](https://github.com/pixelfed/pixelfed/commit/))
- ([](https://github.com/pixelfed/pixelfed/commit/9a5e3471))
## [v0.12.1 (2024-05-07)](https://github.com/pixelfed/pixelfed/compare/v0.12.0...v0.12.1)
### Updates
- Update ApiV1Dot1Controller, fix in app registration bug that prevents proper auth flow due to missing oauth scopes ([cbf996c9](https://github.com/pixelfed/pixelfed/commit/cbf996c9))
- Update ConfigCacheService, fix database race condition and fallback to file config and enable by default ([60a62b59](https://github.com/pixelfed/pixelfed/commit/60a62b59))
## [v0.12.0 (2024-04-29)](https://github.com/pixelfed/pixelfed/compare/v0.11.13...v0.12.0)
### Updates ### Updates
@ -66,7 +79,11 @@
- Update UnfollowPipeline, fix follower count cache bug ([6bdf73de](https://github.com/pixelfed/pixelfed/commit/6bdf73de)) - Update UnfollowPipeline, fix follower count cache bug ([6bdf73de](https://github.com/pixelfed/pixelfed/commit/6bdf73de))
- Update VideoPresenter component, add webkit-playsinline attribute to video element to prevent the full screen video player ([ad032916](https://github.com/pixelfed/pixelfed/commit/ad032916)) - Update VideoPresenter component, add webkit-playsinline attribute to video element to prevent the full screen video player ([ad032916](https://github.com/pixelfed/pixelfed/commit/ad032916))
- Update VideoPlayer component, add playsinline attribute to video element ([8af23607](https://github.com/pixelfed/pixelfed/commit/8af23607)) - Update VideoPlayer component, add playsinline attribute to video element ([8af23607](https://github.com/pixelfed/pixelfed/commit/8af23607))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - Update StatusController, refactor status embeds ([9a7acc12](https://github.com/pixelfed/pixelfed/commit/9a7acc12))
- Update ProfileController, refactor profile embeds ([8b8b1ffc](https://github.com/pixelfed/pixelfed/commit/8b8b1ffc))
- Update profile embed view, fix height bug ([65166570](https://github.com/pixelfed/pixelfed/commit/65166570))
- Update CustomEmojiService, only return local emoji ([7f8bba44](https://github.com/pixelfed/pixelfed/commit/7f8bba44))
- Update Like model, increase max likes per day from 500 to 1500 ([4223119f](https://github.com/pixelfed/pixelfed/commit/4223119f))
## [v0.11.13 (2024-03-05)](https://github.com/pixelfed/pixelfed/compare/v0.11.12...v0.11.13) ## [v0.11.13 (2024-03-05)](https://github.com/pixelfed/pixelfed/compare/v0.11.12...v0.11.13)

View file

@ -174,7 +174,7 @@ class AdminCuratedRegisterController extends Controller
public function apiMessageSendStore(Request $request, $id) public function apiMessageSendStore(Request $request, $id)
{ {
$this->validate($request, [ $this->validate($request, [
'message' => 'required|string|min:5|max:1000', 'message' => 'required|string|min:5|max:3000',
]); ]);
$record = CuratedRegister::findOrFail($id); $record = CuratedRegister::findOrFail($id);
abort_if($record->email_verified_at === null, 400, 'Cannot message an unverified email'); abort_if($record->email_verified_at === null, 400, 'Cannot message an unverified email');

View file

@ -2,45 +2,41 @@
namespace App\Http\Controllers\Api; namespace App\Http\Controllers\Api;
use Cache;
use DB;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use League\Fractal;
use League\Fractal\Serializer\ArraySerializer;
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
use App\AccountLog; use App\AccountLog;
use App\EmailVerification; use App\EmailVerification;
use App\Follower; use App\Http\Controllers\Controller;
use App\Http\Resources\StatusStateless;
use App\Jobs\ReportPipeline\ReportNotifyAdminViaEmail;
use App\Jobs\StatusPipeline\RemoteStatusDelete;
use App\Jobs\StatusPipeline\StatusDelete;
use App\Mail\ConfirmAppEmail;
use App\Mail\PasswordChange;
use App\Place; use App\Place;
use App\Status;
use App\Report;
use App\Profile; use App\Profile;
use App\Report;
use App\Services\AccountService;
use App\Services\BouncerService;
use App\Services\EmailService;
use App\Services\FollowerService;
use App\Services\NetworkTimelineService;
use App\Services\ProfileStatusService;
use App\Services\PublicTimelineService;
use App\Services\StatusService;
use App\Status;
use App\StatusArchived; use App\StatusArchived;
use App\User; use App\User;
use App\UserSetting; use App\UserSetting;
use App\Services\AccountService;
use App\Services\FollowerService;
use App\Services\StatusService;
use App\Services\ProfileStatusService;
use App\Services\LikeService;
use App\Services\ReblogService;
use App\Services\PublicTimelineService;
use App\Services\NetworkTimelineService;
use App\Util\Lexer\RestrictedNames; use App\Util\Lexer\RestrictedNames;
use App\Services\BouncerService; use Cache;
use App\Services\EmailService; use DB;
use Illuminate\Support\Str; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Hash;
use Jenssegers\Agent\Agent;
use Mail;
use App\Mail\PasswordChange;
use App\Mail\ConfirmAppEmail;
use App\Http\Resources\StatusStateless;
use App\Jobs\StatusPipeline\StatusDelete;
use App\Jobs\StatusPipeline\RemoteStatusDelete;
use App\Jobs\ReportPipeline\ReportNotifyAdminViaEmail;
use Illuminate\Support\Facades\RateLimiter; use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\Str;
use Jenssegers\Agent\Agent;
use League\Fractal;
use League\Fractal\Serializer\ArraySerializer;
use Mail;
class ApiV1Dot1Controller extends Controller class ApiV1Dot1Controller extends Controller
{ {
@ -60,21 +56,22 @@ class ApiV1Dot1Controller extends Controller
public function error($msg, $code = 400, $extra = [], $headers = []) public function error($msg, $code = 400, $extra = [], $headers = [])
{ {
$res = [ $res = [
"msg" => $msg, 'msg' => $msg,
"code" => $code 'code' => $code,
]; ];
return response()->json(array_merge($res, $extra), $code, $headers, JSON_UNESCAPED_SLASHES); return response()->json(array_merge($res, $extra), $code, $headers, JSON_UNESCAPED_SLASHES);
} }
public function report(Request $request) public function report(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('write'), 403); abort_unless($request->user()->tokenCan('write'), 403);
$user = $request->user(); $user = $request->user();
abort_if($user->status != null, 403); abort_if($user->status != null, 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
@ -91,19 +88,19 @@ class ApiV1Dot1Controller extends Controller
'copyright', 'copyright',
'impersonation', 'impersonation',
'scam', 'scam',
'terrorism' 'terrorism',
]; ];
if (!$report_type || !$object_id || !$object_type) { if (! $report_type || ! $object_id || ! $object_type) {
return $this->error("Invalid or missing parameters", 400, ["error_code" => "ERROR_INVALID_PARAMS"]); return $this->error('Invalid or missing parameters', 400, ['error_code' => 'ERROR_INVALID_PARAMS']);
} }
if (!in_array($report_type, $types)) { if (! in_array($report_type, $types)) {
return $this->error("Invalid report type", 400, ["error_code" => "ERROR_TYPE_INVALID"]); return $this->error('Invalid report type', 400, ['error_code' => 'ERROR_TYPE_INVALID']);
} }
if ($object_type === "user" && $object_id == $user->profile_id) { if ($object_type === 'user' && $object_id == $user->profile_id) {
return $this->error("Cannot self report", 400, ["error_code" => "ERROR_NO_SELF_REPORTS"]); return $this->error('Cannot self report', 400, ['error_code' => 'ERROR_NO_SELF_REPORTS']);
} }
$rpid = null; $rpid = null;
@ -111,8 +108,8 @@ class ApiV1Dot1Controller extends Controller
switch ($object_type) { switch ($object_type) {
case 'post': case 'post':
$object = Status::find($object_id); $object = Status::find($object_id);
if (!$object) { if (! $object) {
return $this->error("Invalid object id", 400, ["error_code" => "ERROR_INVALID_OBJECT_ID"]); return $this->error('Invalid object id', 400, ['error_code' => 'ERROR_INVALID_OBJECT_ID']);
} }
$object_type = 'App\Status'; $object_type = 'App\Status';
$exists = Report::whereUserId($user->id) $exists = Report::whereUserId($user->id)
@ -125,8 +122,8 @@ class ApiV1Dot1Controller extends Controller
case 'user': case 'user':
$object = Profile::find($object_id); $object = Profile::find($object_id);
if (!$object) { if (! $object) {
return $this->error("Invalid object id", 400, ["error_code" => "ERROR_INVALID_OBJECT_ID"]); return $this->error('Invalid object id', 400, ['error_code' => 'ERROR_INVALID_OBJECT_ID']);
} }
$object_type = 'App\Profile'; $object_type = 'App\Profile';
$exists = Report::whereUserId($user->id) $exists = Report::whereUserId($user->id)
@ -137,16 +134,16 @@ class ApiV1Dot1Controller extends Controller
break; break;
default: default:
return $this->error("Invalid report type", 400, ["error_code" => "ERROR_REPORT_OBJECT_TYPE_INVALID"]); return $this->error('Invalid report type', 400, ['error_code' => 'ERROR_REPORT_OBJECT_TYPE_INVALID']);
break; break;
} }
if ($exists !== 0) { if ($exists !== 0) {
return $this->error("Duplicate report", 400, ["error_code" => "ERROR_REPORT_DUPLICATE"]); return $this->error('Duplicate report', 400, ['error_code' => 'ERROR_REPORT_DUPLICATE']);
} }
if ($object->profile_id == $user->profile_id) { if ($object->profile_id == $user->profile_id) {
return $this->error("Cannot self report", 400, ["error_code" => "ERROR_NO_SELF_REPORTS"]); return $this->error('Cannot self report', 400, ['error_code' => 'ERROR_NO_SELF_REPORTS']);
} }
$report = new Report; $report = new Report;
@ -158,14 +155,15 @@ class ApiV1Dot1Controller extends Controller
$report->type = $report_type; $report->type = $report_type;
$report->save(); $report->save();
if(config('instance.reports.email.enabled')) { if (config('instance.reports.email.enabled')) {
ReportNotifyAdminViaEmail::dispatch($report)->onQueue('default'); ReportNotifyAdminViaEmail::dispatch($report)->onQueue('default');
} }
$res = [ $res = [
"msg" => "Successfully sent report", 'msg' => 'Successfully sent report',
"code" => 200 'code' => 200,
]; ];
return $this->json($res); return $this->json($res);
} }
@ -176,33 +174,33 @@ class ApiV1Dot1Controller extends Controller
*/ */
public function deleteAvatar(Request $request) public function deleteAvatar(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('write'), 403); abort_unless($request->user()->tokenCan('write'), 403);
$user = $request->user(); $user = $request->user();
abort_if($user->status != null, 403); abort_if($user->status != null, 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$avatar = $user->profile->avatar; $avatar = $user->profile->avatar;
if( $avatar->media_path == 'public/avatars/default.png' || if ($avatar->media_path == 'public/avatars/default.png' ||
$avatar->media_path == 'public/avatars/default.jpg' $avatar->media_path == 'public/avatars/default.jpg'
) { ) {
return AccountService::get($user->profile_id); return AccountService::get($user->profile_id);
} }
if(is_file(storage_path('app/' . $avatar->media_path))) { if (is_file(storage_path('app/'.$avatar->media_path))) {
@unlink(storage_path('app/' . $avatar->media_path)); @unlink(storage_path('app/'.$avatar->media_path));
} }
$avatar->media_path = 'public/avatars/default.jpg'; $avatar->media_path = 'public/avatars/default.jpg';
$avatar->change_count = $avatar->change_count + 1; $avatar->change_count = $avatar->change_count + 1;
$avatar->save(); $avatar->save();
Cache::forget('avatar:' . $user->profile_id); Cache::forget('avatar:'.$user->profile_id);
Cache::forget("avatar:{$user->profile_id}"); Cache::forget("avatar:{$user->profile_id}");
Cache::forget('user:account:id:'.$user->id); Cache::forget('user:account:id:'.$user->id);
AccountService::del($user->profile_id); AccountService::del($user->profile_id);
@ -217,33 +215,33 @@ class ApiV1Dot1Controller extends Controller
*/ */
public function accountPosts(Request $request, $id) public function accountPosts(Request $request, $id)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403); abort_unless($request->user()->tokenCan('read'), 403);
$user = $request->user(); $user = $request->user();
abort_if($user->status != null, 403); abort_if($user->status != null, 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$account = AccountService::get($id); $account = AccountService::get($id);
if(!$account || $account['username'] !== $request->input('username')) { if (! $account || $account['username'] !== $request->input('username')) {
return $this->json([]); return $this->json([]);
} }
$posts = ProfileStatusService::get($id); $posts = ProfileStatusService::get($id);
if(!$posts) { if (! $posts) {
return $this->json([]); return $this->json([]);
} }
$res = collect($posts) $res = collect($posts)
->map(function($id) { ->map(function ($id) {
return StatusService::get($id); return StatusService::get($id);
}) })
->filter(function($post) { ->filter(function ($post) {
return $post && isset($post['account']); return $post && isset($post['account']);
}) })
->toArray(); ->toArray();
@ -258,21 +256,21 @@ class ApiV1Dot1Controller extends Controller
*/ */
public function accountChangePassword(Request $request) public function accountChangePassword(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('write'), 403); abort_unless($request->user()->tokenCan('write'), 403);
$user = $request->user(); $user = $request->user();
abort_if($user->status != null, 403); abort_if($user->status != null, 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$this->validate($request, [ $this->validate($request, [
'current_password' => 'bail|required|current_password', 'current_password' => 'bail|required|current_password',
'new_password' => 'required|min:' . config('pixelfed.min_password_length', 8), 'new_password' => 'required|min:'.config('pixelfed.min_password_length', 8),
'confirm_password' => 'required|same:new_password' 'confirm_password' => 'required|same:new_password',
],[ ], [
'current_password' => 'The password you entered is incorrect' 'current_password' => 'The password you entered is incorrect',
]); ]);
$user->password = bcrypt($request->input('new_password')); $user->password = bcrypt($request->input('new_password'));
@ -301,12 +299,12 @@ class ApiV1Dot1Controller extends Controller
*/ */
public function accountLoginActivity(Request $request) public function accountLoginActivity(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403); abort_unless($request->user()->tokenCan('read'), 403);
$user = $request->user(); $user = $request->user();
abort_if($user->status != null, 403); abort_if($user->status != null, 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$agent = new Agent(); $agent = new Agent();
@ -318,8 +316,9 @@ class ApiV1Dot1Controller extends Controller
->groupBy('ip_address') ->groupBy('ip_address')
->limit(10) ->limit(10)
->get() ->get()
->map(function($item) use($agent, $currentIp) { ->map(function ($item) use ($agent, $currentIp) {
$agent->setUserAgent($item->user_agent); $agent->setUserAgent($item->user_agent);
return [ return [
'id' => $item->id, 'id' => $item->id,
'action' => $item->action, 'action' => $item->action,
@ -329,7 +328,7 @@ class ApiV1Dot1Controller extends Controller
'device' => $agent->device(), 'device' => $agent->device(),
'browser' => $agent->browser(), 'browser' => $agent->browser(),
'platform' => $agent->platform(), 'platform' => $agent->platform(),
'created_at' => $item->created_at->format('c') 'created_at' => $item->created_at->format('c'),
]; ];
}); });
@ -343,20 +342,21 @@ class ApiV1Dot1Controller extends Controller
*/ */
public function accountTwoFactor(Request $request) public function accountTwoFactor(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403); abort_unless($request->user()->tokenCan('read'), 403);
$user = $request->user(); $user = $request->user();
abort_if($user->status != null, 403); abort_if($user->status != null, 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$res = [ $res = [
'active' => (bool) $user->{'2fa_enabled'}, 'active' => (bool) $user->{'2fa_enabled'},
'setup_at' => $user->{'2fa_setup_at'} 'setup_at' => $user->{'2fa_setup_at'},
]; ];
return $this->json($res); return $this->json($res);
} }
@ -367,12 +367,12 @@ class ApiV1Dot1Controller extends Controller
*/ */
public function accountEmailsFromPixelfed(Request $request) public function accountEmailsFromPixelfed(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403); abort_unless($request->user()->tokenCan('read'), 403);
$user = $request->user(); $user = $request->user();
abort_if($user->status != null, 403); abort_if($user->status != null, 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$from = config('mail.from.address'); $from = config('mail.from.address');
@ -382,13 +382,13 @@ class ApiV1Dot1Controller extends Controller
->where('created_at', '>', now()->subDays(14)) ->where('created_at', '>', now()->subDays(14))
->limit(10) ->limit(10)
->get() ->get()
->map(function($mail) use($user, $from) { ->map(function ($mail) use ($user, $from) {
return [ return [
'type' => 'Email Verification', 'type' => 'Email Verification',
'subject' => 'Confirm Email', 'subject' => 'Confirm Email',
'to_address' => $user->email, 'to_address' => $user->email,
'from_address' => $from, 'from_address' => $from,
'created_at' => str_replace('@', 'at', $mail->created_at->format('M j, Y @ g:i:s A')) 'created_at' => str_replace('@', 'at', $mail->created_at->format('M j, Y @ g:i:s A')),
]; ];
}) })
->toArray(); ->toArray();
@ -399,13 +399,13 @@ class ApiV1Dot1Controller extends Controller
->orderByDesc('created_at') ->orderByDesc('created_at')
->limit(10) ->limit(10)
->get() ->get()
->map(function($mail) use($user, $from) { ->map(function ($mail) use ($user, $from) {
return [ return [
'type' => 'Password Reset', 'type' => 'Password Reset',
'subject' => 'Reset Password Notification', 'subject' => 'Reset Password Notification',
'to_address' => $user->email, 'to_address' => $user->email,
'from_address' => $from, 'from_address' => $from,
'created_at' => str_replace('@', 'at', now()->parse($mail->created_at)->format('M j, Y @ g:i:s A')) 'created_at' => str_replace('@', 'at', now()->parse($mail->created_at)->format('M j, Y @ g:i:s A')),
]; ];
}) })
->toArray(); ->toArray();
@ -416,13 +416,13 @@ class ApiV1Dot1Controller extends Controller
->orderByDesc('created_at') ->orderByDesc('created_at')
->limit(10) ->limit(10)
->get() ->get()
->map(function($mail) use($user, $from) { ->map(function ($mail) use ($user, $from) {
return [ return [
'type' => 'Password Change', 'type' => 'Password Change',
'subject' => 'Password Change', 'subject' => 'Password Change',
'to_address' => $user->email, 'to_address' => $user->email,
'from_address' => $from, 'from_address' => $from,
'created_at' => str_replace('@', 'at', now()->parse($mail->created_at)->format('M j, Y @ g:i:s A')) 'created_at' => str_replace('@', 'at', now()->parse($mail->created_at)->format('M j, Y @ g:i:s A')),
]; ];
}) })
->toArray(); ->toArray();
@ -444,17 +444,17 @@ class ApiV1Dot1Controller extends Controller
*/ */
public function accountApps(Request $request) public function accountApps(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403); abort_unless($request->user()->tokenCan('read'), 403);
$user = $request->user(); $user = $request->user();
abort_if($user->status != null, 403); abort_if($user->status != null, 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$res = $user->tokens->sortByDesc('created_at')->take(10)->map(function($token, $key) use($request) { $res = $user->tokens->sortByDesc('created_at')->take(10)->map(function ($token, $key) use ($request) {
return [ return [
'id' => $token->id, 'id' => $token->id,
'current_session' => $request->user()->token()->id == $token->id, 'current_session' => $request->user()->token()->id == $token->id,
@ -462,7 +462,7 @@ class ApiV1Dot1Controller extends Controller
'scopes' => $token->scopes, 'scopes' => $token->scopes,
'revoked' => $token->revoked, 'revoked' => $token->revoked,
'created_at' => str_replace('@', 'at', now()->parse($token->created_at)->format('M j, Y @ g:i:s A')), 'created_at' => str_replace('@', 'at', now()->parse($token->created_at)->format('M j, Y @ g:i:s A')),
'expires_at' => str_replace('@', 'at', now()->parse($token->expires_at)->format('M j, Y @ g:i:s A')) 'expires_at' => str_replace('@', 'at', now()->parse($token->expires_at)->format('M j, Y @ g:i:s A')),
]; ];
}); });
@ -483,12 +483,13 @@ class ApiV1Dot1Controller extends Controller
abort_unless((bool) config_cache('pixelfed.open_registration'), 404); abort_unless((bool) config_cache('pixelfed.open_registration'), 404);
abort_unless((bool) config_cache('pixelfed.allow_app_registration'), 404); abort_unless((bool) config_cache('pixelfed.allow_app_registration'), 404);
abort_unless($request->hasHeader('X-PIXELFED-APP'), 403); abort_unless($request->hasHeader('X-PIXELFED-APP'), 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$rl = RateLimiter::attempt('pf:apiv1.1:iar:'.$request->ip(), config('pixelfed.app_registration_rate_limit_attempts', 3), function(){}, config('pixelfed.app_registration_rate_limit_decay', 1800)); $rl = RateLimiter::attempt('pf:apiv1.1:iar:'.$request->ip(), config('pixelfed.app_registration_rate_limit_attempts', 3), function () {
abort_if(!$rl, 400, 'Too many requests'); }, config('pixelfed.app_registration_rate_limit_decay', 1800));
abort_if(! $rl, 400, 'Too many requests');
$this->validate($request, [ $this->validate($request, [
'email' => [ 'email' => [
@ -499,7 +500,7 @@ class ApiV1Dot1Controller extends Controller
'unique:users', 'unique:users',
function ($attribute, $value, $fail) { function ($attribute, $value, $fail) {
$banned = EmailService::isBanned($value); $banned = EmailService::isBanned($value);
if($banned) { if ($banned) {
return $fail('Email is invalid.'); return $fail('Email is invalid.');
} }
}, },
@ -514,24 +515,24 @@ class ApiV1Dot1Controller extends Controller
$underscore = substr_count($value, '_'); $underscore = substr_count($value, '_');
$period = substr_count($value, '.'); $period = substr_count($value, '.');
if(ends_with($value, ['.php', '.js', '.css'])) { if (ends_with($value, ['.php', '.js', '.css'])) {
return $fail('Username is invalid.'); return $fail('Username is invalid.');
} }
if(($dash + $underscore + $period) > 1) { if (($dash + $underscore + $period) > 1) {
return $fail('Username is invalid. Can only contain one dash (-), period (.) or underscore (_).'); return $fail('Username is invalid. Can only contain one dash (-), period (.) or underscore (_).');
} }
if (!ctype_alnum($value[0])) { if (! ctype_alnum($value[0])) {
return $fail('Username is invalid. Must start with a letter or number.'); return $fail('Username is invalid. Must start with a letter or number.');
} }
if (!ctype_alnum($value[strlen($value) - 1])) { if (! ctype_alnum($value[strlen($value) - 1])) {
return $fail('Username is invalid. Must end with a letter or number.'); return $fail('Username is invalid. Must end with a letter or number.');
} }
$val = str_replace(['_', '.', '-'], '', $value); $val = str_replace(['_', '.', '-'], '', $value);
if(!ctype_alnum($val)) { if (! ctype_alnum($val)) {
return $fail('Username is invalid. Username must be alpha-numeric and may contain dashes (-), periods (.) and underscores (_).'); return $fail('Username is invalid. Username must be alpha-numeric and may contain dashes (-), periods (.) and underscores (_).');
} }
@ -548,7 +549,7 @@ class ApiV1Dot1Controller extends Controller
$username = $request->input('username'); $username = $request->input('username');
$password = $request->input('password'); $password = $request->input('password');
if(config('database.default') == 'pgsql') { if (config('database.default') == 'pgsql') {
$username = strtolower($username); $username = strtolower($username);
$email = strtolower($email); $email = strtolower($email);
} }
@ -575,9 +576,9 @@ class ApiV1Dot1Controller extends Controller
$params = http_build_query([ $params = http_build_query([
'ut' => $user->app_register_token, 'ut' => $user->app_register_token,
'rt' => $rtoken, 'rt' => $rtoken,
'ea' => base64_encode($user->email) 'ea' => base64_encode($user->email),
]); ]);
$appUrl = url('/api/v1.1/auth/iarer?'. $params); $appUrl = url('/api/v1.1/auth/iarer?'.$params);
Mail::to($user->email)->send(new ConfirmAppEmail($verify, $appUrl)); Mail::to($user->email)->send(new ConfirmAppEmail($verify, $appUrl));
@ -591,7 +592,7 @@ class ApiV1Dot1Controller extends Controller
$this->validate($request, [ $this->validate($request, [
'ut' => 'required', 'ut' => 'required',
'rt' => 'required', 'rt' => 'required',
'ea' => 'required' 'ea' => 'required',
]); ]);
$ut = $request->input('ut'); $ut = $request->input('ut');
$rt = $request->input('rt'); $rt = $request->input('rt');
@ -600,9 +601,10 @@ class ApiV1Dot1Controller extends Controller
'ut' => $ut, 'ut' => $ut,
'rt' => $rt, 'rt' => $rt,
'domain' => config('pixelfed.domain.app'), 'domain' => config('pixelfed.domain.app'),
'ea' => $ea 'ea' => $ea,
]); ]);
$url = 'pixelfed://confirm-account/'. $ut . '?' . $params; $url = 'pixelfed://confirm-account/'.$ut.'?'.$params;
return redirect()->away($url); return redirect()->away($url);
} }
@ -612,17 +614,18 @@ class ApiV1Dot1Controller extends Controller
abort_unless((bool) config_cache('pixelfed.open_registration'), 404); abort_unless((bool) config_cache('pixelfed.open_registration'), 404);
abort_unless((bool) config_cache('pixelfed.allow_app_registration'), 404); abort_unless((bool) config_cache('pixelfed.allow_app_registration'), 404);
abort_unless($request->hasHeader('X-PIXELFED-APP'), 403); abort_unless($request->hasHeader('X-PIXELFED-APP'), 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$rl = RateLimiter::attempt('pf:apiv1.1:iarc:'.$request->ip(), config('pixelfed.app_registration_confirm_rate_limit_attempts', 20), function(){}, config('pixelfed.app_registration_confirm_rate_limit_decay', 1800)); $rl = RateLimiter::attempt('pf:apiv1.1:iarc:'.$request->ip(), config('pixelfed.app_registration_confirm_rate_limit_attempts', 20), function () {
abort_if(!$rl, 429, 'Too many requests'); }, config('pixelfed.app_registration_confirm_rate_limit_decay', 1800));
abort_if(! $rl, 429, 'Too many requests');
$this->validate($request, [ $request->validate([
'user_token' => 'required', 'user_token' => 'required',
'random_token' => 'required', 'random_token' => 'required',
'email' => 'required' 'email' => 'required',
]); ]);
$verify = EmailVerification::whereEmail($request->input('email')) $verify = EmailVerification::whereEmail($request->input('email'))
@ -630,12 +633,13 @@ class ApiV1Dot1Controller extends Controller
->whereRandomToken($request->input('random_token')) ->whereRandomToken($request->input('random_token'))
->first(); ->first();
if(!$verify) { if (! $verify) {
return response()->json(['error' => 'Invalid tokens'], 403); return response()->json(['error' => 'Invalid tokens'], 403);
} }
if($verify->created_at->lt(now()->subHours(24))) { if ($verify->created_at->lt(now()->subHours(24))) {
$verify->delete(); $verify->delete();
return response()->json(['error' => 'Invalid tokens'], 403); return response()->json(['error' => 'Invalid tokens'], 403);
} }
@ -644,19 +648,19 @@ class ApiV1Dot1Controller extends Controller
$user->last_active_at = now(); $user->last_active_at = now();
$user->save(); $user->save();
$token = $user->createToken('Pixelfed'); $token = $user->createToken('Pixelfed', ['read', 'write', 'follow', 'admin:read', 'admin:write', 'push']);
return response()->json([ return response()->json([
'access_token' => $token->accessToken 'access_token' => $token->accessToken,
]); ]);
} }
public function archive(Request $request, $id) public function archive(Request $request, $id)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('write'), 403); abort_unless($request->user()->tokenCan('write'), 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
@ -665,7 +669,7 @@ class ApiV1Dot1Controller extends Controller
->whereProfileId($request->user()->profile_id) ->whereProfileId($request->user()->profile_id)
->findOrFail($id); ->findOrFail($id);
if($status->scope === 'archived') { if ($status->scope === 'archived') {
return [200]; return [200];
} }
@ -686,10 +690,10 @@ class ApiV1Dot1Controller extends Controller
public function unarchive(Request $request, $id) public function unarchive(Request $request, $id)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('write'), 403); abort_unless($request->user()->tokenCan('write'), 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
@ -698,7 +702,7 @@ class ApiV1Dot1Controller extends Controller
->whereProfileId($request->user()->profile_id) ->whereProfileId($request->user()->profile_id)
->findOrFail($id); ->findOrFail($id);
if($status->scope !== 'archived') { if ($status->scope !== 'archived') {
return [200]; return [200];
} }
@ -718,10 +722,10 @@ class ApiV1Dot1Controller extends Controller
public function archivedPosts(Request $request) public function archivedPosts(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403); abort_unless($request->user()->tokenCan('read'), 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
@ -735,16 +739,16 @@ class ApiV1Dot1Controller extends Controller
public function placesById(Request $request, $id, $slug) public function placesById(Request $request, $id, $slug)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403); abort_unless($request->user()->tokenCan('read'), 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$place = Place::whereSlug($slug)->findOrFail($id); $place = Place::whereSlug($slug)->findOrFail($id);
$posts = Cache::remember('pf-api:v1.1:places-by-id:' . $place->id, 3600, function() use($place) { $posts = Cache::remember('pf-api:v1.1:places-by-id:'.$place->id, 3600, function () use ($place) {
return Status::wherePlaceId($place->id) return Status::wherePlaceId($place->id)
->whereNull('uri') ->whereNull('uri')
->whereScope('public') ->whereScope('public')
@ -753,63 +757,62 @@ class ApiV1Dot1Controller extends Controller
->pluck('id'); ->pluck('id');
}); });
$posts = $posts->map(function($id) { $posts = $posts->map(function ($id) {
return StatusService::get($id); return StatusService::get($id);
}) })
->filter() ->filter()
->values(); ->values();
return [ return [
'place' => 'place' => [
[
'id' => $place->id, 'id' => $place->id,
'name' => $place->name, 'name' => $place->name,
'slug' => $place->slug, 'slug' => $place->slug,
'country' => $place->country, 'country' => $place->country,
'lat' => $place->lat, 'lat' => $place->lat,
'long' => $place->long 'long' => $place->long,
], ],
'posts' => $posts]; 'posts' => $posts];
} }
public function moderatePost(Request $request, $id) public function moderatePost(Request $request, $id)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_if($request->user()->is_admin != true, 403); abort_if($request->user()->is_admin != true, 403);
abort_unless($request->user()->tokenCan('admin:write'), 403); abort_unless($request->user()->tokenCan('admin:write'), 403);
if(config('pixelfed.bouncer.cloud_ips.ban_signups')) { if (config('pixelfed.bouncer.cloud_ips.ban_signups')) {
abort_if(BouncerService::checkIp($request->ip()), 404); abort_if(BouncerService::checkIp($request->ip()), 404);
} }
$this->validate($request, [ $this->validate($request, [
'action' => 'required|in:cw,mark-public,mark-unlisted,mark-private,mark-spammer,delete' 'action' => 'required|in:cw,mark-public,mark-unlisted,mark-private,mark-spammer,delete',
]); ]);
$action = $request->input('action'); $action = $request->input('action');
$status = Status::find($id); $status = Status::find($id);
if(!$status) { if (! $status) {
return response()->json(['error' => 'Cannot find status'], 400); return response()->json(['error' => 'Cannot find status'], 400);
} }
if($status->uri == null) { if ($status->uri == null) {
if($status->profile->user && $status->profile->user->is_admin) { if ($status->profile->user && $status->profile->user->is_admin) {
return response()->json(['error' => 'Cannot moderate admin accounts'], 400); return response()->json(['error' => 'Cannot moderate admin accounts'], 400);
} }
} }
if($action == 'mark-spammer') { if ($action == 'mark-spammer') {
$status->profile->update([ $status->profile->update([
'unlisted' => true, 'unlisted' => true,
'cw' => true, 'cw' => true,
'no_autolink' => true 'no_autolink' => true,
]); ]);
Status::whereProfileId($status->profile_id) Status::whereProfileId($status->profile_id)
->get() ->get()
->each(function($s) { ->each(function ($s) {
if(in_array($s->scope, ['public', 'unlisted'])) { if (in_array($s->scope, ['public', 'unlisted'])) {
$s->scope = 'private'; $s->scope = 'private';
$s->visibility = 'private'; $s->visibility = 'private';
} }
@ -818,60 +821,61 @@ class ApiV1Dot1Controller extends Controller
StatusService::del($s->id, true); StatusService::del($s->id, true);
}); });
Cache::forget('pf:bouncer_v0:exemption_by_pid:' . $status->profile_id); Cache::forget('pf:bouncer_v0:exemption_by_pid:'.$status->profile_id);
Cache::forget('pf:bouncer_v0:recent_by_pid:' . $status->profile_id); Cache::forget('pf:bouncer_v0:recent_by_pid:'.$status->profile_id);
Cache::forget('admin-dash:reports:spam-count'); Cache::forget('admin-dash:reports:spam-count');
} else if ($action == 'cw') { } elseif ($action == 'cw') {
$state = $status->is_nsfw; $state = $status->is_nsfw;
$status->is_nsfw = !$state; $status->is_nsfw = ! $state;
$status->save(); $status->save();
StatusService::del($status->id); StatusService::del($status->id);
} else if ($action == 'mark-public') { } elseif ($action == 'mark-public') {
$state = $status->scope; $state = $status->scope;
$status->scope = 'public'; $status->scope = 'public';
$status->visibility = 'public'; $status->visibility = 'public';
$status->save(); $status->save();
StatusService::del($status->id, true); StatusService::del($status->id, true);
if($state !== 'public') { if ($state !== 'public') {
if($status->uri) { if ($status->uri) {
if($status->in_reply_to_id == null && $status->reblog_of_id == null) { if ($status->in_reply_to_id == null && $status->reblog_of_id == null) {
NetworkTimelineService::add($status->id); NetworkTimelineService::add($status->id);
} }
} else { } else {
if($status->in_reply_to_id == null && $status->reblog_of_id == null) { if ($status->in_reply_to_id == null && $status->reblog_of_id == null) {
PublicTimelineService::add($status->id); PublicTimelineService::add($status->id);
} }
} }
} }
} else if ($action == 'mark-unlisted') { } elseif ($action == 'mark-unlisted') {
$state = $status->scope; $state = $status->scope;
$status->scope = 'unlisted'; $status->scope = 'unlisted';
$status->visibility = 'unlisted'; $status->visibility = 'unlisted';
$status->save(); $status->save();
StatusService::del($status->id); StatusService::del($status->id);
if($state == 'public') { if ($state == 'public') {
PublicTimelineService::del($status->id); PublicTimelineService::del($status->id);
NetworkTimelineService::del($status->id); NetworkTimelineService::del($status->id);
} }
} else if ($action == 'mark-private') { } elseif ($action == 'mark-private') {
$state = $status->scope; $state = $status->scope;
$status->scope = 'private'; $status->scope = 'private';
$status->visibility = 'private'; $status->visibility = 'private';
$status->save(); $status->save();
StatusService::del($status->id); StatusService::del($status->id);
if($state == 'public') { if ($state == 'public') {
PublicTimelineService::del($status->id); PublicTimelineService::del($status->id);
NetworkTimelineService::del($status->id); NetworkTimelineService::del($status->id);
} }
} else if ($action == 'delete') { } elseif ($action == 'delete') {
PublicTimelineService::del($status->id); PublicTimelineService::del($status->id);
NetworkTimelineService::del($status->id); NetworkTimelineService::del($status->id);
Cache::forget('_api:statuses:recent_9:' . $status->profile_id); Cache::forget('_api:statuses:recent_9:'.$status->profile_id);
Cache::forget('profile:status_count:' . $status->profile_id); Cache::forget('profile:status_count:'.$status->profile_id);
Cache::forget('profile:embed:' . $status->profile_id); Cache::forget('profile:embed:'.$status->profile_id);
StatusService::del($status->id, true); StatusService::del($status->id, true);
Cache::forget('profile:status_count:'.$status->profile_id); Cache::forget('profile:status_count:'.$status->profile_id);
$status->uri ? RemoteStatusDelete::dispatch($status) : StatusDelete::dispatch($status); $status->uri ? RemoteStatusDelete::dispatch($status) : StatusDelete::dispatch($status);
return []; return [];
} }
@ -882,34 +886,35 @@ class ApiV1Dot1Controller extends Controller
public function getWebSettings(Request $request) public function getWebSettings(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('read'), 403); abort_unless($request->user()->tokenCan('read'), 403);
$uid = $request->user()->id; $uid = $request->user()->id;
$settings = UserSetting::firstOrCreate([ $settings = UserSetting::firstOrCreate([
'user_id' => $uid 'user_id' => $uid,
]); ]);
if(!$settings->other) { if (! $settings->other) {
return []; return [];
} }
return $settings->other; return $settings->other;
} }
public function setWebSettings(Request $request) public function setWebSettings(Request $request)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('write'), 403); abort_unless($request->user()->tokenCan('write'), 403);
$this->validate($request, [ $this->validate($request, [
'field' => 'required|in:enable_reblogs,hide_reblog_banner', 'field' => 'required|in:enable_reblogs,hide_reblog_banner',
'value' => 'required' 'value' => 'required',
]); ]);
$field = $request->input('field'); $field = $request->input('field');
$value = $request->input('value'); $value = $request->input('value');
$settings = UserSetting::firstOrCreate([ $settings = UserSetting::firstOrCreate([
'user_id' => $request->user()->id 'user_id' => $request->user()->id,
]); ]);
if(!$settings->other) { if (! $settings->other) {
$other = []; $other = [];
} else { } else {
$other = $settings->other; $other = $settings->other;
@ -923,18 +928,21 @@ class ApiV1Dot1Controller extends Controller
public function getMutualAccounts(Request $request, $id) public function getMutualAccounts(Request $request, $id)
{ {
abort_if(!$request->user() || !$request->user()->token(), 403); abort_if(! $request->user() || ! $request->user()->token(), 403);
abort_unless($request->user()->tokenCan('follows'), 403); abort_unless($request->user()->tokenCan('follows'), 403);
$account = AccountService::get($id, true); $account = AccountService::get($id, true);
if(!$account || !isset($account['id'])) { return []; } if (! $account || ! isset($account['id'])) {
return [];
}
$res = collect(FollowerService::mutualAccounts($request->user()->profile_id, $id)) $res = collect(FollowerService::mutualAccounts($request->user()->profile_id, $id))
->map(function($accountId) { ->map(function ($accountId) {
return AccountService::get($accountId, true); return AccountService::get($accountId, true);
}) })
->filter() ->filter()
->take(24) ->take(24)
->values(); ->values();
return $this->json($res); return $this->json($res);
} }
} }

View file

@ -309,6 +309,7 @@ class DirectMessageController extends Controller
$user = $request->user(); $user = $request->user();
abort_if($user->has_roles && !UserRoleService::can('can-direct-message', $user->id), 403, 'Invalid permissions for this action'); abort_if($user->has_roles && !UserRoleService::can('can-direct-message', $user->id), 403, 'Invalid permissions for this action');
abort_if($user->created_at->gt(now()->subHours(72)), 400, 'You need to wait a bit before you can DM another account');
$profile = $user->profile; $profile = $user->profile;
$recipient = Profile::where('id', '!=', $profile->id)->findOrFail($request->input('to_id')); $recipient = Profile::where('id', '!=', $profile->id)->findOrFail($request->input('to_id'));

View file

@ -172,7 +172,7 @@ class ProfileController extends Controller
$user = $this->getCachedUser($username); $user = $this->getCachedUser($username);
abort_if(!$user, 404); abort_if(! $user, 404);
return redirect($user->url()); return redirect($user->url());
} }
@ -254,7 +254,7 @@ class ProfileController extends Controller
abort_if(! $profile || $profile['locked'] || ! $profile['local'], 404); abort_if(! $profile || $profile['locked'] || ! $profile['local'], 404);
$aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile['id'], 86400, function () use ($profile) { $aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile['id'], 3600, function () use ($profile) {
$uid = User::whereProfileId($profile['id'])->first(); $uid = User::whereProfileId($profile['id'])->first();
if (! $uid) { if (! $uid) {
return true; return true;
@ -348,7 +348,7 @@ class ProfileController extends Controller
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
} }
$aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile->id, 86400, function () use ($profile) { $aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile->id, 3600, function () use ($profile) {
$exists = AccountInterstitial::whereUserId($profile->user_id)->where('is_spam', 1)->count(); $exists = AccountInterstitial::whereUserId($profile->user_id)->where('is_spam', 1)->count();
if ($exists) { if ($exists) {
return true; return true;
@ -373,7 +373,7 @@ class ProfileController extends Controller
public function stories(Request $request, $username) public function stories(Request $request, $username)
{ {
abort_if(!(bool) config_cache('instance.stories.enabled') || ! $request->user(), 404); abort_if(! (bool) config_cache('instance.stories.enabled') || ! $request->user(), 404);
$profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail(); $profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
$pid = $profile->id; $pid = $profile->id;
$authed = Auth::user()->profile_id; $authed = Auth::user()->profile_id;

View file

@ -8,6 +8,7 @@ use App\Jobs\SharePipeline\UndoSharePipeline;
use App\Jobs\StatusPipeline\RemoteStatusDelete; use App\Jobs\StatusPipeline\RemoteStatusDelete;
use App\Jobs\StatusPipeline\StatusDelete; use App\Jobs\StatusPipeline\StatusDelete;
use App\Profile; use App\Profile;
use App\Services\AccountService;
use App\Services\HashidService; use App\Services\HashidService;
use App\Services\ReblogService; use App\Services\ReblogService;
use App\Services\StatusService; use App\Services\StatusService;
@ -113,19 +114,33 @@ class StatusController extends Controller
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
} }
$profile = Profile::whereNull(['domain', 'status']) $status = StatusService::get($id);
->whereIsPrivate(false)
->whereUsername($username)
->first();
if (! $profile) { if (
! $status ||
! isset($status['account'], $status['account']['id'], $status['local']) ||
! $status['local'] ||
strtolower($status['account']['username']) !== strtolower($username)
) {
$content = view('status.embed-removed');
return response($content, 404)->header('X-Frame-Options', 'ALLOWALL');
}
$profile = AccountService::get($status['account']['id'], true);
if (! $profile || $profile['locked'] || ! $profile['local']) {
$content = view('status.embed-removed'); $content = view('status.embed-removed');
return response($content)->header('X-Frame-Options', 'ALLOWALL'); return response($content)->header('X-Frame-Options', 'ALLOWALL');
} }
$aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile->id, 86400, function () use ($profile) { $aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile['id'], 3600, function () use ($profile) {
$exists = AccountInterstitial::whereUserId($profile->user_id)->where('is_spam', 1)->count(); $user = Profile::find($profile['id']);
if (! $user) {
return true;
}
$exists = AccountInterstitial::whereUserId($user->user_id)->where('is_spam', 1)->count();
if ($exists) { if ($exists) {
return true; return true;
} }
@ -138,17 +153,22 @@ class StatusController extends Controller
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']); return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
} }
$status = Status::whereProfileId($profile->id)
->whereNull('uri') $status = StatusService::get($id);
->whereScope('public')
->whereIsNsfw(false) if (
->whereIn('type', ['photo', 'video', 'photo:album']) ! $status ||
->find($id); ! isset($status['account'], $status['account']['id']) ||
if (! $status) { intval($status['account']['id']) !== intval($profile['id']) ||
$status['sensitive'] ||
$status['visibility'] !== 'public' ||
$status['pf_type'] !== 'photo'
) {
$content = view('status.embed-removed'); $content = view('status.embed-removed');
return response($content)->header('X-Frame-Options', 'ALLOWALL'); return response($content)->header('X-Frame-Options', 'ALLOWALL');
} }
$showLikes = $request->filled('likes') && $request->likes == true; $showLikes = $request->filled('likes') && $request->likes == true;
$showCaption = $request->filled('caption') && $request->caption !== false; $showCaption = $request->filled('caption') && $request->caption !== false;
$layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full'; $layout = $request->filled('layout') && $request->layout == 'compact' ? 'compact' : 'full';

View file

@ -9,7 +9,7 @@ class Like extends Model
{ {
use SoftDeletes; use SoftDeletes;
const MAX_PER_DAY = 500; const MAX_PER_DAY = 1500;
/** /**
* The attributes that should be mutated to dates. * The attributes that should be mutated to dates.

View file

@ -4,6 +4,7 @@ namespace App\Services;
use App\Models\ConfigCache as ConfigCacheModel; use App\Models\ConfigCache as ConfigCacheModel;
use Cache; use Cache;
use Illuminate\Database\QueryException;
class ConfigCacheService class ConfigCacheService
{ {
@ -25,8 +26,8 @@ class ConfigCacheService
return config($key); return config($key);
} }
try {
return Cache::remember($cacheKey, $ttl, function () use ($key) { return Cache::remember($cacheKey, $ttl, function () use ($key) {
$allowed = [ $allowed = [
'app.name', 'app.name',
'app.short_description', 'app.short_description',
@ -175,6 +176,9 @@ class ConfigCacheService
return $v; return $v;
}); });
} catch (Exception | QueryException $e) {
return config($key);
}
} }
public static function put($key, $val) public static function put($key, $val)

View file

@ -133,6 +133,7 @@ class CustomEmojiService
return CustomEmoji::when(!$pgsql, function($q, $pgsql) { return CustomEmoji::when(!$pgsql, function($q, $pgsql) {
return $q->groupBy('shortcode'); return $q->groupBy('shortcode');
}) })
->whereNull('uri')
->get() ->get()
->map(function($emojo) { ->map(function($emojo) {
$url = url('storage/' . $emojo->media_path); $url = url('storage/' . $emojo->media_path);

618
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -23,7 +23,7 @@ return [
| This value is the version of your Pixelfed instance. | This value is the version of your Pixelfed instance.
| |
*/ */
'version' => '0.11.13', 'version' => '0.12.1',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

BIN
public/embed.js vendored

Binary file not shown.

View file

@ -169,7 +169,7 @@
<script type="text/javascript"> <script type="text/javascript">
import BigPicture from 'bigpicture'; import BigPicture from 'bigpicture';
import ReadMore from './ReadMore.vue'; import ReadMore from './ReadMore.vue';
import VideoPlayer from './../../presenter/VideoPlayer.vue'; import VideoPlayer from '@/presenter/VideoPlayer.vue';
export default { export default {
props: ['status'], props: ['status'],

View file

@ -0,0 +1,75 @@
<template>
<div v-if="status.sensitive == true">
<details class="details-animated">
<summary>
<p class="mb-0 lead font-weight-bold">{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
<p class="font-weight-light">(click to show)</p>
</summary>
<b-carousel :id="status.id + '-carousel'"
style="text-shadow: 1px 1px 2px #333; background-color: #000;"
controls
img-blank
background="#ffffff"
:interval="0"
>
<b-carousel-slide v-for="(media, index) in status.media_attachments" :key="media.id + '-media'">
<video v-if="media.type == 'video'" slot="img" class="embed-responsive-item" preload="none" controls playsinline loop :alt="media.description" width="100%" height="100%">
<source :src="media.url" :type="media.mime">
</video>
<div v-else-if="media.type == 'image'" slot="img" :title="media.description">
<img :class="media.filter_class + ' d-block img-fluid w-100'" :src="media.url" :alt="media.description" loading="lazy" onerror="this.onerror=null;this.src='/storage/no-preview.png'">
</div>
<p v-else class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
</b-carousel-slide>
</b-carousel>
</details>
</div>
<div v-else class="w-100 h-100 p-0">
<!-- <b-carousel :id="status.id + '-carousel'"
style="text-shadow: 1px 1px 2px #333; background-color: #000;"
controls
img-blank
background="#ffffff"
:interval="0"
>
<b-carousel-slide v-for="(media, index) in status.media_attachments" :key="media.id + '-media'">
<video v-if="media.type == 'Video'" slot="img" class="embed-responsive-item" preload="none" controls loop :title="media.description" width="100%" height="100%" :poster="media.preview_url">
<source :src="media.url" :type="media.mime">
</video>
<div v-else-if="media.type == 'Image'" slot="img" :title="media.description">
<img :class="media.filter_class + ' d-block img-fluid w-100'" :src="media.url" :alt="media.description" loading="lazy">
</div>
<p v-else class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
</b-carousel-slide>
</b-carousel> -->
<carousel ref="carousel" :centerMode="true" :loop="false" :per-page="1" :paginationPosition="'bottom-overlay'" paginationActiveColor="#3897f0" paginationColor="#dbdbdb" class="p-0 m-0">
<slide v-for="(media, index) in status.media_attachments" :key="'px-carousel-'+media.id + '-' + index" class="w-100 h-100 d-block mx-auto text-center" style="background: #000; display: flex;align-items: center;">
<video v-if="media.type == 'video'" class="embed-responsive-item" preload="none" controls loop :title="media.description" width="100%" height="100%">
<source :src="media.url" :type="media.mime">
</video>
<div v-else-if="media.type == 'image'" :title="media.description">
<img :class="media.filter_class + ' img-fluid w-100'" :src="media.url" :alt="media.description" loading="lazy" onerror="this.onerror=null;this.src='/storage/no-preview.png'">
</div>
<p v-else class="text-center p-0 font-weight-bold text-white">Error: Problem rendering preview.</p>
</slide>
</carousel>
</div>
</template>
<script type="text/javascript">
export default {
props: ['status']
}
</script>

View file

@ -0,0 +1,188 @@
<template>
<div v-if="status.sensitive == true" class="content-label-wrapper">
<div class="text-light content-label">
<p class="text-center">
<i class="far fa-eye-slash fa-2x"></i>
</p>
<p class="h4 font-weight-bold text-center">
Sensitive Content
</p>
<p class="text-center py-2 content-label-text">
{{ status.spoiler_text ? status.spoiler_text : 'This album may contain sensitive content.'}}
</p>
<p class="mb-0">
<button @click="toggleContentWarning()" class="btn btn-outline-light btn-block btn-sm font-weight-bold">See Post</button>
</p>
</div>
<blur-hash-image
width="32"
height="32"
:punch="1"
:hash="status.media_attachments[0].blurhash"
:alt="altText(status)"/>
</div>
<div v-else class="w-100 h-100 p-0 album-wrapper">
<carousel ref="carousel" :centerMode="true" :loop="false" :per-page="1" :paginationPosition="'bottom-overlay'" paginationActiveColor="#3897f0" paginationColor="#dbdbdb" class="p-0 m-0" :id="'carousel-' + status.id">
<slide v-for="(img, index) in status.media_attachments" :key="'px-carousel-'+img.id + '-' + index" class="" style="background: #000; display: flex;align-items: center;" :title="img.description">
<img
class="img-fluid w-100 p-0"
:src="img.url"
:alt="altText(img)"
loading="lazy"
:data-bp="img.url"
onerror="this.onerror=null;this.src='/storage/no-preview.png'">
</slide>
</carousel>
<div class="album-overlay">
<p v-if="!status.sensitive && sensitive"
@click="status.sensitive = true"
style="
margin-top: 0;
padding: 10px;
color: #fff;
font-size: 10px;
text-align: right;
position: absolute;
top: 0;
right: 0;
border-top-left-radius: 5px;
cursor: pointer;
background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
">
<i class="fas fa-eye-slash fa-lg"></i>
</p>
<p @click.prevent="toggleLightbox"
style="
margin-top: 0;
padding: 10px;
color: #fff;
font-size: 10px;
text-align: right;
position: absolute;
left: 0;
top: 0;
border-bottom-right-radius: 5px;
cursor: pointer;
background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
">
<i class="fas fa-expand fa-lg"></i>
</p>
<p
v-if="status.media_attachments[0].license"
style="
margin-bottom: 0;
padding: 0 5px;
color: #fff;
font-size: 10px;
text-align: right;
position: absolute;
bottom: 0;
right: 0;
border-top-left-radius: 5px;
background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
">
<a :href="status.url" class="font-weight-bold text-light">Photo</a> by <a :href="status.account.url" class="font-weight-bold text-light">&commat;{{status.account.username}}</a> licensed under <a :href="status.media_attachments[0].license.url" class="font-weight-bold text-light">{{status.media_attachments[0].license.title}}</a>
</p>
</div>
</div>
</template>
<script type="text/javascript">
import BigPicture from 'bigpicture';
export default {
props: ['status'],
data() {
return {
sensitive: this.status.sensitive,
cursor: 0
}
},
created() {
// window.addEventListener("keydown", this.keypressNavigation);
},
beforeDestroy() {
// window.removeEventListener("keydown", this.keypressNavigation);
},
methods: {
toggleContentWarning(status) {
this.$emit('togglecw');
},
toggleLightbox(e) {
BigPicture({
el: e.target,
gallery: '#carousel-' + this.status.id,
position: this.$refs.carousel.currentPage
})
},
altText(img) {
let desc = img.description;
if(desc) {
return desc;
}
return 'Photo was not tagged with any alt text.';
},
keypressNavigation(e) {
let ref = this.$refs.carousel;
if (e.keyCode == "37") {
e.preventDefault();
let direction = "backward";
ref.advancePage(direction);
ref.$emit("navigation-click", direction);
}
if (e.keyCode == "39") {
e.preventDefault();
let direction = "forward";
ref.advancePage(direction);
ref.$emit("navigation-click", direction);
}
}
}
}
</script>
<style type="text/css" scoped>
.card-img-top {
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
}
.content-label-wrapper {
position: relative;
}
.content-label {
margin: 0;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 2;
background: rgba(0, 0, 0, 0.2)
}
.album-wrapper {
position: relative;
}
</style>

View file

@ -0,0 +1,160 @@
<template>
<div v-if="status.sensitive == true" class="content-label-wrapper">
<div class="text-light content-label">
<p class="text-center">
<i class="far fa-eye-slash fa-2x"></i>
</p>
<p class="h4 font-weight-bold text-center">
Sensitive Content
</p>
<p class="text-center py-2 content-label-text">
{{ status.spoiler_text ? status.spoiler_text : 'This post may contain sensitive content.'}}
</p>
<p class="mb-0">
<button @click="toggleContentWarning()" class="btn btn-outline-light btn-block btn-sm font-weight-bold">See Post</button>
</p>
</div>
<blur-hash-image
width="32"
height="32"
:punch="1"
:hash="status.media_attachments[0].blurhash"
:alt="altText(status)"/>
</div>
<div v-else>
<div :title="status.media_attachments[0].description" style="position: relative;">
<img class="card-img-top"
:src="status.media_attachments[0].url"
loading="lazy"
:alt="altText(status)"
:width="width()"
:height="height()"
onerror="this.onerror=null;this.src='/storage/no-preview.png'"
@click.prevent="toggleLightbox">
<!-- <blur-hash-image
class="card-img-top"
width="32"
height="32"
:punch="1"
:hash="status.media_attachments[0].blurhash"
:src="status.media_attachments[0].url"
:alt="altText(status)"
@click.prevent="toggleLightbox"/> -->
<p v-if="!status.sensitive && sensitive"
@click="status.sensitive = true"
style="
margin-top: 0;
padding: 10px;
color: #fff;
font-size: 10px;
text-align: right;
position: absolute;
top: 0;
right: 0;
border-top-left-radius: 5px;
cursor: pointer;
background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
">
<i class="fas fa-eye-slash fa-lg"></i>
</p>
<p
v-if="status.media_attachments[0].license"
style="
margin-bottom: 0;
padding: 0 5px;
color: #fff;
font-size: 10px;
text-align: right;
position: absolute;
bottom: 0;
right: 0;
border-top-left-radius: 5px;
background: linear-gradient(0deg, rgba(0,0,0,0.5), rgba(0,0,0,0.5));
"><a :href="status.url" class="font-weight-bold text-light">Photo</a> by <a :href="status.account.url" class="font-weight-bold text-light">&commat;{{status.account.username}}</a> licensed under <a :href="status.media_attachments[0].license.url" class="font-weight-bold text-light">{{status.media_attachments[0].license.title}}</a></p>
</div>
</div>
</template>
<style type="text/css" scoped>
.card-img-top {
border-top-left-radius: 0 !important;
border-top-right-radius: 0 !important;
}
.content-label-wrapper {
position: relative;
}
.content-label {
margin: 0;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 2;
background: rgba(0, 0, 0, 0.2)
}
</style>
<script type="text/javascript">
import BigPicture from 'bigpicture';
export default {
props: ['status'],
data() {
return {
sensitive: this.status.sensitive
}
},
mounted() {
},
methods: {
altText(status) {
let desc = status.media_attachments[0].description;
if(desc) {
return desc;
}
return 'Photo was not tagged with any alt text.';
},
toggleContentWarning(status) {
this.$emit('togglecw');
},
toggleLightbox(e) {
BigPicture({
el: e.target
})
},
width() {
if( !this.status.media_attachments[0].meta ||
!this.status.media_attachments[0].meta.original ||
!this.status.media_attachments[0].meta.original.width ) {
return;
}
return this.status.media_attachments[0].meta.original.width;
},
height() {
if( !this.status.media_attachments[0].meta ||
!this.status.media_attachments[0].meta.original ||
!this.status.media_attachments[0].meta.original.height ) {
return;
}
return this.status.media_attachments[0].meta.original.height;
}
}
}
</script>

View file

@ -0,0 +1,44 @@
<template>
<div v-if="status.sensitive == true">
<details class="details-animated">
<summary>
<p class="mb-0 lead font-weight-bold">{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
<p class="font-weight-light">(click to show)</p>
</summary>
<b-carousel :id="status.id + '-carousel'"
style="text-shadow: 1px 1px 2px #333; background-color: #000;"
controls
img-blank
background="#ffffff"
:interval="0"
>
<b-carousel-slide v-for="(vid, index) in status.media_attachments" :key="vid.id + '-media'">
<video slot="img" class="embed-responsive-item" preload="none" controls playsinline loop :alt="vid.description" width="100%" height="100%">
<source :src="vid.url" :type="vid.mime">
</video>
</b-carousel-slide>
</b-carousel>
</details>
</div>
<div v-else>
<b-carousel :id="status.id + '-carousel'"
style="text-shadow: 1px 1px 2px #333; background-color: #000;"
controls
img-blank
background="#ffffff"
:interval="0"
>
<b-carousel-slide v-for="(vid, index) in status.media_attachments" :key="vid.id + '-media'">
<video slot="img" class="embed-responsive-item" preload="none" controls playsinline loop :alt="vid.description" width="100%" height="100%">
<source :src="vid.url" :type="vid.mime">
</video>
</b-carousel-slide>
</b-carousel>
</div>
</template>
<script type="text/javascript">
export default {
props: ['status']
}
</script>

View file

@ -0,0 +1,90 @@
<template>
<div v-if="status.sensitive == true" class="content-label-wrapper">
<div class="text-light content-label">
<p class="text-center">
<i class="far fa-eye-slash fa-2x"></i>
</p>
<p class="h4 font-weight-bold text-center">
Sensitive Content
</p>
<p class="text-center py-2 content-label-text">
{{ status.spoiler_text ? status.spoiler_text : 'This post may contain sensitive content.'}}
</p>
<p class="mb-0">
<button @click="toggleContentWarning()" class="btn btn-outline-light btn-block btn-sm font-weight-bold">See Post</button>
</p>
</div>
<blur-hash-image
width="32"
height="32"
:punch="1"
:hash="status.media_attachments[0].blurhash"
:alt="altText(status)"/>
</div>
<div v-else class="embed-responsive embed-responsive-16by9">
<video class="video" controls playsinline webkit-playsinline preload="metadata" loop :data-id="status.id" :poster="poster()">
<source :src="status.media_attachments[0].url" :type="status.media_attachments[0].mime">
</video>
</div>
</template>
<style type="text/css" scoped>
.content-label-wrapper {
position: relative;
}
.content-label {
margin: 0;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
z-index: 2;
background: rgba(0, 0, 0, 0.2)
}
</style>
<script type="text/javascript">
export default {
props: ['status'],
methods: {
altText(status) {
let desc = status.media_attachments[0].description;
if(desc) {
return desc;
}
return 'Video was not tagged with any alt text.';
},
playOrPause(e) {
let el = e.target;
if(el.getAttribute('playing') == 1) {
el.removeAttribute('playing');
el.pause();
} else {
el.setAttribute('playing', 1);
el.play();
}
},
toggleContentWarning(status) {
this.$emit('togglecw');
},
poster() {
let url = this.status.media_attachments[0].preview_url;
if(url.endsWith('no-preview.jpg') || url.endsWith('no-preview.png')) {
return;
}
return url;
}
}
}
</script>

View file

@ -48,27 +48,27 @@ Vue.use(VueTimeago, {
Vue.component( Vue.component(
'photo-presenter', 'photo-presenter',
require('./components/presenter/PhotoPresenter.vue').default require('./../components/presenter/PhotoPresenter.vue').default
); );
Vue.component( Vue.component(
'video-presenter', 'video-presenter',
require('./components/presenter/VideoPresenter.vue').default require('./../components/presenter/VideoPresenter.vue').default
); );
Vue.component( Vue.component(
'photo-album-presenter', 'photo-album-presenter',
require('./components/presenter/PhotoAlbumPresenter.vue').default require('./../components/presenter/PhotoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'video-album-presenter', 'video-album-presenter',
require('./components/presenter/VideoAlbumPresenter.vue').default require('./../components/presenter/VideoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'mixed-album-presenter', 'mixed-album-presenter',
require('./components/presenter/MixedAlbumPresenter.vue').default require('./../components/presenter/MixedAlbumPresenter.vue').default
); );
Vue.component( Vue.component(

View file

@ -1,26 +1,26 @@
Vue.component( Vue.component(
'photo-presenter', 'photo-presenter',
require('./components/presenter/PhotoPresenter.vue').default require('./../components/presenter/PhotoPresenter.vue').default
); );
Vue.component( Vue.component(
'video-presenter', 'video-presenter',
require('./components/presenter/VideoPresenter.vue').default require('./../components/presenter/VideoPresenter.vue').default
); );
Vue.component( Vue.component(
'photo-album-presenter', 'photo-album-presenter',
require('./components/presenter/PhotoAlbumPresenter.vue').default require('./../components/presenter/PhotoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'video-album-presenter', 'video-album-presenter',
require('./components/presenter/VideoAlbumPresenter.vue').default require('./../components/presenter/VideoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'mixed-album-presenter', 'mixed-album-presenter',
require('./components/presenter/MixedAlbumPresenter.vue').default require('./../components/presenter/MixedAlbumPresenter.vue').default
); );
Vue.component( Vue.component(

View file

@ -60,27 +60,27 @@ Vue.component(
Vue.component( Vue.component(
'photo-presenter', 'photo-presenter',
require('./components/presenter/PhotoPresenter.vue').default require('./../components/presenter/PhotoPresenter.vue').default
); );
Vue.component( Vue.component(
'video-presenter', 'video-presenter',
require('./components/presenter/VideoPresenter.vue').default require('./../components/presenter/VideoPresenter.vue').default
); );
Vue.component( Vue.component(
'photo-album-presenter', 'photo-album-presenter',
require('./components/presenter/PhotoAlbumPresenter.vue').default require('./../components/presenter/PhotoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'video-album-presenter', 'video-album-presenter',
require('./components/presenter/VideoAlbumPresenter.vue').default require('./../components/presenter/VideoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'mixed-album-presenter', 'mixed-album-presenter',
require('./components/presenter/MixedAlbumPresenter.vue').default require('./../components/presenter/MixedAlbumPresenter.vue').default
); );
Vue.component( Vue.component(

View file

@ -1,26 +1,26 @@
Vue.component( Vue.component(
'photo-presenter', 'photo-presenter',
require('./components/presenter/PhotoPresenter.vue').default require('./../components/presenter/PhotoPresenter.vue').default
); );
Vue.component( Vue.component(
'video-presenter', 'video-presenter',
require('./components/presenter/VideoPresenter.vue').default require('./../components/presenter/VideoPresenter.vue').default
); );
Vue.component( Vue.component(
'photo-album-presenter', 'photo-album-presenter',
require('./components/presenter/PhotoAlbumPresenter.vue').default require('./../components/presenter/PhotoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'video-album-presenter', 'video-album-presenter',
require('./components/presenter/VideoAlbumPresenter.vue').default require('./../components/presenter/VideoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'mixed-album-presenter', 'mixed-album-presenter',
require('./components/presenter/MixedAlbumPresenter.vue').default require('./../components/presenter/MixedAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
@ -32,3 +32,13 @@ Vue.component(
'post-component', 'post-component',
require('./components/PostComponent.vue').default require('./components/PostComponent.vue').default
); );
// Vue.component(
// 'post-next',
// require('./components/PostNext.vue').default
// );
// Vue.component(
// 'video-component',
// require('./components/VideoComponent.vue').default
// );

View file

@ -5,27 +5,27 @@ Vue.component(
Vue.component( Vue.component(
'photo-presenter', 'photo-presenter',
require('./components/presenter/PhotoPresenter.vue').default require('./../components/presenter/PhotoPresenter.vue').default
); );
Vue.component( Vue.component(
'video-presenter', 'video-presenter',
require('./components/presenter/VideoPresenter.vue').default require('./../components/presenter/VideoPresenter.vue').default
); );
Vue.component( Vue.component(
'photo-album-presenter', 'photo-album-presenter',
require('./components/presenter/PhotoAlbumPresenter.vue').default require('./../components/presenter/PhotoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'video-album-presenter', 'video-album-presenter',
require('./components/presenter/VideoAlbumPresenter.vue').default require('./../components/presenter/VideoAlbumPresenter.vue').default
); );
Vue.component( Vue.component(
'mixed-album-presenter', 'mixed-album-presenter',
require('./components/presenter/MixedAlbumPresenter.vue').default require('./../components/presenter/MixedAlbumPresenter.vue').default
); );
Vue.component( Vue.component(

View file

@ -1,53 +1,38 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ app()->getLocale() }}"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<title>{{ $title ?? config_cache('app.name', 'Pixelfed') }}</title>
<title>{{ $title ?? config('app.name', 'Pixelfed') }}</title>
<meta property="og:site_name" content="{{ config_cache('app.name', 'pixelfed') }}"> <meta property="og:site_name" content="{{ config_cache('app.name', 'pixelfed') }}">
<meta property="og:title" content="{{ $title ?? config_cache('app.name', 'pixelfed') }}"> <meta property="og:title" content="{{ $title ?? config_cache('app.name', 'pixelfed') }}">
<meta property="og:type" content="article"> <meta property="og:type" content="profile">
<meta property="og:url" content="{{$profile['url']}}"> <meta property="og:url" content="{{$profile['url']}}">
<meta name="medium" content="image"> <meta name="medium" content="image">
<meta name="theme-color" content="#10c5f8"> <meta name="theme-color" content="#10c5f8">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<link rel="shortcut icon" type="image/png" href="{{url('/img/favicon.png?v=2')}}"> <link rel="shortcut icon" type="image/png" href="{{url('/img/favicon.png?v=2')}}">
<link rel="apple-touch-icon" type="image/png" href="{{url('/img/favicon.png?v=2')}}"> <link rel="apple-touch-icon" type="image/png" href="{{url('/img/favicon.png?v=2')}}">
<link href="{{ mix('css/app.css') }}" rel="stylesheet"> <style>.btn,img{vertical-align:middle}.btn,a{background-color:transparent}.btn:hover,a{text-decoration:none}.card,.col-4,.info-overlay,.square{position:relative}*,::after,::before{box-sizing:border-box}p{margin-top:0;margin-bottom:1rem}a{color:#2c78bf}a:hover{color:#1e5181;text-decoration:underline}img{border-style:none}.small{font-size:.875em;font-weight:400}.btn,body{font-size:.9rem;font-weight:400;line-height:1.6;color:#212529}.row{display:flex;flex-wrap:wrap;margin-right:-15px;margin-left:-15px}.col-4{width:100%;padding-right:15px;padding-left:15px;flex:0 0 33.33333333%;max-width:33.33333333%}.btn{display:inline-block;text-align:center;-webkit-user-select:none;-moz-user-select:none;user-select:none;border:1px solid transparent;padding:.375rem .75rem;border-radius:.25rem;transition:color .15s ease-in-out,background-color .15s ease-in-out,border-color .15s ease-in-out,box-shadow .15s ease-in-out}.card,body{display:flex}@media (prefers-reduced-motion:reduce){.btn{transition:none}}.btn:hover{color:#212529}.btn:focus{outline:0;box-shadow:0 0 0 .2rem rgba(44,120,191,.25)}.btn-primary:focus,.btn-primary:not(:disabled):not(.disabled):active:focus{box-shadow:0 0 0 .2rem rgba(76,140,201,.5)}.btn:disabled{opacity:.65}.btn:not(:disabled):not(.disabled){cursor:pointer}.btn-primary,.btn-primary:disabled{color:#fff;background-color:#2c78bf;border-color:#2c78bf}.btn-primary:focus,.btn-primary:hover{background-color:#2564a0;border-color:#225e96;color:#fff}.btn-primary:not(:disabled):not(.disabled):active{color:#fff;background-color:#225e96;border-color:#20578b}.btn-sm{padding:.25rem .5rem;font-size:.7875rem;line-height:1.5;border-radius:.2rem}.card{flex-direction:column;min-width:0;word-wrap:break-word;background-color:#fff;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}.card-body{flex:1 1 auto;min-height:1px;padding:1.25rem}.card-footer,.card-header{padding:.75rem 1.25rem;background-color:#fff}.card-header{margin-bottom:0;border-bottom:1px solid rgba(0,0,0,.125)}.card-header:first-child{border-radius:calc(.25rem - 1px) calc(.25rem - 1px) 0 0}.card-footer{border-top:1px solid rgba(0,0,0,.125)}.card-footer:last-child{border-radius:0 0 calc(.25rem - 1px) calc(.25rem - 1px)}.bg-white{background-color:#fff!important}.border{border:1px solid #dee2e6!important}.d-flex{display:flex!important}.d-inline-flex{display:inline-flex!important}.justify-content-between{justify-content:space-between!important}.align-items-center{align-items:center!important}.shadow-none{box-shadow:none!important}.mb-0{margin-bottom:0!important}.mb-1{margin-bottom:.25rem!important}.mt-2{margin-top:.5rem!important}.mt-4{margin-top:1.5rem!important}.px-0{padding-right:0!important;padding-left:0!important}.py-1{padding-top:.25rem!important}.pr-1,.px-1{padding-right:.25rem!important}.pb-1,.py-1{padding-bottom:.25rem!important}.px-1{padding-left:.25rem!important}.pl-2{padding-left:.5rem!important}.px-4{padding-right:1.5rem!important;padding-left:1.5rem!important}.text-center{text-align:center!important}.text-uppercase{text-transform:uppercase!important}.font-weight-bold{font-weight:700!important}a.text-dark:focus,a.text-dark:hover{color:#000!important}a.text-muted:focus,a.text-muted:hover{color:#454b50!important}.text-muted{color:#6c757d!important}@media print{*,::after,::before{text-shadow:none!important;box-shadow:none!important}a:not(.btn){text-decoration:underline}img{page-break-inside:avoid}p{orphans:3;widows:3}body{min-width:992px!important}}body{margin:0;text-align:left;background-color:rgba(247,251,253,.4705882353);min-height:100vh;flex-flow:column;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}.text-dark{color:#212529!important}.square{width:100%}.square::after{content:"";display:block;padding-bottom:100%}.square-content{position:absolute;width:100%;height:100%;background-repeat:no-repeat;background-size:cover;background-position:50%}@media (max-width:576px){.card-md-border-0{border-width:0!important;border-radius:0!important}.card-md-rounded-0{border-width:1px 0;border-radius:0!important}}.card{box-shadow:0 2px 6px 0 hsla(0,0%,0%,.2);border:none}body.embed-card{background:#fff!important;margin:0;padding-bottom:0}.status-card-embed{box-shadow:none;border-radius:4px;overflow:hidden}.avatar{border-radius:100%}</style>
<style type="text/css">
body.embed-card {
background: #fff !important;
margin: 0;
padding-bottom: 0;
}
.status-card-embed {
box-shadow: none;
border-radius: 4px;
overflow: hidden;
}
</style>
</head> </head>
<body class="bg-white"> <body class="bg-white">
<div class="embed-card"> <div class="embed-card">
<div class="card status-card-embed card-md-rounded-0 border"> <div class="card status-card-embed card-md-rounded-0 border">
<div class="card-header d-inline-flex align-items-center justify-content-between bg-white"> <div class="card-header d-inline-flex align-items-center justify-content-between bg-white">
<div> <div>
<img src="{{$profile['avatar']}}" width="32px" height="32px" style="border-radius: 32px;"> <img src="{{$profile['avatar']}}" width="32" height="32" class="avatar" onerror="this.onerror=null;this.src='/storage/avatars/default.jpg';">
<a class="username font-weight-bold pl-2 text-dark" target="_blank" href="{{$profile['url']}}"> <a class="username font-weight-bold pl-2 text-dark" target="_blank" href="{{$profile['url']}}">
{{$profile['username']}} {{$profile['username']}}
</a> </a>
</div> </div>
<div> <div>
<a class="small font-weight-bold text-muted pr-1" href="{{config('app.url')}}" target="_blank">{{config('pixelfed.domain.app')}}</a> <a class="small font-weight-bold text-muted pr-1" href="{{config('app.url')}}" target="_blank">{{config('pixelfed.domain.app')}}</a>
<img src="/img/pixelfed-icon-color.svg" width="26px"> <img src="/img/pixelfed-icon-color.svg" width="26" height="26">
</div> </div>
</div> </div>
<div class="card-body pb-1"> <div class="card-body pb-1">
<div class="d-flex justify-content-between align-items-center"> <div class="d-flex justify-content-between align-items-center">
<div class="text-center"> <div class="text-center">
<p class="mb-0 font-weight-bold prettyCount" data-count="{{$profile['statuses_count']}}"></p> <p class="mb-0 font-weight-bold prettyCount" data-count="{{$profile['statuses_count']}}"></p>
@ -58,61 +43,66 @@
<p class="mb-0 text-muted text-uppercase small font-weight-bold">Followers</p> <p class="mb-0 text-muted text-uppercase small font-weight-bold">Followers</p>
</div> </div>
<div class="text-center"> <div class="text-center">
<p class="mb-0"><a href="/i/intent/follow?user={{$profile['username']}}" class="btn btn-primary btn-sm py-1 px-4 text-uppercase font-weight-bold" target="_blank">Follow</a></p> <p class="mb-0"><a href="{{config('app.url')}}/i/intent/follow?user={{$profile['username']}}" class="btn btn-primary btn-sm py-1 px-4 text-uppercase font-weight-bold" target="_blank">Follow</a></p>
</div> </div>
</div> </div>
<div class="row mt-4 mb-1 embed-row"></div> <div class="row mt-4 mb-1 embed-row"></div>
</div> </div>
<div class="card-footer bg-white"> <div class="card-footer bg-white">
<p class="text-center mb-0"> <p class="text-center mb-0">
<a href="{{$profile['url']}}" class="font-weight-bold" target="_blank">View More Posts</a> <a href="{{$profile['url']}}" class="font-weight-bold" target="_blank">View More Posts</a>
</p> </p>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript" src="{{mix('js/manifest.js')}}"></script> <script type="text/javascript">
<script type="text/javascript" src="{{mix('js/vendor.js')}}"></script>
<script type="text/javascript" src="{{mix('js/app.js')}}"></script>
<script type="text/javascript">
window.addEventListener("message", e=>{const t=e.data||{};}); window.addEventListener("message", e=>{const t=e.data||{};});
</script> document.querySelectorAll('.caption-container a').forEach(function(i) {i.setAttribute('target', '_blank');});
<script type="text/javascript">document.querySelectorAll('.caption-container a').forEach(function(i) {i.setAttribute('target', '_blank');});</script> function formatCount(count = 0, locale = 'en-GB', notation = 'compact') {
<script type="text/javascript"> if(count < 1) {
document.querySelectorAll('.prettyCount').forEach(function(i) { return 0;
i.innerText = App.util.format.count(i.getAttribute('data-count'));
});
</script>
<script type="text/javascript">
axios.get('/api/pixelfed/v1/accounts/{{$profile['id']}}/statuses', {
params: {
only_media: true,
limit: 24
} }
}) return new Intl.NumberFormat(locale, { notation: notation , compactDisplay: "short" }).format(count);
}
function generateElements(html) {
const template = document.createElement('template');
template.innerHTML = html.trim();
return template.content.children;
}
document.querySelectorAll('.prettyCount').forEach(function(i) {
i.innerText = formatCount(i.getAttribute('data-count'));
});
fetch("{{config('app.url')}}/api/pixelfed/v1/accounts/{{$profile['id']}}/statuses?only_media=true&limit=24")
.then(res => res.json())
.then(res => { .then(res => {
let parent = $('.embed-row'); let parent = document.querySelector('.embed-row');
res.data res.filter(post => post.pf_type == 'photo' && !post.sensitive && post.visibility === 'public')
.filter(res => res.pf_type == 'photo')
.filter(res => !res.sensitive)
.slice(0, 9) .slice(0, 9)
.forEach(post => { .forEach((post, idx) => {
let el = `<div class="col-4 mt-2 px-0"> let mediaUrl = post.media_attachments[0].preview_url ? post.media_attachments[0].preview_url : post.media_attachments[0].url;
<a class="card info-overlay card-md-border-0 px-1 shadow-none" href="${post.url}" target="_blank"> let html = `<div class="col-4 mt-2 px-0"><a class="card info-overlay card-md-border-0 px-1 shadow-none" href="${post.url}" target="_blank"><div class="square"><div class="square-content" style="background-image: url('${mediaUrl}')"></div></div></a></div>`;
<div class="square"> let el = document.createElement('div');
<div class="square-content" style="background-image: url('${post.media_attachments[0].url}')"> el.innerHTML = html;
</div> parent.appendChild(el.firstChild);
</div> });
</a>
</div>`;
parent.append(el);
}) })
}) window.addEventListener("message", e => {
.finally(() => { const t = e.data || {};
window.parent.postMessage({type:"setHeight",id:0,height:document.getElementsByTagName("html")[0].scrollHeight},"*"); if (window.parent && t.type === 'setHeight') {
updateHeight(t.id)
}
});
function updateHeight(id) {
setTimeout(() => { setTimeout(() => {
window.parent.postMessage({type:"setHeight",id:0,height:document.getElementsByTagName("html")[0].scrollHeight},"*"); window.parent.postMessage({
}, 5000); type: 'setHeight',
}) id: id,
</script> height: document.documentElement.scrollHeight
}, "*");
}, 2500)
}
</script>
</body> </body>
</html> </html>

View file

@ -1,152 +1,49 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="{{ app()->getLocale() }}"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<title>{{ $title ?? config_cache('app.name', 'Pixelfed') }}</title>
<title>{{ $title ?? config('app.name', 'Pixelfed') }}</title> <meta property="og:site_name" content="{{ config_cache('app.name', 'pixelfed') }}">
<meta property="og:title" content="{{ $title ?? config_cache('app.name', 'pixelfed') }}">
<meta property="og:site_name" content="{{ config('app.name', 'pixelfed') }}">
<meta property="og:title" content="{{ $title ?? config('app.name', 'pixelfed') }}">
<meta property="og:type" content="article"> <meta property="og:type" content="article">
<meta property="og:url" content="{{$status->url()}}"> <meta property="og:url" content="{{$status['url']}}">
<meta name="medium" content="image"> <meta name="medium" content="image">
<meta name="theme-color" content="#10c5f8"> <meta name="theme-color" content="#10c5f8">
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<link rel="shortcut icon" type="image/png" href="/img/favicon.png?v=2"> <link rel="shortcut icon" type="image/png" href="/img/favicon.png?v=2">
<link rel="apple-touch-icon" type="image/png" href="/img/favicon.png?v=2"> <link rel="apple-touch-icon" type="image/png" href="/img/favicon.png?v=2">
<link href="{{ mix('css/app.css') }}" rel="stylesheet"> <style type="text/css">hr,p{margin-bottom:1rem}.small,body{font-weight:400}.card,body{display:flex}*,::after,::before{box-sizing:border-box}p{margin-top:0}a{color:#2c78bf;text-decoration:none;background-color:transparent}a:hover{color:#1e5181;text-decoration:underline}img{vertical-align:middle;border-style:none}hr{box-sizing:content-box;height:0;overflow:visible;margin-top:1rem;border:0;border-top:1px solid rgba(0,0,0,.1)}.small{font-size:.875em}.card{position:relative;flex-direction:column;min-width:0;word-wrap:break-word;background-color:#fff;background-clip:border-box;border:1px solid rgba(0,0,0,.125);border-radius:.25rem}.card-body{flex:1 1 auto;min-height:1px;padding:1.25rem}.card-footer,.card-header{padding:.75rem 1.25rem;background-color:#fff}.card-header{margin-bottom:0;border-bottom:1px solid rgba(0,0,0,.125)}.card-header:first-child{border-radius:calc(.25rem - 1px) calc(.25rem - 1px) 0 0}.card-footer{border-top:1px solid rgba(0,0,0,.125)}.card-footer:last-child{border-radius:0 0 calc(.25rem - 1px) calc(.25rem - 1px)}.bg-white{background-color:#fff!important}.border{border:1px solid #dee2e6!important}.d-inline-flex{display:inline-flex!important}.justify-content-between{justify-content:space-between!important}.align-items-center{align-items:center!important}.my-0{margin-top:0!important}.mb-0,.my-0{margin-bottom:0!important}.mb-2{margin-bottom:.5rem!important}.pr-1{padding-right:.25rem!important}.pl-2{padding-left:.5rem!important}.text-uppercase{text-transform:uppercase!important}.font-weight-bold{font-weight:700!important}a.text-dark:focus,a.text-dark:hover{color:#000!important}a.text-muted:focus,a.text-muted:hover{color:#454b50!important}.text-muted{color:#6c757d!important}@media print{*,::after,::before{text-shadow:none!important;box-shadow:none!important}a:not(.btn){text-decoration:underline}img{page-break-inside:avoid}p{orphans:3;widows:3}body{min-width:992px!important}}body{margin:0;font-size:.9rem;line-height:1.6;color:#212529;text-align:left;background-color:rgba(247,251,253,.4705882353);min-height:100vh;flex-flow:column;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif}.text-dark{color:#212529!important}@media (max-width:576px){.card-md-rounded-0{border-width:1px 0;border-radius:0!important}}.card{box-shadow:0 2px 6px 0 hsla(0,0%,0%,.2);border:none}.status-card-embed{box-shadow:none;border-radius:4px;overflow:hidden}body.embed-card{background:#fff!important;margin:0;padding-bottom:0}.avatar{border-radius:100%}</style>
<style type="text/css">
body.embed-card {
background: #fff !important;
margin: 0;
padding-bottom: 0;
}
.status-card-embed {
box-shadow: none;
border-radius: 4px;
overflow: hidden;
}
</style>
</head> </head>
<body class="bg-white"> <body class="bg-white">
<div class="embed-card"> <div class="embed-card">
@php($item = $status)
<div class="card status-card-embed card-md-rounded-0 border"> <div class="card status-card-embed card-md-rounded-0 border">
<div class="card-header d-inline-flex align-items-center bg-white"> <div class="card-header d-inline-flex align-items-center bg-white">
<img src="{{$item->profile->avatarUrl()}}" width="32px" height="32px" style="border-radius: 32px;"> <img src="{{$status['account']['avatar']}}" width="32" height="32" class="avatar" onerror="this.onerror=null;this.src='/storage/avatars/default.jpg';">
<a class="username font-weight-bold pl-2 text-dark" target="_blank" href="{{$item->profile->url()}}"> <a class="username font-weight-bold pl-2 text-dark" target="_blank" rel="ugc" href="{{$status['account']['url']}}">
{{$item->profile->username}} {{$status['account']['username']}}
</a> </a>
</div> </div>
<a href="{{$status->url()}}" target="_blank"> <a href="{{$status['url']}}" target="_blank" rel="ugc">
@php($status = $item) <div>
@switch($status->viewType()) <img src="{{$status['media_attachments'][0]['preview_url'] ?? $status['media_attachments'][0]['url']}}" width="100%">
@case('photo')
@case('image')
@if($status->is_nsfw)
<details class="details-animated">
<summary>
<p class="mb-0 lead font-weight-bold">CW / NSFW / Hidden Media</p>
<p class="font-weight-light">(click to show)</p>
</summary>
<a class="max-hide-overflow {{$status->firstMedia()->filter_class}}" href="{{$status->url()}}" target="_blank">
<img class="card-img-top" src="{{$status->mediaUrl()}}">
</a>
</details>
@else
<div class="{{$status->firstMedia()->filter_class}}">
<img src="{{$status->mediaUrl()}}" width="100%">
</div> </div>
@endif
@break
@case('photo:album')
<div id="photo-carousel-wrapper-{{$status->id}}" class="carousel slide carousel-fade mb-n3 " data-ride="carousel">
<ol class="carousel-indicators">
@for($i = 0; $i < $status->media_count; $i++)
<li data-target="#photo-carousel-wrapper-{{$status->id}}" data-slide-to="{{$i}}" class="{{$i == 0 ? 'active' : ''}}"></li>
@endfor
</ol>
<div class="carousel-inner">
@foreach($status->media()->orderBy('order')->get() as $media)
<div class="carousel-item {{$loop->iteration == 1 ? 'active' : ''}}">
<figure class="{{$media->filter_class}}">
<div class="float-right mr-3 badge badge-dark border border-secondary rounded-pill p-2" style="position:absolute;top:8px;right:0;margin-bottom:-20px;">{{$loop->iteration}}/{{$loop->count}}</div>
<img class="d-block w-100" src="{{$media->url()}}" alt="{{$status->caption}}">
</figure>
</div>
@endforeach
</div>
<a class="carousel-control-prev" href="#photo-carousel-wrapper-{{$status->id}}" role="button" data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#photo-carousel-wrapper-{{$status->id}}" role="button" data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
@break
@case('video')
@if($status->is_nsfw)
<details class="details-animated">
<summary>
<p class="mb-0 lead font-weight-bold">CW / NSFW / Hidden Media</p>
<p class="font-weight-light">(click to show)</p>
</summary>
<div class="embed-responsive embed-responsive-16by9">
<video class="video" preload="none" controls loop>
<source src="{{$status->firstMedia()->url()}}" type="{{$status->firstMedia()->mime}}">
</video>
</div>
</details>
@else
<div class="embed-responsive embed-responsive-16by9">
<video class="video" preload="none" controls loop>
<source src="{{$status->firstMedia()->url()}}" type="{{$status->firstMedia()->mime}}">
</video>
</div>
@endif
@break
@case('video-album')
@if($status->is_nsfw)
<details class="details-animated">
<summary>
<p class="mb-0 lead font-weight-bold">CW / NSFW / Hidden Media</p>
<p class="font-weight-light">(click to show)</p>
</summary>
<div class="embed-responsive embed-responsive-16by9">
<video class="video" preload="none" controls loop>
<source src="{{$status->firstMedia()->url()}}" type="{{$status->firstMedia()->mime}}">
</video>
</div>
</details>
@else
<div class="embed-responsive embed-responsive-16by9">
<video class="video" preload="none" controls loop>
<source src="{{$status->firstMedia()->url()}}" type="{{$status->firstMedia()->mime}}">
</video>
</div>
@endif
@break
@endswitch
</a> </a>
@if($layout != 'compact') @if($layout != 'compact')
<div class="card-body"> <div class="card-body">
<div class="view-more mb-2"> <div class="view-more mb-2">
<a class="font-weight-bold" href="{{$status->url()}}" target="_blank">View More on Pixelfed</a> <a class="font-weight-bold" href="{{$status['url']}}" target="_blank">View More on Pixelfed</a>
</div> </div>
<hr> <hr>
<div class="caption"> <div class="caption">
<p class="my-0"> <p class="my-0">
<span class="username font-weight-bold"> <span class="username font-weight-bold">
<bdi><a class="text-dark" href="{{$item->profile->url()}}" target="_blank">{{$item->profile->username}}</a></bdi> <bdi><a class="text-dark" href="{{$status['account']['url']}}" target="_blank">{{$status['account']['username']}}</a></bdi>
</span> </span>
@if($showCaption) @if($showCaption)
<span class="caption-container">{!! $item->rendered ?? e($item->caption) !!}</span> <span class="caption-container">{{ $status['content_text'] }}</span>
@endif @endif
</p> </p>
</div> </div>
@ -154,19 +51,22 @@
@endif @endif
<div class="card-footer bg-white d-inline-flex justify-content-between align-items-center"> <div class="card-footer bg-white d-inline-flex justify-content-between align-items-center">
<div class="timestamp"> <div class="timestamp">
<p class="small text-uppercase mb-0"><a href="{{$item->url()}}" class="text-muted" target="_blank">{{$item->created_at->diffForHumans()}}</a></p> <p class="small text-uppercase mb-0">
<a href="{{$status['url']}}" class="text-muted" target="_blank" rel="ugc">
{{now()->parse($status['created_at'])->diffForHumans()}}
</a>
</p>
</div> </div>
<div> <div>
<a class="small font-weight-bold text-muted pr-1" href="{{config('app.url')}}" target="_blank">{{config('pixelfed.domain.app')}}</a> <a class="small font-weight-bold text-muted pr-1" href="{{config('app.url')}}" target="_blank">{{config('pixelfed.domain.app')}}</a>
<img src="/img/pixelfed-icon-color.svg" width="26px"> <img src="/img/pixelfed-icon-color.svg" width="26" height="26" />
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript">window.addEventListener("message",e=>{const t=e.data||{};window.parent&&"setHeight"===t.type&&window.parent.postMessage({type:"setHeight",id:t.id,height:document.getElementsByTagName("html")[0].scrollHeight},"*")});</script> <script type="text/javascript">
<script type="text/javascript">document.querySelectorAll('.caption-container a').forEach(function(i) {i.setAttribute('target', '_blank');});</script> window.addEventListener("message",e=>{const t=e.data||{};window.parent&&"setHeight"===t.type&&window.parent.postMessage({type:"setHeight",id:t.id,height:document.getElementsByTagName("html")[0].scrollHeight},"*")});
<script type="text/javascript" src="{{ mix('js/manifest.js') }}"></script> document.querySelectorAll('.caption-container a').forEach(function(i) {i.setAttribute('target', '_blank');});
<script type="text/javascript" src="{{ mix('js/vendor.js') }}"></script> </script>
<script type="text/javascript" src="{{ mix('js/app.js') }}"></script>
</body> </body>
</html> </html>

6
webpack.mix.js vendored
View file

@ -1,7 +1,9 @@
let mix = require('laravel-mix'); let mix = require('laravel-mix');
const fs = require("fs"); const fs = require("fs");
const path = require("path");
mix.before(() => { mix.before(() => {
fs.rmSync('public/css', { recursive: true, force: true });
fs.rmSync('public/js', { recursive: true, force: true }); fs.rmSync('public/js', { recursive: true, force: true });
}); });
@ -57,6 +59,10 @@ mix.options({
} }
} }
}) })
mix.alias({
'@': path.join(__dirname, 'resources/assets/components'),
'~': path.join(__dirname, 'resources/assets/js/components'),
});
mix.webpackConfig({ mix.webpackConfig({
optimization: { optimization: {
providedExports: false, providedExports: false,