Skip to content

Commit aa07464

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Add 1.18 (go-gitea#19151) [skip ci] Updated translations via Crowdin Fix NPE `/repos/issues/search` when not signed in (go-gitea#19154) [skip ci] Updated licenses and gitignores Use custom favicon when viewing static files if it exists (go-gitea#19130) not send notification emails to inactive users (part 2) (go-gitea#19142) Make migrations SKIP_TLS_VERIFY apply to git too (go-gitea#19132) Do not send notification emails to inactive users (go-gitea#19131)
2 parents 9d7ab3c + c604c9a commit aa07464

File tree

15 files changed

+85
-33
lines changed

15 files changed

+85
-33
lines changed

.golangci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ linters:
1313
#- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
1414
- gofmt
1515
- misspell
16-
#- gocritic # TODO: disabled until fixed with go 1.18
16+
- gocritic
1717
- bidichk
1818
- ineffassign
1919
- revive
@@ -23,6 +23,7 @@ linters:
2323
fast: false
2424

2525
run:
26+
go: 1.18
2627
timeout: 10m
2728
skip-dirs:
2829
- node_modules

modules/git/repo.go

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,16 @@ func (repo *Repository) IsEmpty() (bool, error) {
9898

9999
// CloneRepoOptions options when clone a repository
100100
type CloneRepoOptions struct {
101-
Timeout time.Duration
102-
Mirror bool
103-
Bare bool
104-
Quiet bool
105-
Branch string
106-
Shared bool
107-
NoCheckout bool
108-
Depth int
109-
Filter string
101+
Timeout time.Duration
102+
Mirror bool
103+
Bare bool
104+
Quiet bool
105+
Branch string
106+
Shared bool
107+
NoCheckout bool
108+
Depth int
109+
Filter string
110+
SkipTLSVerify bool
110111
}
111112

112113
// Clone clones original repository to target path.
@@ -124,6 +125,9 @@ func CloneWithArgs(ctx context.Context, from, to string, args []string, opts Clo
124125
}
125126

126127
cmd := NewCommandContextNoGlobals(ctx, args...).AddArguments("clone")
128+
if opts.SkipTLSVerify {
129+
cmd.AddArguments("-c", "http.sslVerify=false")
130+
}
127131
if opts.Mirror {
128132
cmd.AddArguments("--mirror")
129133
}

modules/repository/repo.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,10 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
7272
}
7373

7474
if err = git.Clone(ctx, opts.CloneAddr, repoPath, git.CloneRepoOptions{
75-
Mirror: true,
76-
Quiet: true,
77-
Timeout: migrateTimeout,
75+
Mirror: true,
76+
Quiet: true,
77+
Timeout: migrateTimeout,
78+
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
7879
}); err != nil {
7980
return repo, fmt.Errorf("Clone: %v", err)
8081
}
@@ -88,10 +89,11 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
8889
}
8990

9091
if err = git.Clone(ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{
91-
Mirror: true,
92-
Quiet: true,
93-
Timeout: migrateTimeout,
94-
Branch: "master",
92+
Mirror: true,
93+
Quiet: true,
94+
Timeout: migrateTimeout,
95+
Branch: "master",
96+
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
9597
}); err != nil {
9698
log.Warn("Clone wiki: %v", err)
9799
if err := util.RemoveAll(wikiPath); err != nil {

options/license/mplus

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
These fonts are free softwares. Unlimited permission is
3+
granted to use, copy, and distribute it, with or without
4+
modification, either commercially and noncommercially.
5+
THESE FONTS ARE PROVIDED "AS IS" WITHOUT WARRANTY.
6+

options/locale/locale_es-ES.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ register_helper_msg=¿Ya tienes una cuenta? ¡Inicia sesión!
282282
social_register_helper_msg=¿Ya tienes una cuenta? ¡Enlázala!
283283
disable_register_prompt=Registro deshabilitado. Por favor, póngase en contacto con el administrador del sitio.
284284
disable_register_mail=Correo electrónico de confirmación de registro deshabilitado.
285+
manual_activation_only=Póngase en contacto con el administrador del sitio para completar la activación.
285286
remember_me=Recordar este Dispositivo
286287
forgot_password_title=He olvidado mi contraseña
287288
forgot_password=¿Has olvidado tu contraseña?
@@ -558,6 +559,8 @@ comment_type_group_assignee=Asignado
558559
comment_type_group_title=Título
559560
comment_type_group_branch=Rama
560561
comment_type_group_time_tracking=Seguimiento de Tiempo
562+
comment_type_group_deadline=Fecha límite
563+
comment_type_group_dependency=Dependencia
561564
privacy=Privacidad
562565
keep_activity_private=Ocultar la actividad de la página del perfil
563566
keep_activity_private_popup=Hace la actividad visible sólo para ti y los administradores

options/locale/locale_ja-JP.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ register_helper_msg=既にアカウントをお持ちですか? 今すぐサ
282282
social_register_helper_msg=既にアカウントをお持ちですか? 今すぐ連携しましょう!
283283
disable_register_prompt=登録は無効になっています。 サイト管理者にお問い合わせください。
284284
disable_register_mail=登録でのメール確認は無効になっています。
285+
manual_activation_only=アクティベーションを完了するにはサイト管理者に連絡してください。
285286
remember_me=このデバイスで自動サインイン
286287
forgot_password_title=パスワードを忘れた
287288
forgot_password=パスワードをお忘れですか?
@@ -1374,6 +1375,9 @@ issues.lock.reason=ロックする理由
13741375
issues.lock.title=このイシューの会話をロックします。
13751376
issues.unlock.title=このイシューの会話をアンロックします。
13761377
issues.comment_on_locked=ロックされているイシューにコメントはできません。
1378+
issues.delete=削除
1379+
issues.delete.title=このイシューを削除しますか?
1380+
issues.delete.text=本当にこのイシューを削除しますか? (これはすべてのコンテンツを完全に削除します。 保存しておきたい場合は、代わりにクローズすることを検討してください)
13771381
issues.tracker=タイムトラッカー
13781382
issues.start_tracking_short=タイマー 開始
13791383
issues.start_tracking=タイムトラッキングを開始

options/locale/locale_pt-PT.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ register_helper_msg=Já tem uma conta? Inicie a sessão agora!
282282
social_register_helper_msg=Já tem uma conta? Associe-a agora!
283283
disable_register_prompt=As inscrições estão desabilitadas. Entre em contacto com o administrador do sítio.
284284
disable_register_mail=A confirmação por email da inscrição está desabilitada.
285+
manual_activation_only=Contacte o administrador para completar a habilitação.
285286
remember_me=Memorizar este dispositivo
286287
forgot_password_title=Esqueci-me da senha
287288
forgot_password=Esqueceu a sua senha?

options/locale/locale_zh-TW.ini

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ register_helper_msg=已經有帳戶了?立即登入!
282282
social_register_helper_msg=已經有帳戶了?立即連結!
283283
disable_register_prompt=註冊功能已停用。 請聯繫您的網站管理員。
284284
disable_register_mail=已停用註冊確認電子郵件。
285+
manual_activation_only=請聯絡您的網站管理員以完成啟用程序。
285286
remember_me=記得這個裝置
286287
forgot_password_title=忘記密碼
287288
forgot_password=忘記密碼?
@@ -1181,6 +1182,7 @@ projects.board.deletion_desc=刪除專案看板會將所有相關的問題移動
11811182
projects.board.color=顏色
11821183
projects.open=開啟
11831184
projects.close=關閉
1185+
projects.board.assigned_to=指派給
11841186

11851187
issues.desc=管理錯誤報告、任務和里程碑。
11861188
issues.filter_assignees=篩選負責人
@@ -1373,6 +1375,9 @@ issues.lock.reason=鎖定原因
13731375
issues.lock.title=鎖定此問題的對話。
13741376
issues.unlock.title=解鎖此問題的對話。
13751377
issues.comment_on_locked=您無法在已鎖定的問題上留言。
1378+
issues.delete=刪除
1379+
issues.delete.title=刪除此問題?
1380+
issues.delete.text=您真的要刪除此問題嗎?(這將會永久移除所有內容。若您還想保留,請考慮改為關閉它。)
13761381
issues.tracker=時間追蹤
13771382
issues.start_tracking_short=開始計時
13781383
issues.start_tracking=開始時間追蹤
@@ -1786,6 +1791,7 @@ settings.pulls.allow_rebase_merge_commit=啟用 Rebase 顯式合併提交(--no-f
17861791
settings.pulls.allow_squash_commits=啟用 Squash 合併提交
17871792
settings.pulls.allow_manual_merge=允許將合併請求標記為手動合併
17881793
settings.pulls.enable_autodetect_manual_merge=啟用自動偵測手動合併(注意:在某些特殊情況下可能發生誤判)
1794+
settings.pulls.allow_rebase_update=啟用透過 Rebase 更新合併請求分支
17891795
settings.pulls.default_delete_branch_after_merge=預設在合併後刪除合併請求分支
17901796
settings.projects_desc=啟用儲存庫專案
17911797
settings.admin_settings=管理員設定

routers/api/v1/repo/issue.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -245,18 +245,23 @@ func SearchIssues(ctx *context.APIContext) {
245245
UpdatedAfterUnix: since,
246246
}
247247

248+
ctxUserID := int64(0)
249+
if ctx.IsSigned {
250+
ctxUserID = ctx.User.ID
251+
}
252+
248253
// Filter for: Created by User, Assigned to User, Mentioning User, Review of User Requested
249254
if ctx.FormBool("created") {
250-
issuesOpt.PosterID = ctx.User.ID
255+
issuesOpt.PosterID = ctxUserID
251256
}
252257
if ctx.FormBool("assigned") {
253-
issuesOpt.AssigneeID = ctx.User.ID
258+
issuesOpt.AssigneeID = ctxUserID
254259
}
255260
if ctx.FormBool("mentioned") {
256-
issuesOpt.MentionedID = ctx.User.ID
261+
issuesOpt.MentionedID = ctxUserID
257262
}
258263
if ctx.FormBool("review_requested") {
259-
issuesOpt.ReviewRequestedID = ctx.User.ID
264+
issuesOpt.ReviewRequestedID = ctxUserID
260265
}
261266

262267
if issues, err = models.Issues(issuesOpt); err != nil {

routers/private/mail.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func SendEmail(ctx *context.PrivateContext) {
6060
}
6161
} else {
6262
err := user_model.IterateUser(func(user *user_model.User) error {
63-
if len(user.Email) > 0 {
63+
if len(user.Email) > 0 && user.IsActive {
6464
emails = append(emails, user.Email)
6565
}
6666
return nil

routers/web/web.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ func Routes(sessioner func(http.Handler) http.Handler) *web.Route {
9999
http.Redirect(w, req, path.Join(setting.StaticURLPrefix, "/assets/img/apple-touch-icon.png"), 301)
100100
})
101101

102+
// redirect default favicon to the path of the custom favicon with a default as a fallback
103+
routes.Get("/favicon.ico", func(w http.ResponseWriter, req *http.Request) {
104+
http.Redirect(w, req, path.Join(setting.StaticURLPrefix, "/assets/img/favicon.png"), 301)
105+
})
106+
102107
common := []interface{}{}
103108

104109
if setting.EnableGzip {

services/mailer/mail.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ func SendActivateEmailMail(u *user_model.User, email *user_model.EmailAddress) {
146146

147147
// SendRegisterNotifyMail triggers a notify e-mail by admin created a account.
148148
func SendRegisterNotifyMail(u *user_model.User) {
149-
if setting.MailService == nil {
150-
// No mail service configured
149+
if setting.MailService == nil || !u.IsActive {
150+
// No mail service configured OR user is inactive
151151
return
152152
}
153153
locale := translation.NewLocale(u.Language)
@@ -176,8 +176,8 @@ func SendRegisterNotifyMail(u *user_model.User) {
176176

177177
// SendCollaboratorMail sends mail notification to new collaborator.
178178
func SendCollaboratorMail(u, doer *user_model.User, repo *repo_model.Repository) {
179-
if setting.MailService == nil {
180-
// No mail service configured
179+
if setting.MailService == nil || !u.IsActive {
180+
// No mail service configured OR the user is inactive
181181
return
182182
}
183183
locale := translation.NewLocale(u.Language)
@@ -405,6 +405,10 @@ func SendIssueAssignedMail(issue *models.Issue, doer *user_model.User, content s
405405

406406
langMap := make(map[string][]*user_model.User)
407407
for _, user := range recipients {
408+
if !user.IsActive {
409+
// don't send emails to inactive users
410+
continue
411+
}
408412
langMap[user.Language] = append(langMap[user.Language], user)
409413
}
410414

services/mailer/mail_issue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,10 @@ func mailIssueCommentBatch(ctx *mailCommentContext, users []*user_model.User, vi
126126

127127
langMap := make(map[string][]*user_model.User)
128128
for _, user := range users {
129+
if !user.IsActive {
130+
// Exclude deactivated users
131+
continue
132+
}
129133
// At this point we exclude:
130134
// user that don't have all mails enabled or users only get mail on mention and this is one ...
131135
if !(user.EmailNotificationsPreference == user_model.EmailNotificationsEnabled ||

services/mailer/mail_repo.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ func SendRepoTransferNotifyMail(doer, newOwner *user_model.User, repo *repo_mode
3131

3232
langMap := make(map[string][]string)
3333
for _, user := range users {
34+
if !user.IsActive {
35+
// don't send emails to inactive users
36+
continue
37+
}
3438
langMap[user.Language] = append(langMap[user.Language], user.Email)
3539
}
3640

services/migrations/dump.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"code.gitea.io/gitea/modules/log"
2323
base "code.gitea.io/gitea/modules/migration"
2424
"code.gitea.io/gitea/modules/repository"
25+
"code.gitea.io/gitea/modules/setting"
2526
"code.gitea.io/gitea/modules/structs"
2627

2728
"gopkg.in/yaml.v2"
@@ -149,9 +150,10 @@ func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOp
149150
}
150151

151152
err = git.Clone(g.ctx, remoteAddr, repoPath, git.CloneRepoOptions{
152-
Mirror: true,
153-
Quiet: true,
154-
Timeout: migrateTimeout,
153+
Mirror: true,
154+
Quiet: true,
155+
Timeout: migrateTimeout,
156+
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
155157
})
156158
if err != nil {
157159
return fmt.Errorf("Clone: %v", err)
@@ -166,10 +168,11 @@ func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOp
166168
}
167169

168170
if err := git.Clone(g.ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{
169-
Mirror: true,
170-
Quiet: true,
171-
Timeout: migrateTimeout,
172-
Branch: "master",
171+
Mirror: true,
172+
Quiet: true,
173+
Timeout: migrateTimeout,
174+
Branch: "master",
175+
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
173176
}); err != nil {
174177
log.Warn("Clone wiki: %v", err)
175178
if err := os.RemoveAll(wikiPath); err != nil {

0 commit comments

Comments
 (0)