1
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-07-01 02:05:30 +00:00

Remove unused data from router

Co-authored-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt>
This commit is contained in:
Rafael Girão 2024-06-11 18:49:23 +00:00
parent 1b3b35def8
commit eb00a7e733

View File

@ -6,7 +6,6 @@ package setting
import ( import (
"errors" "errors"
"net/http" "net/http"
"time"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/base" "code.gitea.io/gitea/modules/base"
@ -101,25 +100,17 @@ func loadNotificationsData(ctx *context.Context) {
} }
type UserEmail struct { type UserEmail struct {
user_model.EmailAddress user_model.EmailAddress
CanBePrimary bool
} }
pendingActivation := ctx.Cache.IsExist("MailResendLimit_" + ctx.Doer.LowerName)
emails := make([]*UserEmail, len(emlist)) emails := make([]*UserEmail, len(emlist))
for i, em := range emlist { for i, em := range emlist {
if !em.IsActivated {
continue
}
var email UserEmail var email UserEmail
email.EmailAddress = *em email.EmailAddress = *em
email.CanBePrimary = em.IsActivated
emails[i] = &email emails[i] = &email
} }
ctx.Data["Emails"] = emails ctx.Data["Emails"] = emails
ctx.Data["EmailNotificationsPreference"] = ctx.Doer.EmailNotificationsPreference ctx.Data["EmailNotificationsPreference"] = ctx.Doer.EmailNotificationsPreference
ctx.Data["UINotificationsPreference"] = ctx.Doer.UINotificationsPreference ctx.Data["UINotificationsPreference"] = ctx.Doer.UINotificationsPreference
ctx.Data["ActivationsPending"] = pendingActivation
ctx.Data["CanAddEmails"] = !pendingActivation || !setting.Service.RegisterEmailConfirm
ctx.Data["UserDisabledFeatures"] = user_model.DisabledFeaturesWithLoginType(ctx.Doer)
if setting.Service.UserDeleteWithCommentsMaxTime != 0 {
ctx.Data["UserDeleteWithCommentsMaxTime"] = setting.Service.UserDeleteWithCommentsMaxTime.String()
ctx.Data["UserDeleteWithComments"] = ctx.Doer.CreatedUnix.AsTime().Add(setting.Service.UserDeleteWithCommentsMaxTime).After(time.Now())
}
} }