fix default avatar not proxying; simplify /_/info endpoint code and make it dynamic incase you somehow change the settings at runtime

This commit is contained in:
Laptop
2024-11-04 18:30:08 +02:00
parent fb5c597ec1
commit 09c6cb7125
2 changed files with 10 additions and 11 deletions

View File

@@ -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)
}

16
main.go
View File

@@ -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,
})
})
}