diff --git a/models/avatars/avatar.go b/models/avatars/avatar.go index ad59bd8769..43d52c562b 100644 --- a/models/avatars/avatar.go +++ b/models/avatars/avatar.go @@ -165,10 +165,7 @@ func GenerateUserAvatarFastLink(userName string, size int) string { } // GenerateUserAvatarImageLink returns a link for `User.Avatar` image file: "/avatars/${User.Avatar}" -func GenerateUserAvatarImageLink(userAvatar string, size int) string { - if size > 0 { - return setting.AppSubURL + "/avatars/" + url.PathEscape(userAvatar) + "?size=" + strconv.Itoa(size) - } +func GenerateUserAvatarImageLink(userAvatar string) string { return setting.AppSubURL + "/avatars/" + url.PathEscape(userAvatar) } @@ -210,9 +207,6 @@ func generateEmailAvatarLink(ctx context.Context, email string, size int, final } // for non-final link, we should return fast (use a 302 redirection link) urlStr := setting.AppSubURL + "/avatar/" + url.PathEscape(emailHash) - if size > 0 { - urlStr += "?size=" + strconv.Itoa(size) - } return urlStr } diff --git a/models/user/avatar.go b/models/user/avatar.go index d534bd7bea..cc1b1b7b9d 100644 --- a/models/user/avatar.go +++ b/models/user/avatar.go @@ -60,7 +60,8 @@ func GenerateRandomAvatar(ctx context.Context, u *User) error { return nil } -// AvatarLinkWithSize returns a link to the user's avatar with size. size <= 0 means default size +// AvatarLinkWithSize returns a link to the user's avatar. Size is only used for +// GenerateEmailAvatarFastLink, for external email-based avatar services func (u *User) AvatarLinkWithSize(ctx context.Context, size int) string { if u.IsGhost() || u.ID <= 0 { return avatars.DefaultAvatarLink() @@ -88,7 +89,7 @@ func (u *User) AvatarLinkWithSize(ctx context.Context, size int) string { if u.Avatar == "" { return avatars.DefaultAvatarLink() } - return avatars.GenerateUserAvatarImageLink(u.Avatar, size) + return avatars.GenerateUserAvatarImageLink(u.Avatar) } return avatars.GenerateEmailAvatarFastLink(ctx, u.AvatarEmail, size) } diff --git a/modules/repository/commits_test.go b/modules/repository/commits_test.go index 4b6d4bfe51..ef998f7916 100644 --- a/modules/repository/commits_test.go +++ b/modules/repository/commits_test.go @@ -5,7 +5,6 @@ package repository import ( - "strconv" "testing" "time" @@ -13,7 +12,6 @@ import ( repo_model "forgejo.org/models/repo" "forgejo.org/models/unittest" "forgejo.org/modules/git" - "forgejo.org/modules/setting" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -126,7 +124,7 @@ func TestPushCommits_AvatarLink(t *testing.T) { } assert.Equal(t, - "/avatars/ab53a2911ddf9b4817ac01ddcd3d975f?size="+strconv.Itoa(28*setting.Avatar.RenderedSizeFactor), + "/avatars/ab53a2911ddf9b4817ac01ddcd3d975f", pushCommits.AvatarLink(db.DefaultContext, "user2@example.com")) assert.Equal(t, diff --git a/routers/web/user/setting/profile.go b/routers/web/user/setting/profile.go index e0ce88b582..125e387866 100644 --- a/routers/web/user/setting/profile.go +++ b/routers/web/user/setting/profile.go @@ -123,7 +123,6 @@ func ProfilePost(ctx *context.Context) { } // UpdateAvatarSetting update user's avatar -// FIXME: limit size. func UpdateAvatarSetting(ctx *context.Context, form *forms.AvatarForm, ctxUser *user_model.User) error { ctxUser.UseCustomAvatar = form.Source == forms.AvatarLocal if len(form.Gravatar) > 0 {