|
@@ -3,18 +3,20 @@
|
|
namespace App\Http\Controllers\Admin;
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
|
|
use App\AccountInterstitial;
|
|
use App\AccountInterstitial;
|
|
-use App\Http\Resources\AdminReport;
|
|
|
|
|
|
+use App\Http\Resources\Admin\AdminModeratedProfileResource;
|
|
use App\Http\Resources\AdminRemoteReport;
|
|
use App\Http\Resources\AdminRemoteReport;
|
|
|
|
+use App\Http\Resources\AdminReport;
|
|
use App\Http\Resources\AdminSpamReport;
|
|
use App\Http\Resources\AdminSpamReport;
|
|
use App\Jobs\DeletePipeline\DeleteAccountPipeline;
|
|
use App\Jobs\DeletePipeline\DeleteAccountPipeline;
|
|
use App\Jobs\DeletePipeline\DeleteRemoteProfilePipeline;
|
|
use App\Jobs\DeletePipeline\DeleteRemoteProfilePipeline;
|
|
use App\Jobs\StatusPipeline\RemoteStatusDelete;
|
|
use App\Jobs\StatusPipeline\RemoteStatusDelete;
|
|
use App\Jobs\StatusPipeline\StatusDelete;
|
|
use App\Jobs\StatusPipeline\StatusDelete;
|
|
use App\Jobs\StoryPipeline\StoryDelete;
|
|
use App\Jobs\StoryPipeline\StoryDelete;
|
|
|
|
+use App\Models\ModeratedProfile;
|
|
|
|
+use App\Models\RemoteReport;
|
|
use App\Notification;
|
|
use App\Notification;
|
|
use App\Profile;
|
|
use App\Profile;
|
|
use App\Report;
|
|
use App\Report;
|
|
-use App\Models\RemoteReport;
|
|
|
|
use App\Services\AccountService;
|
|
use App\Services\AccountService;
|
|
use App\Services\ModLogService;
|
|
use App\Services\ModLogService;
|
|
use App\Services\NetworkTimelineService;
|
|
use App\Services\NetworkTimelineService;
|
|
@@ -24,12 +26,13 @@ use App\Services\StatusService;
|
|
use App\Status;
|
|
use App\Status;
|
|
use App\Story;
|
|
use App\Story;
|
|
use App\User;
|
|
use App\User;
|
|
|
|
+use App\Util\ActivityPub\Helpers;
|
|
use Cache;
|
|
use Cache;
|
|
-use Storage;
|
|
|
|
use Carbon\Carbon;
|
|
use Carbon\Carbon;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Http\Request;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\Redis;
|
|
use Illuminate\Support\Facades\Redis;
|
|
|
|
+use Storage;
|
|
|
|
|
|
trait AdminReportController
|
|
trait AdminReportController
|
|
{
|
|
{
|
|
@@ -201,10 +204,7 @@ trait AdminReportController
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
- public function render()
|
|
|
|
- {
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
|
|
+ public function render() {}
|
|
};
|
|
};
|
|
}
|
|
}
|
|
|
|
|
|
@@ -829,6 +829,16 @@ trait AdminReportController
|
|
$profile->cw = true;
|
|
$profile->cw = true;
|
|
$profile->save();
|
|
$profile->save();
|
|
|
|
|
|
|
|
+ if ($profile->remote_url) {
|
|
|
|
+ ModeratedProfile::updateOrCreate([
|
|
|
|
+ 'profile_url' => $profile->remote_url,
|
|
|
|
+ 'profile_id' => $profile->id,
|
|
|
|
+ ], [
|
|
|
|
+ 'is_nsfw' => true,
|
|
|
|
+ 'domain' => $profile->domain,
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
foreach (Status::whereProfileId($profile->id)->cursor() as $status) {
|
|
foreach (Status::whereProfileId($profile->id)->cursor() as $status) {
|
|
$status->is_nsfw = true;
|
|
$status->is_nsfw = true;
|
|
$status->save();
|
|
$status->save();
|
|
@@ -879,6 +889,16 @@ trait AdminReportController
|
|
$profile->unlisted = true;
|
|
$profile->unlisted = true;
|
|
$profile->save();
|
|
$profile->save();
|
|
|
|
|
|
|
|
+ if ($profile->remote_url) {
|
|
|
|
+ ModeratedProfile::updateOrCreate([
|
|
|
|
+ 'profile_url' => $profile->remote_url,
|
|
|
|
+ 'profile_id' => $profile->id,
|
|
|
|
+ ], [
|
|
|
|
+ 'is_unlisted' => true,
|
|
|
|
+ 'domain' => $profile->domain,
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
foreach (Status::whereProfileId($profile->id)->whereScope('public')->cursor() as $status) {
|
|
foreach (Status::whereProfileId($profile->id)->whereScope('public')->cursor() as $status) {
|
|
$status->scope = 'unlisted';
|
|
$status->scope = 'unlisted';
|
|
$status->visibility = 'unlisted';
|
|
$status->visibility = 'unlisted';
|
|
@@ -929,6 +949,16 @@ trait AdminReportController
|
|
$profile->unlisted = true;
|
|
$profile->unlisted = true;
|
|
$profile->save();
|
|
$profile->save();
|
|
|
|
|
|
|
|
+ if ($profile->remote_url) {
|
|
|
|
+ ModeratedProfile::updateOrCreate([
|
|
|
|
+ 'profile_url' => $profile->remote_url,
|
|
|
|
+ 'profile_id' => $profile->id,
|
|
|
|
+ ], [
|
|
|
|
+ 'is_unlisted' => true,
|
|
|
|
+ 'domain' => $profile->domain,
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
foreach (Status::whereProfileId($profile->id)->cursor() as $status) {
|
|
foreach (Status::whereProfileId($profile->id)->cursor() as $status) {
|
|
$status->scope = 'private';
|
|
$status->scope = 'private';
|
|
$status->visibility = 'private';
|
|
$status->visibility = 'private';
|
|
@@ -982,6 +1012,16 @@ trait AdminReportController
|
|
|
|
|
|
$ts = now()->addMonth();
|
|
$ts = now()->addMonth();
|
|
|
|
|
|
|
|
+ if ($profile->remote_url) {
|
|
|
|
+ ModeratedProfile::updateOrCreate([
|
|
|
|
+ 'profile_url' => $profile->remote_url,
|
|
|
|
+ 'profile_id' => $profile->id,
|
|
|
|
+ ], [
|
|
|
|
+ 'is_banned' => true,
|
|
|
|
+ 'domain' => $profile->domain,
|
|
|
|
+ ]);
|
|
|
|
+ }
|
|
|
|
+
|
|
if ($profile->user_id) {
|
|
if ($profile->user_id) {
|
|
$user = $profile->user;
|
|
$user = $profile->user;
|
|
abort_if($user->is_admin, 403, 'You cannot delete admin accounts.');
|
|
abort_if($user->is_admin, 403, 'You cannot delete admin accounts.');
|
|
@@ -1354,7 +1394,7 @@ trait AdminReportController
|
|
{
|
|
{
|
|
$this->validate($request, [
|
|
$this->validate($request, [
|
|
'id' => 'required|exists:remote_reports,id',
|
|
'id' => 'required|exists:remote_reports,id',
|
|
- 'action' => 'required|in:mark-read,cw-posts,unlist-posts,delete-posts,private-posts,mark-all-read-by-domain,mark-all-read-by-username,cw-all-posts,private-all-posts,unlist-all-posts'
|
|
|
|
|
|
+ 'action' => 'required|in:mark-read,cw-posts,unlist-posts,delete-posts,private-posts,mark-all-read-by-domain,mark-all-read-by-username,cw-all-posts,private-all-posts,unlist-all-posts',
|
|
]);
|
|
]);
|
|
|
|
|
|
$report = RemoteReport::findOrFail($request->input('id'));
|
|
$report = RemoteReport::findOrFail($request->input('id'));
|
|
@@ -1373,11 +1413,11 @@ trait AdminReportController
|
|
break;
|
|
break;
|
|
case 'cw-posts':
|
|
case 'cw-posts':
|
|
$statuses = Status::find($report->status_ids);
|
|
$statuses = Status::find($report->status_ids);
|
|
- foreach($statuses as $status) {
|
|
|
|
- if($report->account_id != $status->profile_id) {
|
|
|
|
|
|
+ foreach ($statuses as $status) {
|
|
|
|
+ if ($report->account_id != $status->profile_id) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if(!$status->is_nsfw) {
|
|
|
|
|
|
+ if (! $status->is_nsfw) {
|
|
$ogNonCwStatuses[] = $status->id;
|
|
$ogNonCwStatuses[] = $status->id;
|
|
}
|
|
}
|
|
$status->is_nsfw = true;
|
|
$status->is_nsfw = true;
|
|
@@ -1388,11 +1428,11 @@ trait AdminReportController
|
|
$report->save();
|
|
$report->save();
|
|
break;
|
|
break;
|
|
case 'cw-all-posts':
|
|
case 'cw-all-posts':
|
|
- foreach(Status::whereProfileId($report->account_id)->lazyById(50, 'id') as $status) {
|
|
|
|
- if($status->is_nsfw || $status->reblog_of_id) {
|
|
|
|
|
|
+ foreach (Status::whereProfileId($report->account_id)->lazyById(50, 'id') as $status) {
|
|
|
|
+ if ($status->is_nsfw || $status->reblog_of_id) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if(!$status->is_nsfw) {
|
|
|
|
|
|
+ if (! $status->is_nsfw) {
|
|
$ogNonCwStatuses[] = $status->id;
|
|
$ogNonCwStatuses[] = $status->id;
|
|
}
|
|
}
|
|
$status->is_nsfw = true;
|
|
$status->is_nsfw = true;
|
|
@@ -1402,11 +1442,11 @@ trait AdminReportController
|
|
break;
|
|
break;
|
|
case 'unlist-posts':
|
|
case 'unlist-posts':
|
|
$statuses = Status::find($report->status_ids);
|
|
$statuses = Status::find($report->status_ids);
|
|
- foreach($statuses as $status) {
|
|
|
|
- if($report->account_id != $status->profile_id) {
|
|
|
|
|
|
+ foreach ($statuses as $status) {
|
|
|
|
+ if ($report->account_id != $status->profile_id) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if($status->scope === 'public') {
|
|
|
|
|
|
+ if ($status->scope === 'public') {
|
|
$ogPublicStatuses[] = $status->id;
|
|
$ogPublicStatuses[] = $status->id;
|
|
$status->scope = 'unlisted';
|
|
$status->scope = 'unlisted';
|
|
$status->visibility = 'unlisted';
|
|
$status->visibility = 'unlisted';
|
|
@@ -1418,8 +1458,8 @@ trait AdminReportController
|
|
$report->save();
|
|
$report->save();
|
|
break;
|
|
break;
|
|
case 'unlist-all-posts':
|
|
case 'unlist-all-posts':
|
|
- foreach(Status::whereProfileId($report->account_id)->lazyById(50, 'id') as $status) {
|
|
|
|
- if($status->visibility !== 'public' || $status->reblog_of_id) {
|
|
|
|
|
|
+ foreach (Status::whereProfileId($report->account_id)->lazyById(50, 'id') as $status) {
|
|
|
|
+ if ($status->visibility !== 'public' || $status->reblog_of_id) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
$ogPublicStatuses[] = $status->id;
|
|
$ogPublicStatuses[] = $status->id;
|
|
@@ -1431,12 +1471,12 @@ trait AdminReportController
|
|
break;
|
|
break;
|
|
case 'private-posts':
|
|
case 'private-posts':
|
|
$statuses = Status::find($report->status_ids);
|
|
$statuses = Status::find($report->status_ids);
|
|
- foreach($statuses as $status) {
|
|
|
|
- if($report->account_id != $status->profile_id) {
|
|
|
|
|
|
+ foreach ($statuses as $status) {
|
|
|
|
+ if ($report->account_id != $status->profile_id) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if(in_array($status->scope, ['public', 'unlisted', 'private'])) {
|
|
|
|
- if($status->scope === 'public') {
|
|
|
|
|
|
+ if (in_array($status->scope, ['public', 'unlisted', 'private'])) {
|
|
|
|
+ if ($status->scope === 'public') {
|
|
$ogPublicStatuses[] = $status->id;
|
|
$ogPublicStatuses[] = $status->id;
|
|
}
|
|
}
|
|
$status->scope = 'private';
|
|
$status->scope = 'private';
|
|
@@ -1449,13 +1489,13 @@ trait AdminReportController
|
|
$report->save();
|
|
$report->save();
|
|
break;
|
|
break;
|
|
case 'private-all-posts':
|
|
case 'private-all-posts':
|
|
- foreach(Status::whereProfileId($report->account_id)->lazyById(50, 'id') as $status) {
|
|
|
|
- if(!in_array($status->visibility, ['public', 'unlisted']) || $status->reblog_of_id) {
|
|
|
|
|
|
+ foreach (Status::whereProfileId($report->account_id)->lazyById(50, 'id') as $status) {
|
|
|
|
+ if (! in_array($status->visibility, ['public', 'unlisted']) || $status->reblog_of_id) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- if($status->visibility === 'public') {
|
|
|
|
|
|
+ if ($status->visibility === 'public') {
|
|
$ogPublicStatuses[] = $status->id;
|
|
$ogPublicStatuses[] = $status->id;
|
|
- } else if($status->visibility === 'unlisted') {
|
|
|
|
|
|
+ } elseif ($status->visibility === 'unlisted') {
|
|
$ogUnlistedStatuses[] = $status->id;
|
|
$ogUnlistedStatuses[] = $status->id;
|
|
}
|
|
}
|
|
$status->visibility = 'private';
|
|
$status->visibility = 'private';
|
|
@@ -1466,8 +1506,8 @@ trait AdminReportController
|
|
break;
|
|
break;
|
|
case 'delete-posts':
|
|
case 'delete-posts':
|
|
$statuses = Status::find($report->status_ids);
|
|
$statuses = Status::find($report->status_ids);
|
|
- foreach($statuses as $status) {
|
|
|
|
- if($report->account_id != $status->profile_id) {
|
|
|
|
|
|
+ foreach ($statuses as $status) {
|
|
|
|
+ if ($report->account_id != $status->profile_id) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
StatusDelete::dispatch($status);
|
|
StatusDelete::dispatch($status);
|
|
@@ -1484,16 +1524,16 @@ trait AdminReportController
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
- if($ogPublicStatuses && count($ogPublicStatuses)) {
|
|
|
|
- Storage::disk('local')->put('mod-log-cache/' . $report->account_id . '/' . now()->format('Y-m-d') . '-og-public-statuses.json', json_encode($ogPublicStatuses, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
|
|
|
|
|
|
+ if ($ogPublicStatuses && count($ogPublicStatuses)) {
|
|
|
|
+ Storage::disk('local')->put('mod-log-cache/'.$report->account_id.'/'.now()->format('Y-m-d').'-og-public-statuses.json', json_encode($ogPublicStatuses, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
|
}
|
|
}
|
|
|
|
|
|
- if($ogNonCwStatuses && count($ogNonCwStatuses)) {
|
|
|
|
- Storage::disk('local')->put('mod-log-cache/' . $report->account_id . '/' . now()->format('Y-m-d') . '-og-noncw-statuses.json', json_encode($ogNonCwStatuses, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
|
|
|
|
|
|
+ if ($ogNonCwStatuses && count($ogNonCwStatuses)) {
|
|
|
|
+ Storage::disk('local')->put('mod-log-cache/'.$report->account_id.'/'.now()->format('Y-m-d').'-og-noncw-statuses.json', json_encode($ogNonCwStatuses, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
|
}
|
|
}
|
|
|
|
|
|
- if($ogUnlistedStatuses && count($ogUnlistedStatuses)) {
|
|
|
|
- Storage::disk('local')->put('mod-log-cache/' . $report->account_id . '/' . now()->format('Y-m-d') . '-og-unlisted-statuses.json', json_encode($ogUnlistedStatuses, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES));
|
|
|
|
|
|
+ if ($ogUnlistedStatuses && count($ogUnlistedStatuses)) {
|
|
|
|
+ Storage::disk('local')->put('mod-log-cache/'.$report->account_id.'/'.now()->format('Y-m-d').'-og-unlisted-statuses.json', json_encode($ogUnlistedStatuses, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
|
|
}
|
|
}
|
|
|
|
|
|
ModLogService::boot()
|
|
ModLogService::boot()
|
|
@@ -1504,18 +1544,210 @@ trait AdminReportController
|
|
->action('admin.report.moderate')
|
|
->action('admin.report.moderate')
|
|
->metadata([
|
|
->metadata([
|
|
'action' => $request->input('action'),
|
|
'action' => $request->input('action'),
|
|
- 'duration_active' => now()->parse($report->created_at)->diffForHumans()
|
|
|
|
|
|
+ 'duration_active' => now()->parse($report->created_at)->diffForHumans(),
|
|
])
|
|
])
|
|
->accessLevel('admin')
|
|
->accessLevel('admin')
|
|
->save();
|
|
->save();
|
|
|
|
|
|
- if($report->status_ids) {
|
|
|
|
- foreach($report->status_ids as $sid) {
|
|
|
|
|
|
+ if ($report->status_ids) {
|
|
|
|
+ foreach ($report->status_ids as $sid) {
|
|
RemoteReport::whereNull('action_taken_at')
|
|
RemoteReport::whereNull('action_taken_at')
|
|
->whereJsonContains('status_ids', [$sid])
|
|
->whereJsonContains('status_ids', [$sid])
|
|
->update(['action_taken_at' => now()]);
|
|
->update(['action_taken_at' => now()]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
return [200];
|
|
return [200];
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function getModeratedProfiles(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $this->validate($request, [
|
|
|
|
+ 'search' => 'sometimes|string|min:3|max:120',
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ if ($request->filled('search')) {
|
|
|
|
+ $query = '%'.$request->input('search').'%';
|
|
|
|
+ $profiles = DB::table('moderated_profiles')
|
|
|
|
+ ->join('profiles', 'moderated_profiles.profile_id', '=', 'profiles.id')
|
|
|
|
+ ->where('profiles.username', 'LIKE', $query)
|
|
|
|
+ ->select('moderated_profiles.*', 'profiles.username')
|
|
|
|
+ ->orderByDesc('moderated_profiles.id')
|
|
|
|
+ ->cursorPaginate(10);
|
|
|
|
+
|
|
|
|
+ return AdminModeratedProfileResource::collection($profiles);
|
|
|
|
+ }
|
|
|
|
+ $profiles = ModeratedProfile::orderByDesc('id')->cursorPaginate(10);
|
|
|
|
+
|
|
|
|
+ return AdminModeratedProfileResource::collection($profiles);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function getModeratedProfile(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $this->validate($request, [
|
|
|
|
+ 'id' => 'required',
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ $profile = ModeratedProfile::findOrFail($request->input('id'));
|
|
|
|
+
|
|
|
|
+ return new AdminModeratedProfileResource($profile);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function exportModeratedProfiles(Request $request)
|
|
|
|
+ {
|
|
|
|
+ return response()->streamDownload(function () {
|
|
|
|
+ $profiles = ModeratedProfile::get();
|
|
|
|
+ $res = AdminModeratedProfileResource::collection($profiles);
|
|
|
|
+ echo json_encode([
|
|
|
|
+ '_pixelfed_export' => true,
|
|
|
|
+ 'meta' => [
|
|
|
|
+ 'ns' => 'https://pixelfed.org',
|
|
|
|
+ 'origin' => config('pixelfed.domain.app'),
|
|
|
|
+ 'date' => now()->format('c'),
|
|
|
|
+ 'type' => 'moderated-profiles',
|
|
|
|
+ 'version' => "1.0"
|
|
|
|
+ ],
|
|
|
|
+ 'data' => $res
|
|
|
|
+ ], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES);
|
|
|
|
+ }, 'data-export.json');
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function deleteModeratedProfile(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $this->validate($request, [
|
|
|
|
+ 'id' => 'required',
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ $profile = ModeratedProfile::findOrFail($request->input('id'));
|
|
|
|
+
|
|
|
|
+ ModLogService::boot()
|
|
|
|
+ ->objectUid($profile->profile_id)
|
|
|
|
+ ->objectId($profile->id)
|
|
|
|
+ ->objectType('App\Models\ModeratedProfile::class')
|
|
|
|
+ ->user(request()->user())
|
|
|
|
+ ->action('admin.moderated-profiles.delete')
|
|
|
|
+ ->metadata([
|
|
|
|
+ 'profile_url' => $profile->profile_url,
|
|
|
|
+ 'profile_id' => $profile->profile_id,
|
|
|
|
+ 'domain' => $profile->domain,
|
|
|
|
+ 'note' => $profile->note,
|
|
|
|
+ 'is_banned' => $profile->is_banned,
|
|
|
|
+ 'is_nsfw' => $profile->is_nsfw,
|
|
|
|
+ 'is_unlisted' => $profile->is_unlisted,
|
|
|
|
+ 'is_noautolink' => $profile->is_noautolink,
|
|
|
|
+ 'is_nodms' => $profile->is_nodms,
|
|
|
|
+ 'is_notrending' => $profile->is_notrending,
|
|
|
|
+ ])
|
|
|
|
+ ->accessLevel('admin')
|
|
|
|
+ ->save();
|
|
|
|
+
|
|
|
|
+ $profile->delete();
|
|
|
|
+
|
|
|
|
+ return ['status' => 200, 'message' => 'Successfully deleted moderated profile!'];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function updateModeratedProfile(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $this->validate($request, [
|
|
|
|
+ 'id' => 'required|exists:moderated_profiles',
|
|
|
|
+ 'note' => 'sometimes|nullable|string|max:500',
|
|
|
|
+ 'is_banned' => 'required|boolean',
|
|
|
|
+ 'is_noautolink' => 'required|boolean',
|
|
|
|
+ 'is_nodms' => 'required|boolean',
|
|
|
|
+ 'is_notrending' => 'required|boolean',
|
|
|
|
+ 'is_nsfw' => 'required|boolean',
|
|
|
|
+ 'is_unlisted' => 'required|boolean',
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ $fields = [
|
|
|
|
+ 'note',
|
|
|
|
+ 'is_banned',
|
|
|
|
+ 'is_noautolink',
|
|
|
|
+ 'is_nodms',
|
|
|
|
+ 'is_notrending',
|
|
|
|
+ 'is_nsfw',
|
|
|
|
+ 'is_unlisted',
|
|
|
|
+ ];
|
|
|
|
+
|
|
|
|
+ $profile = ModeratedProfile::findOrFail($request->input('id'));
|
|
|
|
+ $profile->update($request->only($fields));
|
|
|
|
+
|
|
|
|
+ ModLogService::boot()
|
|
|
|
+ ->objectUid($profile->profile_id)
|
|
|
|
+ ->objectId($profile->id)
|
|
|
|
+ ->objectType('App\Models\ModeratedProfile::class')
|
|
|
|
+ ->user(request()->user())
|
|
|
|
+ ->action('admin.moderated-profiles.update')
|
|
|
|
+ ->metadata($request->only($fields))
|
|
|
|
+ ->accessLevel('admin')
|
|
|
|
+ ->save();
|
|
|
|
+
|
|
|
|
+ return [200];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public function createModeratedProfile(Request $request)
|
|
|
|
+ {
|
|
|
|
+ $this->validate($request, [
|
|
|
|
+ 'url' => 'required|url|starts_with:https://',
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ $url = $request->input('url');
|
|
|
|
+ $host = parse_url($url, PHP_URL_HOST);
|
|
|
|
+
|
|
|
|
+ abort_if($host === config('pixelfed.domain.app'), 400, 'You cannot add local users!');
|
|
|
|
+
|
|
|
|
+ $exists = ModeratedProfile::whereProfileUrl($url)->exists();
|
|
|
|
+ abort_if($exists, 400, 'Moderated profile already exists!');
|
|
|
|
+
|
|
|
|
+ $profile = Profile::whereRemoteUrl($url)->first();
|
|
|
|
+
|
|
|
|
+ if ($profile) {
|
|
|
|
+ $rec = ModeratedProfile::updateOrCreate([
|
|
|
|
+ 'profile_id' => $profile->id,
|
|
|
|
+ ], [
|
|
|
|
+ 'profile_url' => $profile->remote_url,
|
|
|
|
+ 'domain' => $profile->domain,
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ ModLogService::boot()
|
|
|
|
+ ->objectUid($rec->profile_id)
|
|
|
|
+ ->objectId($rec->id)
|
|
|
|
+ ->objectType('App\Models\ModeratedProfile::class')
|
|
|
|
+ ->user(request()->user())
|
|
|
|
+ ->action('admin.moderated-profiles.create')
|
|
|
|
+ ->metadata([
|
|
|
|
+ 'profile_existed' => true,
|
|
|
|
+ ])
|
|
|
|
+ ->accessLevel('admin')
|
|
|
|
+ ->save();
|
|
|
|
+
|
|
|
|
+ return $rec;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ $remoteSearch = Helpers::profileFetch($url);
|
|
|
|
+
|
|
|
|
+ if ($remoteSearch) {
|
|
|
|
+ $rec = ModeratedProfile::updateOrCreate([
|
|
|
|
+ 'profile_id' => $remoteSearch->id,
|
|
|
|
+ ], [
|
|
|
|
+ 'profile_url' => $remoteSearch->remote_url,
|
|
|
|
+ 'domain' => $remoteSearch->domain,
|
|
|
|
+ ]);
|
|
|
|
+
|
|
|
|
+ ModLogService::boot()
|
|
|
|
+ ->objectUid($rec->profile_id)
|
|
|
|
+ ->objectId($rec->id)
|
|
|
|
+ ->objectType('App\Models\ModeratedProfile::class')
|
|
|
|
+ ->user(request()->user())
|
|
|
|
+ ->action('admin.moderated-profiles.create')
|
|
|
|
+ ->metadata([
|
|
|
|
+ 'profile_existed' => false,
|
|
|
|
+ ])
|
|
|
|
+ ->accessLevel('admin')
|
|
|
|
+ ->save();
|
|
|
|
+
|
|
|
|
+ return $rec;
|
|
|
|
+ }
|
|
|
|
+ abort(400, 'Invalid account');
|
|
|
|
+ }
|
|
}
|
|
}
|