From 2559b0cf16d5243f7396bf7b30166b9dbfb69d09 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Mon, 6 Mar 2023 17:42:30 -0500 Subject: [PATCH] experiment with allowing user avatar to be visible --- web.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/web.go b/web.go index 274559f..5b900c0 100644 --- a/web.go +++ b/web.go @@ -2112,11 +2112,29 @@ func somedays() string { return fmt.Sprintf("%d", secs) } +func lookatme(ava string) string { + if strings.Contains(ava, serverName + "/" + userSep) { + idx := strings.LastIndexByte(ava, '/') + if idx < len(ava) { + name := ava[idx+1:] + user, _ := butwhatabout(name) + if user != nil && user.URL == ava { + return user.Options.Avatar + } + } + } + return "" +} + func avatate(w http.ResponseWriter, r *http.Request) { if develMode { loadAvatarColors() } n := r.FormValue("a") + if redir := lookatme(n); redir != "" { + http.Redirect(w, r, redir, http.StatusSeeOther) + return + } a := genAvatar(n) if !develMode { w.Header().Set("Cache-Control", "max-age="+somedays())