From 6cce2103215450498428194097d812ebb384026a Mon Sep 17 00:00:00 2001 From: Shlee Date: Sat, 29 Aug 2026 12:39:14 +0930 Subject: [PATCH] Refactor boilerplate examples for deduplication Updated boilerplate examples for ActivityPub Delivery, Username validation, and Notification services to replace repeated code snippets with concise method calls. --- notes/DeduplicationChanges.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/notes/DeduplicationChanges.md b/notes/DeduplicationChanges.md index 599928729..ba5614c0a 100644 --- a/notes/DeduplicationChanges.md +++ b/notes/DeduplicationChanges.md @@ -2,6 +2,7 @@ - `ActivityPubDeliveryService::pool($profile, $audience, $activity);` replaces + ``` $payload = json_encode($activity); @@ -44,7 +45,9 @@ replaces # Username validation boilerplate - `new ValidUsername,` + replaces + ``` function ($attribute, $value, $fail) { $dash = substr_count($value, '-'); @@ -82,7 +85,9 @@ replaces # Notification boilerplate - `NotificationService::createNotification($recipient->id, $profile->id, 'dm', $dm->id, DirectMessage::class);` - `NotificationService::firstOrCreateNotification($parent->profile_id, $actor->id, 'share', $parent->id, Status::class);` -replaces repeated + +replaces + ``` $notification = new Notification; $notification->profile_id = $recipient->id; @@ -98,6 +103,7 @@ replaces repeated - `return FractalService::collection($media, new MediaTransformer);` replaces + ``` $fractal = new Fractal\Manager; $fractal->setSerializer(new ArraySerializer);