mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-12-22 13:03:16 +00:00
Update StatusHashtagObserver
This commit is contained in:
parent
9dfc377322
commit
1cd96ced2a
1 changed files with 17 additions and 15 deletions
|
@ -5,32 +5,31 @@ namespace App\Observers;
|
|||
use DB;
|
||||
use App\StatusHashtag;
|
||||
use App\Services\StatusHashtagService;
|
||||
use App\Jobs\HomeFeedPipeline\HashtagInsertFanoutPipeline;
|
||||
use App\Jobs\HomeFeedPipeline\HashtagRemoveFanoutPipeline;
|
||||
use Illuminate\Contracts\Events\ShouldHandleEventsAfterCommit;
|
||||
|
||||
class StatusHashtagObserver
|
||||
class StatusHashtagObserver implements ShouldHandleEventsAfterCommit
|
||||
{
|
||||
/**
|
||||
* Handle events after all transactions are committed.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $afterCommit = true;
|
||||
|
||||
/**
|
||||
* Handle the notification "created" event.
|
||||
*
|
||||
* @param \App\Notification $notification
|
||||
* @param \App\StatusHashtag $hashtag
|
||||
* @return void
|
||||
*/
|
||||
public function created(StatusHashtag $hashtag)
|
||||
{
|
||||
StatusHashtagService::set($hashtag->hashtag_id, $hashtag->status_id);
|
||||
DB::table('hashtags')->where('id', $hashtag->hashtag_id)->increment('cached_count');
|
||||
if($hashtag->status_visibility && $hashtag->status_visibility === 'public') {
|
||||
HashtagInsertFanoutPipeline::dispatch($hashtag)->onQueue('feed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the notification "updated" event.
|
||||
*
|
||||
* @param \App\Notification $notification
|
||||
* @param \App\StatusHashtag $hashtag
|
||||
* @return void
|
||||
*/
|
||||
public function updated(StatusHashtag $hashtag)
|
||||
|
@ -39,21 +38,24 @@ class StatusHashtagObserver
|
|||
}
|
||||
|
||||
/**
|
||||
* Handle the notification "deleted" event.
|
||||
* Handle the notification "deleting" event.
|
||||
*
|
||||
* @param \App\Notification $notification
|
||||
* @param \App\StatusHashtag $hashtag
|
||||
* @return void
|
||||
*/
|
||||
public function deleted(StatusHashtag $hashtag)
|
||||
public function deleting(StatusHashtag $hashtag)
|
||||
{
|
||||
StatusHashtagService::del($hashtag->hashtag_id, $hashtag->status_id);
|
||||
DB::table('hashtags')->where('id', $hashtag->hashtag_id)->decrement('cached_count');
|
||||
if($hashtag->status_visibility && $hashtag->status_visibility === 'public') {
|
||||
HashtagRemoveFanoutPipeline::dispatch($hashtag->status_id, $hashtag->hashtag_id)->onQueue('feed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle the notification "restored" event.
|
||||
*
|
||||
* @param \App\Notification $notification
|
||||
* @param \App\StatusHashtag $hashtag
|
||||
* @return void
|
||||
*/
|
||||
public function restored(StatusHashtag $hashtag)
|
||||
|
@ -64,7 +66,7 @@ class StatusHashtagObserver
|
|||
/**
|
||||
* Handle the notification "force deleted" event.
|
||||
*
|
||||
* @param \App\Notification $notification
|
||||
* @param \App\StatusHashtag $hashtag
|
||||
* @return void
|
||||
*/
|
||||
public function forceDeleted(StatusHashtag $hashtag)
|
||||
|
|
Loading…
Reference in a new issue