|
@@ -2,28 +2,35 @@
|
|
|
|
|
|
namespace App;
|
|
namespace App;
|
|
|
|
|
|
-use Laravel\Passport\HasApiTokens;
|
|
|
|
-use Illuminate\Notifications\Notifiable;
|
|
|
|
|
|
+use App\Services\AvatarService;
|
|
|
|
+use App\Util\RateLimit\User as UserRateLimit;
|
|
|
|
+use Illuminate\Database\Eloquent\Factories\HasFactory;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Database\Eloquent\SoftDeletes;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
use Illuminate\Foundation\Auth\User as Authenticatable;
|
|
-use App\Util\RateLimit\User as UserRateLimit;
|
|
|
|
-use App\Services\AvatarService;
|
|
|
|
|
|
+use Illuminate\Notifications\Notifiable;
|
|
|
|
+use Laravel\Passport\HasApiTokens;
|
|
|
|
+use NotificationChannels\Expo\ExpoPushToken;
|
|
|
|
+use NotificationChannels\WebPush\HasPushSubscriptions;
|
|
|
|
|
|
class User extends Authenticatable
|
|
class User extends Authenticatable
|
|
{
|
|
{
|
|
- use Notifiable, SoftDeletes, HasApiTokens, UserRateLimit;
|
|
|
|
|
|
+ use HasApiTokens, HasFactory, HasPushSubscriptions, Notifiable, SoftDeletes, UserRateLimit;
|
|
|
|
|
|
/**
|
|
/**
|
|
* The attributes that should be mutated to dates.
|
|
* The attributes that should be mutated to dates.
|
|
*
|
|
*
|
|
* @var array
|
|
* @var array
|
|
*/
|
|
*/
|
|
- protected $casts = [
|
|
|
|
- 'deleted_at' => 'datetime',
|
|
|
|
- 'email_verified_at' => 'datetime',
|
|
|
|
- '2fa_setup_at' => 'datetime',
|
|
|
|
- 'last_active_at' => 'datetime',
|
|
|
|
- ];
|
|
|
|
|
|
+ protected function casts(): array
|
|
|
|
+ {
|
|
|
|
+ return [
|
|
|
|
+ 'deleted_at' => 'datetime',
|
|
|
|
+ 'email_verified_at' => 'datetime',
|
|
|
|
+ '2fa_setup_at' => 'datetime',
|
|
|
|
+ 'last_active_at' => 'datetime',
|
|
|
|
+ 'expo_token' => ExpoPushToken::class,
|
|
|
|
+ ];
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* The attributes that are mass assignable.
|
|
* The attributes that are mass assignable.
|
|
@@ -38,7 +45,12 @@ class User extends Authenticatable
|
|
'app_register_ip',
|
|
'app_register_ip',
|
|
'email_verified_at',
|
|
'email_verified_at',
|
|
'last_active_at',
|
|
'last_active_at',
|
|
- 'register_source'
|
|
|
|
|
|
+ 'register_source',
|
|
|
|
+ 'expo_token',
|
|
|
|
+ 'notify_like',
|
|
|
|
+ 'notify_follow',
|
|
|
|
+ 'notify_mention',
|
|
|
|
+ 'notify_comment',
|
|
];
|
|
];
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -50,7 +62,7 @@ class User extends Authenticatable
|
|
'email', 'password', 'is_admin', 'remember_token',
|
|
'email', 'password', 'is_admin', 'remember_token',
|
|
'email_verified_at', '2fa_enabled', '2fa_secret',
|
|
'email_verified_at', '2fa_enabled', '2fa_secret',
|
|
'2fa_backup_codes', '2fa_setup_at', 'deleted_at',
|
|
'2fa_backup_codes', '2fa_setup_at', 'deleted_at',
|
|
- 'updated_at'
|
|
|
|
|
|
+ 'updated_at',
|
|
];
|
|
];
|
|
|
|
|
|
public function profile()
|
|
public function profile()
|
|
@@ -93,7 +105,7 @@ class User extends Authenticatable
|
|
|
|
|
|
public function storageUsedKey()
|
|
public function storageUsedKey()
|
|
{
|
|
{
|
|
- return 'profile:storage:used:' . $this->id;
|
|
|
|
|
|
+ return 'profile:storage:used:'.$this->id;
|
|
}
|
|
}
|
|
|
|
|
|
public function accountLog()
|
|
public function accountLog()
|
|
@@ -108,11 +120,15 @@ class User extends Authenticatable
|
|
|
|
|
|
public function avatarUrl()
|
|
public function avatarUrl()
|
|
{
|
|
{
|
|
- if(!$this->profile_id || $this->status) {
|
|
|
|
- return config('app.url') . '/storage/avatars/default.jpg';
|
|
|
|
|
|
+ if (! $this->profile_id || $this->status) {
|
|
|
|
+ return config('app.url').'/storage/avatars/default.jpg';
|
|
}
|
|
}
|
|
|
|
|
|
return AvatarService::get($this->profile_id);
|
|
return AvatarService::get($this->profile_id);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public function routeNotificationForExpo(): ?ExpoPushToken
|
|
|
|
+ {
|
|
|
|
+ return $this->expo_token;
|
|
|
|
+ }
|
|
}
|
|
}
|