1
0
Fork 1
mirror of https://github.com/pixelfed/pixelfed.git synced 2024-12-23 16:24:29 +00:00
pixelfed/app/Observers/StatusObserver.php

83 lines
1.7 KiB
PHP
Raw Normal View History

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;
2022-09-13 03:26:54 +00:00
class StatusObserver
{
/**
* 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);
}
/**
* 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)
{
//
}
}