Skip to content

Commit 79032d9

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: Document that all unmerged feature PRs will be moved to next milestone when the feature freeze time comes (go-gitea#29578) Make admin pages wider because of left sidebar added and some tables become too narrow (go-gitea#29581) Refactor star/watch button (go-gitea#29576) Remove unnecessary SanitizeHTML from code (go-gitea#29575) Add missing database transaction for new issue (go-gitea#29490) Fix incorrect package link method calls in templates (go-gitea#29580) Move some asymkey functions to service layer (go-gitea#28894) Add user blocking (go-gitea#29028) # Conflicts: # templates/repo/issue/view_content/context_menu.tmpl
2 parents 65964a4 + 76789bd commit 79032d9

File tree

140 files changed

+3099
-740
lines changed

Some content is hidden

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

140 files changed

+3099
-740
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ We assume in good faith that the information you provide is legally binding.
464464
We adopted a release schedule to streamline the process of working on, finishing, and issuing releases. \
465465
The overall goal is to make a major release every three or four months, which breaks down into two or three months of general development followed by one month of testing and polishing known as the release freeze. \
466466
All the feature pull requests should be
467-
merged before feature freeze. And, during the frozen period, a corresponding
467+
merged before feature freeze. All feature pull requests haven't been merged before this feature freeze will be moved to next milestone, please notice our feature freeze announcement on discord. And, during the frozen period, a corresponding
468468
release branch is open for fixes backported from main branch. Release candidates
469469
are made during this period for user testing to
470470
obtain a final version that is maintained in this branch.

cmd/admin_regenerate.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
package cmd
55

66
import (
7-
asymkey_model "code.gitea.io/gitea/models/asymkey"
87
"code.gitea.io/gitea/modules/graceful"
8+
asymkey_service "code.gitea.io/gitea/services/asymkey"
99
repo_service "code.gitea.io/gitea/services/repository"
1010

1111
"github.com/urfave/cli/v2"
@@ -42,5 +42,5 @@ func runRegenerateKeys(_ *cli.Context) error {
4242
if err := initDB(ctx); err != nil {
4343
return err
4444
}
45-
return asymkey_model.RewriteAllPublicKeys(ctx)
45+
return asymkey_service.RewriteAllPublicKeys(ctx)
4646
}

docs/content/administration/mail-templates.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Please check [Gitea's logs](administration/logging-config.md) for error messages
224224
{{if not (eq .Body "")}}
225225
<h3>Message content</h3>
226226
<hr>
227-
{{.Body | SanitizeHTML}}
227+
{{.Body}}
228228
{{end}}
229229
</p>
230230
<hr>

docs/content/administration/mail-templates.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ _主题_ 和 _邮件正文_ 由 [Golang的模板引擎](https://go.dev/pkg/text/
207207
{{if not (eq .Body "")}}
208208
<h3>消息内容:</h3>
209209
<hr>
210-
{{.Body | SanitizeHTML}}
210+
{{.Body}}
211211
{{end}}
212212
</p>
213213
<hr>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
date: "2024-01-31T00:00:00+00:00"
3+
title: "Blocking a user"
4+
slug: "blocking-user"
5+
sidebar_position: 25
6+
toc: false
7+
draft: false
8+
aliases:
9+
- /en-us/webhooks
10+
menu:
11+
sidebar:
12+
parent: "usage"
13+
name: "Blocking a user"
14+
sidebar_position: 30
15+
identifier: "blocking-user"
16+
---
17+
18+
# Blocking a user
19+
20+
Gitea supports blocking of users to restrict how they can interact with you and your content.
21+
22+
You can block a user in your account settings, from the user's profile or from comments created by the user.
23+
The user is not directly notified about the block, but they can notice they are blocked when they attempt to interact with you.
24+
Organization owners can block anyone who is not a member of the organization too.
25+
If a blocked user has admin permissions, they can still perform all actions even if blocked.
26+
27+
### When you block a user
28+
29+
- the user stops following you
30+
- you stop following the user
31+
- the user's stars are removed from your repositories
32+
- your stars are removed from their repositories
33+
- the user stops watching your repositories
34+
- you stop watching their repositories
35+
- the user's issue assignments are removed from your repositories
36+
- your issue assignments are removed from their repositories
37+
- the user is removed as a collaborator on your repositories
38+
- you are removed as a collaborator on their repositories
39+
- any pending repository transfers to or from the blocked user are canceled
40+
41+
### When you block a user, the user cannot
42+
43+
- follow you
44+
- watch your repositories
45+
- star your repositories
46+
- fork your repositories
47+
- transfer repositories to you
48+
- open issues or pull requests on your repositories
49+
- comment on issues or pull requests you've created
50+
- comment on issues or pull requests on your repositories
51+
- react to your comments on issues or pull requests
52+
- react to comments on issues or pull requests on your repositories
53+
- assign you to issues or pull requests
54+
- add you as a collaborator on their repositories
55+
- send you notifications by @mentioning your username
56+
- be added as team member (if blocked by an organization)

models/asymkey/ssh_key_authorized_keys.go

Lines changed: 6 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"path/filepath"
1313
"strings"
1414
"sync"
15-
"time"
1615

1716
"code.gitea.io/gitea/models/db"
1817
"code.gitea.io/gitea/modules/log"
@@ -44,6 +43,12 @@ const (
4443

4544
var sshOpLocker sync.Mutex
4645

46+
func WithSSHOpLocker(f func() error) error {
47+
sshOpLocker.Lock()
48+
defer sshOpLocker.Unlock()
49+
return f()
50+
}
51+
4752
// AuthorizedStringForKey creates the authorized keys string appropriate for the provided key
4853
func AuthorizedStringForKey(key *PublicKey) string {
4954
sb := &strings.Builder{}
@@ -114,65 +119,6 @@ func appendAuthorizedKeysToFile(keys ...*PublicKey) error {
114119
return nil
115120
}
116121

117-
// RewriteAllPublicKeys removes any authorized key and rewrite all keys from database again.
118-
// Note: db.GetEngine(ctx).Iterate does not get latest data after insert/delete, so we have to call this function
119-
// outside any session scope independently.
120-
func RewriteAllPublicKeys(ctx context.Context) error {
121-
// Don't rewrite key if internal server
122-
if setting.SSH.StartBuiltinServer || !setting.SSH.CreateAuthorizedKeysFile {
123-
return nil
124-
}
125-
126-
sshOpLocker.Lock()
127-
defer sshOpLocker.Unlock()
128-
129-
if setting.SSH.RootPath != "" {
130-
// First of ensure that the RootPath is present, and if not make it with 0700 permissions
131-
// This of course doesn't guarantee that this is the right directory for authorized_keys
132-
// but at least if it's supposed to be this directory and it doesn't exist and we're the
133-
// right user it will at least be created properly.
134-
err := os.MkdirAll(setting.SSH.RootPath, 0o700)
135-
if err != nil {
136-
log.Error("Unable to MkdirAll(%s): %v", setting.SSH.RootPath, err)
137-
return err
138-
}
139-
}
140-
141-
fPath := filepath.Join(setting.SSH.RootPath, "authorized_keys")
142-
tmpPath := fPath + ".tmp"
143-
t, err := os.OpenFile(tmpPath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600)
144-
if err != nil {
145-
return err
146-
}
147-
defer func() {
148-
t.Close()
149-
if err := util.Remove(tmpPath); err != nil {
150-
log.Warn("Unable to remove temporary authorized keys file: %s: Error: %v", tmpPath, err)
151-
}
152-
}()
153-
154-
if setting.SSH.AuthorizedKeysBackup {
155-
isExist, err := util.IsExist(fPath)
156-
if err != nil {
157-
log.Error("Unable to check if %s exists. Error: %v", fPath, err)
158-
return err
159-
}
160-
if isExist {
161-
bakPath := fmt.Sprintf("%s_%d.gitea_bak", fPath, time.Now().Unix())
162-
if err = util.CopyFile(fPath, bakPath); err != nil {
163-
return err
164-
}
165-
}
166-
}
167-
168-
if err := RegeneratePublicKeys(ctx, t); err != nil {
169-
return err
170-
}
171-
172-
t.Close()
173-
return util.Rename(tmpPath, fPath)
174-
}
175-
176122
// RegeneratePublicKeys regenerates the authorized_keys file
177123
func RegeneratePublicKeys(ctx context.Context, t io.StringWriter) error {
178124
if err := db.GetEngine(ctx).Where("type != ?", KeyTypePrincipal).Iterate(new(PublicKey), func(idx int, bean any) (err error) {

models/asymkey/ssh_key_principals.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,51 +9,11 @@ import (
99
"strings"
1010

1111
"code.gitea.io/gitea/models/db"
12-
"code.gitea.io/gitea/models/perm"
1312
user_model "code.gitea.io/gitea/models/user"
1413
"code.gitea.io/gitea/modules/setting"
1514
"code.gitea.io/gitea/modules/util"
1615
)
1716

18-
// AddPrincipalKey adds new principal to database and authorized_principals file.
19-
func AddPrincipalKey(ctx context.Context, ownerID int64, content string, authSourceID int64) (*PublicKey, error) {
20-
dbCtx, committer, err := db.TxContext(ctx)
21-
if err != nil {
22-
return nil, err
23-
}
24-
defer committer.Close()
25-
26-
// Principals cannot be duplicated.
27-
has, err := db.GetEngine(dbCtx).
28-
Where("content = ? AND type = ?", content, KeyTypePrincipal).
29-
Get(new(PublicKey))
30-
if err != nil {
31-
return nil, err
32-
} else if has {
33-
return nil, ErrKeyAlreadyExist{0, "", content}
34-
}
35-
36-
key := &PublicKey{
37-
OwnerID: ownerID,
38-
Name: content,
39-
Content: content,
40-
Mode: perm.AccessModeWrite,
41-
Type: KeyTypePrincipal,
42-
LoginSourceID: authSourceID,
43-
}
44-
if err = db.Insert(dbCtx, key); err != nil {
45-
return nil, fmt.Errorf("addKey: %w", err)
46-
}
47-
48-
if err = committer.Commit(); err != nil {
49-
return nil, err
50-
}
51-
52-
committer.Close()
53-
54-
return key, RewriteAllPrincipalKeys(ctx)
55-
}
56-
5717
// CheckPrincipalKeyString strips spaces and returns an error if the given principal contains newlines
5818
func CheckPrincipalKeyString(ctx context.Context, user *user_model.User, content string) (_ string, err error) {
5919
if setting.SSH.Disabled {

models/fixtures/access.yml

Lines changed: 31 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -42,120 +42,132 @@
4242

4343
-
4444
id: 8
45-
user_id: 15
45+
user_id: 10
4646
repo_id: 21
4747
mode: 2
4848

4949
-
5050
id: 9
51+
user_id: 10
52+
repo_id: 32
53+
mode: 2
54+
55+
-
56+
id: 10
57+
user_id: 15
58+
repo_id: 21
59+
mode: 2
60+
61+
-
62+
id: 11
5163
user_id: 15
5264
repo_id: 22
5365
mode: 2
5466

5567
-
56-
id: 10
68+
id: 12
5769
user_id: 15
5870
repo_id: 23
5971
mode: 4
6072

6173
-
62-
id: 11
74+
id: 13
6375
user_id: 15
6476
repo_id: 24
6577
mode: 4
6678

6779
-
68-
id: 12
80+
id: 14
6981
user_id: 15
7082
repo_id: 32
7183
mode: 2
7284

7385
-
74-
id: 13
86+
id: 15
7587
user_id: 18
7688
repo_id: 21
7789
mode: 2
7890

7991
-
80-
id: 14
92+
id: 16
8193
user_id: 18
8294
repo_id: 22
8395
mode: 2
8496

8597
-
86-
id: 15
98+
id: 17
8799
user_id: 18
88100
repo_id: 23
89101
mode: 4
90102

91103
-
92-
id: 16
104+
id: 18
93105
user_id: 18
94106
repo_id: 24
95107
mode: 4
96108

97109
-
98-
id: 17
110+
id: 19
99111
user_id: 20
100112
repo_id: 24
101113
mode: 1
102114

103115
-
104-
id: 18
116+
id: 20
105117
user_id: 20
106118
repo_id: 27
107119
mode: 4
108120

109121
-
110-
id: 19
122+
id: 21
111123
user_id: 20
112124
repo_id: 28
113125
mode: 4
114126

115127
-
116-
id: 20
128+
id: 22
117129
user_id: 29
118130
repo_id: 4
119131
mode: 2
120132

121133
-
122-
id: 21
134+
id: 23
123135
user_id: 29
124136
repo_id: 24
125137
mode: 1
126138

127139
-
128-
id: 22
140+
id: 24
129141
user_id: 31
130142
repo_id: 27
131143
mode: 4
132144

133145
-
134-
id: 23
146+
id: 25
135147
user_id: 31
136148
repo_id: 28
137149
mode: 4
138150

139151
-
140-
id: 24
152+
id: 26
141153
user_id: 38
142154
repo_id: 60
143155
mode: 2
144156

145157
-
146-
id: 25
158+
id: 27
147159
user_id: 38
148160
repo_id: 61
149161
mode: 1
150162

151163
-
152-
id: 26
164+
id: 28
153165
user_id: 39
154166
repo_id: 61
155167
mode: 1
156168

157169
-
158-
id: 27
170+
id: 29
159171
user_id: 40
160172
repo_id: 61
161173
mode: 4

0 commit comments

Comments
 (0)