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 11:38:29 +00:00
|
|
|
use App\Models\ImportPost;
|
2023-06-26 10:16:49 +00:00
|
|
|
use App\Services\ImportService;
|
2023-11-13 03:54:32 +00:00
|
|
|
use App\Jobs\HomeFeedPipeline\FeedRemovePipeline;
|
2023-11-16 04:57:13 +00:00
|
|
|
use App\Jobs\HomeFeedPipeline\FeedRemoveRemotePipeline;
|
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) {
|
2023-06-26 10:46:57 +00:00
|
|
|
ImportPost::whereProfileId($status->profile_id)->whereStatusId($status->id)->delete();
|
2023-06-26 10:16:49 +00:00
|
|
|
ImportService::clearImportedFiles($status->profile_id);
|
|
|
|
}
|
2023-11-13 03:54:32 +00:00
|
|
|
|
|
|
|
if(config('exp.cached_home_timeline')) {
|
2023-11-16 04:57:13 +00:00
|
|
|
if($status->uri) {
|
|
|
|
FeedRemoveRemotePipeline::dispatch($status->id, $status->profile_id)->onQueue('feed');
|
|
|
|
} else {
|
|
|
|
FeedRemovePipeline::dispatch($status->id, $status->profile_id)->onQueue('feed');
|
|
|
|
}
|
2023-11-13 03:54:32 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|