diff --git a/app/Domains/Message/MessageRepository.php b/app/Domains/Message/MessageRepository.php index 026c6a9..a768ee3 100644 --- a/app/Domains/Message/MessageRepository.php +++ b/app/Domains/Message/MessageRepository.php @@ -46,7 +46,7 @@ protected function createPrompt(): MessagesDto $prompts[] = MessageDto::from([ 'role' => 'user', - 'content' => $this->parent_message->content + 'content' => $this->parent_message->content, ]); $messages = Message::query() diff --git a/app/Http/Controllers/MessageReplyController.php b/app/Http/Controllers/MessageReplyController.php index 50026f5..a5cf8e2 100644 --- a/app/Http/Controllers/MessageReplyController.php +++ b/app/Http/Controllers/MessageReplyController.php @@ -4,12 +4,11 @@ use App\Jobs\ReplyMessageCreateJob; use App\Models\Message; -use Illuminate\Http\Request; class MessageReplyController extends Controller { - - public function reply(Message $message) { + public function reply(Message $message) + { $validated = request()->validate([ 'content' => ['required'], ]); @@ -24,7 +23,7 @@ public function reply(Message $message) { /** * @NOTE we always start with the parent */ - if($message->parent_id) { + if ($message->parent_id) { $message = $message->parent; } diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 9709e2a..e722f7e 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -35,12 +35,13 @@ public function share(Request $request): array { $profile_photo_url = null; - if(!auth()->guest()) { + if (! auth()->guest()) { $profile_photo_url = auth()->user()->profile_photo_url; } + return array_merge(parent::share($request), [ 'copy' => config('copy'), - 'profile_photo_url' => $profile_photo_url + 'profile_photo_url' => $profile_photo_url, ]); } } diff --git a/app/Jobs/ReplyMessageCreateJob.php b/app/Jobs/ReplyMessageCreateJob.php index 5d1a26b..e5515aa 100644 --- a/app/Jobs/ReplyMessageCreateJob.php +++ b/app/Jobs/ReplyMessageCreateJob.php @@ -4,12 +4,11 @@ use App\Models\Message; use App\OpenAi\Dtos\Response; +use Facades\App\Domains\Message\MessageRepository; use Illuminate\Bus\Queueable; -use Illuminate\Contracts\Queue\ShouldBeUnique; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Queue\InteractsWithQueue; -use Facades\App\Domains\Message\MessageRepository; use Illuminate\Queue\SerializesModels; class ReplyMessageCreateJob implements ShouldQueue diff --git a/app/Models/User.php b/app/Models/User.php index 85b419f..8337dea 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -19,6 +19,7 @@ * @property string $name * @property string $password * @property string $email + * @property string $profile_photo_url * @property Collection $meta_data */ class User extends Authenticatable diff --git a/routes/web.php b/routes/web.php index dd02a78..f03d4b6 100644 --- a/routes/web.php +++ b/routes/web.php @@ -57,7 +57,7 @@ function () { ); Route::controller(MessageReplyController::class)->group( - function() { + function () { Route::put('/message_reply/{message}/update', 'reply') ->name('message_reply.reply'); } diff --git a/tests/Feature/Http/Controllers/MessageReplyControllerTest.php b/tests/Feature/Http/Controllers/MessageReplyControllerTest.php index 3ec38ee..eb58c00 100644 --- a/tests/Feature/Http/Controllers/MessageReplyControllerTest.php +++ b/tests/Feature/Http/Controllers/MessageReplyControllerTest.php @@ -2,13 +2,9 @@ namespace Tests\Feature\Http\Controllers; -use App\Jobs\MessageCreatedJob; use App\Jobs\ReplyMessageCreateJob; use App\Models\Message; -use App\Models\MetaData; use App\Models\User; -use Illuminate\Foundation\Testing\RefreshDatabase; -use Illuminate\Foundation\Testing\WithFaker; use Illuminate\Support\Facades\Queue; use Tests\TestCase; @@ -20,10 +16,10 @@ public function test_reply(): void $user = User::factory()->create(); $parent = Message::factory()->create(); $message = Message::factory()->create([ - 'parent_id' => $parent->id + 'parent_id' => $parent->id, ]); $this->actingAs($user)->put(route('message_reply.reply', [ - 'message' => $message->id + 'message' => $message->id, ]), [ 'content' => 'Foo bar', ]); diff --git a/tests/Feature/Jobs/ReplyMessageCreateJobTest.php b/tests/Feature/Jobs/ReplyMessageCreateJobTest.php index 050e28a..9ad0b25 100644 --- a/tests/Feature/Jobs/ReplyMessageCreateJobTest.php +++ b/tests/Feature/Jobs/ReplyMessageCreateJobTest.php @@ -2,8 +2,6 @@ namespace Tests\Feature\Jobs; -use Illuminate\Foundation\Testing\RefreshDatabase; -use Illuminate\Foundation\Testing\WithFaker; use Tests\TestCase; class ReplyMessageCreateJobTest extends TestCase