2022-09-13 03:26:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Observers;
|
|
|
|
|
|
|
|
use App\Status;
|
|
|
|
use App\Services\ProfileStatusService;
|
2022-12-16 07:43:20 +00:00
|
|
|
use Cache;
|
2023-06-26 10:16:49 +00:00
|
|
|
use App\Services\ImportService;
|
2022-09-13 03:26:54 +00:00
|
|
|
|
|
|
|
class StatusObserver
|
|
|
|
{
|
2022-09-27 05:55:36 +00:00
|
|
|
/**
|
|
|
|
* Handle events after all transactions are committed.
|
|
|
|
*
|
|
|
|
* @var bool
|
|
|
|
*/
|
|
|
|
public $afterCommit = true;
|
|
|
|
|
2022-09-13 03:26:54 +00:00
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
2022-12-16 07:43:20 +00:00
|
|
|
if(config('instance.timeline.home.cached')) {
|
|
|
|
Cache::forget('pf:timelines:home:' . $status->profile_id);
|
|
|
|
}
|
|
|
|
|
2022-09-13 03:26:54 +00:00
|
|
|
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)
|
|
|
|
{
|
2022-12-16 07:43:20 +00:00
|
|
|
if(config('instance.timeline.home.cached')) {
|
|
|
|
Cache::forget('pf:timelines:home:' . $status->profile_id);
|
|
|
|
}
|
|
|
|
|
2022-09-13 03:26:54 +00:00
|
|
|
ProfileStatusService::delete($status->profile_id, $status->id);
|
2023-06-26 10:16:49 +00:00
|
|
|
|
|
|
|
if($status->uri == null) {
|
|
|
|
ImportService::clearImportedFiles($status->profile_id);
|
|
|
|
}
|
2022-09-13 03:26:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|