|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Models;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
fix: add return type declarations to Eloquent relation methods
Larastan 3.x requires explicit return types on relation methods to
verify relation existence when using with(), has(), etc. This adds
the appropriate return type declarations to all relation methods
flagged by the larastan.relationExistence rule.
Models fixed:
- Profile (avatar, statuses)
- User (profile)
- Status (profile, media, hashtags)
- DirectMessage (status, author, recipient)
- Report (reporter, status, reportedUser)
- Like (actor, status)
- Media (status)
- Notification (item)
- HashtagFollow (hashtag)
- OauthClient (user)
- Story (profile)
- StatusHashtag (status, hashtag, profile, media)
- AccountInterstitial (user)
- Hashtag (posts)
- CustomFilter (keywords)
- CustomFilterKeyword (customFilter)
- AdminShadowFilter (profile)
- ImportPost (status)
4 weeks ago
|
|
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @property-read Status|null $status
|
|
|
|
|
* @property-read int $count aggregate/computed alias
|
|
|
|
|
* @property-read string $month_year aggregate/computed alias
|
|
|
|
|
*/
|
|
|
|
|
class AccountInterstitial extends Model
|
|
|
|
|
{
|
|
|
|
|
public const JSON_MESSAGE = 'Please use web browser to proceed.';
|
|
|
|
|
|
|
|
|
|
protected function casts(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
|
|
|
|
'read_at' => 'datetime',
|
|
|
|
|
'appeal_requested_at' => 'datetime',
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
fix: add return type declarations to Eloquent relation methods
Larastan 3.x requires explicit return types on relation methods to
verify relation existence when using with(), has(), etc. This adds
the appropriate return type declarations to all relation methods
flagged by the larastan.relationExistence rule.
Models fixed:
- Profile (avatar, statuses)
- User (profile)
- Status (profile, media, hashtags)
- DirectMessage (status, author, recipient)
- Report (reporter, status, reportedUser)
- Like (actor, status)
- Media (status)
- Notification (item)
- HashtagFollow (hashtag)
- OauthClient (user)
- Story (profile)
- StatusHashtag (status, hashtag, profile, media)
- AccountInterstitial (user)
- Hashtag (posts)
- CustomFilter (keywords)
- CustomFilterKeyword (customFilter)
- AdminShadowFilter (profile)
- ImportPost (status)
4 weeks ago
|
|
|
public function user(): BelongsTo
|
|
|
|
|
{
|
|
|
|
|
return $this->belongsTo(User::class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function status()
|
|
|
|
|
{
|
fix: add return type declarations to Eloquent relation methods
Larastan 3.x requires explicit return types on relation methods to
verify relation existence when using with(), has(), etc. This adds
the appropriate return type declarations to all relation methods
flagged by the larastan.relationExistence rule.
Models fixed:
- Profile (avatar, statuses)
- User (profile)
- Status (profile, media, hashtags)
- DirectMessage (status, author, recipient)
- Report (reporter, status, reportedUser)
- Like (actor, status)
- Media (status)
- Notification (item)
- HashtagFollow (hashtag)
- OauthClient (user)
- Story (profile)
- StatusHashtag (status, hashtag, profile, media)
- AccountInterstitial (user)
- Hashtag (posts)
- CustomFilter (keywords)
- CustomFilterKeyword (customFilter)
- AdminShadowFilter (profile)
- ImportPost (status)
4 weeks ago
|
|
|
if ($this->item_type != Status::class) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $this->hasOne(Status::class, 'id', 'item_id');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Create an AccountInterstitial for a moderated status.
|
|
|
|
|
*
|
|
|
|
|
* @param Status $status The status being moderated
|
|
|
|
|
* @param string $type The interstitial type (e.g. 'post.cw', 'post.unlist', 'post.removed', 'post.autospam')
|
|
|
|
|
* @param string $view The blade view for the interstitial
|
|
|
|
|
*/
|
|
|
|
|
public static function createFromStatus(Status $status, string $type, string $view): self
|
|
|
|
|
{
|
|
|
|
|
$media = $status->media;
|
|
|
|
|
|
|
|
|
|
$ai = new self;
|
|
|
|
|
$ai->user_id = $status->profile->user_id;
|
|
|
|
|
$ai->type = $type;
|
|
|
|
|
$ai->view = $view;
|
|
|
|
|
$ai->item_type = Status::class;
|
|
|
|
|
$ai->item_id = $status->id;
|
|
|
|
|
$ai->has_media = (bool) $media->count();
|
|
|
|
|
$ai->blurhash = $media->count() ? $media->first()->blurhash : null;
|
|
|
|
|
$ai->meta = json_encode([
|
|
|
|
|
'caption' => $status->caption,
|
|
|
|
|
'created_at' => $status->created_at,
|
|
|
|
|
'type' => $status->type,
|
|
|
|
|
'url' => $status->url(),
|
|
|
|
|
'is_nsfw' => $status->is_nsfw,
|
|
|
|
|
'scope' => $status->scope,
|
|
|
|
|
'reblog' => $status->reblog_of_id,
|
|
|
|
|
'likes_count' => $status->likes_count,
|
|
|
|
|
'reblogs_count' => $status->reblogs_count,
|
|
|
|
|
]);
|
|
|
|
|
$ai->save();
|
|
|
|
|
|
|
|
|
|
$u = $status->profile->user;
|
|
|
|
|
$u->has_interstitial = true;
|
|
|
|
|
$u->save();
|
|
|
|
|
|
|
|
|
|
return $ai;
|
|
|
|
|
}
|
|
|
|
|
}
|