Skip to content

Commit 1bbc980

Browse files
committed
merge main branch
2 parents c1c1a8b + cc1f8cb commit 1bbc980

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+2209
-888
lines changed

.drone.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,10 @@ services:
230230
MINIO_ACCESS_KEY: 123456
231231
MINIO_SECRET_KEY: 12345678
232232

233+
- name: smtpimap
234+
image: tabascoterrier/docker-imap-devel:latest
235+
pull: always
236+
233237
steps:
234238
- name: fetch-tags
235239
image: docker:git

.golangci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,14 @@ linters-settings:
7676
extra-rules: true
7777
lang-version: "1.19"
7878
depguard:
79-
# TODO: use depguard to replace import checks in gitea-vet
8079
list-type: denylist
8180
# Check the list against standard lib.
8281
include-go-root: true
8382
packages-with-error-message:
8483
- encoding/json: "use gitea's modules/json instead of encoding/json"
8584
- github.com/unknwon/com: "use gitea's util and replacements"
85+
- io/ioutil: "use os or io instead"
86+
- golang.org/x/exp: "it's experimental and unreliable."
8687

8788
issues:
8889
max-issues-per-linter: 0

Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ $(EXECUTABLE): $(GO_SOURCES) $(TAGS_PREREQ)
751751
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) build $(GOFLAGS) $(EXTRA_GOFLAGS) -tags '$(TAGS)' -ldflags '-s -w $(LDFLAGS)' -o $@
752752

753753
.PHONY: release
754-
release: frontend generate release-windows release-linux release-darwin release-copy release-compress vendor release-sources release-docs release-check
754+
release: frontend generate release-windows release-linux release-darwin release-freebsd release-copy release-compress vendor release-sources release-docs release-check
755755

756756
$(DIST_DIRS):
757757
mkdir -p $(DIST_DIRS)
@@ -780,6 +780,13 @@ ifeq ($(CI),true)
780780
cp /build/* $(DIST)/binaries
781781
endif
782782

783+
.PHONY: release-freebsd
784+
release-freebsd: | $(DIST_DIRS)
785+
CGO_CFLAGS="$(CGO_CFLAGS)" $(GO) run $(XGO_PACKAGE) -go $(XGO_VERSION) -dest $(DIST)/binaries -tags 'netgo osusergo $(TAGS)' -ldflags '$(LDFLAGS)' -targets 'freebsd/amd64' -out gitea-$(VERSION) .
786+
ifeq ($(CI),true)
787+
cp /build/* $(DIST)/binaries
788+
endif
789+
783790
.PHONY: release-copy
784791
release-copy: | $(DIST_DIRS)
785792
cd $(DIST); for file in `find . -type f -name "*"`; do cp $${file} ./release/; done;

assets/go-licenses.json

Lines changed: 53 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/admin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ func parseSMTPConfig(c *cli.Context, conf *smtp.Source) error {
950950
if c.IsSet("auth-type") {
951951
conf.Auth = c.String("auth-type")
952952
validAuthTypes := []string{"PLAIN", "LOGIN", "CRAM-MD5"}
953-
if !contains(validAuthTypes, strings.ToUpper(c.String("auth-type"))) {
953+
if !util.SliceContainsString(validAuthTypes, strings.ToUpper(c.String("auth-type"))) {
954954
return errors.New("Auth must be one of PLAIN/LOGIN/CRAM-MD5")
955955
}
956956
conf.Auth = c.String("auth-type")

cmd/dump.go

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,6 @@ func runDump(ctx *cli.Context) error {
409409
return nil
410410
}
411411

412-
func contains(slice []string, s string) bool {
413-
for _, v := range slice {
414-
if v == s {
415-
return true
416-
}
417-
}
418-
return false
419-
}
420-
421412
// addRecursiveExclude zips absPath to specified insidePath inside writer excluding excludeAbsPath
422413
func addRecursiveExclude(w archiver.Writer, insidePath, absPath string, excludeAbsPath []string, verbose bool) error {
423414
absPath, err := filepath.Abs(absPath)
@@ -438,7 +429,7 @@ func addRecursiveExclude(w archiver.Writer, insidePath, absPath string, excludeA
438429
currentAbsPath := path.Join(absPath, file.Name())
439430
currentInsidePath := path.Join(insidePath, file.Name())
440431
if file.IsDir() {
441-
if !contains(excludeAbsPath, currentAbsPath) {
432+
if !util.SliceContainsString(excludeAbsPath, currentAbsPath) {
442433
if err := addFile(w, currentInsidePath, currentAbsPath, false); err != nil {
443434
return err
444435
}

custom/conf/app.example.ini

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1664,6 +1664,47 @@ ROUTER = console
16641664
;; convert \r\n to \n for Sendmail
16651665
;SENDMAIL_CONVERT_CRLF = true
16661666

1667+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1668+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1669+
;[email.incoming]
1670+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1671+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1672+
;;
1673+
;; Enable handling of incoming emails.
1674+
;ENABLED = false
1675+
;;
1676+
;; The email address including the %{token} placeholder that will be replaced per user/action.
1677+
;; Example: incoming+%{token}@example.com
1678+
;; The placeholder must appear in the user part of the address (before the @).
1679+
;REPLY_TO_ADDRESS =
1680+
;;
1681+
;; IMAP server host
1682+
;HOST =
1683+
;;
1684+
;; IMAP server port
1685+
;PORT =
1686+
;;
1687+
;; Username of the receiving account
1688+
;USERNAME =
1689+
;;
1690+
;; Password of the receiving account
1691+
;PASSWORD =
1692+
;;
1693+
;; Whether the IMAP server uses TLS.
1694+
;USE_TLS = false
1695+
;;
1696+
;; If set to true, completely ignores server certificate validation errors. This option is unsafe.
1697+
;SKIP_TLS_VERIFY = true
1698+
;;
1699+
;; The mailbox name where incoming mail will end up.
1700+
;MAILBOX = INBOX
1701+
;;
1702+
;; Whether handled messages should be deleted from the mailbox.
1703+
;DELETE_HANDLED_MESSAGE = true
1704+
;;
1705+
;; Maximum size of a message to handle. Bigger messages are ignored. Set to 0 to allow every size.
1706+
;MAXIMUM_MESSAGE_SIZE = 10485760
1707+
16671708
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16681709
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16691710
;[cache]

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,6 +750,20 @@ and
750750
- `SEND_BUFFER_LEN`: **100**: Buffer length of mailing queue. **DEPRECATED** use `LENGTH` in `[queue.mailer]`
751751
- `SEND_AS_PLAIN_TEXT`: **false**: Send mails only in plain text, without HTML alternative.
752752

753+
## Incoming Email (`email.incoming`)
754+
755+
- `ENABLED`: **false**: Enable handling of incoming emails.
756+
- `REPLY_TO_ADDRESS`: **\<empty\>**: The email address including the `%{token}` placeholder that will be replaced per user/action. Example: `incoming+%{token}@example.com`. The placeholder must appear in the user part of the address (before the `@`).
757+
- `HOST`: **\<empty\>**: IMAP server host.
758+
- `PORT`: **\<empty\>**: IMAP server port.
759+
- `USERNAME`: **\<empty\>**: Username of the receiving account.
760+
- `PASSWORD`: **\<empty\>**: Password of the receiving account.
761+
- `USE_TLS`: **false**: Whether the IMAP server uses TLS.
762+
- `SKIP_TLS_VERIFY`: **false**: If set to `true`, completely ignores server certificate validation errors. This option is unsafe.
763+
- `MAILBOX`: **INBOX**: The mailbox name where incoming mail will end up.
764+
- `DELETE_HANDLED_MESSAGE`: **true**: Whether handled messages should be deleted from the mailbox.
765+
- `MAXIMUM_MESSAGE_SIZE`: **10485760**: Maximum size of a message to handle. Bigger messages are ignored. Set to 0 to allow every size.
766+
753767
## Cache (`cache`)
754768

755769
- `ENABLED`: **true**: Enable the cache.
@@ -1048,7 +1062,7 @@ Default templates for project boards:
10481062

10491063
## Git - Timeout settings (`git.timeout`)
10501064

1051-
- `DEFAUlT`: **360**: Git operations default timeout seconds.
1065+
- `DEFAULT`: **360**: Git operations default timeout seconds.
10521066
- `MIGRATE`: **600**: Migrate external repositories timeout seconds.
10531067
- `MIRROR`: **300**: Mirror external repositories timeout seconds.
10541068
- `CLONE`: **300**: Git clone from internal repositories timeout seconds.

docs/content/doc/advanced/external-renderers.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,5 +192,5 @@ And so you could write some CSS:
192192
Add your stylesheet to your custom directory e.g `custom/public/css/my-style-XXXXX.css` and import it using a custom header file `custom/templates/custom/header.tmpl`:
193193

194194
```html
195-
<link type="text/css" href="{{AppSubUrl}}/assets/css/my-style-XXXXX.css" />
195+
<link rel="stylesheet" href="{{AppSubUrl}}/assets/css/my-style-XXXXX.css" />
196196
```

docs/content/doc/features/comparison.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ _Symbols used in table:_
106106
| Issue search ||||||||
107107
| Global issue search | [/](https://github.com/go-gitea/gitea/issues/2434) |||||||
108108
| Issue dependency ||||||||
109-
| Create issue via email | [](https://github.com/go-gitea/gitea/issues/6226) ||| ||||
109+
| Create issue via email | [](https://github.com/go-gitea/gitea/issues/6226) ||| ||||
110110
| Service Desk | [](https://github.com/go-gitea/gitea/issues/6219) |||||||
111111

112112
## Pull/Merge requests

docs/content/doc/features/comparison.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ _表格中的符号含义:_
9292
| 工单搜索 ||||||||
9393
| 工单全局搜索 | [](https://github.com/go-gitea/gitea/issues/2434) |||||||
9494
| 工单依赖关系 ||||||||
95-
| 通过 Email 创建工单 | [](https://github.com/go-gitea/gitea/issues/6226) | [](https://github.com/gogs/gogs/issues/2602) || ||||
95+
| 通过 Email 创建工单 | [](https://github.com/go-gitea/gitea/issues/6226) | [](https://github.com/gogs/gogs/issues/2602) || ||||
9696
| 服务台 | [](https://github.com/go-gitea/gitea/issues/6219) ||| [](https://gitlab.com/groups/gitlab-org/-/epics/3103) ||||
9797

9898
#### Pull/Merge requests

docs/content/doc/features/comparison.zh-tw.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ menu:
9393
| 問題搜尋 ||||||||
9494
| 全域問題搜尋 | [](https://github.com/go-gitea/gitea/issues/2434) |||||||
9595
| 問題相依 ||||||||
96-
| 從電子郵件建立問題 | [](https://github.com/go-gitea/gitea/issues/6226) | [](https://github.com/gogs/gogs/issues/2602) || ||||
96+
| 從電子郵件建立問題 | [](https://github.com/go-gitea/gitea/issues/6226) | [](https://github.com/gogs/gogs/issues/2602) || ||||
9797
| 服務台 | [](https://github.com/go-gitea/gitea/issues/6219) ||| [](https://gitlab.com/groups/gitlab-org/-/epics/3103) ||||
9898

9999
## 拉取/合併請求
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
date: "2022-12-01T00:00:00+00:00"
3+
title: "Incoming Email"
4+
slug: "incoming-email"
5+
draft: false
6+
toc: false
7+
menu:
8+
sidebar:
9+
parent: "usage"
10+
name: "Incoming Email"
11+
weight: 13
12+
identifier: "incoming-email"
13+
---
14+
15+
# Incoming Email
16+
17+
Gitea supports the execution of several actions through incoming mails. This page describes how to set this up.
18+
19+
**Table of Contents**
20+
21+
{{< toc >}}
22+
23+
## Requirements
24+
25+
Handling incoming email messages requires an IMAP-enabled email account.
26+
The recommended strategy is to use [email sub-addressing](https://en.wikipedia.org/wiki/Email_address#Sub-addressing) but a catch-all mailbox does work too.
27+
The receiving email address contains a user/action specific token which tells Gitea which action should be performed.
28+
This token is expected in the `To` and `Delivered-To` header fields.
29+
30+
Gitea tries to detect automatic responses to skip and the email server should be configured to reduce the incoming noise too (spam, newsletter).
31+
32+
## Configuration
33+
34+
To activate the handling of incoming email messages you have to configure the `email.incoming` section in the configuration file.
35+
36+
The `REPLY_TO_ADDRESS` contains the address an email client will respond to.
37+
This address needs to contain the `%{token}` placeholder which will be replaced with a token describing the user/action.
38+
This placeholder must only appear once in the address and must be in the user part of the address (before the `@`).
39+
40+
An example using email sub-addressing may look like this: `incoming+%{token}@example.com`
41+
42+
If a catch-all mailbox is used, the placeholder may be used anywhere in the user part of the address: `incoming+%{token}@example.com`, `incoming_%{token}@example.com`, `%{token}@example.com`
43+
44+
## Security
45+
46+
Be careful when choosing the domain used for receiving incoming email.
47+
It's recommended receiving incoming email on a subdomain, such as `incoming.example.com` to prevent potential security problems with other services running on `example.com`.

0 commit comments

Comments
 (0)