Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,12 @@ LEVEL = Info
;;
;; convert \r\n to \n for Sendmail
;SENDMAIL_CONVERT_CRLF = true
;;
;; convert links of attached images to inline images. Only for images hosted in this gitea instance.
;BASE64_EMBED_IMAGES = false
;;
;; The maximum size of sum of all images in a single email. Default is 9.5MB
;BASE64_EMBED_IMAGES_MAX_SIZE_PER_EMAIL = 9961472

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Expand Down
13 changes: 13 additions & 0 deletions models/fixtures/attachment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,3 +153,16 @@
download_count: 0
size: 0
created_unix: 946684800

-
id: 13
uuid: 1b267670-1793-4cd0-abc1-449269b7cff9
repo_id: 1
issue_id: 23
release_id: 0
uploader_id: 0
comment_id: 2
name: gitea.png
download_count: 0
size: 1458
created_unix: 946684800
17 changes: 17 additions & 0 deletions models/fixtures/issue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -372,3 +372,20 @@
created_unix: 1707270422
updated_unix: 1707270422
is_locked: false

-
id: 23
repo_id: 1
index: 6
poster_id: 1
original_author_id: 0
name: issue23
content: 'content including this image: <image alt="gitea.png" src="attachments/1b267670-1793-4cd0-abc1-449269b7cff9" /> with some more content behind it'
milestone_id: 0
priority: 0
is_closed: false
is_pull: false
num_comments: 0
created_unix: 946684801
updated_unix: 978307201
is_locked: false
2 changes: 1 addition & 1 deletion models/fixtures/issue_index.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
-
group_id: 1
max_index: 5
max_index: 6

-
group_id: 2
Expand Down
2 changes: 1 addition & 1 deletion models/fixtures/repository.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
num_watches: 4
num_stars: 0
num_forks: 0
num_issues: 2
num_issues: 3
num_closed_issues: 1
num_pulls: 3
num_closed_pulls: 0
Expand Down
10 changes: 5 additions & 5 deletions models/issues/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func Test_GetIssueIDsByRepoID(t *testing.T) {

ids, err := issues_model.GetIssueIDsByRepoID(db.DefaultContext, 1)
assert.NoError(t, err)
assert.Len(t, ids, 5)
assert.Len(t, ids, 6)
}

func TestIssueAPIURL(t *testing.T) {
Expand Down Expand Up @@ -170,7 +170,7 @@ func TestIssues(t *testing.T) {
PageSize: 4,
},
},
[]int64{1, 2, 3, 5},
[]int64{1, 23, 2, 3},
},
{
issues_model.IssuesOptions{
Expand Down Expand Up @@ -249,11 +249,11 @@ func TestIssue_InsertIssue(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())

// there are 5 issues and max index is 5 on repository 1, so this one should 6
issue := testInsertIssue(t, "my issue1", "special issue's comments?", 6)
issue := testInsertIssue(t, "my issue1", "special issue's comments?", 7)
_, err := db.DeleteByID[issues_model.Issue](db.DefaultContext, issue.ID)
assert.NoError(t, err)

issue = testInsertIssue(t, `my issue2, this is my son's love \n \r \ `, "special issue's '' comments?", 7)
issue = testInsertIssue(t, `my issue2, this is my son's love \n \r \ `, "special issue's '' comments?", 8)
_, err = db.DeleteByID[issues_model.Issue](db.DefaultContext, issue.ID)
assert.NoError(t, err)
}
Expand Down Expand Up @@ -380,7 +380,7 @@ func TestCountIssues(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
count, err := issues_model.CountIssues(db.DefaultContext, &issues_model.IssuesOptions{})
assert.NoError(t, err)
assert.EqualValues(t, 22, count)
assert.EqualValues(t, 23, count)
}

func TestIssueLoadAttributes(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion models/issues/issue_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func Test_NewIssueUsers(t *testing.T) {
newIssue := &issues_model.Issue{
RepoID: repo.ID,
PosterID: 4,
Index: 6,
Index: 7,
Title: "newTestIssueTitle",
Content: "newTestIssueContent",
}
Expand Down
2 changes: 1 addition & 1 deletion models/repo/attachment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func TestDeleteAttachments(t *testing.T) {

count, err = repo_model.DeleteAttachmentsByComment(db.DefaultContext, 2, false)
assert.NoError(t, err)
assert.Equal(t, 2, count)
assert.Equal(t, 3, count)

err = repo_model.DeleteAttachment(db.DefaultContext, &repo_model.Attachment{ID: 8}, false)
assert.NoError(t, err)
Expand Down
26 changes: 13 additions & 13 deletions modules/indexer/issues/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func searchIssueWithKeyword(t *testing.T) {
Keyword: "issue2",
RepoIDs: []int64{1},
},
[]int64{2},
[]int64{2, 23},
},
{
SearchOptions{
Expand Down Expand Up @@ -106,7 +106,7 @@ func searchIssueByIndex(t *testing.T) {
Keyword: "2",
RepoIDs: []int64{1, 2, 3, 32},
},
[]int64{17, 12, 7, 2},
[]int64{17, 12, 7, 2, 23},
},
{
SearchOptions{
Expand All @@ -133,7 +133,7 @@ func searchIssueInRepo(t *testing.T) {
SearchOptions{
RepoIDs: []int64{1},
},
[]int64{11, 5, 3, 2, 1},
[]int64{11, 5, 3, 2, 23, 1},
},
{
SearchOptions{
Expand Down Expand Up @@ -177,7 +177,7 @@ func searchIssueByID(t *testing.T) {
opts: SearchOptions{
PosterID: optional.Some(int64(1)),
},
expectedIDs: []int64{11, 6, 3, 2, 1},
expectedIDs: []int64{11, 6, 3, 2, 23, 1},
},
{
opts: SearchOptions{
Expand All @@ -188,7 +188,7 @@ func searchIssueByID(t *testing.T) {
{
// NOTE: This tests no assignees filtering and also ToSearchOptions() to ensure it will set AssigneeID to 0 when it is passed as -1.
opts: *ToSearchOptions("", &issues.IssuesOptions{AssigneeID: optional.Some(db.NoConditionID)}),
expectedIDs: []int64{22, 21, 16, 15, 14, 13, 12, 11, 20, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2},
expectedIDs: []int64{22, 21, 16, 15, 14, 13, 12, 11, 20, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2, 23},
},
{
opts: SearchOptions{
Expand All @@ -212,7 +212,7 @@ func searchIssueByID(t *testing.T) {
opts: SearchOptions{
SubscriberID: optional.Some(int64(1)),
},
expectedIDs: []int64{11, 6, 5, 3, 2, 1},
expectedIDs: []int64{11, 6, 5, 3, 2, 23, 1},
},
{
// issue 20 request user 15 and team 5 which user 15 belongs to
Expand Down Expand Up @@ -247,7 +247,7 @@ func searchIssueIsPull(t *testing.T) {
SearchOptions{
IsPull: optional.Some(false),
},
[]int64{17, 16, 15, 14, 13, 6, 5, 18, 10, 7, 4, 1},
[]int64{17, 16, 15, 14, 13, 6, 5, 18, 10, 7, 4, 23, 1},
},
{
SearchOptions{
Expand All @@ -272,7 +272,7 @@ func searchIssueIsClosed(t *testing.T) {
SearchOptions{
IsClosed: optional.Some(false),
},
[]int64{22, 21, 17, 16, 15, 14, 13, 12, 11, 20, 6, 19, 18, 10, 7, 9, 8, 3, 2, 1},
[]int64{22, 21, 17, 16, 15, 14, 13, 12, 11, 20, 6, 19, 18, 10, 7, 9, 8, 3, 2, 23, 1},
},
{
SearchOptions{
Expand All @@ -297,7 +297,7 @@ func searchIssueIsArchived(t *testing.T) {
SearchOptions{
IsArchived: optional.Some(false),
},
[]int64{22, 21, 17, 16, 15, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2, 1},
[]int64{22, 21, 17, 16, 15, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2, 23, 1},
},
{
SearchOptions{
Expand Down Expand Up @@ -359,7 +359,7 @@ func searchIssueByLabelID(t *testing.T) {
SearchOptions{
ExcludedLabelIDs: []int64{1},
},
[]int64{22, 21, 17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3},
[]int64{22, 21, 17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3, 23},
},
}
for _, test := range tests {
Expand All @@ -378,7 +378,7 @@ func searchIssueByTime(t *testing.T) {
SearchOptions{
UpdatedAfterUnix: optional.Some(int64(0)),
},
[]int64{22, 21, 17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2, 1},
[]int64{22, 21, 17, 16, 15, 14, 13, 12, 11, 20, 6, 5, 19, 18, 10, 7, 4, 9, 8, 3, 2, 23, 1},
},
}
for _, test := range tests {
Expand All @@ -397,7 +397,7 @@ func searchIssueWithOrder(t *testing.T) {
SearchOptions{
SortBy: internal.SortByCreatedAsc,
},
[]int64{1, 2, 3, 8, 9, 4, 7, 10, 18, 19, 5, 6, 20, 11, 12, 13, 14, 15, 16, 17, 21, 22},
[]int64{1, 23, 2, 3, 8, 9, 4, 7, 10, 18, 19, 5, 6, 20, 11, 12, 13, 14, 15, 16, 17, 21, 22},
},
}
for _, test := range tests {
Expand Down Expand Up @@ -451,7 +451,7 @@ func searchIssueWithPaginator(t *testing.T) {
},
},
[]int64{22, 21, 17, 16, 15},
22,
23,
},
}
for _, test := range tests {
Expand Down
24 changes: 14 additions & 10 deletions modules/setting/mailer.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,23 @@ import (

"code.gitea.io/gitea/modules/log"

shellquote "github.com/kballard/go-shellquote"
"github.com/kballard/go-shellquote"
)

// Mailer represents mail service.
type Mailer struct {
// Mailer
Name string `ini:"NAME"`
From string `ini:"FROM"`
EnvelopeFrom string `ini:"ENVELOPE_FROM"`
OverrideEnvelopeFrom bool `ini:"-"`
FromName string `ini:"-"`
FromEmail string `ini:"-"`
SendAsPlainText bool `ini:"SEND_AS_PLAIN_TEXT"`
SubjectPrefix string `ini:"SUBJECT_PREFIX"`
OverrideHeader map[string][]string `ini:"-"`
Name string `ini:"NAME"`
From string `ini:"FROM"`
EnvelopeFrom string `ini:"ENVELOPE_FROM"`
OverrideEnvelopeFrom bool `ini:"-"`
FromName string `ini:"-"`
FromEmail string `ini:"-"`
SendAsPlainText bool `ini:"SEND_AS_PLAIN_TEXT"`
SubjectPrefix string `ini:"SUBJECT_PREFIX"`
OverrideHeader map[string][]string `ini:"-"`
Base64EmbedImages bool `ini:"BASE64_EMBED_IMAGES"`
Base64EmbedImagesMaxSizePerEmail int64 `ini:"BASE64_EMBED_IMAGES_MAX_SIZE_PER_EMAIL"`

// SMTP sender
Protocol string `ini:"PROTOCOL"`
Expand Down Expand Up @@ -150,6 +152,8 @@ func loadMailerFrom(rootCfg ConfigProvider) {
sec.Key("SENDMAIL_TIMEOUT").MustDuration(5 * time.Minute)
sec.Key("SENDMAIL_CONVERT_CRLF").MustBool(true)
sec.Key("FROM").MustString(sec.Key("USER").String())
sec.Key("BASE64_EMBED_IMAGES").MustBool(false)
sec.Key("BASE64_EMBED_IMAGES_MAX_SIZE_PER_EMAIL").MustInt64(9.5 * 1024 * 1024)

// Now map the values on to the MailService
MailService = &Mailer{}
Expand Down
4 changes: 2 additions & 2 deletions services/issue/issue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestIssue_DeleteIssue(t *testing.T) {

issueIDs, err := issues_model.GetIssueIDsByRepoID(db.DefaultContext, 1)
assert.NoError(t, err)
assert.Len(t, issueIDs, 5)
assert.Len(t, issueIDs, 6)

issue := &issues_model.Issue{
RepoID: 1,
Expand All @@ -48,7 +48,7 @@ func TestIssue_DeleteIssue(t *testing.T) {
assert.NoError(t, err)
issueIDs, err = issues_model.GetIssueIDsByRepoID(db.DefaultContext, 1)
assert.NoError(t, err)
assert.Len(t, issueIDs, 4)
assert.Len(t, issueIDs, 5)

// check attachment removal
attachments, err := repo_model.GetAttachmentsByIssueID(db.DefaultContext, 4)
Expand Down
4 changes: 2 additions & 2 deletions services/issue/suggestion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ func Test_Suggestion(t *testing.T) {
}{
{
keyword: "",
expectedIndexes: []int64{5, 1, 4, 2, 3},
expectedIndexes: []int64{5, 6, 1, 4, 2},
},
{
keyword: "1",
expectedIndexes: []int64{1},
},
{
keyword: "issue",
expectedIndexes: []int64{4, 1, 2, 3},
expectedIndexes: []int64{6, 4, 1, 2, 3},
},
{
keyword: "pull",
Expand Down
Loading
Loading