Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions routers/web/user/avatar.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@ import (

"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/httpcache"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
)

func doRedirect(ctx *context.Context, location string) {
ctx.Resp.Header().Set("Cache-Control", httpcache.GetCacheControl())
ctx.Redirect(location)
}

// Avatar redirect browser to user avatar of requested size
func Avatar(ctx *context.Context) {
userName := ctx.Params(":username")
Expand All @@ -43,7 +49,7 @@ func Avatar(ctx *context.Context) {
user = models.NewGhostUser()
}

ctx.Redirect(user.RealSizedAvatarLink(size))
doRedirect(ctx, user.RealSizedAvatarLink(size))
}

// AvatarByEmailHash redirects the browser to the appropriate Avatar link
Expand All @@ -63,7 +69,7 @@ func AvatarByEmailHash(ctx *context.Context) {
return
}
if len(email) == 0 {
ctx.Redirect(models.DefaultAvatarLink())
doRedirect(ctx, models.DefaultAvatarLink())
return
}
size := ctx.FormInt("size")
Expand Down Expand Up @@ -94,5 +100,5 @@ func AvatarByEmailHash(ctx *context.Context) {
}
}

ctx.Redirect(models.MakeFinalAvatarURL(avatarURL, size))
doRedirect(ctx, models.MakeFinalAvatarURL(avatarURL, size))
}