Skip to content

Commit

Permalink
Merge remote-tracking branch 'giteaofficial/main'
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
zjjhot committed Mar 21, 2022
2 parents 9d7ab3c + c604c9a commit aa07464
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 33 deletions.
3 changes: 2 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ linters:
#- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
- gofmt
- misspell
#- gocritic # TODO: disabled until fixed with go 1.18
- gocritic
- bidichk
- ineffassign
- revive
Expand All @@ -23,6 +23,7 @@ linters:
fast: false

run:
go: 1.18
timeout: 10m
skip-dirs:
- node_modules
Expand Down
22 changes: 13 additions & 9 deletions modules/git/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,16 @@ func (repo *Repository) IsEmpty() (bool, error) {

// CloneRepoOptions options when clone a repository
type CloneRepoOptions struct {
Timeout time.Duration
Mirror bool
Bare bool
Quiet bool
Branch string
Shared bool
NoCheckout bool
Depth int
Filter string
Timeout time.Duration
Mirror bool
Bare bool
Quiet bool
Branch string
Shared bool
NoCheckout bool
Depth int
Filter string
SkipTLSVerify bool
}

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

cmd := NewCommandContextNoGlobals(ctx, args...).AddArguments("clone")
if opts.SkipTLSVerify {
cmd.AddArguments("-c", "http.sslVerify=false")
}
if opts.Mirror {
cmd.AddArguments("--mirror")
}
Expand Down
16 changes: 9 additions & 7 deletions modules/repository/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,10 @@ func MigrateRepositoryGitData(ctx context.Context, u *user_model.User,
}

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

if err = git.Clone(ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{
Mirror: true,
Quiet: true,
Timeout: migrateTimeout,
Branch: "master",
Mirror: true,
Quiet: true,
Timeout: migrateTimeout,
Branch: "master",
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
}); err != nil {
log.Warn("Clone wiki: %v", err)
if err := util.RemoveAll(wikiPath); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions options/license/mplus
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

These fonts are free softwares. Unlimited permission is
granted to use, copy, and distribute it, with or without
modification, either commercially and noncommercially.
THESE FONTS ARE PROVIDED "AS IS" WITHOUT WARRANTY.

3 changes: 3 additions & 0 deletions options/locale/locale_es-ES.ini
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ register_helper_msg=¿Ya tienes una cuenta? ¡Inicia sesión!
social_register_helper_msg=¿Ya tienes una cuenta? ¡Enlázala!
disable_register_prompt=Registro deshabilitado. Por favor, póngase en contacto con el administrador del sitio.
disable_register_mail=Correo electrónico de confirmación de registro deshabilitado.
manual_activation_only=Póngase en contacto con el administrador del sitio para completar la activación.
remember_me=Recordar este Dispositivo
forgot_password_title=He olvidado mi contraseña
forgot_password=¿Has olvidado tu contraseña?
Expand Down Expand Up @@ -558,6 +559,8 @@ comment_type_group_assignee=Asignado
comment_type_group_title=Título
comment_type_group_branch=Rama
comment_type_group_time_tracking=Seguimiento de Tiempo
comment_type_group_deadline=Fecha límite
comment_type_group_dependency=Dependencia
privacy=Privacidad
keep_activity_private=Ocultar la actividad de la página del perfil
keep_activity_private_popup=Hace la actividad visible sólo para ti y los administradores
Expand Down
4 changes: 4 additions & 0 deletions options/locale/locale_ja-JP.ini
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ register_helper_msg=既にアカウントをお持ちですか? 今すぐサ
social_register_helper_msg=既にアカウントをお持ちですか? 今すぐ連携しましょう!
disable_register_prompt=登録は無効になっています。 サイト管理者にお問い合わせください。
disable_register_mail=登録でのメール確認は無効になっています。
manual_activation_only=アクティベーションを完了するにはサイト管理者に連絡してください。
remember_me=このデバイスで自動サインイン
forgot_password_title=パスワードを忘れた
forgot_password=パスワードをお忘れですか?
Expand Down Expand Up @@ -1374,6 +1375,9 @@ issues.lock.reason=ロックする理由
issues.lock.title=このイシューの会話をロックします。
issues.unlock.title=このイシューの会話をアンロックします。
issues.comment_on_locked=ロックされているイシューにコメントはできません。
issues.delete=削除
issues.delete.title=このイシューを削除しますか?
issues.delete.text=本当にこのイシューを削除しますか? (これはすべてのコンテンツを完全に削除します。 保存しておきたい場合は、代わりにクローズすることを検討してください)
issues.tracker=タイムトラッカー
issues.start_tracking_short=タイマー 開始
issues.start_tracking=タイムトラッキングを開始
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_pt-PT.ini
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ register_helper_msg=Já tem uma conta? Inicie a sessão agora!
social_register_helper_msg=Já tem uma conta? Associe-a agora!
disable_register_prompt=As inscrições estão desabilitadas. Entre em contacto com o administrador do sítio.
disable_register_mail=A confirmação por email da inscrição está desabilitada.
manual_activation_only=Contacte o administrador para completar a habilitação.
remember_me=Memorizar este dispositivo
forgot_password_title=Esqueci-me da senha
forgot_password=Esqueceu a sua senha?
Expand Down
6 changes: 6 additions & 0 deletions options/locale/locale_zh-TW.ini
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ register_helper_msg=已經有帳戶了?立即登入!
social_register_helper_msg=已經有帳戶了?立即連結!
disable_register_prompt=註冊功能已停用。 請聯繫您的網站管理員。
disable_register_mail=已停用註冊確認電子郵件。
manual_activation_only=請聯絡您的網站管理員以完成啟用程序。
remember_me=記得這個裝置
forgot_password_title=忘記密碼
forgot_password=忘記密碼?
Expand Down Expand Up @@ -1181,6 +1182,7 @@ projects.board.deletion_desc=刪除專案看板會將所有相關的問題移動
projects.board.color=顏色
projects.open=開啟
projects.close=關閉
projects.board.assigned_to=指派給

issues.desc=管理錯誤報告、任務和里程碑。
issues.filter_assignees=篩選負責人
Expand Down Expand Up @@ -1373,6 +1375,9 @@ issues.lock.reason=鎖定原因
issues.lock.title=鎖定此問題的對話。
issues.unlock.title=解鎖此問題的對話。
issues.comment_on_locked=您無法在已鎖定的問題上留言。
issues.delete=刪除
issues.delete.title=刪除此問題?
issues.delete.text=您真的要刪除此問題嗎?(這將會永久移除所有內容。若您還想保留,請考慮改為關閉它。)
issues.tracker=時間追蹤
issues.start_tracking_short=開始計時
issues.start_tracking=開始時間追蹤
Expand Down Expand Up @@ -1786,6 +1791,7 @@ settings.pulls.allow_rebase_merge_commit=啟用 Rebase 顯式合併提交(--no-f
settings.pulls.allow_squash_commits=啟用 Squash 合併提交
settings.pulls.allow_manual_merge=允許將合併請求標記為手動合併
settings.pulls.enable_autodetect_manual_merge=啟用自動偵測手動合併(注意:在某些特殊情況下可能發生誤判)
settings.pulls.allow_rebase_update=啟用透過 Rebase 更新合併請求分支
settings.pulls.default_delete_branch_after_merge=預設在合併後刪除合併請求分支
settings.projects_desc=啟用儲存庫專案
settings.admin_settings=管理員設定
Expand Down
13 changes: 9 additions & 4 deletions routers/api/v1/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,18 +245,23 @@ func SearchIssues(ctx *context.APIContext) {
UpdatedAfterUnix: since,
}

ctxUserID := int64(0)
if ctx.IsSigned {
ctxUserID = ctx.User.ID
}

// Filter for: Created by User, Assigned to User, Mentioning User, Review of User Requested
if ctx.FormBool("created") {
issuesOpt.PosterID = ctx.User.ID
issuesOpt.PosterID = ctxUserID
}
if ctx.FormBool("assigned") {
issuesOpt.AssigneeID = ctx.User.ID
issuesOpt.AssigneeID = ctxUserID
}
if ctx.FormBool("mentioned") {
issuesOpt.MentionedID = ctx.User.ID
issuesOpt.MentionedID = ctxUserID
}
if ctx.FormBool("review_requested") {
issuesOpt.ReviewRequestedID = ctx.User.ID
issuesOpt.ReviewRequestedID = ctxUserID
}

if issues, err = models.Issues(issuesOpt); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion routers/private/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func SendEmail(ctx *context.PrivateContext) {
}
} else {
err := user_model.IterateUser(func(user *user_model.User) error {
if len(user.Email) > 0 {
if len(user.Email) > 0 && user.IsActive {
emails = append(emails, user.Email)
}
return nil
Expand Down
5 changes: 5 additions & 0 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ func Routes(sessioner func(http.Handler) http.Handler) *web.Route {
http.Redirect(w, req, path.Join(setting.StaticURLPrefix, "/assets/img/apple-touch-icon.png"), 301)
})

// redirect default favicon to the path of the custom favicon with a default as a fallback
routes.Get("/favicon.ico", func(w http.ResponseWriter, req *http.Request) {
http.Redirect(w, req, path.Join(setting.StaticURLPrefix, "/assets/img/favicon.png"), 301)
})

common := []interface{}{}

if setting.EnableGzip {
Expand Down
12 changes: 8 additions & 4 deletions services/mailer/mail.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ func SendActivateEmailMail(u *user_model.User, email *user_model.EmailAddress) {

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

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

langMap := make(map[string][]*user_model.User)
for _, user := range recipients {
if !user.IsActive {
// don't send emails to inactive users
continue
}
langMap[user.Language] = append(langMap[user.Language], user)
}

Expand Down
4 changes: 4 additions & 0 deletions services/mailer/mail_issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ func mailIssueCommentBatch(ctx *mailCommentContext, users []*user_model.User, vi

langMap := make(map[string][]*user_model.User)
for _, user := range users {
if !user.IsActive {
// Exclude deactivated users
continue
}
// At this point we exclude:
// user that don't have all mails enabled or users only get mail on mention and this is one ...
if !(user.EmailNotificationsPreference == user_model.EmailNotificationsEnabled ||
Expand Down
4 changes: 4 additions & 0 deletions services/mailer/mail_repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func SendRepoTransferNotifyMail(doer, newOwner *user_model.User, repo *repo_mode

langMap := make(map[string][]string)
for _, user := range users {
if !user.IsActive {
// don't send emails to inactive users
continue
}
langMap[user.Language] = append(langMap[user.Language], user.Email)
}

Expand Down
17 changes: 10 additions & 7 deletions services/migrations/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"code.gitea.io/gitea/modules/log"
base "code.gitea.io/gitea/modules/migration"
"code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"

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

err = git.Clone(g.ctx, remoteAddr, repoPath, git.CloneRepoOptions{
Mirror: true,
Quiet: true,
Timeout: migrateTimeout,
Mirror: true,
Quiet: true,
Timeout: migrateTimeout,
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
})
if err != nil {
return fmt.Errorf("Clone: %v", err)
Expand All @@ -166,10 +168,11 @@ func (g *RepositoryDumper) CreateRepo(repo *base.Repository, opts base.MigrateOp
}

if err := git.Clone(g.ctx, wikiRemotePath, wikiPath, git.CloneRepoOptions{
Mirror: true,
Quiet: true,
Timeout: migrateTimeout,
Branch: "master",
Mirror: true,
Quiet: true,
Timeout: migrateTimeout,
Branch: "master",
SkipTLSVerify: setting.Migrations.SkipTLSVerify,
}); err != nil {
log.Warn("Clone wiki: %v", err)
if err := os.RemoveAll(wikiPath); err != nil {
Expand Down

0 comments on commit aa07464

Please sign in to comment.