Added support for custom notification sounds
This commit is contained in:
parent
518586b6ab
commit
25f00b1dc7
@ -58,6 +58,7 @@ class ProfileController extends Controller
|
|||||||
$incoming_fields = $request->validate ([
|
$incoming_fields = $request->validate ([
|
||||||
"avatar" => "image|max:4096",
|
"avatar" => "image|max:4096",
|
||||||
"song" => "file|mimes:audio/mpeg,mp3|max:4096",
|
"song" => "file|mimes:audio/mpeg,mp3|max:4096",
|
||||||
|
"notification_sound" => "file|mimes:audio/mpeg,mp3|max:1024",
|
||||||
"bio" => "sometimes|nullable|string",
|
"bio" => "sometimes|nullable|string",
|
||||||
"about_you" => "sometimes|nullable|string",
|
"about_you" => "sometimes|nullable|string",
|
||||||
"status" => "sometimes|nullable|string",
|
"status" => "sometimes|nullable|string",
|
||||||
@ -76,9 +77,11 @@ class ProfileController extends Controller
|
|||||||
|
|
||||||
$changing_avatar = false;
|
$changing_avatar = false;
|
||||||
$changing_song = false;
|
$changing_song = false;
|
||||||
|
$changing_notification_sound = false;
|
||||||
|
|
||||||
$old_avatar = null;
|
$old_avatar = null;
|
||||||
$old_song = null;
|
$old_song = null;
|
||||||
|
$old_notification_sound = null;
|
||||||
if (isset ($incoming_fields["avatar"]) && !empty ($incoming_fields["avatar"]))
|
if (isset ($incoming_fields["avatar"]) && !empty ($incoming_fields["avatar"]))
|
||||||
{
|
{
|
||||||
$manager = new ImageManager (new Driver ());
|
$manager = new ImageManager (new Driver ());
|
||||||
@ -104,6 +107,16 @@ class ProfileController extends Controller
|
|||||||
$changing_song = true;
|
$changing_song = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isset ($incoming_fields ["notification_sound"]) && !empty ($incoming_fields["notification_sound"]))
|
||||||
|
{
|
||||||
|
$file = $request->file ("notification_sound");
|
||||||
|
Storage::disk ("public")->put ("notification_sounds/" . $fname . ".mp3", file_get_contents ($file));
|
||||||
|
|
||||||
|
$old_notification_sound = "notification_sounds/" . $user->notification_sound;
|
||||||
|
$user->notification_sound = $fname . ".mp3";
|
||||||
|
$changing_notification_sound = true;
|
||||||
|
}
|
||||||
|
|
||||||
$user->bio = $incoming_fields["bio"];
|
$user->bio = $incoming_fields["bio"];
|
||||||
$user->about_you = $incoming_fields["about_you"];
|
$user->about_you = $incoming_fields["about_you"];
|
||||||
$user->status = $incoming_fields["status"];
|
$user->status = $incoming_fields["status"];
|
||||||
@ -128,6 +141,9 @@ class ProfileController extends Controller
|
|||||||
if ($changing_song)
|
if ($changing_song)
|
||||||
Storage::disk ("public")->delete (str_replace ("/storage/", "", $old_song));
|
Storage::disk ("public")->delete (str_replace ("/storage/", "", $old_song));
|
||||||
|
|
||||||
|
if ($changing_notification_sound)
|
||||||
|
Storage::disk ("public")->delete (str_replace ("/storage/", "", $old_notification_sound));
|
||||||
|
|
||||||
$response = ActionsUser::update_profile ();
|
$response = ActionsUser::update_profile ();
|
||||||
if (isset ($response["error"]))
|
if (isset ($response["error"]))
|
||||||
return back ()->with ("error", "Error updating profile: " . $response["error"]);
|
return back ()->with ("error", "Error updating profile: " . $response["error"]);
|
||||||
|
@ -82,6 +82,13 @@ class User extends Authenticatable
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function notificationSound () : Attribute
|
||||||
|
{
|
||||||
|
return Attribute::make (get: function ($value) {
|
||||||
|
return $value ? "/storage/notification_sounds/" . $value : "/resources/sounds/notification.mp3";
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public function actor ()
|
public function actor ()
|
||||||
{
|
{
|
||||||
return $this->hasOne (Actor::class);
|
return $this->hasOne (Actor::class);
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
@if (auth ()->check ())
|
@if (auth ()->check ())
|
||||||
<script>
|
<script>
|
||||||
const notification_sound = new Audio ("/resources/sounds/notification.mp3")
|
const notification_sound = new Audio ("{{ auth ()->user ()->notification_sound }}")
|
||||||
|
|
||||||
function register_echo ()
|
function register_echo ()
|
||||||
{
|
{
|
||||||
|
@ -36,8 +36,14 @@
|
|||||||
@error("song")
|
@error("song")
|
||||||
<p class="error">{{ $message }}</p>
|
<p class="error">{{ $message }}</p>
|
||||||
@enderror
|
@enderror
|
||||||
|
<small>Max file size: 4MB</small>
|
||||||
|
<br><br>
|
||||||
|
<small>Select custom notification sound:</small>
|
||||||
|
<input type="file" name="notification_sound" accept="audio/*"><br>
|
||||||
|
@error("notification_sound")
|
||||||
|
<p class="error">{{ $message }}</p>
|
||||||
|
@enderror
|
||||||
<small>Max file size: 1MB</small>
|
<small>Max file size: 1MB</small>
|
||||||
<br>
|
|
||||||
<h1>Bio:</h1>
|
<h1>Bio:</h1>
|
||||||
<br>
|
<br>
|
||||||
<textarea name="bio" id="bio" cols="58" placeholder="Bio">{{ $user->bio }}</textarea>
|
<textarea name="bio" id="bio" cols="58" placeholder="Bio">{{ $user->bio }}</textarea>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user