mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-25 15:55:22 +00:00
commit
24c467c558
8 changed files with 641 additions and 477 deletions
|
@ -2,356 +2,385 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Auth;
|
|
||||||
use Cache;
|
|
||||||
use DB;
|
|
||||||
use View;
|
|
||||||
use App\AccountInterstitial;
|
use App\AccountInterstitial;
|
||||||
use App\Follower;
|
use App\Follower;
|
||||||
use App\FollowRequest;
|
use App\FollowRequest;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\Story;
|
|
||||||
use App\Status;
|
|
||||||
use App\User;
|
|
||||||
use App\UserSetting;
|
|
||||||
use App\UserFilter;
|
|
||||||
use League\Fractal;
|
|
||||||
use App\Services\AccountService;
|
use App\Services\AccountService;
|
||||||
use App\Services\FollowerService;
|
use App\Services\FollowerService;
|
||||||
use App\Services\StatusService;
|
use App\Services\StatusService;
|
||||||
use App\Util\Lexer\Nickname;
|
use App\Status;
|
||||||
use App\Util\Webfinger\Webfinger;
|
use App\Story;
|
||||||
use App\Transformer\ActivityPub\ProfileOutbox;
|
|
||||||
use App\Transformer\ActivityPub\ProfileTransformer;
|
use App\Transformer\ActivityPub\ProfileTransformer;
|
||||||
|
use App\User;
|
||||||
|
use App\UserFilter;
|
||||||
|
use App\UserSetting;
|
||||||
|
use Auth;
|
||||||
|
use Cache;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use League\Fractal;
|
||||||
|
use View;
|
||||||
|
|
||||||
class ProfileController extends Controller
|
class ProfileController extends Controller
|
||||||
{
|
{
|
||||||
public function show(Request $request, $username)
|
public function show(Request $request, $username)
|
||||||
{
|
{
|
||||||
// redirect authed users to Metro 2.0
|
if ($request->wantsJson() && (bool) config_cache('federation.activitypub.enabled')) {
|
||||||
if($request->user()) {
|
$user = $this->getCachedUser($username, true);
|
||||||
// unless they force static view
|
abort_if(! $user, 404, 'Not found');
|
||||||
if(!$request->has('fs') || $request->input('fs') != '1') {
|
|
||||||
$pid = AccountService::usernameToId($username);
|
|
||||||
if($pid) {
|
|
||||||
return redirect('/i/web/profile/' . $pid);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = Profile::whereNull('domain')
|
return $this->showActivityPub($request, $user);
|
||||||
->whereNull('status')
|
}
|
||||||
->whereUsername($username)
|
|
||||||
->firstOrFail();
|
|
||||||
|
|
||||||
|
// redirect authed users to Metro 2.0
|
||||||
|
if ($request->user()) {
|
||||||
|
// unless they force static view
|
||||||
|
if (! $request->has('fs') || $request->input('fs') != '1') {
|
||||||
|
$pid = AccountService::usernameToId($username);
|
||||||
|
if ($pid) {
|
||||||
|
return redirect('/i/web/profile/'.$pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($request->wantsJson() && config_cache('federation.activitypub.enabled')) {
|
$user = $this->getCachedUser($username);
|
||||||
return $this->showActivityPub($request, $user);
|
|
||||||
}
|
|
||||||
|
|
||||||
$aiCheck = Cache::remember('profile:ai-check:spam-login:' . $user->id, 86400, function() use($user) {
|
abort_unless($user, 404);
|
||||||
$exists = AccountInterstitial::whereUserId($user->user_id)->where('is_spam', 1)->count();
|
|
||||||
if($exists) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
$aiCheck = Cache::remember('profile:ai-check:spam-login:'.$user->id, 3600, function () use ($user) {
|
||||||
});
|
$exists = AccountInterstitial::whereUserId($user->user_id)->where('is_spam', 1)->count();
|
||||||
if($aiCheck) {
|
if ($exists) {
|
||||||
return redirect('/login');
|
return true;
|
||||||
}
|
}
|
||||||
return $this->buildProfile($request, $user);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function buildProfile(Request $request, $user)
|
return false;
|
||||||
{
|
});
|
||||||
$username = $user->username;
|
if ($aiCheck) {
|
||||||
$loggedIn = Auth::check();
|
return redirect('/login');
|
||||||
$isPrivate = false;
|
}
|
||||||
$isBlocked = false;
|
|
||||||
if(!$loggedIn) {
|
|
||||||
$key = 'profile:settings:' . $user->id;
|
|
||||||
$ttl = now()->addHours(6);
|
|
||||||
$settings = Cache::remember($key, $ttl, function() use($user) {
|
|
||||||
return $user->user->settings;
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($user->is_private == true) {
|
return $this->buildProfile($request, $user);
|
||||||
$profile = null;
|
}
|
||||||
return view('profile.private', compact('user'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$owner = false;
|
protected function buildProfile(Request $request, $user)
|
||||||
$is_following = false;
|
{
|
||||||
|
$username = $user->username;
|
||||||
|
$loggedIn = Auth::check();
|
||||||
|
$isPrivate = false;
|
||||||
|
$isBlocked = false;
|
||||||
|
if (! $loggedIn) {
|
||||||
|
$key = 'profile:settings:'.$user->id;
|
||||||
|
$ttl = now()->addHours(6);
|
||||||
|
$settings = Cache::remember($key, $ttl, function () use ($user) {
|
||||||
|
return $user->user->settings;
|
||||||
|
});
|
||||||
|
|
||||||
$profile = $user;
|
if ($user->is_private == true) {
|
||||||
$settings = [
|
$profile = null;
|
||||||
'crawlable' => $settings->crawlable,
|
|
||||||
'following' => [
|
|
||||||
'count' => $settings->show_profile_following_count,
|
|
||||||
'list' => $settings->show_profile_following
|
|
||||||
],
|
|
||||||
'followers' => [
|
|
||||||
'count' => $settings->show_profile_follower_count,
|
|
||||||
'list' => $settings->show_profile_followers
|
|
||||||
]
|
|
||||||
];
|
|
||||||
return view('profile.show', compact('profile', 'settings'));
|
|
||||||
} else {
|
|
||||||
$key = 'profile:settings:' . $user->id;
|
|
||||||
$ttl = now()->addHours(6);
|
|
||||||
$settings = Cache::remember($key, $ttl, function() use($user) {
|
|
||||||
return $user->user->settings;
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($user->is_private == true) {
|
return view('profile.private', compact('user'));
|
||||||
$isPrivate = $this->privateProfileCheck($user, $loggedIn);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$isBlocked = $this->blockedProfileCheck($user);
|
$owner = false;
|
||||||
|
$is_following = false;
|
||||||
|
|
||||||
$owner = $loggedIn && Auth::id() === $user->user_id;
|
$profile = $user;
|
||||||
$is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false;
|
$settings = [
|
||||||
|
'crawlable' => $settings->crawlable,
|
||||||
|
'following' => [
|
||||||
|
'count' => $settings->show_profile_following_count,
|
||||||
|
'list' => $settings->show_profile_following,
|
||||||
|
],
|
||||||
|
'followers' => [
|
||||||
|
'count' => $settings->show_profile_follower_count,
|
||||||
|
'list' => $settings->show_profile_followers,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
if ($isPrivate == true || $isBlocked == true) {
|
return view('profile.show', compact('profile', 'settings'));
|
||||||
$requested = Auth::check() ? FollowRequest::whereFollowerId(Auth::user()->profile_id)
|
} else {
|
||||||
->whereFollowingId($user->id)
|
$key = 'profile:settings:'.$user->id;
|
||||||
->exists() : false;
|
$ttl = now()->addHours(6);
|
||||||
return view('profile.private', compact('user', 'is_following', 'requested'));
|
$settings = Cache::remember($key, $ttl, function () use ($user) {
|
||||||
}
|
return $user->user->settings;
|
||||||
|
});
|
||||||
|
|
||||||
$is_admin = is_null($user->domain) ? $user->user->is_admin : false;
|
if ($user->is_private == true) {
|
||||||
$profile = $user;
|
$isPrivate = $this->privateProfileCheck($user, $loggedIn);
|
||||||
$settings = [
|
}
|
||||||
'crawlable' => $settings->crawlable,
|
|
||||||
'following' => [
|
|
||||||
'count' => $settings->show_profile_following_count,
|
|
||||||
'list' => $settings->show_profile_following
|
|
||||||
],
|
|
||||||
'followers' => [
|
|
||||||
'count' => $settings->show_profile_follower_count,
|
|
||||||
'list' => $settings->show_profile_followers
|
|
||||||
]
|
|
||||||
];
|
|
||||||
return view('profile.show', compact('profile', 'settings'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function permalinkRedirect(Request $request, $username)
|
$isBlocked = $this->blockedProfileCheck($user);
|
||||||
{
|
|
||||||
$user = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
|
|
||||||
|
|
||||||
if ($request->wantsJson() && config_cache('federation.activitypub.enabled')) {
|
$owner = $loggedIn && Auth::id() === $user->user_id;
|
||||||
return $this->showActivityPub($request, $user);
|
$is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false;
|
||||||
}
|
|
||||||
|
|
||||||
return redirect($user->url());
|
if ($isPrivate == true || $isBlocked == true) {
|
||||||
}
|
$requested = Auth::check() ? FollowRequest::whereFollowerId(Auth::user()->profile_id)
|
||||||
|
->whereFollowingId($user->id)
|
||||||
|
->exists() : false;
|
||||||
|
|
||||||
protected function privateProfileCheck(Profile $profile, $loggedIn)
|
return view('profile.private', compact('user', 'is_following', 'requested'));
|
||||||
{
|
}
|
||||||
if (!Auth::check()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$user = Auth::user()->profile;
|
$is_admin = is_null($user->domain) ? $user->user->is_admin : false;
|
||||||
if($user->id == $profile->id || !$profile->is_private) {
|
$profile = $user;
|
||||||
return false;
|
$settings = [
|
||||||
}
|
'crawlable' => $settings->crawlable,
|
||||||
|
'following' => [
|
||||||
|
'count' => $settings->show_profile_following_count,
|
||||||
|
'list' => $settings->show_profile_following,
|
||||||
|
],
|
||||||
|
'followers' => [
|
||||||
|
'count' => $settings->show_profile_follower_count,
|
||||||
|
'list' => $settings->show_profile_followers,
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
$follows = Follower::whereProfileId($user->id)->whereFollowingId($profile->id)->exists();
|
return view('profile.show', compact('profile', 'settings'));
|
||||||
if ($follows == false) {
|
}
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
protected function getCachedUser($username, $withTrashed = false)
|
||||||
}
|
{
|
||||||
|
$val = str_replace(['_', '.', '-'], '', $username);
|
||||||
|
if (! ctype_alnum($val)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$hash = ($withTrashed ? 'wt:' : 'wot:').strtolower($username);
|
||||||
|
|
||||||
public static function accountCheck(Profile $profile)
|
return Cache::remember('pfc:cached-user:'.$hash, ($withTrashed ? 14400 : 900), function () use ($username, $withTrashed) {
|
||||||
{
|
if (! $withTrashed) {
|
||||||
switch ($profile->status) {
|
return Profile::whereNull(['domain', 'status'])
|
||||||
case 'disabled':
|
->whereUsername($username)
|
||||||
case 'suspended':
|
->first();
|
||||||
case 'delete':
|
} else {
|
||||||
return view('profile.disabled');
|
return Profile::withTrashed()
|
||||||
break;
|
->whereNull('domain')
|
||||||
|
->whereUsername($username)
|
||||||
|
->first();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
public function permalinkRedirect(Request $request, $username)
|
||||||
break;
|
{
|
||||||
}
|
if ($request->wantsJson() && (bool) config_cache('federation.activitypub.enabled')) {
|
||||||
return abort(404);
|
$user = $this->getCachedUser($username, true);
|
||||||
}
|
|
||||||
|
|
||||||
protected function blockedProfileCheck(Profile $profile)
|
return $this->showActivityPub($request, $user);
|
||||||
{
|
}
|
||||||
$pid = Auth::user()->profile->id;
|
|
||||||
$blocks = UserFilter::whereUserId($profile->id)
|
|
||||||
->whereFilterType('block')
|
|
||||||
->whereFilterableType('App\Profile')
|
|
||||||
->pluck('filterable_id')
|
|
||||||
->toArray();
|
|
||||||
if (in_array($pid, $blocks)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
$user = $this->getCachedUser($username);
|
||||||
}
|
|
||||||
|
|
||||||
public function showActivityPub(Request $request, $user)
|
return redirect($user->url());
|
||||||
{
|
}
|
||||||
abort_if(!config_cache('federation.activitypub.enabled'), 404);
|
|
||||||
abort_if($user->domain, 404);
|
|
||||||
|
|
||||||
return Cache::remember('pf:activitypub:user-object:by-id:' . $user->id, 3600, function() use($user) {
|
protected function privateProfileCheck(Profile $profile, $loggedIn)
|
||||||
$fractal = new Fractal\Manager();
|
{
|
||||||
$resource = new Fractal\Resource\Item($user, new ProfileTransformer);
|
if (! Auth::check()) {
|
||||||
$res = $fractal->createData($resource)->toArray();
|
return true;
|
||||||
return response(json_encode($res['data']))->header('Content-Type', 'application/activity+json');
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function showAtomFeed(Request $request, $user)
|
$user = Auth::user()->profile;
|
||||||
{
|
if ($user->id == $profile->id || ! $profile->is_private) {
|
||||||
abort_if(!config('federation.atom.enabled'), 404);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$pid = AccountService::usernameToId($user);
|
$follows = Follower::whereProfileId($user->id)->whereFollowingId($profile->id)->exists();
|
||||||
|
if ($follows == false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
abort_if(!$pid, 404);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$profile = AccountService::get($pid, true);
|
public static function accountCheck(Profile $profile)
|
||||||
|
{
|
||||||
|
switch ($profile->status) {
|
||||||
|
case 'disabled':
|
||||||
|
case 'suspended':
|
||||||
|
case 'delete':
|
||||||
|
return view('profile.disabled');
|
||||||
|
break;
|
||||||
|
|
||||||
abort_if(!$profile || $profile['locked'] || !$profile['local'], 404);
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$aiCheck = Cache::remember('profile:ai-check:spam-login:' . $profile['id'], 86400, function() use($profile) {
|
return abort(404);
|
||||||
$uid = User::whereProfileId($profile['id'])->first();
|
}
|
||||||
if(!$uid) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
$exists = AccountInterstitial::whereUserId($uid->id)->where('is_spam', 1)->count();
|
|
||||||
if($exists) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
protected function blockedProfileCheck(Profile $profile)
|
||||||
});
|
{
|
||||||
|
$pid = Auth::user()->profile->id;
|
||||||
|
$blocks = UserFilter::whereUserId($profile->id)
|
||||||
|
->whereFilterType('block')
|
||||||
|
->whereFilterableType('App\Profile')
|
||||||
|
->pluck('filterable_id')
|
||||||
|
->toArray();
|
||||||
|
if (in_array($pid, $blocks)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
abort_if($aiCheck, 404);
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$enabled = Cache::remember('profile:atom:enabled:' . $profile['id'], 84600, function() use ($profile) {
|
public function showActivityPub(Request $request, $user)
|
||||||
$uid = User::whereProfileId($profile['id'])->first();
|
{
|
||||||
if(!$uid) {
|
abort_if(! config_cache('federation.activitypub.enabled'), 404);
|
||||||
return false;
|
abort_if(! $user, 404, 'Not found');
|
||||||
}
|
abort_if($user->domain, 404);
|
||||||
$settings = UserSetting::whereUserId($uid->id)->first();
|
|
||||||
if(!$settings) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $settings->show_atom;
|
return Cache::remember('pf:activitypub:user-object:by-id:'.$user->id, 1800, function () use ($user) {
|
||||||
});
|
$fractal = new Fractal\Manager();
|
||||||
|
$resource = new Fractal\Resource\Item($user, new ProfileTransformer);
|
||||||
|
$res = $fractal->createData($resource)->toArray();
|
||||||
|
|
||||||
abort_if(!$enabled, 404);
|
return response(json_encode($res['data']))->header('Content-Type', 'application/activity+json');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$data = Cache::remember('pf:atom:user-feed:by-id:' . $profile['id'], 900, function() use($pid, $profile) {
|
public function showAtomFeed(Request $request, $user)
|
||||||
$items = Status::whereProfileId($pid)
|
{
|
||||||
->whereScope('public')
|
abort_if(! config('federation.atom.enabled'), 404);
|
||||||
->whereIn('type', ['photo', 'photo:album'])
|
|
||||||
->orderByDesc('id')
|
|
||||||
->take(10)
|
|
||||||
->get()
|
|
||||||
->map(function($status) {
|
|
||||||
return StatusService::get($status->id, true);
|
|
||||||
})
|
|
||||||
->filter(function($status) {
|
|
||||||
return $status &&
|
|
||||||
isset($status['account']) &&
|
|
||||||
isset($status['media_attachments']) &&
|
|
||||||
count($status['media_attachments']);
|
|
||||||
})
|
|
||||||
->values();
|
|
||||||
$permalink = config('app.url') . "/users/{$profile['username']}.atom";
|
|
||||||
$headers = ['Content-Type' => 'application/atom+xml'];
|
|
||||||
|
|
||||||
if($items && $items->count()) {
|
$pid = AccountService::usernameToId($user);
|
||||||
$headers['Last-Modified'] = now()->parse($items->first()['created_at'])->toRfc7231String();
|
|
||||||
}
|
|
||||||
|
|
||||||
return compact('items', 'permalink', 'headers');
|
abort_if(! $pid, 404);
|
||||||
});
|
|
||||||
abort_if(!$data || !isset($data['items']) || !isset($data['permalink']), 404);
|
|
||||||
return response()
|
|
||||||
->view('atom.user',
|
|
||||||
[
|
|
||||||
'profile' => $profile,
|
|
||||||
'items' => $data['items'],
|
|
||||||
'permalink' => $data['permalink']
|
|
||||||
]
|
|
||||||
)
|
|
||||||
->withHeaders($data['headers']);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function meRedirect()
|
$profile = AccountService::get($pid, true);
|
||||||
{
|
|
||||||
abort_if(!Auth::check(), 404);
|
|
||||||
return redirect(Auth::user()->url());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function embed(Request $request, $username)
|
abort_if(! $profile || $profile['locked'] || ! $profile['local'], 404);
|
||||||
{
|
|
||||||
$res = view('profile.embed-removed');
|
|
||||||
|
|
||||||
if(!config('instance.embed.profile')) {
|
$aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile['id'], 86400, function () use ($profile) {
|
||||||
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
$uid = User::whereProfileId($profile['id'])->first();
|
||||||
}
|
if (! $uid) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
$exists = AccountInterstitial::whereUserId($uid->id)->where('is_spam', 1)->count();
|
||||||
|
if ($exists) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if(strlen($username) > 15 || strlen($username) < 2) {
|
return false;
|
||||||
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
$profile = Profile::whereUsername($username)
|
abort_if($aiCheck, 404);
|
||||||
->whereIsPrivate(false)
|
|
||||||
->whereNull('status')
|
|
||||||
->whereNull('domain')
|
|
||||||
->first();
|
|
||||||
|
|
||||||
if(!$profile) {
|
$enabled = Cache::remember('profile:atom:enabled:'.$profile['id'], 84600, function () use ($profile) {
|
||||||
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
$uid = User::whereProfileId($profile['id'])->first();
|
||||||
}
|
if (! $uid) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$settings = UserSetting::whereUserId($uid->id)->first();
|
||||||
|
if (! $settings) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
$aiCheck = Cache::remember('profile:ai-check:spam-login:' . $profile->id, 86400, function() use($profile) {
|
return $settings->show_atom;
|
||||||
$exists = AccountInterstitial::whereUserId($profile->user_id)->where('is_spam', 1)->count();
|
});
|
||||||
if($exists) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
abort_if(! $enabled, 404);
|
||||||
});
|
|
||||||
|
|
||||||
if($aiCheck) {
|
$data = Cache::remember('pf:atom:user-feed:by-id:'.$profile['id'], 14400, function () use ($pid, $profile) {
|
||||||
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
$items = Status::whereProfileId($pid)
|
||||||
}
|
->whereScope('public')
|
||||||
|
->whereIn('type', ['photo', 'photo:album'])
|
||||||
|
->orderByDesc('id')
|
||||||
|
->take(10)
|
||||||
|
->get()
|
||||||
|
->map(function ($status) {
|
||||||
|
return StatusService::get($status->id, true);
|
||||||
|
})
|
||||||
|
->filter(function ($status) {
|
||||||
|
return $status &&
|
||||||
|
isset($status['account']) &&
|
||||||
|
isset($status['media_attachments']) &&
|
||||||
|
count($status['media_attachments']);
|
||||||
|
})
|
||||||
|
->values();
|
||||||
|
$permalink = config('app.url')."/users/{$profile['username']}.atom";
|
||||||
|
$headers = ['Content-Type' => 'application/atom+xml'];
|
||||||
|
|
||||||
if(AccountService::canEmbed($profile->user_id) == false) {
|
if ($items && $items->count()) {
|
||||||
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
$headers['Last-Modified'] = now()->parse($items->first()['created_at'])->toRfc7231String();
|
||||||
}
|
}
|
||||||
|
|
||||||
$profile = AccountService::get($profile->id);
|
return compact('items', 'permalink', 'headers');
|
||||||
$res = view('profile.embed', compact('profile'));
|
});
|
||||||
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
abort_if(! $data || ! isset($data['items']) || ! isset($data['permalink']), 404);
|
||||||
}
|
|
||||||
|
|
||||||
public function stories(Request $request, $username)
|
return response()
|
||||||
{
|
->view('atom.user',
|
||||||
abort_if(!config_cache('instance.stories.enabled') || !$request->user(), 404);
|
[
|
||||||
$profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
|
'profile' => $profile,
|
||||||
$pid = $profile->id;
|
'items' => $data['items'],
|
||||||
$authed = Auth::user()->profile_id;
|
'permalink' => $data['permalink'],
|
||||||
abort_if($pid != $authed && !FollowerService::follows($authed, $pid), 404);
|
]
|
||||||
$exists = Story::whereProfileId($pid)
|
)
|
||||||
->whereActive(true)
|
->withHeaders($data['headers']);
|
||||||
->exists();
|
}
|
||||||
abort_unless($exists, 404);
|
|
||||||
return view('profile.story', compact('pid', 'profile'));
|
public function meRedirect()
|
||||||
}
|
{
|
||||||
|
abort_if(! Auth::check(), 404);
|
||||||
|
|
||||||
|
return redirect(Auth::user()->url());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function embed(Request $request, $username)
|
||||||
|
{
|
||||||
|
$res = view('profile.embed-removed');
|
||||||
|
|
||||||
|
if (! config('instance.embed.profile')) {
|
||||||
|
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen($username) > 15 || strlen($username) < 2) {
|
||||||
|
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$profile = $this->getCachedUser($username);
|
||||||
|
|
||||||
|
if (! $profile || $profile->is_private) {
|
||||||
|
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$aiCheck = Cache::remember('profile:ai-check:spam-login:'.$profile->id, 86400, function () use ($profile) {
|
||||||
|
$exists = AccountInterstitial::whereUserId($profile->user_id)->where('is_spam', 1)->count();
|
||||||
|
if ($exists) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if ($aiCheck) {
|
||||||
|
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (AccountService::canEmbed($profile->user_id) == false) {
|
||||||
|
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$profile = AccountService::get($profile->id);
|
||||||
|
$res = view('profile.embed', compact('profile'));
|
||||||
|
|
||||||
|
return response($res)->withHeaders(['X-Frame-Options' => 'ALLOWALL']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function stories(Request $request, $username)
|
||||||
|
{
|
||||||
|
abort_if(! config_cache('instance.stories.enabled') || ! $request->user(), 404);
|
||||||
|
$profile = Profile::whereNull('domain')->whereUsername($username)->firstOrFail();
|
||||||
|
$pid = $profile->id;
|
||||||
|
$authed = Auth::user()->profile_id;
|
||||||
|
abort_if($pid != $authed && ! FollowerService::follows($authed, $pid), 404);
|
||||||
|
$exists = Story::whereProfileId($pid)
|
||||||
|
->whereActive(true)
|
||||||
|
->exists();
|
||||||
|
abort_unless($exists, 404);
|
||||||
|
|
||||||
|
return view('profile.story', compact('pid', 'profile'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,8 @@ trait PrivacySettings
|
||||||
Cache::forget('pf:acct:settings:hidden-following:' . $pid);
|
Cache::forget('pf:acct:settings:hidden-following:' . $pid);
|
||||||
Cache::forget('pf:acct-trans:hideFollowing:' . $pid);
|
Cache::forget('pf:acct-trans:hideFollowing:' . $pid);
|
||||||
Cache::forget('pf:acct-trans:hideFollowers:' . $pid);
|
Cache::forget('pf:acct-trans:hideFollowers:' . $pid);
|
||||||
|
Cache::forget('pfc:cached-user:wt:' . strtolower($profile->username));
|
||||||
|
Cache::forget('pfc:cached-user:wot:' . strtolower($profile->username));
|
||||||
return redirect(route('settings.privacy'))->with('status', 'Settings successfully updated!');
|
return redirect(route('settings.privacy'))->with('status', 'Settings successfully updated!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,166 +2,202 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use App\Page;
|
||||||
|
use App\Profile;
|
||||||
|
use App\Services\FollowerService;
|
||||||
|
use App\Status;
|
||||||
|
use App\User;
|
||||||
|
use App\Util\ActivityPub\Helpers;
|
||||||
|
use App\Util\Localization\Localization;
|
||||||
|
use Auth;
|
||||||
|
use Cache;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use App, Auth, Cache, View;
|
use View;
|
||||||
use App\Util\Lexer\PrettyNumber;
|
|
||||||
use App\{Follower, Page, Profile, Status, User, UserFilter};
|
|
||||||
use App\Util\Localization\Localization;
|
|
||||||
use App\Services\FollowerService;
|
|
||||||
use App\Util\ActivityPub\Helpers;
|
|
||||||
|
|
||||||
class SiteController extends Controller
|
class SiteController extends Controller
|
||||||
{
|
{
|
||||||
public function home(Request $request)
|
public function home(Request $request)
|
||||||
{
|
{
|
||||||
if (Auth::check()) {
|
if (Auth::check()) {
|
||||||
return $this->homeTimeline($request);
|
return $this->homeTimeline($request);
|
||||||
} else {
|
} else {
|
||||||
return $this->homeGuest();
|
return $this->homeGuest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function homeGuest()
|
public function homeGuest()
|
||||||
{
|
{
|
||||||
return view('site.index');
|
return view('site.index');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function homeTimeline(Request $request)
|
public function homeTimeline(Request $request)
|
||||||
{
|
{
|
||||||
if($request->has('force_old_ui')) {
|
if ($request->has('force_old_ui')) {
|
||||||
return view('timeline.home', ['layout' => 'feed']);
|
return view('timeline.home', ['layout' => 'feed']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect('/i/web');
|
return redirect('/i/web');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeLocale(Request $request, $locale)
|
public function changeLocale(Request $request, $locale)
|
||||||
{
|
{
|
||||||
// todo: add other locales after pushing new l10n strings
|
// todo: add other locales after pushing new l10n strings
|
||||||
$locales = Localization::languages();
|
$locales = Localization::languages();
|
||||||
if(in_array($locale, $locales)) {
|
if (in_array($locale, $locales)) {
|
||||||
if($request->user()) {
|
if ($request->user()) {
|
||||||
$user = $request->user();
|
$user = $request->user();
|
||||||
$user->language = $locale;
|
$user->language = $locale;
|
||||||
$user->save();
|
$user->save();
|
||||||
}
|
}
|
||||||
session()->put('locale', $locale);
|
session()->put('locale', $locale);
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect(route('site.language'));
|
return redirect(route('site.language'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function about()
|
public function about()
|
||||||
{
|
{
|
||||||
return Cache::remember('site.about_v2', now()->addMinutes(15), function() {
|
return Cache::remember('site.about_v2', now()->addMinutes(15), function () {
|
||||||
$user_count = number_format(User::count());
|
$user_count = number_format(User::count());
|
||||||
$post_count = number_format(Status::count());
|
$post_count = number_format(Status::count());
|
||||||
$rules = config_cache('app.rules') ? json_decode(config_cache('app.rules'), true) : null;
|
$rules = config_cache('app.rules') ? json_decode(config_cache('app.rules'), true) : null;
|
||||||
return view('site.about', compact('rules', 'user_count', 'post_count'))->render();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function language()
|
return view('site.about', compact('rules', 'user_count', 'post_count'))->render();
|
||||||
{
|
});
|
||||||
return view('site.language');
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public function communityGuidelines(Request $request)
|
public function language()
|
||||||
{
|
{
|
||||||
return Cache::remember('site:help:community-guidelines', now()->addDays(120), function() {
|
return view('site.language');
|
||||||
$slug = '/site/kb/community-guidelines';
|
}
|
||||||
$page = Page::whereSlug($slug)->whereActive(true)->first();
|
|
||||||
return View::make('site.help.community-guidelines')->with(compact('page'))->render();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public function privacy(Request $request)
|
public function communityGuidelines(Request $request)
|
||||||
{
|
{
|
||||||
$page = Cache::remember('site:privacy', now()->addDays(120), function() {
|
return Cache::remember('site:help:community-guidelines', now()->addDays(120), function () {
|
||||||
$slug = '/site/privacy';
|
$slug = '/site/kb/community-guidelines';
|
||||||
return Page::whereSlug($slug)->whereActive(true)->first();
|
$page = Page::whereSlug($slug)->whereActive(true)->first();
|
||||||
});
|
|
||||||
return View::make('site.privacy')->with(compact('page'))->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function terms(Request $request)
|
return View::make('site.help.community-guidelines')->with(compact('page'))->render();
|
||||||
{
|
});
|
||||||
$page = Cache::remember('site:terms', now()->addDays(120), function() {
|
}
|
||||||
$slug = '/site/terms';
|
|
||||||
return Page::whereSlug($slug)->whereActive(true)->first();
|
|
||||||
});
|
|
||||||
return View::make('site.terms')->with(compact('page'))->render();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function redirectUrl(Request $request)
|
public function privacy(Request $request)
|
||||||
{
|
{
|
||||||
abort_if(!$request->user(), 404);
|
$page = Cache::remember('site:privacy', now()->addDays(120), function () {
|
||||||
$this->validate($request, [
|
$slug = '/site/privacy';
|
||||||
'url' => 'required|url'
|
|
||||||
]);
|
|
||||||
$url = request()->input('url');
|
|
||||||
abort_if(Helpers::validateUrl($url) == false, 404);
|
|
||||||
return view('site.redirect', compact('url'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function followIntent(Request $request)
|
return Page::whereSlug($slug)->whereActive(true)->first();
|
||||||
{
|
});
|
||||||
$this->validate($request, [
|
|
||||||
'user' => 'string|min:1|max:15|exists:users,username',
|
|
||||||
]);
|
|
||||||
$profile = Profile::whereUsername($request->input('user'))->firstOrFail();
|
|
||||||
$user = $request->user();
|
|
||||||
abort_if($user && $profile->id == $user->profile_id, 404);
|
|
||||||
$following = $user != null ? FollowerService::follows($user->profile_id, $profile->id) : false;
|
|
||||||
return view('site.intents.follow', compact('profile', 'user', 'following'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function legacyProfileRedirect(Request $request, $username)
|
return View::make('site.privacy')->with(compact('page'))->render();
|
||||||
{
|
}
|
||||||
$username = Str::contains($username, '@') ? '@' . $username : $username;
|
|
||||||
if(str_contains($username, '@')) {
|
|
||||||
$profile = Profile::whereUsername($username)
|
|
||||||
->firstOrFail();
|
|
||||||
|
|
||||||
if($profile->domain == null) {
|
public function terms(Request $request)
|
||||||
$url = "/$profile->username";
|
{
|
||||||
} else {
|
$page = Cache::remember('site:terms', now()->addDays(120), function () {
|
||||||
$url = "/i/web/profile/_/{$profile->id}";
|
$slug = '/site/terms';
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
return Page::whereSlug($slug)->whereActive(true)->first();
|
||||||
$profile = Profile::whereUsername($username)
|
});
|
||||||
->whereNull('domain')
|
|
||||||
->firstOrFail();
|
|
||||||
$url = "/$profile->username";
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect($url);
|
return View::make('site.terms')->with(compact('page'))->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function legacyWebfingerRedirect(Request $request, $username, $domain)
|
public function redirectUrl(Request $request)
|
||||||
{
|
{
|
||||||
$un = '@'.$username.'@'.$domain;
|
abort_if(! $request->user(), 404);
|
||||||
$profile = Profile::whereUsername($un)
|
$this->validate($request, [
|
||||||
->firstOrFail();
|
'url' => 'required|url',
|
||||||
|
]);
|
||||||
|
$url = request()->input('url');
|
||||||
|
abort_if(Helpers::validateUrl($url) == false, 404);
|
||||||
|
|
||||||
if($profile->domain == null) {
|
return view('site.redirect', compact('url'));
|
||||||
$url = "/$profile->username";
|
}
|
||||||
} else {
|
|
||||||
$url = $request->user() ? "/i/web/profile/_/{$profile->id}" : $profile->url();
|
|
||||||
}
|
|
||||||
|
|
||||||
return redirect($url);
|
public function followIntent(Request $request)
|
||||||
}
|
{
|
||||||
|
$this->validate($request, [
|
||||||
|
'user' => 'string|min:1|max:15|exists:users,username',
|
||||||
|
]);
|
||||||
|
$profile = Profile::whereUsername($request->input('user'))->firstOrFail();
|
||||||
|
$user = $request->user();
|
||||||
|
abort_if($user && $profile->id == $user->profile_id, 404);
|
||||||
|
$following = $user != null ? FollowerService::follows($user->profile_id, $profile->id) : false;
|
||||||
|
|
||||||
public function legalNotice(Request $request)
|
return view('site.intents.follow', compact('profile', 'user', 'following'));
|
||||||
{
|
}
|
||||||
$page = Cache::remember('site:legal-notice', now()->addDays(120), function() {
|
|
||||||
$slug = '/site/legal-notice';
|
public function legacyProfileRedirect(Request $request, $username)
|
||||||
return Page::whereSlug($slug)->whereActive(true)->first();
|
{
|
||||||
});
|
$username = Str::contains($username, '@') ? '@'.$username : $username;
|
||||||
abort_if(!$page, 404);
|
if (str_contains($username, '@')) {
|
||||||
return View::make('site.legal-notice')->with(compact('page'))->render();
|
$profile = Profile::whereUsername($username)
|
||||||
}
|
->firstOrFail();
|
||||||
|
|
||||||
|
if ($profile->domain == null) {
|
||||||
|
$url = "/$profile->username";
|
||||||
|
} else {
|
||||||
|
$url = "/i/web/profile/_/{$profile->id}";
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$profile = Profile::whereUsername($username)
|
||||||
|
->whereNull('domain')
|
||||||
|
->firstOrFail();
|
||||||
|
$url = "/$profile->username";
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function legacyWebfingerRedirect(Request $request, $username, $domain)
|
||||||
|
{
|
||||||
|
$un = '@'.$username.'@'.$domain;
|
||||||
|
$profile = Profile::whereUsername($un)
|
||||||
|
->firstOrFail();
|
||||||
|
|
||||||
|
if ($profile->domain == null) {
|
||||||
|
$url = "/$profile->username";
|
||||||
|
} else {
|
||||||
|
$url = $request->user() ? "/i/web/profile/_/{$profile->id}" : $profile->url();
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect($url);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function legalNotice(Request $request)
|
||||||
|
{
|
||||||
|
$page = Cache::remember('site:legal-notice', now()->addDays(120), function () {
|
||||||
|
$slug = '/site/legal-notice';
|
||||||
|
|
||||||
|
return Page::whereSlug($slug)->whereActive(true)->first();
|
||||||
|
});
|
||||||
|
abort_if(! $page, 404);
|
||||||
|
|
||||||
|
return View::make('site.legal-notice')->with(compact('page'))->render();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function curatedOnboarding(Request $request)
|
||||||
|
{
|
||||||
|
if ($request->user()) {
|
||||||
|
return redirect('/i/web');
|
||||||
|
}
|
||||||
|
|
||||||
|
$regOpen = (bool) config_cache('pixelfed.open_registration');
|
||||||
|
$curOnboarding = (bool) config_cache('instance.curated_registration.enabled');
|
||||||
|
$curOnlyClosed = (bool) config('instance.curated_registration.state.only_enabled_on_closed_reg');
|
||||||
|
if ($regOpen) {
|
||||||
|
if ($curOnlyClosed) {
|
||||||
|
return redirect('/register');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (! $curOnboarding) {
|
||||||
|
return redirect('/');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('auth.curated-register.index', ['step' => 1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,67 +3,80 @@
|
||||||
namespace App\Transformer\ActivityPub;
|
namespace App\Transformer\ActivityPub;
|
||||||
|
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use League\Fractal;
|
|
||||||
use App\Services\AccountService;
|
use App\Services\AccountService;
|
||||||
|
use League\Fractal;
|
||||||
|
|
||||||
class ProfileTransformer extends Fractal\TransformerAbstract
|
class ProfileTransformer extends Fractal\TransformerAbstract
|
||||||
{
|
{
|
||||||
public function transform(Profile $profile)
|
public function transform(Profile $profile)
|
||||||
{
|
{
|
||||||
$res = [
|
$res = [
|
||||||
'@context' => [
|
'@context' => [
|
||||||
'https://w3id.org/security/v1',
|
'https://w3id.org/security/v1',
|
||||||
'https://www.w3.org/ns/activitystreams',
|
'https://www.w3.org/ns/activitystreams',
|
||||||
[
|
[
|
||||||
'toot' => 'http://joinmastodon.org/ns#',
|
'toot' => 'http://joinmastodon.org/ns#',
|
||||||
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
|
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
|
||||||
'alsoKnownAs' => [
|
'alsoKnownAs' => [
|
||||||
'@id' => 'as:alsoKnownAs',
|
'@id' => 'as:alsoKnownAs',
|
||||||
'@type' => '@id'
|
'@type' => '@id',
|
||||||
],
|
],
|
||||||
'movedTo' => [
|
'movedTo' => [
|
||||||
'@id' => 'as:movedTo',
|
'@id' => 'as:movedTo',
|
||||||
'@type' => '@id'
|
'@type' => '@id',
|
||||||
],
|
],
|
||||||
'indexable' => 'toot:indexable',
|
'indexable' => 'toot:indexable',
|
||||||
|
'suspended' => 'toot:suspended',
|
||||||
|
],
|
||||||
],
|
],
|
||||||
],
|
'id' => $profile->permalink(),
|
||||||
'id' => $profile->permalink(),
|
'type' => 'Person',
|
||||||
'type' => 'Person',
|
'following' => $profile->permalink('/following'),
|
||||||
'following' => $profile->permalink('/following'),
|
'followers' => $profile->permalink('/followers'),
|
||||||
'followers' => $profile->permalink('/followers'),
|
'inbox' => $profile->permalink('/inbox'),
|
||||||
'inbox' => $profile->permalink('/inbox'),
|
'outbox' => $profile->permalink('/outbox'),
|
||||||
'outbox' => $profile->permalink('/outbox'),
|
'preferredUsername' => $profile->username,
|
||||||
'preferredUsername' => $profile->username,
|
'name' => $profile->name,
|
||||||
'name' => $profile->name,
|
'summary' => $profile->bio,
|
||||||
'summary' => $profile->bio,
|
'url' => $profile->url(),
|
||||||
'url' => $profile->url(),
|
'manuallyApprovesFollowers' => (bool) $profile->is_private,
|
||||||
'manuallyApprovesFollowers' => (bool) $profile->is_private,
|
'indexable' => (bool) $profile->indexable,
|
||||||
'indexable' => (bool) $profile->indexable,
|
'published' => $profile->created_at->format('Y-m-d').'T00:00:00Z',
|
||||||
'published' => $profile->created_at->format('Y-m-d') . 'T00:00:00Z',
|
'publicKey' => [
|
||||||
'publicKey' => [
|
'id' => $profile->permalink().'#main-key',
|
||||||
'id' => $profile->permalink().'#main-key',
|
'owner' => $profile->permalink(),
|
||||||
'owner' => $profile->permalink(),
|
'publicKeyPem' => $profile->public_key,
|
||||||
'publicKeyPem' => $profile->public_key,
|
],
|
||||||
],
|
'icon' => [
|
||||||
'icon' => [
|
'type' => 'Image',
|
||||||
'type' => 'Image',
|
'mediaType' => 'image/jpeg',
|
||||||
'mediaType' => 'image/jpeg',
|
'url' => $profile->avatarUrl(),
|
||||||
'url' => $profile->avatarUrl(),
|
],
|
||||||
],
|
'endpoints' => [
|
||||||
'endpoints' => [
|
'sharedInbox' => config('app.url').'/f/inbox',
|
||||||
'sharedInbox' => config('app.url') . '/f/inbox'
|
],
|
||||||
]
|
];
|
||||||
];
|
|
||||||
|
|
||||||
if($profile->aliases->count()) {
|
if ($profile->status === 'delete' || $profile->deleted_at != null) {
|
||||||
$res['alsoKnownAs'] = $profile->aliases->map(fn($alias) => $alias->uri);
|
$res['suspended'] = true;
|
||||||
}
|
$res['name'] = '';
|
||||||
|
unset($res['icon']);
|
||||||
|
$res['summary'] = '';
|
||||||
|
$res['indexable'] = false;
|
||||||
|
$res['manuallyApprovesFollowers'] = false;
|
||||||
|
} else {
|
||||||
|
if ($profile->aliases->count()) {
|
||||||
|
$res['alsoKnownAs'] = $profile->aliases->map(fn ($alias) => $alias->uri);
|
||||||
|
}
|
||||||
|
|
||||||
if($profile->moved_to_profile_id) {
|
if ($profile->moved_to_profile_id) {
|
||||||
$res['movedTo'] = AccountService::get($profile->moved_to_profile_id)['url'];
|
$movedTo = AccountService::get($profile->moved_to_profile_id);
|
||||||
}
|
if ($movedTo && isset($movedTo['url'], $movedTo['id'])) {
|
||||||
|
$res['movedTo'] = $movedTo['url'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
24
app/Transformer/ActivityPub/Verb/DeleteActor.php
Normal file
24
app/Transformer/ActivityPub/Verb/DeleteActor.php
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformer\ActivityPub\Verb;
|
||||||
|
|
||||||
|
use App\Profile;
|
||||||
|
use League\Fractal;
|
||||||
|
|
||||||
|
class DeleteActor extends Fractal\TransformerAbstract
|
||||||
|
{
|
||||||
|
public function transform(Profile $profile)
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||||
|
'id' => $profile->permalink('#delete'),
|
||||||
|
'type' => 'Delete',
|
||||||
|
'actor' => $profile->permalink(),
|
||||||
|
'to' => [
|
||||||
|
'https://www.w3.org/ns/activitystreams#Public'
|
||||||
|
],
|
||||||
|
'object' => $profile->permalink()
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::table('instances', function (Blueprint $table) {
|
||||||
|
$table->string('shared_inbox')->nullable()->index();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::table('instances', function (Blueprint $table) {
|
||||||
|
$table->dropColumn('shared_inbox');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
|
@ -0,0 +1,32 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use App\Instance;
|
||||||
|
use App\Profile;
|
||||||
|
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
foreach(Instance::lazyById(50, 'id') as $instance) {
|
||||||
|
$si = Profile::whereDomain($instance->domain)->whereNotNull('sharedInbox')->first();
|
||||||
|
if($si && $si->sharedInbox) {
|
||||||
|
$instance->shared_inbox = $si->sharedInbox;
|
||||||
|
$instance->save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
|
@ -29,7 +29,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware(['validemail', 'twofact
|
||||||
Route::get('auth/pci/{id}/{code}', 'ParentalControlsController@inviteRegister');
|
Route::get('auth/pci/{id}/{code}', 'ParentalControlsController@inviteRegister');
|
||||||
Route::post('auth/pci/{id}/{code}', 'ParentalControlsController@inviteRegisterStore');
|
Route::post('auth/pci/{id}/{code}', 'ParentalControlsController@inviteRegisterStore');
|
||||||
|
|
||||||
Route::get('auth/sign_up', 'CuratedRegisterController@index')->name('auth.curated-onboarding');
|
Route::get('auth/sign_up', 'SiteController@curatedOnboarding')->name('auth.curated-onboarding');
|
||||||
Route::post('auth/sign_up', 'CuratedRegisterController@proceed');
|
Route::post('auth/sign_up', 'CuratedRegisterController@proceed');
|
||||||
Route::get('auth/sign_up/concierge/response-sent', 'CuratedRegisterController@conciergeResponseSent');
|
Route::get('auth/sign_up/concierge/response-sent', 'CuratedRegisterController@conciergeResponseSent');
|
||||||
Route::get('auth/sign_up/concierge', 'CuratedRegisterController@concierge');
|
Route::get('auth/sign_up/concierge', 'CuratedRegisterController@concierge');
|
||||||
|
|
Loading…
Reference in a new issue