added support for profile song
This commit is contained in:
parent
248fbc14e8
commit
a9a22984d2
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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"]))
|
||||
|
@ -42,7 +42,10 @@ class User extends Authenticatable
|
||||
"interests_books",
|
||||
"interests_heroes",
|
||||
|
||||
"blurbs"
|
||||
"blurbs",
|
||||
|
||||
"profile_song",
|
||||
"notification_sound"
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->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");
|
||||
});
|
||||
}
|
||||
};
|
@ -30,6 +30,13 @@
|
||||
<p class="error">{{ $message }}</p>
|
||||
@enderror
|
||||
<small>Max file size: 4MB (jpg/png/gif)</small>
|
||||
<br><br>
|
||||
<small>Select song:</small>
|
||||
<input type="file" name="song" accept="audio/*"><br>
|
||||
@error("song")
|
||||
<p class="error">{{ $message }}</p>
|
||||
@enderror
|
||||
<small>Max file size: 1MB</small>
|
||||
<br>
|
||||
<h1>Bio:</h1>
|
||||
<br>
|
||||
|
@ -35,12 +35,18 @@
|
||||
@endif
|
||||
<p><b>Joined: </b> {{ $user->created_at->diffForHumans () }}</p>
|
||||
</div>
|
||||
|
||||
<audio src="{{ $user->profile_song ? '/storage/songs/' . $user->profile_song : '#' }}" id="music" autoplay loop controls></audio>
|
||||
|
||||
<script>
|
||||
let music = document.getElementById ('music');
|
||||
music.volume = 0.1;
|
||||
music.play ()
|
||||
</script>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
|
||||
<audio src="#" id="music" autoplay loop controls></audio>
|
||||
|
||||
<div class="mood">
|
||||
@if ($user != null)
|
||||
<p><b>Mood:</b> {{ $user->mood }}</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user