2022-09-19 02:06:03 +03:00
|
|
|
package controllers
|
|
|
|
|
|
|
|
import (
|
2022-10-02 12:21:25 +03:00
|
|
|
"net/http"
|
|
|
|
|
2022-09-19 02:06:03 +03:00
|
|
|
"github.com/Redume/EveryNasa/api/utils"
|
2022-09-25 11:04:39 +03:00
|
|
|
"github.com/Redume/EveryNasa/functions"
|
2022-09-19 02:06:03 +03:00
|
|
|
"github.com/reujab/wallpaper"
|
|
|
|
)
|
|
|
|
|
|
|
|
var WallpaperUpdate = func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
var url string
|
|
|
|
url = r.FormValue("url")
|
|
|
|
if url == "" {
|
|
|
|
utils.Respond(w, utils.Message(false, "URL is required"))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
err := wallpaper.SetFromURL(url)
|
|
|
|
if err != nil {
|
2022-09-25 11:04:39 +03:00
|
|
|
functions.Logger(err.Error())
|
2022-10-02 12:21:25 +03:00
|
|
|
utils.Respond(w, utils.Message(false, "An error occurred while setting the wallpaper"))
|
|
|
|
return
|
2022-09-19 02:06:03 +03:00
|
|
|
}
|
2022-10-02 12:21:25 +03:00
|
|
|
|
|
|
|
utils.Respond(w, utils.Message(true, "Wallpaper successfully updated"))
|
2022-09-19 02:06:03 +03:00
|
|
|
}
|