Update notification pipelines, fix non-local saving

This commit is contained in:
Daniel Supernault 2024-02-04 07:18:05 -07:00
parent 4d4013896c
commit fa97a1f38e
No known key found for this signature in database
GPG key ID: 23740873EE6F76A1
4 changed files with 50 additions and 42 deletions

View file

@ -91,19 +91,21 @@ class CommentPipeline implements ShouldQueue
return; return;
} }
DB::transaction(function() use($target, $actor, $comment) { if($target->user_id && $target->domain === null) {
$notification = new Notification(); DB::transaction(function() use($target, $actor, $comment) {
$notification->profile_id = $target->id; $notification = new Notification();
$notification->actor_id = $actor->id; $notification->profile_id = $target->id;
$notification->action = 'comment'; $notification->actor_id = $actor->id;
$notification->item_id = $comment->id; $notification->action = 'comment';
$notification->item_type = "App\Status"; $notification->item_id = $comment->id;
$notification->save(); $notification->item_type = "App\Status";
$notification->save();
NotificationService::setNotification($notification); NotificationService::setNotification($notification);
NotificationService::set($notification->profile_id, $notification->id); NotificationService::set($notification->profile_id, $notification->id);
StatusService::del($comment->id); StatusService::del($comment->id);
}); });
}
if($exists = Cache::get('status:replies:all:' . $status->id)) { if($exists = Cache::get('status:replies:all:' . $status->id)) {
if($exists && $exists->count() == 3) { if($exists && $exists->count() == 3) {

View file

@ -72,16 +72,18 @@ class FollowPipeline implements ShouldQueue
$target->save(); $target->save();
AccountService::del($target->id); AccountService::del($target->id);
try { if($target->user_id && $target->domain === null) {
$notification = new Notification(); try {
$notification->profile_id = $target->id; $notification = new Notification();
$notification->actor_id = $actor->id; $notification->profile_id = $target->id;
$notification->action = 'follow'; $notification->actor_id = $actor->id;
$notification->item_id = $target->id; $notification->action = 'follow';
$notification->item_type = "App\Profile"; $notification->item_id = $target->id;
$notification->save(); $notification->item_type = "App\Profile";
} catch (Exception $e) { $notification->save();
Log::error($e); } catch (Exception $e) {
Log::error($e);
}
} }
} }
} }

View file

@ -79,16 +79,18 @@ class LikePipeline implements ShouldQueue
return true; return true;
} }
try { if($status->uri === null && $status->object_url === null && $status->url === null) {
$notification = new Notification(); try {
$notification->profile_id = $status->profile_id; $notification = new Notification();
$notification->actor_id = $actor->id; $notification->profile_id = $status->profile_id;
$notification->action = 'like'; $notification->actor_id = $actor->id;
$notification->item_id = $status->id; $notification->action = 'like';
$notification->item_type = "App\Status"; $notification->item_id = $status->id;
$notification->save(); $notification->item_type = "App\Status";
$notification->save();
} catch (Exception $e) { } catch (Exception $e) {
}
} }
} }

View file

@ -87,18 +87,20 @@ class StatusReplyPipeline implements ShouldQueue
Cache::forget('status:replies:all:' . $reply->id); Cache::forget('status:replies:all:' . $reply->id);
Cache::forget('status:replies:all:' . $status->id); Cache::forget('status:replies:all:' . $status->id);
DB::transaction(function() use($target, $actor, $status) { if($target->user_id && $target->domain === null) {
$notification = new Notification(); DB::transaction(function() use($target, $actor, $status) {
$notification->profile_id = $target->id; $notification = new Notification();
$notification->actor_id = $actor->id; $notification->profile_id = $target->id;
$notification->action = 'comment'; $notification->actor_id = $actor->id;
$notification->item_id = $status->id; $notification->action = 'comment';
$notification->item_type = "App\Status"; $notification->item_id = $status->id;
$notification->save(); $notification->item_type = "App\Status";
$notification->save();
NotificationService::setNotification($notification); NotificationService::setNotification($notification);
NotificationService::set($notification->profile_id, $notification->id); NotificationService::set($notification->profile_id, $notification->id);
}); });
}
if($exists = Cache::get('status:replies:all:' . $reply->id)) { if($exists = Cache::get('status:replies:all:' . $reply->id)) {
if($exists && $exists->count() == 3) { if($exists && $exists->count() == 3) {