Convert string references to `::class`

PHP 5.5.9 adds the new static `class` property which provides the fully qualified class name. This is preferred over using strings for class names since the `class` property references are checked by PHP.
pull/6782/head
Shift 4 weeks ago
parent 4c77809444
commit 19880c2ffb
No known key found for this signature in database
GPG Key ID: 5A96F038425C5A1C

@ -23,7 +23,7 @@ class AccountInterstitial extends Model
public function status()
{
if ($this->item_type != 'App\Status') {
if ($this->item_type != \App\Status::class) {
return;
}

@ -239,7 +239,7 @@ class FixDuplicateProfiles extends Command
protected function checkUserFilter($id, $oid)
{
UserFilter::whereUserId($oid)->update(['user_id' => $id]);
UserFilter::whereFilterableType('App\Profile')->whereFilterableId($oid)->update(['filterable_id' => $id]);
UserFilter::whereFilterableType(\App\Profile::class)->whereFilterableId($oid)->update(['filterable_id' => $id]);
}
protected function checkUserPronoun($id, $oid)

@ -598,7 +598,7 @@ class AccountController extends Controller
$limit = $request->input('limit') ?? 40;
$mutes = UserFilter::whereUserId($user->profile_id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('mute')
->simplePaginate($limit)
->pluck('filterable_id');
@ -631,7 +631,7 @@ class AccountController extends Controller
$blocked = UserFilter::select('filterable_id', 'filterable_type', 'filter_type', 'user_id')
->whereUserId($user->profile_id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('block')
->simplePaginate($limit)
->pluck('filterable_id');

@ -114,7 +114,7 @@ trait AdminAutospamController
public function postAutospamTrainSpamApi(Request $request)
{
$aiCount = AccountInterstitial::whereItemType('App\Status')
$aiCount = AccountInterstitial::whereItemType(\App\Status::class)
->whereIsSpam(true)
->count();
abort_if($aiCount < 100, 422, 'You don\'t have enough data to pre-train against.');

@ -230,7 +230,7 @@ trait AdminReportController
AccountInterstitial::chunk(500, function ($reports) {
foreach ($reports as $report) {
if ($report->item_type != 'App\Status') {
if ($report->item_type != \App\Status::class) {
continue;
}
@ -326,7 +326,7 @@ trait AdminReportController
if ($action == 'dismiss-all') {
AccountInterstitial::whereType('post.autospam')
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->whereNull('appeal_handled_at')
->whereUserId($appeal->user_id)
->update(['appeal_handled_at' => $now, 'is_spam' => true]);
@ -339,7 +339,7 @@ trait AdminReportController
if ($action == 'approve-all') {
AccountInterstitial::whereType('post.autospam')
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->whereNull('appeal_handled_at')
->whereUserId($appeal->user_id)
->get()
@ -365,7 +365,7 @@ trait AdminReportController
if ($action == 'mark-spammer') {
AccountInterstitial::whereType('post.autospam')
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->whereNull('appeal_handled_at')
->whereUserId($appeal->user_id)
->update(['appeal_handled_at' => $now, 'is_spam' => true]);
@ -777,7 +777,7 @@ trait AdminReportController
->save();
Report::where('reported_profile_id', $profile->id)
->whereObjectType('App\Story')
->whereObjectType(\App\Story::class)
->whereNull('admin_seen')
->update([
'admin_seen' => now(),
@ -803,9 +803,9 @@ trait AdminReportController
return [200];
case 'nsfw':
if ($report->object_type === 'App\Profile') {
if ($report->object_type === \App\Profile::class) {
$profile = Profile::find($report->object_id);
} elseif ($report->object_type === 'App\Status') {
} elseif ($report->object_type === \App\Status::class) {
$status = Status::find($report->object_id);
if (! $status) {
return [200];
@ -862,9 +862,9 @@ trait AdminReportController
return [200];
case 'unlist':
if ($report->object_type === 'App\Profile') {
if ($report->object_type === \App\Profile::class) {
$profile = Profile::find($report->object_id);
} elseif ($report->object_type === 'App\Status') {
} elseif ($report->object_type === \App\Status::class) {
$status = Status::find($report->object_id);
if (! $status) {
return [200];
@ -921,9 +921,9 @@ trait AdminReportController
return [200];
case 'private':
if ($report->object_type === 'App\Profile') {
if ($report->object_type === \App\Profile::class) {
$profile = Profile::find($report->object_id);
} elseif ($report->object_type === 'App\Status') {
} elseif ($report->object_type === \App\Status::class) {
$status = Status::find($report->object_id);
if (! $status) {
return [200];
@ -984,9 +984,9 @@ trait AdminReportController
abort(404);
}
if ($report->object_type === 'App\Profile') {
if ($report->object_type === \App\Profile::class) {
$profile = Profile::find($report->object_id);
} elseif ($report->object_type === 'App\Status') {
} elseif ($report->object_type === \App\Status::class) {
$status = Status::find($report->object_id);
if (! $status) {
return [200];
@ -1297,7 +1297,7 @@ trait AdminReportController
if ($action == 'mark-all-read') {
AccountInterstitial::whereType('post.autospam')
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->whereNull('appeal_handled_at')
->whereUserId($appeal->user_id)
->update([
@ -1308,7 +1308,7 @@ trait AdminReportController
if ($action == 'mark-all-not-spam') {
AccountInterstitial::whereType('post.autospam')
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->whereUserId($appeal->user_id)
->get()
->each(function ($report) use ($meta) {

@ -37,7 +37,7 @@ class AdminShadowFilterController extends Controller
->pluck('id')
->toArray();
return $q->where('item_type', 'App\Profile')->whereIn('item_id', $ids);
return $q->where('item_type', \App\Profile::class)->whereIn('item_id', $ids);
})
->latest()
->paginate(10)

@ -77,7 +77,7 @@ class AdminApiController extends Controller
'item_type' => $report->item_type,
'created_at' => $report->created_at,
];
if ($report->item_type === 'App\\Status') {
if ($report->item_type === \App\Status::class) {
$status = StatusService::get($report->item_id, false);
if (! $status) {
return;
@ -172,7 +172,7 @@ class AdminApiController extends Controller
if ($action == 'dismiss-all') {
AccountInterstitial::whereType('post.autospam')
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->whereNull('appeal_handled_at')
->whereUserId($appeal->user_id)
->update(['appeal_handled_at' => $now, 'is_spam' => true]);
@ -213,7 +213,7 @@ class AdminApiController extends Controller
if ($action == 'approve-all') {
AccountInterstitial::whereType('post.autospam')
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->whereNull('appeal_handled_at')
->whereUserId($appeal->user_id)
->get()
@ -272,7 +272,7 @@ class AdminApiController extends Controller
$r['reported_by_account'] = AccountService::get($report->profile_id, true);
}
if ($report->object_type === 'App\\Status') {
if ($report->object_type === \App\Status::class) {
$status = StatusService::get($report->object_id, false);
if (! $status) {
return;
@ -285,7 +285,7 @@ class AdminApiController extends Controller
}
}
if ($report->object_type === 'App\\Profile') {
if ($report->object_type === \App\Profile::class) {
$acct = AccountService::get($report->object_id, true);
if ($acct) {
$r['account'] = $acct;

@ -911,7 +911,7 @@ class ApiV1Controller extends Controller
$blocked = UserFilter::whereUserId($target->id)
->whereFilterType('block')
->whereFilterableId($user->profile_id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->exists();
if ($blocked == true) {
@ -1168,7 +1168,7 @@ class ApiV1Controller extends Controller
$blocks = UserFilter::select('filterable_id', 'filterable_type', 'filter_type', 'user_id')
->whereUserId($user->profile_id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('block')
->orderByDesc('id')
->simplePaginate($limit)
@ -1286,7 +1286,7 @@ class ApiV1Controller extends Controller
$filter = UserFilter::firstOrCreate([
'user_id' => $pid,
'filterable_id' => $profile->id,
'filterable_type' => 'App\Profile',
'filterable_type' => \App\Profile::class,
'filter_type' => 'block',
]);
@ -1323,7 +1323,7 @@ class ApiV1Controller extends Controller
$filter = UserFilter::whereUserId($pid)
->whereFilterableId($profile->id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('block')
->first();
@ -2304,7 +2304,7 @@ class ApiV1Controller extends Controller
}
$mutes = UserFilter::whereUserId($user->profile_id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('mute')
->orderByDesc('id')
->simplePaginate($limit)
@ -2388,7 +2388,7 @@ class ApiV1Controller extends Controller
$filter = UserFilter::firstOrCreate([
'user_id' => $pid,
'filterable_id' => $account->id,
'filterable_type' => 'App\Profile',
'filterable_type' => \App\Profile::class,
'filter_type' => 'mute',
]);
@ -2424,7 +2424,7 @@ class ApiV1Controller extends Controller
$filter = UserFilter::whereUserId($pid)
->whereFilterableId($profile->id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('mute')
->first();
@ -3966,7 +3966,7 @@ class ApiV1Controller extends Controller
$count = $collection->items()->count();
$item = CollectionItem::firstOrCreate([
'collection_id' => $collection->id,
'object_type' => 'App\Status',
'object_type' => \App\Status::class,
'object_id' => $status->id,
], [
'order' => $count,

@ -126,10 +126,10 @@ class ApiV1Dot1Controller extends Controller
if (! $object) {
return $this->error('Invalid object id', 400, ['error_code' => 'ERROR_INVALID_OBJECT_ID']);
}
$object_type = 'App\Status';
$object_type = \App\Status::class;
$exists = Report::whereUserId($user->id)
->whereObjectId($object->id)
->whereObjectType('App\Status')
->whereObjectType(\App\Status::class)
->count();
$rpid = $object->profile_id;
@ -140,10 +140,10 @@ class ApiV1Dot1Controller extends Controller
if (! $object) {
return $this->error('Invalid object id', 400, ['error_code' => 'ERROR_INVALID_OBJECT_ID']);
}
$object_type = 'App\Profile';
$object_type = \App\Profile::class;
$exists = Report::whereUserId($user->id)
->whereObjectId($object->id)
->whereObjectType('App\Profile')
->whereObjectType(\App\Profile::class)
->count();
$rpid = $object->id;
break;
@ -159,10 +159,10 @@ class ApiV1Dot1Controller extends Controller
if (! Follower::whereProfileId($user->profile_id)->whereFollowingId($object->profile_id)->exists()) {
return $this->error('Invalid object id', 400, ['error_code' => 'ERROR_INVALID_OBJECT_ID']);
}
$object_type = 'App\Story';
$object_type = \App\Story::class;
$exists = Report::whereUserId($user->id)
->whereObjectId($object->id)
->whereObjectType('App\Story')
->whereObjectType(\App\Story::class)
->count();
$rpid = $object->profile_id;
@ -313,7 +313,7 @@ class ApiV1Dot1Controller extends Controller
$log = new AccountLog;
$log->user_id = $user->id;
$log->item_id = $user->id;
$log->item_type = 'App\User';
$log->item_type = \App\User::class;
$log->action = 'account.edit.password';
$log->message = 'Password changed';
$log->link = null;

@ -104,7 +104,7 @@ class LoginController extends Controller
$log = new AccountLog;
$log->user_id = $user->id;
$log->item_id = $user->id;
$log->item_type = 'App\User';
$log->item_type = \App\User::class;
$log->action = 'auth.login';
$log->message = 'Account Login';
$log->link = null;

@ -155,7 +155,7 @@ class CollectionController extends Controller
$item = CollectionItem::firstOrCreate([
'collection_id' => $collection->id,
'object_type' => 'App\Status',
'object_type' => \App\Status::class,
'object_id' => $status->id,
], [
'order' => $count,
@ -294,7 +294,7 @@ class CollectionController extends Controller
->findOrFail($postId);
$item = CollectionItem::whereCollectionId($collection->id)
->whereObjectType('App\Status')
->whereObjectType(\App\Status::class)
->whereObjectId($status->id)
->firstOrFail();

@ -48,7 +48,7 @@ class CommentController extends Controller
}
$filtered = UserFilter::whereUserId($status->profile_id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereIn('filter_type', ['block'])
->whereFilterableId($profile->id)
->exists();

@ -260,7 +260,7 @@ class ComposeController extends Controller
abort_if($user->has_roles && ! UserRoleService::can('can-post', $user->id), 403, 'Invalid permissions for this action');
$blocked = UserFilter::whereFilterableType('App\Profile')
$blocked = UserFilter::whereFilterableType(\App\Profile::class)
->whereFilterType('block')
->whereFilterableId($request->user()->profile_id)
->pluck('user_id');
@ -326,7 +326,7 @@ class ComposeController extends Controller
if (! $tag) {
return [];
}
Notification::whereItemType('App\MediaTag')
Notification::whereItemType(\App\MediaTag::class)
->whereItemId($tag->id)
->whereProfileId($profile_id)
->whereAction('tagged')
@ -440,7 +440,7 @@ class ComposeController extends Controller
return [];
}
$blocked = UserFilter::whereFilterableType('App\Profile')
$blocked = UserFilter::whereFilterableType(\App\Profile::class)
->whereFilterType('block')
->whereFilterableId($request->user()->profile_id)
->pluck('user_id')
@ -662,7 +662,7 @@ class ComposeController extends Controller
$count = $collection->items()->count();
CollectionItem::firstOrCreate([
'collection_id' => $collection->id,
'object_type' => 'App\Status',
'object_type' => \App\Status::class,
'object_id' => $status->id,
], [
'order' => $count,

@ -208,7 +208,7 @@ class DirectMessageController extends Controller
$nf = UserFilter::whereUserId($recipient->id)
->whereFilterableId($profile->id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('dm.mute')
->exists();
@ -218,7 +218,7 @@ class DirectMessageController extends Controller
$notification->actor_id = $profile->id;
$notification->action = 'dm';
$notification->item_id = $dm->id;
$notification->item_type = "App\DirectMessage";
$notification->item_type = \App\DirectMessage::class;
$notification->save();
}
@ -574,7 +574,7 @@ class DirectMessageController extends Controller
$q = mb_substr($q, 1);
}
$blocked = UserFilter::whereFilterableType('App\Profile')
$blocked = UserFilter::whereFilterableType(\App\Profile::class)
->whereFilterType('block')
->whereFilterableId($request->user()->profile_id)
->pluck('user_id');
@ -654,7 +654,7 @@ class DirectMessageController extends Controller
[
'user_id' => $pid,
'filterable_id' => $fid,
'filterable_type' => 'App\Profile',
'filterable_type' => \App\Profile::class,
'filter_type' => 'dm.mute',
]
);
@ -676,7 +676,7 @@ class DirectMessageController extends Controller
$f = UserFilter::whereUserId($pid)
->whereFilterableId($fid)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('dm.mute')
->firstOrFail();

@ -184,7 +184,7 @@ class InternalApiController extends Controller
$ai->user_id = $status->profile->user_id;
$ai->type = 'post.cw';
$ai->view = 'account.moderation.post.cw';
$ai->item_type = 'App\Status';
$ai->item_type = \App\Status::class;
$ai->item_id = $status->id;
$ai->has_media = (bool) $media->count();
$ai->blurhash = $media->count() ? $media->first()->blurhash : null;
@ -226,7 +226,7 @@ class InternalApiController extends Controller
$ai = AccountInterstitial::whereUserId($status->profile->user_id)
->whereType('post.cw')
->whereItemId($status->id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->first();
$ai->delete();
}
@ -255,7 +255,7 @@ class InternalApiController extends Controller
$ai->user_id = $status->profile->user_id;
$ai->type = 'post.unlist';
$ai->view = 'account.moderation.post.unlist';
$ai->item_type = 'App\Status';
$ai->item_type = \App\Status::class;
$ai->item_id = $status->id;
$ai->has_media = (bool) $media->count();
$ai->blurhash = $media->count() ? $media->first()->blurhash : null;

@ -41,7 +41,7 @@ class MediaTagController extends Controller
if (! $tag) {
return [];
}
Notification::whereItemType('App\MediaTag')
Notification::whereItemType(\App\MediaTag::class)
->whereItemId($tag->id)
->whereProfileId($profile_id)
->whereAction('tagged')

@ -224,7 +224,7 @@ class ProfileController extends Controller
$pid = Auth::user()->profile->id;
$blocks = UserFilter::whereUserId($profile->id)
->whereFilterType('block')
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->pluck('filterable_id')
->toArray();
if (in_array($pid, $blocks)) {

@ -150,10 +150,10 @@ class ReportController extends Controller
case 'post':
case 'comment':
$object = Status::findOrFail($object_id);
$object_type = 'App\Status';
$object_type = \App\Status::class;
$exists = Report::whereUserId(Auth::id())
->whereObjectId($object->id)
->whereObjectType('App\Status')
->whereObjectType(\App\Status::class)
->count();
$rpid = $object->profile_id;
@ -161,20 +161,20 @@ class ReportController extends Controller
case 'user':
$object = Profile::findOrFail($object_id);
$object_type = 'App\Profile';
$object_type = \App\Profile::class;
$exists = Report::whereUserId(Auth::id())
->whereObjectId($object->id)
->whereObjectType('App\Profile')
->whereObjectType(\App\Profile::class)
->count();
$rpid = $object->id;
break;
case 'group':
$object = Group::findOrFail($object_id);
$object_type = 'App\Models\Group';
$object_type = \App\Models\Group::class;
$exists = Report::whereUserId(Auth::id())
->whereObjectId($object->id)
->whereObjectType('App\Models\Group')
->whereObjectType(\App\Models\Group::class)
->count();
$rpid = $object->profile_id;
break;

@ -225,7 +225,7 @@ class SeasonalController extends Controller
$log = AccountLog::firstOrCreate([
[
'item_type' => 'App\User',
'item_type' => \App\User::class,
'item_id' => $user->id,
'user_id' => $user->id,
'action' => 'seasonal.my2020.view',

@ -138,7 +138,7 @@ trait HomeSettings
$log = new AccountLog;
$log->user_id = $user->id;
$log->item_id = $user->id;
$log->item_type = 'App\User';
$log->item_type = \App\User::class;
$log->action = 'account.edit.password';
$log->message = $revokeSessions
? 'Password changed and all sessions revoked'
@ -193,7 +193,7 @@ trait HomeSettings
$log = new AccountLog;
$log->user_id = $user->id;
$log->item_id = $user->id;
$log->item_type = 'App\User';
$log->item_type = \App\User::class;
$log->action = 'account.edit.email';
$log->message = 'Email changed';
$log->link = null;

@ -133,7 +133,7 @@ trait PrivacySettings
DB::transaction(function () use ($fid, $pid) {
$filter = UserFilter::whereUserId($pid)
->whereFilterableId($fid)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('mute')
->firstOrFail();
$filter->delete();
@ -162,7 +162,7 @@ trait PrivacySettings
DB::transaction(function () use ($fid, $pid) {
$filter = UserFilter::whereUserId($pid)
->whereFilterableId($fid)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('block')
->firstOrFail();
$filter->delete();

@ -265,7 +265,7 @@ class StatusController extends Controller
$ai->user_id = $status->profile->user_id;
$ai->type = 'post.removed';
$ai->view = 'account.moderation.post.removed';
$ai->item_type = 'App\Status';
$ai->item_type = \App\Status::class;
$ai->item_id = $status->id;
$ai->has_media = (bool) $media->count();
$ai->blurhash = $media->count() ? $media->first()->blurhash : null;

@ -726,7 +726,7 @@ class StoryApiV1Controller extends Controller
$n->profile_id = $dm->to_id;
$n->actor_id = $dm->from_id;
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->item_type = \App\DirectMessage::class;
$n->action = 'story:comment';
$n->save();
} else {

@ -460,7 +460,7 @@ class StoryComposeController extends Controller
abort_if(! FollowerService::follows($pid, $story->profile_id), 422, 'Cannot report a story from an account you do not follow');
if (Report::whereProfileId($pid)
->whereObjectType('App\Story')
->whereObjectType(\App\Story::class)
->whereObjectId($story->id)
->exists()
) {
@ -474,7 +474,7 @@ class StoryComposeController extends Controller
$report->profile_id = $pid;
$report->user_id = $request->user()->id;
$report->object_id = $story->id;
$report->object_type = 'App\Story';
$report->object_type = \App\Story::class;
$report->reported_profile_id = $story->profile_id;
$report->type = $type;
$report->message = null;
@ -550,7 +550,7 @@ class StoryComposeController extends Controller
$n->profile_id = $dm->to_id;
$n->actor_id = $dm->from_id;
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->item_type = \App\DirectMessage::class;
$n->action = 'story:react';
$n->save();
} else {
@ -627,7 +627,7 @@ class StoryComposeController extends Controller
$n->profile_id = $dm->to_id;
$n->actor_id = $dm->from_id;
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->item_type = \App\DirectMessage::class;
$n->action = 'story:comment';
$n->save();
} else {

@ -72,7 +72,7 @@ class TimelineController extends Controller
});
$filtered = UserFilter::whereUserId($user->profile_id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereIn('filter_type', ['mute', 'block'])
->pluck('filterable_id')->toArray();

@ -41,11 +41,11 @@ class AdminReport extends JsonResource
'created_at' => $this->created_at,
];
if ($this->object_id && $this->object_type === 'App\Status') {
if ($this->object_id && $this->object_type === \App\Status::class) {
$res['status'] = StatusService::get($this->object_id, false);
}
if ($this->object_id && $this->object_type === 'App\Story') {
if ($this->object_id && $this->object_type === \App\Story::class) {
$story = Story::find($this->object_id);
if ($story) {
$res['story'] = $story->toAdminEntity();

@ -31,7 +31,7 @@ class AdminSpamReport extends JsonResource
'created_at' => $this->created_at,
];
if ($this->item_id && $this->item_type === 'App\Status') {
if ($this->item_id && $this->item_type === \App\Status::class) {
$res['status'] = StatusService::get($this->item_id, false);
}

@ -34,7 +34,7 @@ class AutospamPretrainPipeline implements ShouldQueue
{
$classifier = $this->classifier;
$aiCount = AccountInterstitial::whereItemType('App\Status')
$aiCount = AccountInterstitial::whereItemType(\App\Status::class)
->whereIsSpam(true)
->count();
@ -42,7 +42,7 @@ class AutospamPretrainPipeline implements ShouldQueue
return;
}
AccountInterstitial::whereItemType('App\Status')
AccountInterstitial::whereItemType(\App\Status::class)
->whereIsSpam(true)
->inRandomOrder()
->take(config('autospam.nlp.spam_sample_limit'))

@ -106,7 +106,7 @@ class CommentPipeline implements ShouldQueue
}
$filtered = UserFilter::whereUserId($target->id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereIn('filter_type', ['mute', 'block'])
->whereFilterableId($actor->id)
->exists();
@ -122,7 +122,7 @@ class CommentPipeline implements ShouldQueue
$notification->actor_id = $actor->id;
$notification->action = 'comment';
$notification->item_id = $comment->id;
$notification->item_type = "App\Status";
$notification->item_type = \App\Status::class;
$notification->save();
NotificationService::setNotification($notification);

@ -138,7 +138,7 @@ class DeleteAccountPipeline implements ShouldQueue
RemoteAuth::whereUserId($user->id)->delete();
AccountLog::whereItemType('App\User')->whereItemId($user->id)->forceDelete();
AccountLog::whereItemType(\App\User::class)->whereItemId($user->id)->forceDelete();
AccountInterstitial::whereUserId($user->id)->delete();

@ -119,7 +119,7 @@ class DeleteRemoteProfilePipeline implements ShouldQueue
}
// Delete mutes/blocks
UserFilter::whereFilterableType('App\Profile')->whereFilterableId($pid)->delete();
UserFilter::whereFilterableType(\App\Profile::class)->whereFilterableId($pid)->delete();
// Delete mentions
Mention::whereProfileId($pid)->forceDelete();

@ -76,7 +76,7 @@ class DeleteRemoteStatusPipeline implements ShouldQueue
NetworkTimelineService::del($status->id);
StatusService::del($status->id, true);
Bookmark::whereStatusId($status->id)->delete();
Notification::whereItemType('App\Status')
Notification::whereItemType(\App\Status::class)
->whereItemId($status->id)
->forceDelete();
DirectMessage::whereStatusId($status->id)->delete();
@ -88,7 +88,7 @@ class DeleteRemoteStatusPipeline implements ShouldQueue
MediaDeletePipeline::dispatch($media)->onQueue('mmo');
});
Mention::whereStatusId($status->id)->forceDelete();
Report::whereObjectType('App\Status')->whereObjectId($status->id)->delete();
Report::whereObjectType(\App\Status::class)->whereObjectId($status->id)->delete();
StatusHashtag::whereStatusId($status->id)->delete();
StatusView::whereStatusId($status->id)->delete();
Status::whereReblogOfId($status->id)->forceDelete();

@ -82,7 +82,7 @@ class FollowPipeline implements ShouldQueue
$notification->actor_id = $actor->id;
$notification->action = 'follow';
$notification->item_id = $target->id;
$notification->item_type = "App\Profile";
$notification->item_type = \App\Profile::class;
$notification->save();
} catch (\Exception $e) {
Log::error($e);

@ -95,7 +95,7 @@ class UnfollowPipeline implements ShouldQueue
->whereAction('follow')
->whereActorId($actor)
->whereItemId($target)
->whereItemType('App\Profile')
->whereItemType(\App\Profile::class)
->get()
->each(function ($n) {
NotificationService::del($n->profile_id, $n->id);

@ -87,7 +87,7 @@ class GroupCommentPipeline implements ShouldQueue
$notification->actor_id = $actor->id;
$notification->action = 'group:comment';
$notification->item_id = $comment->id;
$notification->item_type = "App\Status";
$notification->item_type = \App\Status::class;
$notification->save();
return $notification;

@ -47,7 +47,7 @@ class GroupMemberInvite implements ShouldQueue
$notification->actor_id = $actor->id;
$notification->action = 'group:invite';
$notification->item_id = $invite->group_id;
$notification->item_type = 'App\Models\Group';
$notification->item_type = \App\Models\Group::class;
$notification->save();
}
}

@ -44,7 +44,7 @@ class JoinApproved implements ShouldQueue
$n->profile_id = $member->profile_id;
$n->actor_id = $member->profile_id;
$n->item_id = $member->group_id;
$n->item_type = 'App\Models\Group';
$n->item_type = \App\Models\Group::class;
$n->save();
GroupService::del($member->group_id);

@ -41,7 +41,7 @@ class JoinRejected implements ShouldQueue
$n->profile_id = $member->profile_id;
$n->actor_id = $member->profile_id;
$n->item_id = $member->group_id;
$n->item_type = 'App\Models\Group';
$n->item_type = \App\Models\Group::class;
$n->action = 'group.join.rejected';
$n->save();
}

@ -69,7 +69,7 @@ class LikePipeline implements ShouldQueue
->whereActorId($actor->id)
->whereAction('group:like')
->whereItemId($status->id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->count();
if ($actor->id === $status->profile_id || $exists !== 0) {
@ -82,7 +82,7 @@ class LikePipeline implements ShouldQueue
$notification->actor_id = $actor->id;
$notification->action = 'group:like';
$notification->item_id = $status->id;
$notification->item_type = "App\Status";
$notification->item_type = \App\Status::class;
$notification->save();
} catch (\Exception $e) {

@ -73,7 +73,7 @@ class UnlikePipeline implements ShouldQueue
->whereActorId($actor->id)
->whereAction('group:like')
->whereItemId($status->id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->first();
if ($exists) {

@ -61,12 +61,12 @@ class NewCommentPipeline implements ShouldQueue
$groupId = $status->group_id;
$postId = $status->id;
if ($parentClass === 'App\Models\GroupPost') {
if ($parentClass === \App\Models\GroupPost::class) {
$parent->reply_count = GroupPostService::getCommentCount($parent->id, false);
$parent->save();
GroupPostService::del($groupId, $postId);
GroupFeedService::del($groupId, $postId);
} elseif ($parentClass === 'App\Models\GroupComment') {
} elseif ($parentClass === \App\Models\GroupComment::class) {
$gp = GroupPost::whereId($parent->status_id)->firstOrFail();
if ($gp->group_id !== $status->group_id) {
return;

@ -115,7 +115,7 @@ class FeedInsertPipeline implements ShouldBeUniqueUntilProcessing, ShouldQueue
$skipIds = UserDomainBlock::where('domain', $domain)->pluck('profile_id')->toArray();
}
$filters = UserFilter::whereFilterableType('App\Profile')
$filters = UserFilter::whereFilterableType(\App\Profile::class)
->whereFilterableId($status['account']['id'])
->whereIn('filter_type', ['mute', 'block'])
->pluck('user_id')

@ -113,7 +113,7 @@ class FeedInsertRemotePipeline implements ShouldBeUniqueUntilProcessing, ShouldQ
$skipIds = UserDomainBlock::where('domain', $domain)->pluck('profile_id')->toArray();
}
$filters = UserFilter::whereFilterableType('App\Profile')
$filters = UserFilter::whereFilterableType(\App\Profile::class)
->whereFilterableId($status['account']['id'])
->whereIn('filter_type', ['mute', 'block'])
->pluck('user_id')

@ -113,7 +113,7 @@ class HashtagInsertFanoutPipeline implements ShouldBeUniqueUntilProcessing, Shou
$skipIds = UserDomainBlock::where('domain', $domain)->pluck('profile_id')->toArray();
}
$filters = UserFilter::whereFilterableType('App\Profile')
$filters = UserFilter::whereFilterableType(\App\Profile::class)
->whereFilterableId($status['account']['id'])
->whereIn('filter_type', ['mute', 'block'])
->pluck('user_id')

@ -87,7 +87,7 @@ class LikePipeline implements ShouldQueue
'actor_id' => $actor->id,
'action' => 'like',
'item_id' => $status->id,
'item_type' => 'App\Status',
'item_type' => \App\Status::class,
]
);

@ -71,7 +71,7 @@ class UnlikePipeline implements ShouldQueue
->whereActorId($actor->id)
->whereAction('like')
->whereItemId($status->id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->chunkById(100, function ($notifications) {
foreach ($notifications as $notification) {
$notification->forceDelete();

@ -88,7 +88,7 @@ class MentionPipeline implements ShouldQueue
->whereActorId($actor->id)
->whereIn('action', ['mention', 'comment'])
->whereItemId($status->id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->count();
if ($actor->id === $target || $exists !== 0) {
@ -100,7 +100,7 @@ class MentionPipeline implements ShouldQueue
'profile_id' => $target,
'actor_id' => $actor->id,
'action' => 'mention',
'item_type' => 'App\Status',
'item_type' => \App\Status::class,
'item_id' => $status->id,
]
);

@ -85,7 +85,7 @@ class CleanupLegacyAccountMovePipeline implements ShouldQueue
throw new Exception('Invalid move accounts');
}
UserFilter::where('filterable_type', 'App\Profile')
UserFilter::where('filterable_type', \App\Profile::class)
->where('filterable_id', $actorAccount['id'])
->update(['filterable_id' => $targetAccount['id']]);

@ -79,7 +79,7 @@ class SharePipeline implements ShouldQueue
'profile_id' => $target->id,
'actor_id' => $actor->id,
'action' => 'share',
'item_type' => 'App\Status',
'item_type' => \App\Status::class,
'item_id' => $status->reblog_of_id ?? $status->id,
]
);

@ -54,7 +54,7 @@ class UndoSharePipeline implements ShouldQueue
->whereActorId($status->profile_id)
->whereAction('share')
->whereItemId($status->reblog_of_id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->first();
if ($notification) {

@ -127,11 +127,11 @@ class RemoteStatusDelete implements ShouldBeUniqueUntilProcessing, ShouldQueue
}
}
AccountInterstitial::where('item_type', 'App\Status')
AccountInterstitial::where('item_type', \App\Status::class)
->where('item_id', $status->id)
->delete();
Bookmark::whereStatusId($status->id)->delete();
CollectionItem::whereObjectType('App\Status')
CollectionItem::whereObjectType(\App\Status::class)
->whereObjectId($status->id)
->get()
->each(function ($col) {
@ -140,7 +140,7 @@ class RemoteStatusDelete implements ShouldBeUniqueUntilProcessing, ShouldQueue
});
$dms = DirectMessage::whereStatusId($status->id)->get();
foreach ($dms as $dm) {
$not = Notification::whereItemType('App\DirectMessage')
$not = Notification::whereItemType(\App\DirectMessage::class)
->whereItemId($dm->id)
->first();
if ($not) {
@ -157,7 +157,7 @@ class RemoteStatusDelete implements ShouldBeUniqueUntilProcessing, ShouldQueue
});
$mediaTags = MediaTag::where('status_id', $status->id)->get();
foreach ($mediaTags as $mtag) {
$not = Notification::whereItemType('App\MediaTag')
$not = Notification::whereItemType(\App\MediaTag::class)
->whereItemId($mtag->id)
->first();
if ($not) {
@ -167,10 +167,10 @@ class RemoteStatusDelete implements ShouldBeUniqueUntilProcessing, ShouldQueue
$mtag->delete();
}
Mention::whereStatusId($status->id)->forceDelete();
Notification::whereItemType('App\Status')
Notification::whereItemType(\App\Status::class)
->whereItemId($status->id)
->forceDelete();
Report::whereObjectType('App\Status')
Report::whereObjectType(\App\Status::class)
->whereObjectId($status->id)
->delete();
StatusArchived::whereStatusId($status->id)->delete();

@ -120,7 +120,7 @@ class StatusDelete implements ShouldQueue
Bookmark::whereStatusId($status->id)->delete();
CollectionItem::whereObjectType('App\Status')
CollectionItem::whereObjectType(\App\Status::class)
->whereObjectId($status->id)
->get()
->each(function ($col) {
@ -130,7 +130,7 @@ class StatusDelete implements ShouldQueue
$dms = DirectMessage::whereStatusId($status->id)->get();
foreach ($dms as $dm) {
$not = Notification::whereItemType('App\DirectMessage')
$not = Notification::whereItemType(\App\DirectMessage::class)
->whereItemId($dm->id)
->first();
if ($not) {
@ -143,7 +143,7 @@ class StatusDelete implements ShouldQueue
$mediaTags = MediaTag::where('status_id', $status->id)->get();
foreach ($mediaTags as $mtag) {
$not = Notification::whereItemType('App\MediaTag')
$not = Notification::whereItemType(\App\MediaTag::class)
->whereItemId($mtag->id)
->first();
if ($not) {
@ -154,11 +154,11 @@ class StatusDelete implements ShouldQueue
}
Mention::whereStatusId($status->id)->forceDelete();
Notification::whereItemType('App\Status')
Notification::whereItemType(\App\Status::class)
->whereItemId($status->id)
->forceDelete();
Report::whereObjectType('App\Status')
Report::whereObjectType(\App\Status::class)
->whereObjectId($status->id)
->delete();
@ -167,7 +167,7 @@ class StatusDelete implements ShouldQueue
StatusView::whereStatusId($status->id)->delete();
Status::whereInReplyToId($status->id)->update(['in_reply_to_id' => null]);
AccountInterstitial::where('item_type', 'App\Status')
AccountInterstitial::where('item_type', \App\Status::class)
->where('item_id', $status->id)
->delete();

@ -90,7 +90,7 @@ class StatusReplyPipeline implements ShouldQueue
->whereActorId($actor->id)
->whereIn('action', ['mention', 'comment'])
->whereItemId($status->id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->count();
if ($actor->id === $target || $exists !== 0) {
@ -122,7 +122,7 @@ class StatusReplyPipeline implements ShouldQueue
$notification->actor_id = $actor->id;
$notification->action = 'comment';
$notification->item_id = $status->id;
$notification->item_type = "App\Status";
$notification->item_type = \App\Status::class;
$notification->save();
NotificationService::setNotification($notification);

@ -34,7 +34,7 @@ class LogFailedLogin
$log = new AccountLog;
$log->user_id = $user->id;
$log->item_id = $user->id;
$log->item_type = 'App\User';
$log->item_type = \App\User::class;
$log->action = 'auth.failed';
$log->message = 'Failed login attempt';
$log->link = null;

@ -50,7 +50,7 @@ class AdminNewAutospam extends Mailable
$reported_account = null;
$url = url('/i/admin/reports/autospam/'.$this->report->id.'?ref=email');
if ($data['item_type'] === 'App\Status') {
if ($data['item_type'] === \App\Status::class) {
$reported_status = StatusService::get($this->report->item_id, false);
$reported_account = AccountService::get($reported_status['account']['id'], true);
}

@ -22,7 +22,7 @@ class AdminShadowFilter extends Model
public function account()
{
if ($this->item_type === 'App\Profile') {
if ($this->item_type === \App\Profile::class) {
return AccountService::get($this->item_id, true);
}

@ -68,7 +68,7 @@ class UserFilterObserver
protected function filterCreate(UserFilter $userFilter)
{
if ($userFilter->filterable_type !== 'App\Profile') {
if ($userFilter->filterable_type !== \App\Profile::class) {
return;
}
@ -87,7 +87,7 @@ class UserFilterObserver
protected function filterDelete(UserFilter $userFilter)
{
if ($userFilter->filterable_type !== 'App\Profile') {
if ($userFilter->filterable_type !== \App\Profile::class) {
return;
}

@ -254,7 +254,7 @@ class Profile extends Model
public function mutedIds()
{
return UserFilter::whereUserId($this->id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('mute')
->pluck('filterable_id');
}
@ -262,7 +262,7 @@ class Profile extends Model
public function blockedIds()
{
return UserFilter::whereUserId($this->id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('block')
->pluck('filterable_id');
}

@ -14,10 +14,10 @@ class EventServiceProvider extends ServiceProvider
*/
protected $listen = [
'Illuminate\Auth\Events\Login' => [
'App\Listeners\AuthLogin',
\App\Listeners\AuthLogin::class,
],
'Illuminate\Auth\Events\Failed' => [
'App\Listeners\LogFailedLogin',
\App\Listeners\LogFailedLogin::class,
],
];

@ -30,12 +30,12 @@ class Report extends Model
$class = $this->object_type;
switch ($class) {
case 'App\Status':
case \App\Status::class:
$column = 'id';
break;
default:
$class = 'App\Status';
$class = \App\Status::class;
$column = 'id';
break;
}

@ -11,7 +11,7 @@ class AdminShadowFilterService
public static function queryFilter($name = 'hide_from_public_feeds')
{
return AdminShadowFilter::whereItemType('App\Profile')
return AdminShadowFilter::whereItemType(\App\Profile::class)
->whereActive(1)
->where('hide_from_public_feeds', true)
->pluck('item_id')
@ -26,7 +26,7 @@ class AdminShadowFilterService
}
return Cache::remember($key, 86400, function () {
return AdminShadowFilter::whereItemType('App\Profile')
return AdminShadowFilter::whereItemType(\App\Profile::class)
->whereActive(1)
->where('hide_from_public_feeds', true)
->pluck('item_id')

@ -78,7 +78,7 @@ class MediaTagService
$n->profile_id = $tag->profile_id;
$n->actor_id = $p->id;
$n->item_id = $tag->id;
$n->item_type = 'App\MediaTag';
$n->item_type = \App\MediaTag::class;
$n->action = 'tagged';
$n->save();

@ -117,7 +117,7 @@ class ModLogService
$log = $this->log;
$item_id = $log->id;
$item_type = 'App\ModLog';
$item_type = \App\ModLog::class;
$action = 'admin.user.modlog.comment';
$admins = User::whereNull('status')
@ -139,7 +139,7 @@ class ModLogService
public function unfanout()
{
Notification::whereItemType('App\ModLog')
Notification::whereItemType(\App\ModLog::class)
->whereItemId($this->log->id)
->delete();
}

@ -29,12 +29,12 @@ class RelationshipService
'following' => Follower::whereProfileId($aid)->whereFollowingId($tid)->exists(),
'followed_by' => Follower::whereProfileId($tid)->whereFollowingId($aid)->exists(),
'blocking' => UserFilter::whereUserId($aid)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterableId($tid)
->whereFilterType('block')
->exists(),
'muting' => UserFilter::whereUserId($aid)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterableId($tid)
->whereFilterType('mute')
->exists(),

@ -30,7 +30,7 @@ class NotificationTransformer extends Fractal\TransformerAbstract
public function includeStatus(Notification $notification)
{
$item = $notification;
if ($item->item_id && $item->item_type == 'App\Status') {
if ($item->item_id && $item->item_type == \App\Status::class) {
$status = Status::with('media')->find($item->item_id);
if ($status) {
return $this->item($status, new StatusTransformer);

@ -27,11 +27,11 @@ class NotificationTransformer extends Fractal\TransformerAbstract
}
}
if ($n->item_id && $n->item_type == 'App\Status') {
if ($n->item_id && $n->item_type == \App\Status::class) {
$res['status'] = StatusService::get($n->item_id, false);
}
if ($n->item_id && $n->item_type == 'App\ModLog') {
if ($n->item_id && $n->item_type == \App\ModLog::class) {
$ml = $n->item;
if ($ml && $ml->object_uid) {
$res['modlog'] = [
@ -41,7 +41,7 @@ class NotificationTransformer extends Fractal\TransformerAbstract
}
}
if ($n->item_id && $n->item_type == 'App\MediaTag') {
if ($n->item_id && $n->item_type == \App\MediaTag::class) {
$ml = $n->item;
if ($ml && $ml->tagged_username) {
$np = StatusService::get($ml->status_id, false);

@ -16,7 +16,7 @@ class UserFilter extends Model
public function mutedUserIds($profile_id)
{
return $this->whereUserId($profile_id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('mute')
->pluck('filterable_id');
}
@ -24,7 +24,7 @@ class UserFilter extends Model
public function blockedUserIds($profile_id)
{
return $this->whereUserId($profile_id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('block')
->pluck('filterable_id');
}

@ -537,7 +537,7 @@ class Inbox
$nf = UserFilter::whereUserId($profile->id)
->whereFilterableId($actor->id)
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->whereFilterType('dm.mute')
->exists();
@ -547,7 +547,7 @@ class Inbox
$notification->actor_id = $actor->id;
$notification->action = 'dm';
$notification->item_id = $dm->id;
$notification->item_type = "App\DirectMessage";
$notification->item_type = \App\DirectMessage::class;
$notification->save();
if (NotificationAppGatewayService::enabled()) {
@ -678,7 +678,7 @@ class Inbox
'actor_id' => $actor->id,
'action' => 'share',
'item_id' => $parent->id,
'item_type' => 'App\Status',
'item_type' => \App\Status::class,
]
);
@ -817,7 +817,7 @@ class Inbox
}
$notifications = Notification::whereActorId($status->profile_id)
->whereItemId($status->id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->get();
foreach ($notifications as $notification) {
$notification->forceDelete();
@ -955,7 +955,7 @@ class Inbox
->whereActorId($profile->id)
->whereAction('share')
->whereItemId($status->id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->get();
foreach ($notifications as $notification) {
$notification->forceDelete();
@ -983,7 +983,7 @@ class Inbox
->whereActorId($profile->id)
->whereAction('follow')
->whereItemId($following->id)
->whereItemType('App\Profile')
->whereItemType(\App\Profile::class)
->get();
foreach ($notifications as $notification) {
$notification->forceDelete();
@ -1017,7 +1017,7 @@ class Inbox
->whereActorId($profile->id)
->whereAction('like')
->whereItemId($status->id)
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->get();
foreach ($notifications as $notification) {
@ -1203,7 +1203,7 @@ class Inbox
$n->profile_id = $dm->to_id;
$n->actor_id = $dm->from_id;
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->item_type = \App\DirectMessage::class;
$n->action = 'story:react';
$n->save();
@ -1323,7 +1323,7 @@ class Inbox
$n->profile_id = $dm->to_id;
$n->actor_id = $dm->from_id;
$n->item_id = $dm->id;
$n->item_type = 'App\DirectMessage';
$n->item_type = \App\DirectMessage::class;
$n->action = 'story:comment';
$n->save();

@ -36,7 +36,7 @@ class Bouncer
$uid = $status->profile->user_id;
$ids = AccountInterstitial::whereUserId($uid)
->whereType('post.autospam')
->whereItemType('App\Status')
->whereItemType(\App\Status::class)
->whereNotNull('appeal_handled_at')
->latest()
->take(5)
@ -117,7 +117,7 @@ class Bouncer
$ai->user_id = $status->profile->user_id;
$ai->type = 'post.autospam';
$ai->view = 'account.moderation.post.autospam';
$ai->item_type = 'App\Status';
$ai->item_type = \App\Status::class;
$ai->item_id = $status->id;
$ai->has_media = (bool) $media->count();
$ai->blurhash = $media->count() ? $media->first()->blurhash : null;
@ -152,7 +152,7 @@ class Bouncer
$notification->actor_id = $status->profile_id;
$notification->action = 'autospam.warning';
$notification->item_id = $status->id;
$notification->item_type = "App\Status";
$notification->item_type = \App\Status::class;
$notification->save();
StatusService::del($status->id);

@ -21,7 +21,7 @@ return new class extends Migration
public function up(): void
{
UserFilter::whereFilterType('block')
->whereFilterableType('App\Profile')
->whereFilterableType(\App\Profile::class)
->chunk(10, function($filters) {
foreach($filters as $filter) {
$actor = Profile::whereNull('status')->find($filter->user_id);

Loading…
Cancel
Save