|
|
@ -2,48 +2,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use App\AccountInterstitial;
|
|
|
|
use App\{
|
|
|
|
use App\Bookmark;
|
|
|
|
AccountInterstitial,
|
|
|
|
use App\DirectMessage;
|
|
|
|
Bookmark,
|
|
|
|
use App\DiscoverCategory;
|
|
|
|
DirectMessage,
|
|
|
|
use App\Follower;
|
|
|
|
DiscoverCategory,
|
|
|
|
|
|
|
|
Hashtag,
|
|
|
|
|
|
|
|
Follower,
|
|
|
|
|
|
|
|
Like,
|
|
|
|
|
|
|
|
Media,
|
|
|
|
|
|
|
|
MediaTag,
|
|
|
|
|
|
|
|
Notification,
|
|
|
|
|
|
|
|
Profile,
|
|
|
|
|
|
|
|
StatusHashtag,
|
|
|
|
|
|
|
|
Status,
|
|
|
|
|
|
|
|
User,
|
|
|
|
|
|
|
|
UserFilter,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
use Auth,Cache;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
|
|
|
|
use League\Fractal;
|
|
|
|
|
|
|
|
use App\Transformer\Api\{
|
|
|
|
|
|
|
|
AccountTransformer,
|
|
|
|
|
|
|
|
StatusTransformer,
|
|
|
|
|
|
|
|
// StatusMediaContainerTransformer,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
use App\Util\Media\Filter;
|
|
|
|
|
|
|
|
use App\Jobs\StatusPipeline\NewStatusPipeline;
|
|
|
|
|
|
|
|
use App\Jobs\ModPipeline\HandleSpammerPipeline;
|
|
|
|
use App\Jobs\ModPipeline\HandleSpammerPipeline;
|
|
|
|
use League\Fractal\Serializer\ArraySerializer;
|
|
|
|
use App\Profile;
|
|
|
|
use League\Fractal\Pagination\IlluminatePaginatorAdapter;
|
|
|
|
use App\Services\BookmarkService;
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
use App\Services\DiscoverService;
|
|
|
|
use Illuminate\Support\Str;
|
|
|
|
|
|
|
|
use App\Services\MediaTagService;
|
|
|
|
|
|
|
|
use App\Services\ModLogService;
|
|
|
|
use App\Services\ModLogService;
|
|
|
|
use App\Services\PublicTimelineService;
|
|
|
|
use App\Services\PublicTimelineService;
|
|
|
|
use App\Services\SnowflakeService;
|
|
|
|
|
|
|
|
use App\Services\StatusService;
|
|
|
|
use App\Services\StatusService;
|
|
|
|
use App\Services\UserFilterService;
|
|
|
|
use App\Services\UserFilterService;
|
|
|
|
use App\Services\DiscoverService;
|
|
|
|
use App\Status; // StatusMediaContainerTransformer,
|
|
|
|
use App\Services\BookmarkService;
|
|
|
|
use App\Transformer\Api\StatusTransformer;
|
|
|
|
|
|
|
|
use App\User;
|
|
|
|
|
|
|
|
use Auth;
|
|
|
|
|
|
|
|
use Cache;
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
|
|
|
|
use Illuminate\Validation\Rule;
|
|
|
|
|
|
|
|
use League\Fractal;
|
|
|
|
|
|
|
|
use League\Fractal\Serializer\ArraySerializer;
|
|
|
|
|
|
|
|
|
|
|
|
class InternalApiController extends Controller
|
|
|
|
class InternalApiController extends Controller
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -52,8 +33,8 @@ class InternalApiController extends Controller
|
|
|
|
public function __construct()
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->middleware('auth');
|
|
|
|
$this->middleware('auth');
|
|
|
|
$this->fractal = new Fractal\Manager();
|
|
|
|
$this->fractal = new Fractal\Manager;
|
|
|
|
$this->fractal->setSerializer(new ArraySerializer());
|
|
|
|
$this->fractal->setSerializer(new ArraySerializer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// deprecated v2 compose api
|
|
|
|
// deprecated v2 compose api
|
|
|
@ -63,10 +44,7 @@ class InternalApiController extends Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// deprecated
|
|
|
|
// deprecated
|
|
|
|
public function discover(Request $request)
|
|
|
|
public function discover(Request $request) {}
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function discoverPosts(Request $request)
|
|
|
|
public function discoverPosts(Request $request)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -84,6 +62,7 @@ class InternalApiController extends Controller
|
|
|
|
})
|
|
|
|
})
|
|
|
|
->take(12)
|
|
|
|
->take(12)
|
|
|
|
->values();
|
|
|
|
->values();
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json(compact('posts'));
|
|
|
|
return response()->json(compact('posts'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -110,7 +89,7 @@ class InternalApiController extends Controller
|
|
|
|
public function statusReplies(Request $request, int $id)
|
|
|
|
public function statusReplies(Request $request, int $id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$this->validate($request, [
|
|
|
|
$this->validate($request, [
|
|
|
|
'limit' => 'nullable|int|min:1|max:6'
|
|
|
|
'limit' => 'nullable|int|min:1|max:6',
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
$parent = Status::whereScope('public')->findOrFail($id);
|
|
|
|
$parent = Status::whereScope('public')->findOrFail($id);
|
|
|
|
$limit = $request->input('limit') ?? 3;
|
|
|
|
$limit = $request->input('limit') ?? 3;
|
|
|
@ -118,16 +97,13 @@ class InternalApiController extends Controller
|
|
|
|
->orderBy('created_at', 'desc')
|
|
|
|
->orderBy('created_at', 'desc')
|
|
|
|
->take($limit)
|
|
|
|
->take($limit)
|
|
|
|
->get();
|
|
|
|
->get();
|
|
|
|
$resource = new Fractal\Resource\Collection($children, new StatusTransformer());
|
|
|
|
$resource = new Fractal\Resource\Collection($children, new StatusTransformer);
|
|
|
|
$res = $this->fractal->createData($resource)->toArray();
|
|
|
|
$res = $this->fractal->createData($resource)->toArray();
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json($res);
|
|
|
|
return response()->json($res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function stories(Request $request)
|
|
|
|
public function stories(Request $request) {}
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function discoverCategories(Request $request)
|
|
|
|
public function discoverCategories(Request $request)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -136,9 +112,10 @@ class InternalApiController extends Controller
|
|
|
|
return [
|
|
|
|
return [
|
|
|
|
'name' => $item->name,
|
|
|
|
'name' => $item->name,
|
|
|
|
'url' => $item->url(),
|
|
|
|
'url' => $item->url(),
|
|
|
|
'thumb' => $item->thumb()
|
|
|
|
'thumb' => $item->thumb(),
|
|
|
|
];
|
|
|
|
];
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json($res);
|
|
|
|
return response()->json($res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -153,15 +130,15 @@ class InternalApiController extends Controller
|
|
|
|
'addcw',
|
|
|
|
'addcw',
|
|
|
|
'remcw',
|
|
|
|
'remcw',
|
|
|
|
'unlist',
|
|
|
|
'unlist',
|
|
|
|
'spammer'
|
|
|
|
'spammer',
|
|
|
|
])
|
|
|
|
]),
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'item_id' => 'required|integer|min:1',
|
|
|
|
'item_id' => 'required|integer|min:1',
|
|
|
|
'item_type' => [
|
|
|
|
'item_type' => [
|
|
|
|
'required',
|
|
|
|
'required',
|
|
|
|
'string',
|
|
|
|
'string',
|
|
|
|
Rule::in(['profile', 'status'])
|
|
|
|
Rule::in(['profile', 'status']),
|
|
|
|
]
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
$action = $request->input('action');
|
|
|
|
$action = $request->input('action');
|
|
|
@ -184,7 +161,7 @@ class InternalApiController extends Controller
|
|
|
|
->action('admin.status.moderate')
|
|
|
|
->action('admin.status.moderate')
|
|
|
|
->metadata([
|
|
|
|
->metadata([
|
|
|
|
'action' => 'cw',
|
|
|
|
'action' => 'cw',
|
|
|
|
'message' => 'Success!'
|
|
|
|
'message' => 'Success!',
|
|
|
|
])
|
|
|
|
])
|
|
|
|
->accessLevel('admin')
|
|
|
|
->accessLevel('admin')
|
|
|
|
->save();
|
|
|
|
->save();
|
|
|
@ -229,7 +206,7 @@ class InternalApiController extends Controller
|
|
|
|
->action('admin.status.moderate')
|
|
|
|
->action('admin.status.moderate')
|
|
|
|
->metadata([
|
|
|
|
->metadata([
|
|
|
|
'action' => 'remove_cw',
|
|
|
|
'action' => 'remove_cw',
|
|
|
|
'message' => 'Success!'
|
|
|
|
'message' => 'Success!',
|
|
|
|
])
|
|
|
|
])
|
|
|
|
->accessLevel('admin')
|
|
|
|
->accessLevel('admin')
|
|
|
|
->save();
|
|
|
|
->save();
|
|
|
@ -255,7 +232,7 @@ class InternalApiController extends Controller
|
|
|
|
->action('admin.status.moderate')
|
|
|
|
->action('admin.status.moderate')
|
|
|
|
->metadata([
|
|
|
|
->metadata([
|
|
|
|
'action' => 'unlist',
|
|
|
|
'action' => 'unlist',
|
|
|
|
'message' => 'Success!'
|
|
|
|
'message' => 'Success!',
|
|
|
|
])
|
|
|
|
])
|
|
|
|
->accessLevel('admin')
|
|
|
|
->accessLevel('admin')
|
|
|
|
->save();
|
|
|
|
->save();
|
|
|
@ -299,7 +276,7 @@ class InternalApiController extends Controller
|
|
|
|
->action('admin.status.moderate')
|
|
|
|
->action('admin.status.moderate')
|
|
|
|
->metadata([
|
|
|
|
->metadata([
|
|
|
|
'action' => 'spammer',
|
|
|
|
'action' => 'spammer',
|
|
|
|
'message' => 'Success!'
|
|
|
|
'message' => 'Success!',
|
|
|
|
])
|
|
|
|
])
|
|
|
|
->accessLevel('admin')
|
|
|
|
->accessLevel('admin')
|
|
|
|
->save();
|
|
|
|
->save();
|
|
|
@ -307,6 +284,7 @@ class InternalApiController extends Controller
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
StatusService::del($status->id, true);
|
|
|
|
StatusService::del($status->id, true);
|
|
|
|
|
|
|
|
|
|
|
|
return ['msg' => 200];
|
|
|
|
return ['msg' => 200];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -331,6 +309,7 @@ class InternalApiController extends Controller
|
|
|
|
if ($status) {
|
|
|
|
if ($status) {
|
|
|
|
BookmarkService::add($pid, $status['id']);
|
|
|
|
BookmarkService::add($pid, $status['id']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return $status;
|
|
|
|
return $status;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
->filter(function ($bookmark) {
|
|
|
|
->filter(function ($bookmark) {
|
|
|
@ -350,7 +329,7 @@ class InternalApiController extends Controller
|
|
|
|
'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
|
|
|
|
'max_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
|
|
|
|
'since_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
|
|
|
|
'since_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
|
|
|
|
'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
|
|
|
|
'min_id' => 'nullable|integer|min:0|max:'.PHP_INT_MAX,
|
|
|
|
'limit' => 'nullable|integer|min:1|max:24'
|
|
|
|
'limit' => 'nullable|integer|min:1|max:24',
|
|
|
|
]);
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
$profile = Profile::whereNull('status')->findOrFail($id);
|
|
|
|
$profile = Profile::whereNull('status')->findOrFail($id);
|
|
|
@ -369,17 +348,19 @@ class InternalApiController extends Controller
|
|
|
|
$pid = Auth::user()->profile->id;
|
|
|
|
$pid = Auth::user()->profile->id;
|
|
|
|
$following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function () use ($pid) {
|
|
|
|
$following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function () use ($pid) {
|
|
|
|
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
|
|
|
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
|
|
|
|
|
|
|
|
|
|
|
return $following->push($pid)->toArray();
|
|
|
|
return $following->push($pid)->toArray();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$visibility = true == in_array($profile->id, $following) ? ['public', 'unlisted', 'private'] : [];
|
|
|
|
$visibility = in_array($profile->id, $following) == true ? ['public', 'unlisted', 'private'] : [];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
if (Auth::check()) {
|
|
|
|
if (Auth::check()) {
|
|
|
|
$pid = Auth::user()->profile->id;
|
|
|
|
$pid = Auth::user()->profile->id;
|
|
|
|
$following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function () use ($pid) {
|
|
|
|
$following = Cache::remember('profile:following:'.$pid, now()->addMinutes(1440), function () use ($pid) {
|
|
|
|
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
|
|
|
$following = Follower::whereProfileId($pid)->pluck('following_id');
|
|
|
|
|
|
|
|
|
|
|
|
return $following->push($pid)->toArray();
|
|
|
|
return $following->push($pid)->toArray();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$visibility = true == in_array($profile->id, $following) ? ['public', 'unlisted', 'private'] : ['public', 'unlisted'];
|
|
|
|
$visibility = in_array($profile->id, $following) == true ? ['public', 'unlisted', 'private'] : ['public', 'unlisted'];
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
$visibility = ['public', 'unlisted'];
|
|
|
|
$visibility = ['public', 'unlisted'];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -391,7 +372,6 @@ class InternalApiController extends Controller
|
|
|
|
'id',
|
|
|
|
'id',
|
|
|
|
'uri',
|
|
|
|
'uri',
|
|
|
|
'caption',
|
|
|
|
'caption',
|
|
|
|
'rendered',
|
|
|
|
|
|
|
|
'profile_id',
|
|
|
|
'profile_id',
|
|
|
|
'type',
|
|
|
|
'type',
|
|
|
|
'in_reply_to_id',
|
|
|
|
'in_reply_to_id',
|
|
|
@ -411,7 +391,7 @@ class InternalApiController extends Controller
|
|
|
|
->limit($limit)
|
|
|
|
->limit($limit)
|
|
|
|
->get();
|
|
|
|
->get();
|
|
|
|
|
|
|
|
|
|
|
|
$resource = new Fractal\Resource\Collection($timeline, new StatusTransformer());
|
|
|
|
$resource = new Fractal\Resource\Collection($timeline, new StatusTransformer);
|
|
|
|
$res = $this->fractal->createData($resource)->toArray();
|
|
|
|
$res = $this->fractal->createData($resource)->toArray();
|
|
|
|
|
|
|
|
|
|
|
|
return response()->json($res);
|
|
|
|
return response()->json($res);
|
|
|
@ -431,6 +411,7 @@ class InternalApiController extends Controller
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$pid = $request->user()->profile_id;
|
|
|
|
$pid = $request->user()->profile_id;
|
|
|
|
$exists = Redis::sismember('email:manual', $pid);
|
|
|
|
$exists = Redis::sismember('email:manual', $pid);
|
|
|
|
|
|
|
|
|
|
|
|
return view('account.email.request_verification', compact('exists'));
|
|
|
|
return view('account.email.request_verification', compact('exists'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -438,6 +419,7 @@ class InternalApiController extends Controller
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$pid = $request->user()->profile_id;
|
|
|
|
$pid = $request->user()->profile_id;
|
|
|
|
Redis::sadd('email:manual', $pid);
|
|
|
|
Redis::sadd('email:manual', $pid);
|
|
|
|
|
|
|
|
|
|
|
|
return redirect('/i/verify-email')->with(['status' => 'Successfully sent manual verification request!']);
|
|
|
|
return redirect('/i/verify-email')->with(['status' => 'Successfully sent manual verification request!']);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|