Skip to content

Commit ae9d629

Browse files
committed
Merge remote-tracking branch 'origin/main' into zzc/dev/sidebar_board_option
2 parents 7e1b786 + 1f8ac27 commit ae9d629

File tree

23 files changed

+326
-86
lines changed

23 files changed

+326
-86
lines changed

.devcontainer/devcontainer.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
"ghcr.io/devcontainers-contrib/features/poetry:2": {},
1111
"ghcr.io/devcontainers/features/python:1": {
1212
"version": "3.12"
13-
}
13+
},
14+
"ghcr.io/warrenbuckley/codespace-features/sqlite:1": {}
1415
},
1516
"customizations": {
1617
"vscode": {
@@ -25,7 +26,7 @@
2526
"Vue.volar",
2627
"ms-azuretools.vscode-docker",
2728
"vitest.explorer",
28-
"qwtel.sqlite-viewer",
29+
"cweijan.vscode-database-client2",
2930
"GitHub.vscode-pull-request-github",
3031
"Azurite.azurite"
3132
]

.gitpod.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ vscode:
4343
- Vue.volar
4444
- ms-azuretools.vscode-docker
4545
- vitest.explorer
46-
- qwtel.sqlite-viewer
46+
- cweijan.vscode-database-client2
4747
- GitHub.vscode-pull-request-github
4848

4949
ports:

Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ COMMA := ,
2525

2626
XGO_VERSION := go-1.22.x
2727

28-
AIR_PACKAGE ?= github.com/cosmtrek/air@v1
28+
AIR_PACKAGE ?= github.com/air-verse/air@v1
2929
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/cmd/[email protected]
3030
GOFUMPT_PACKAGE ?= mvdan.cc/[email protected]
31-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.57.2
31+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.0
3232
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/[email protected]
3333
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/[email protected]
3434
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@db51e79a0e37c572d8b59ae0c58bf2bbbbe53285

custom/conf/app.example.ini

+10
Original file line numberDiff line numberDiff line change
@@ -1687,6 +1687,16 @@ LEVEL = Info
16871687
;; convert \r\n to \n for Sendmail
16881688
;SENDMAIL_CONVERT_CRLF = true
16891689

1690+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1691+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1692+
;[mailer.override_header]
1693+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1694+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1695+
;; This is empty by default, use it only if you know what you need it for.
1696+
1697+
;Content-Type = text/html; charset=utf-8
1698+
;In-Reply-To =
1699+
16901700
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16911701
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16921702
;[email.incoming]

docs/content/administration/config-cheat-sheet.en-us.md

+18-1
Original file line numberDiff line numberDiff line change
@@ -724,11 +724,13 @@ Define allowed algorithms and their minimum key length (use -1 to disable a type
724724

725725
## Mailer (`mailer`)
726726

727-
⚠️ This section is for Gitea 1.18 and later. If you are using Gitea 1.17 or older,
727+
:::warning
728+
This section is for Gitea 1.18 and later. If you are using Gitea 1.17 or older,
728729
please refer to
729730
[Gitea 1.17 app.ini example](https://github.com/go-gitea/gitea/blob/release/v1.17/custom/conf/app.example.ini)
730731
and
731732
[Gitea 1.17 configuration document](https://github.com/go-gitea/gitea/blob/release/v1.17/docs/content/doc/advanced/config-cheat-sheet.en-us.md)
733+
:::
732734

733735
- `ENABLED`: **false**: Enable to use a mail service.
734736
- `PROTOCOL`: **_empty_**: Mail server protocol. One of "smtp", "smtps", "smtp+starttls", "smtp+unix", "sendmail", "dummy". _Before 1.18, this was inferred from a combination of `MAILER_TYPE` and `IS_TLS_ENABLED`._
@@ -761,6 +763,21 @@ and
761763
- `SEND_BUFFER_LEN`: **100**: Buffer length of mailing queue. **DEPRECATED** use `LENGTH` in `[queue.mailer]`
762764
- `SEND_AS_PLAIN_TEXT`: **false**: Send mails only in plain text, without HTML alternative.
763765

766+
## Override Email Headers (`mailer.override_header`)
767+
768+
:::warning
769+
This is empty by default, use it only if you know what you need it for.
770+
:::
771+
772+
examples would be:
773+
774+
```ini
775+
[mailer.override_header]
776+
777+
Content-Type = text/html; charset=utf-8
778+
In-Reply-To =
779+
```
780+
764781
## Incoming Email (`email.incoming`)
765782

766783
- `ENABLED`: **false**: Enable handling of incoming emails.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ require (
2020
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
2121
github.com/ProtonMail/go-crypto v1.0.0
2222
github.com/PuerkitoBio/goquery v1.9.1
23-
github.com/alecthomas/chroma/v2 v2.13.0
23+
github.com/alecthomas/chroma/v2 v2.14.0
2424
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
2525
github.com/blevesearch/bleve/v2 v2.3.10
2626
github.com/buildkite/terminal-to-html/v3 v3.11.0

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ github.com/RoaringBitmap/roaring v0.4.23/go.mod h1:D0gp8kJQgE1A4LQ5wFLggQEyvDi06
8282
github.com/RoaringBitmap/roaring v0.7.1/go.mod h1:jdT9ykXwHFNdJbEtxePexlFYH9LXucApeS0/+/g+p1I=
8383
github.com/RoaringBitmap/roaring v1.9.0 h1:lwKhr90/j0jVXJyh5X+vQN1VVn77rQFfYnh6RDRGCcE=
8484
github.com/RoaringBitmap/roaring v1.9.0/go.mod h1:6AXUsoIEzDTFFQCe1RbGA6uFONMhvejWj5rqITANK90=
85-
github.com/alecthomas/assert/v2 v2.6.0 h1:o3WJwILtexrEUk3cUVal3oiQY2tfgr/FHWiz/v2n4FU=
86-
github.com/alecthomas/assert/v2 v2.6.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
85+
github.com/alecthomas/assert/v2 v2.7.0 h1:QtqSACNS3tF7oasA8CU6A6sXZSBDqnm7RfpLl9bZqbE=
86+
github.com/alecthomas/assert/v2 v2.7.0/go.mod h1:Bze95FyfUr7x34QZrjL+XP+0qgp/zg8yS+TtBj1WA3k=
8787
github.com/alecthomas/chroma/v2 v2.2.0/go.mod h1:vf4zrexSH54oEjJ7EdB65tGNHmH3pGZmVkgTP5RHvAs=
88-
github.com/alecthomas/chroma/v2 v2.13.0 h1:VP72+99Fb2zEcYM0MeaWJmV+xQvz5v5cxRHd+ooU1lI=
89-
github.com/alecthomas/chroma/v2 v2.13.0/go.mod h1:BUGjjsD+ndS6eX37YgTchSEG+Jg9Jv1GiZs9sqPqztk=
88+
github.com/alecthomas/chroma/v2 v2.14.0 h1:R3+wzpnUArGcQz7fCETQBzO5n9IMNi13iIs46aU4V9E=
89+
github.com/alecthomas/chroma/v2 v2.14.0/go.mod h1:QolEbTfmUHIMVpBqxeDnNBj2uoeI4EbYP4i6n68SG4I=
9090
github.com/alecthomas/repr v0.0.0-20220113201626-b1b626ac65ae/go.mod h1:2kn6fqh/zIyPLmm3ugklbEi5hg5wS435eygvNfaDQL8=
9191
github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc=
9292
github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4=

modules/setting/mailer.go

+15-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,15 @@ import (
1818
// Mailer represents mail service.
1919
type Mailer struct {
2020
// Mailer
21-
Name string `ini:"NAME"`
22-
From string `ini:"FROM"`
23-
EnvelopeFrom string `ini:"ENVELOPE_FROM"`
24-
OverrideEnvelopeFrom bool `ini:"-"`
25-
FromName string `ini:"-"`
26-
FromEmail string `ini:"-"`
27-
SendAsPlainText bool `ini:"SEND_AS_PLAIN_TEXT"`
28-
SubjectPrefix string `ini:"SUBJECT_PREFIX"`
21+
Name string `ini:"NAME"`
22+
From string `ini:"FROM"`
23+
EnvelopeFrom string `ini:"ENVELOPE_FROM"`
24+
OverrideEnvelopeFrom bool `ini:"-"`
25+
FromName string `ini:"-"`
26+
FromEmail string `ini:"-"`
27+
SendAsPlainText bool `ini:"SEND_AS_PLAIN_TEXT"`
28+
SubjectPrefix string `ini:"SUBJECT_PREFIX"`
29+
OverrideHeader map[string][]string `ini:"-"`
2930

3031
// SMTP sender
3132
Protocol string `ini:"PROTOCOL"`
@@ -151,6 +152,12 @@ func loadMailerFrom(rootCfg ConfigProvider) {
151152
log.Fatal("Unable to map [mailer] section on to MailService. Error: %v", err)
152153
}
153154

155+
overrideHeader := rootCfg.Section("mailer.override_header").Keys()
156+
MailService.OverrideHeader = make(map[string][]string)
157+
for _, key := range overrideHeader {
158+
MailService.OverrideHeader[key.Name()] = key.Strings(",")
159+
}
160+
154161
// Infer SMTPPort if not set
155162
if MailService.SMTPPort == "" {
156163
switch MailService.Protocol {

modules/structs/activity.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ package structs
66
import "time"
77

88
type Activity struct {
9-
ID int64 `json:"id"`
10-
UserID int64 `json:"user_id"` // Receiver user
9+
ID int64 `json:"id"`
10+
UserID int64 `json:"user_id"` // Receiver user
11+
// the type of action
12+
//
13+
// enum: create_repo,rename_repo,star_repo,watch_repo,commit_repo,create_issue,create_pull_request,transfer_repo,push_tag,comment_issue,merge_pull_request,close_issue,reopen_issue,close_pull_request,reopen_pull_request,delete_tag,delete_branch,mirror_sync_push,mirror_sync_create,mirror_sync_delete,approve_pull_request,reject_pull_request,comment_pull,publish_release,pull_review_dismissed,pull_request_ready_for_review,auto_merge_pull_request
1114
OpType string `json:"op_type"`
1215
ActUserID int64 `json:"act_user_id"`
1316
ActUser *User `json:"act_user"`

package-lock.json

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"@citation-js/plugin-csl": "0.7.11",
1010
"@citation-js/plugin-software-formats": "0.6.1",
1111
"@github/markdown-toolbar-element": "2.2.3",
12-
"@github/relative-time-element": "4.4.0",
12+
"@github/relative-time-element": "4.4.1",
1313
"@github/text-expander-element": "2.6.1",
1414
"@mcaptcha/vanilla-glue": "0.1.0-alpha-3",
1515
"@primer/octicons": "19.9.0",

routers/api/packages/nuget/nuget.go

+29-19
Original file line numberDiff line numberDiff line change
@@ -96,20 +96,34 @@ func FeedCapabilityResource(ctx *context.Context) {
9696
xmlResponse(ctx, http.StatusOK, Metadata)
9797
}
9898

99-
var searchTermExtract = regexp.MustCompile(`'([^']+)'`)
99+
var (
100+
searchTermExtract = regexp.MustCompile(`'([^']+)'`)
101+
searchTermExact = regexp.MustCompile(`\s+eq\s+'`)
102+
)
100103

101-
func getSearchTerm(ctx *context.Context) string {
104+
func getSearchTerm(ctx *context.Context) packages_model.SearchValue {
102105
searchTerm := strings.Trim(ctx.FormTrim("searchTerm"), "'")
103-
if searchTerm == "" {
104-
// $filter contains a query like:
105-
// (((Id ne null) and substringof('microsoft',tolower(Id)))
106-
// We don't support these queries, just extract the search term.
107-
match := searchTermExtract.FindStringSubmatch(ctx.FormTrim("$filter"))
108-
if len(match) == 2 {
109-
searchTerm = strings.TrimSpace(match[1])
106+
if searchTerm != "" {
107+
return packages_model.SearchValue{
108+
Value: searchTerm,
109+
ExactMatch: false,
110+
}
111+
}
112+
113+
// $filter contains a query like:
114+
// (((Id ne null) and substringof('microsoft',tolower(Id)))
115+
// https://www.odata.org/documentation/odata-version-2-0/uri-conventions/ section 4.5
116+
// We don't support these queries, just extract the search term.
117+
filter := ctx.FormTrim("$filter")
118+
match := searchTermExtract.FindStringSubmatch(filter)
119+
if len(match) == 2 {
120+
return packages_model.SearchValue{
121+
Value: strings.TrimSpace(match[1]),
122+
ExactMatch: searchTermExact.MatchString(filter),
110123
}
111124
}
112-
return searchTerm
125+
126+
return packages_model.SearchValue{}
113127
}
114128

115129
// https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Protocol/LegacyFeed/V2FeedQueryBuilder.cs
@@ -118,11 +132,9 @@ func SearchServiceV2(ctx *context.Context) {
118132
paginator := db.NewAbsoluteListOptions(skip, take)
119133

120134
pvs, total, err := packages_model.SearchLatestVersions(ctx, &packages_model.PackageSearchOptions{
121-
OwnerID: ctx.Package.Owner.ID,
122-
Type: packages_model.TypeNuGet,
123-
Name: packages_model.SearchValue{
124-
Value: getSearchTerm(ctx),
125-
},
135+
OwnerID: ctx.Package.Owner.ID,
136+
Type: packages_model.TypeNuGet,
137+
Name: getSearchTerm(ctx),
126138
IsInternal: optional.Some(false),
127139
Paginator: paginator,
128140
})
@@ -169,10 +181,8 @@ func SearchServiceV2(ctx *context.Context) {
169181
// http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part2-url-conventions/odata-v4.0-errata03-os-part2-url-conventions-complete.html#_Toc453752351
170182
func SearchServiceV2Count(ctx *context.Context) {
171183
count, err := nuget_model.CountPackages(ctx, &packages_model.PackageSearchOptions{
172-
OwnerID: ctx.Package.Owner.ID,
173-
Name: packages_model.SearchValue{
174-
Value: getSearchTerm(ctx),
175-
},
184+
OwnerID: ctx.Package.Owner.ID,
185+
Name: getSearchTerm(ctx),
176186
IsInternal: optional.Some(false),
177187
})
178188
if err != nil {

routers/web/repo/issue_content_history.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ func GetContentHistoryDetail(ctx *context.Context) {
156156

157157
// use chroma to render the diff html
158158
diffHTMLBuf := bytes.Buffer{}
159-
diffHTMLBuf.WriteString("<pre class='chroma' style='tab-size: 4'>")
159+
diffHTMLBuf.WriteString("<pre class='chroma'>")
160160
for _, it := range diff {
161161
if it.Type == diffmatchpatch.DiffInsert {
162162
diffHTMLBuf.WriteString("<span class='gi'>")

services/gitdiff/gitdiff.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ func readFileName(rd *strings.Reader) (string, bool) {
10611061
char, _ := rd.ReadByte()
10621062
_ = rd.UnreadByte()
10631063
if char == '"' {
1064-
fmt.Fscanf(rd, "%q ", &name)
1064+
_, _ = fmt.Fscanf(rd, "%q ", &name)
10651065
if len(name) == 0 {
10661066
log.Error("Reader has no file name: reader=%+v", rd)
10671067
return "", true
@@ -1073,12 +1073,12 @@ func readFileName(rd *strings.Reader) (string, bool) {
10731073
} else {
10741074
// This technique is potentially ambiguous it may not be possible to uniquely identify the filenames from the diff line alone
10751075
ambiguity = true
1076-
fmt.Fscanf(rd, "%s ", &name)
1076+
_, _ = fmt.Fscanf(rd, "%s ", &name)
10771077
char, _ := rd.ReadByte()
10781078
_ = rd.UnreadByte()
10791079
for !(char == 0 || char == '"' || char == 'b') {
10801080
var suffix string
1081-
fmt.Fscanf(rd, "%s ", &suffix)
1081+
_, _ = fmt.Fscanf(rd, "%s ", &suffix)
10821082
name += " " + suffix
10831083
char, _ = rd.ReadByte()
10841084
_ = rd.UnreadByte()

services/mailer/mailer.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func (m *Message) ToMessage() *gomail.Message {
5757
msg.SetHeader(header, m.Headers[header]...)
5858
}
5959

60-
if len(setting.MailService.SubjectPrefix) > 0 {
60+
if setting.MailService.SubjectPrefix != "" {
6161
msg.SetHeader("Subject", setting.MailService.SubjectPrefix+" "+m.Subject)
6262
} else {
6363
msg.SetHeader("Subject", m.Subject)
@@ -79,6 +79,14 @@ func (m *Message) ToMessage() *gomail.Message {
7979
if len(msg.GetHeader("Message-ID")) == 0 {
8080
msg.SetHeader("Message-ID", m.generateAutoMessageID())
8181
}
82+
83+
for k, v := range setting.MailService.OverrideHeader {
84+
if len(msg.GetHeader(k)) != 0 {
85+
log.Debug("Mailer override header '%s' as per config", k)
86+
}
87+
msg.SetHeader(k, v...)
88+
}
89+
8290
return msg
8391
}
8492

0 commit comments

Comments
 (0)