]> source.dussan.org Git - gitea.git/commit
Avatar refactor, move avatar code from `models` to `models.avatars`, remove duplicate...
authorwxiaoguang <wxiaoguang@gmail.com>
Tue, 5 Oct 2021 23:25:46 +0000 (07:25 +0800)
committerGitHub <noreply@github.com>
Tue, 5 Oct 2021 23:25:46 +0000 (01:25 +0200)
commitf0ba87fda88c7bb601eee17f3e3a72bea8a71521
treecb5caf3a22fceaec8d2d421bec0cb094ecdb9c53
parent48c2578bd8ce4ddd90bf926bd40388f57c90fe14
Avatar refactor, move avatar code from `models` to `models.avatars`, remove duplicated code (#17123)

Why this refactor

The goal is to move most files from `models` package to `models.xxx` package. Many models depend on avatar model, so just move this first.

And the existing logic is not clear, there are too many function like `AvatarLink`, `RelAvatarLink`, `SizedRelAvatarLink`, `SizedAvatarLink`, `MakeFinalAvatarURL`, `HashedAvatarLink`, etc. This refactor make everything clear:

* user.AvatarLink()
* user.AvatarLinkWithSize(size)
* avatars.GenerateEmailAvatarFastLink(email, size)
* avatars.GenerateEmailAvatarFinalLink(email, size)

And many duplicated code are deleted in route handler, the handler and the model share the same avatar logic now.
16 files changed:
integrations/user_avatar_test.go
models/avatar.go [deleted file]
models/avatar_test.go [deleted file]
models/avatars/avatar.go [new file with mode: 0644]
models/avatars/avatar_test.go [new file with mode: 0644]
models/user_avatar.go
modules/httpcache/httpcache.go
modules/httpcache/httpcache_test.go
modules/repository/commits.go
modules/templates/helper.go
routers/web/repo/issue.go
routers/web/user/avatar.go
routers/web/web.go
services/auth/sspi_windows.go
templates/base/head.tmpl
templates/repo/issue/view_content/comments.tmpl