StarlioX/api/controllers/wallpaper.go

28 lines
588 B
Go
Raw Permalink Normal View History

2022-09-19 02:06:03 +03:00
package controllers
import (
2023-06-05 18:54:14 +03:00
"github.com/Redume/Starlio/utils"
"github.com/gofiber/fiber/v2"
2022-09-19 02:06:03 +03:00
"github.com/reujab/wallpaper"
)
var WallpaperUpdate = func(c *fiber.Ctx) error {
2022-09-19 02:06:03 +03:00
var url string
url = c.FormValue("url")
2022-09-19 02:06:03 +03:00
if url == "" {
utils.Respond(c, utils.Message(false, "URL is required"))
return nil
2022-09-19 02:06:03 +03:00
}
err := wallpaper.SetFromURL(url)
if err != nil {
utils.Logger(err.Error())
utils.Respond(c, utils.Message(false, "An error occurred while setting the wallpaper"))
return nil
2022-09-19 02:06:03 +03:00
}
utils.Respond(c, utils.Message(true, "Wallpaper successfully updated"))
return nil
2022-09-19 02:06:03 +03:00
}