diff --git a/app/Http/Controllers/AP/APOutboxController.php b/app/Http/Controllers/AP/APOutboxController.php index b2164a1..1873d6e 100644 --- a/app/Http/Controllers/AP/APOutboxController.php +++ b/app/Http/Controllers/AP/APOutboxController.php @@ -373,7 +373,7 @@ class APOutboxController extends Controller $note->activity_id = $create_activity->id; $note->save (); - $response = TypeActivity::post_to_instances ($create_activity, $actor); + $response = TypeActivity::post_to_instances ($create_activity, $actor, true); return response ()->json ("success", 200); } } diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index 10e17e0..b8cac7a 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -55,6 +55,7 @@ class ProfileController extends Controller $incoming_fields = $request->validate ([ "avatar" => "image|max:4096", + "song" => "file|mimes:audio/mpeg,mp3|max:1024", "bio" => "sometimes|nullable|string", "about_you" => "sometimes|nullable|string", "status" => "sometimes|nullable|string", @@ -69,24 +70,38 @@ class ProfileController extends Controller ]); $user = auth ()->user (); - $fname = $user->id . "-" . uniqid () . ".jpg"; + $fname = $user->id . "-" . uniqid (); $changing_avatar = false; + $changing_song = false; + + $old_avatar = null; + $old_song = null; if (isset ($incoming_fields["avatar"]) && !empty ($incoming_fields["avatar"])) { $manager = new ImageManager (new Driver ()); $image = $manager->read ($request->file ("avatar")); $image_data = $image->cover (256, 256)->toJpeg (); - Storage::disk ("public")->put ("avatars/" . $fname, $image_data); + Storage::disk ("public")->put ("avatars/" . $fname . ".jpg", $image_data); $old_avatar = $user->avatar; - $user->avatar = $fname; + $user->avatar = $fname . ".jpg"; $user->actor->icon = env ("APP_URL") . $user->avatar; $changing_avatar = true; } + if (isset ($incoming_fields["song"]) && !empty ($incoming_fields["song"])) + { + $file = $request->file ("song"); + Storage::disk ("public")->put ("songs/" . $fname . ".mp3", file_get_contents ($file)); + + $old_song = $user->profile_song; + $user->profile_song = $fname . ".mp3"; + $changing_song = true; + } + $user->bio = $incoming_fields["bio"]; $user->about_you = $incoming_fields["about_you"]; $user->status = $incoming_fields["status"]; @@ -106,9 +121,10 @@ class ProfileController extends Controller $user->actor->save (); if ($changing_avatar) - { Storage::disk ("public")->delete (str_replace ("/storage/", "", $old_avatar)); - } + + if ($changing_song) + Storage::disk ("public")->delete (str_replace ("/storage/", "", $old_song)); $response = ActionsUser::update_profile (); if (isset ($response["error"])) diff --git a/app/Models/User.php b/app/Models/User.php index 86bdd4e..5be5476 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -42,7 +42,10 @@ class User extends Authenticatable "interests_books", "interests_heroes", - "blurbs" + "blurbs", + + "profile_song", + "notification_sound" ]; /** diff --git a/database/migrations/2025_01_08_234254_add_fields_to_users_table.php b/database/migrations/2025_01_08_234254_add_fields_to_users_table.php new file mode 100644 index 0000000..6f0e3a6 --- /dev/null +++ b/database/migrations/2025_01_08_234254_add_fields_to_users_table.php @@ -0,0 +1,30 @@ +string ("profile_song")->nullable (); + $table->string ("notification_sound")->nullable (); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn ("profile_song"); + $table->dropColumn ("notification_sound"); + }); + } +}; diff --git a/resources/views/users/edit.blade.php b/resources/views/users/edit.blade.php index 6936b71..cb4d55d 100644 --- a/resources/views/users/edit.blade.php +++ b/resources/views/users/edit.blade.php @@ -30,6 +30,13 @@
{{ $message }}
@enderror Max file size: 4MB (jpg/png/gif) +{{ $message }}
+ @enderror + Max file size: 1MBJoined: {{ $user->created_at->diffForHumans () }}
+ + + + @endif - -Mood: {{ $user->mood }}