From 09c6cb71251599432b62972e4f97131223d8fb01 Mon Sep 17 00:00:00 2001 From: Laptop Date: Mon, 4 Nov 2024 18:30:08 +0200 Subject: [PATCH] fix default avatar not proxying; simplify /_/info endpoint code and make it dynamic incase you somehow change the settings at runtime --- lib/sc/user.go | 5 +++++ main.go | 16 +++++----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/lib/sc/user.go b/lib/sc/user.go index 8d25b22..6d9d5d8 100644 --- a/lib/sc/user.go +++ b/lib/sc/user.go @@ -158,6 +158,11 @@ func (u *User) Fix(large bool) { u.Avatar = strings.Replace(u.Avatar, "-large.", "-t200x200.", 1) } + // maybe hardcoding it isn't the best decision, but it should be ok + if u.Avatar == "https://a1.sndcdn.com/images/default_avatar_large.png" { + u.Avatar = "" + } + if cfg.ProxyImages && u.Avatar != "" { u.Avatar = "/_/proxy/images?url=" + url.QueryEscape(u.Avatar) } diff --git a/main.go b/main.go index 292b466..152f3c8 100644 --- a/main.go +++ b/main.go @@ -149,18 +149,12 @@ func main() { FullyPreloadTrack bool } - data, err := cfg.JSON.Marshal(info{ - ProxyImages: cfg.ProxyImages, - ProxyStreams: cfg.ProxyStreams, - FullyPreloadTrack: cfg.FullyPreloadTrack, - }) - if err != nil { - log.Println("Failed to marshal instance info:", err) - } - app.Get("/_/info", func(c *fiber.Ctx) error { - c.Set("Content-Type", "application/json") - return c.Send(data) + return c.JSON(info{ + ProxyImages: cfg.ProxyImages, + ProxyStreams: cfg.ProxyStreams, + FullyPreloadTrack: cfg.FullyPreloadTrack, + }) }) }