You've already forked top-wallpaper
Simplify httpGet function in client_test.go for cleaner code
This commit is contained in:
@@ -63,13 +63,16 @@ func Fetch(ctx context.Context) {
|
|||||||
|
|
||||||
func doFetch(rc *redis.Redis, l echo.Logger, nsfw bool, size int) {
|
func doFetch(rc *redis.Redis, l echo.Logger, nsfw bool, size int) {
|
||||||
val, err := rc.Get(rc.GetCacheKey(nsfw))
|
val, err := rc.Get(rc.GetCacheKey(nsfw))
|
||||||
|
|
||||||
|
l.Info("Checking cache for Reddit image...", " nsfw=", nsfw)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
l.Error("Error fetching from Redis: ", err)
|
l.Error("Error fetching from Redis: ", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if val != "" {
|
if val != "" {
|
||||||
l.Info("Reddit image fetched from cache...")
|
l.Info("Reddit image is in cache... skipping...")
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -79,8 +82,7 @@ func doFetch(rc *redis.Redis, l echo.Logger, nsfw bool, size int) {
|
|||||||
latestImageVal, err := GetLatestImage(func() (*http.Response, error) {
|
latestImageVal, err := GetLatestImage(func() (*http.Response, error) {
|
||||||
|
|
||||||
jsonUrl := wallpaperURL
|
jsonUrl := wallpaperURL
|
||||||
nsfwMode := os.Getenv("NSFW_MODE")
|
if nsfw {
|
||||||
if nsfwMode == "true" {
|
|
||||||
jsonUrl = nsfwWallpaperURL
|
jsonUrl = nsfwWallpaperURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user