2022-09-19 02:06:03 +03:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
2023-03-18 16:40:05 +03:00
|
|
|
"github.com/Redume/EveryNasa/utils"
|
2022-10-23 15:26:51 +03:00
|
|
|
"github.com/gofiber/fiber/v2"
|
2022-09-19 02:06:03 +03:00
|
|
|
"github.com/reujab/wallpaper"
|
|
|
|
)
|
|
|
|
|
2022-10-23 15:26:51 +03:00
|
|
|
var WallpaperUpdate = func(c *fiber.Ctx) error {
|
2022-09-19 02:06:03 +03:00
|
|
|
var url string
|
2022-10-23 15:26:51 +03:00
|
|
|
url = c.FormValue("url")
|
2022-09-19 02:06:03 +03:00
|
|
|
if url == "" {
|
2022-10-23 15:26:51 +03:00
|
|
|
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 {
|
2023-03-18 16:40:05 +03:00
|
|
|
utils.Logger(err.Error())
|
2022-10-23 15:26:51 +03:00
|
|
|
utils.Respond(c, utils.Message(false, "An error occurred while setting the wallpaper"))
|
|
|
|
return nil
|
2022-09-19 02:06:03 +03:00
|
|
|
}
|
2022-10-02 12:21:25 +03:00
|
|
|
|
2022-10-23 15:26:51 +03:00
|
|
|
utils.Respond(c, utils.Message(true, "Wallpaper successfully updated"))
|
|
|
|
|
|
|
|
return nil
|
2022-09-19 02:06:03 +03:00
|
|
|
}
|