mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-09 16:24:51 +00:00
Add StatusObserver
This commit is contained in:
parent
4d95d2cb7f
commit
d122c2d042
2 changed files with 70 additions and 1 deletions
66
app/Observers/StatusObserver.php
Normal file
66
app/Observers/StatusObserver.php
Normal file
|
@ -0,0 +1,66 @@
|
|||
<?php
|
||||
|
||||
namespace App\Observers;
|
||||
|
||||
use App\Status;
|
||||
use App\Services\ProfileStatusService;
|
||||
|
||||
class StatusObserver
|
||||
{
|
||||
/**
|
||||
* Handle the Status "created" event.
|
||||
*
|
||||
* @param \App\Status $status
|
||||
* @return void
|
||||
*/
|
||||
public function created(Status $status)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Status "updated" event.
|
||||
*
|
||||
* @param \App\Status $status
|
||||
* @return void
|
||||
*/
|
||||
public function updated(Status $status)
|
||||
{
|
||||
if(in_array($status->scope, ['public', 'unlisted']) && in_array($status->type, ['photo', 'photo:album', 'video'])) {
|
||||
ProfileStatusService::add($status->profile_id, $status->id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Status "deleted" event.
|
||||
*
|
||||
* @param \App\Status $status
|
||||
* @return void
|
||||
*/
|
||||
public function deleted(Status $status)
|
||||
{
|
||||
ProfileStatusService::delete($status->profile_id, $status->id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Status "restored" event.
|
||||
*
|
||||
* @param \App\Status $status
|
||||
* @return void
|
||||
*/
|
||||
public function restored(Status $status)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the Status "force deleted" event.
|
||||
*
|
||||
* @param \App\Status $status
|
||||
* @return void
|
||||
*/
|
||||
public function forceDeleted(Status $status)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
|
@ -8,7 +8,8 @@ use App\Observers\{
|
|||
NotificationObserver,
|
||||
ModLogObserver,
|
||||
ProfileObserver,
|
||||
StatusHashtagObserver,
|
||||
StatusHashtagObserver,
|
||||
StatusObserver,
|
||||
UserObserver,
|
||||
UserFilterObserver,
|
||||
};
|
||||
|
@ -19,6 +20,7 @@ use App\{
|
|||
ModLog,
|
||||
Profile,
|
||||
StatusHashtag,
|
||||
Status,
|
||||
User,
|
||||
UserFilter
|
||||
};
|
||||
|
@ -47,6 +49,7 @@ class AppServiceProvider extends ServiceProvider
|
|||
Profile::observe(ProfileObserver::class);
|
||||
StatusHashtag::observe(StatusHashtagObserver::class);
|
||||
User::observe(UserObserver::class);
|
||||
Status::observe(StatusObserver::class);
|
||||
UserFilter::observe(UserFilterObserver::class);
|
||||
Horizon::auth(function ($request) {
|
||||
return Auth::check() && $request->user()->is_admin;
|
||||
|
|
Loading…
Reference in a new issue