Skip to content

Commit b22ae56

Browse files
authored
Merge branch 'main' into telackey/sort
2 parents cee7c08 + aba96f6 commit b22ae56

File tree

94 files changed

+946
-752
lines changed

Some content is hidden

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

94 files changed

+946
-752
lines changed

.eslintrc.cjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ module.exports = {
336336
'@typescript-eslint/no-unsafe-unary-minus': [2],
337337
'@typescript-eslint/no-unused-expressions': [0],
338338
'@typescript-eslint/no-unused-vars': [2, {vars: 'all', args: 'all', caughtErrors: 'all', ignoreRestSiblings: false, argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_', destructuredArrayIgnorePattern: '^_'}],
339-
'@typescript-eslint/no-use-before-define': [0],
339+
'@typescript-eslint/no-use-before-define': [2, {functions: false, classes: true, variables: true, allowNamedExports: true, typedefs: false, enums: false, ignoreTypeReferences: true}],
340340
'@typescript-eslint/no-useless-constructor': [0],
341341
'@typescript-eslint/no-useless-empty-export': [0],
342342
'@typescript-eslint/no-wrapper-object-types': [2],
@@ -693,7 +693,7 @@ module.exports = {
693693
'no-unused-labels': [2],
694694
'no-unused-private-class-members': [2],
695695
'no-unused-vars': [0], // handled by @typescript-eslint/no-unused-vars
696-
'no-use-before-define': [2, {functions: false, classes: true, variables: true, allowNamedExports: true}],
696+
'no-use-before-define': [0], // handled by @typescript-eslint/no-use-before-define
697697
'no-use-extend-native/no-use-extend-native': [2],
698698
'no-useless-backreference': [2],
699699
'no-useless-call': [2],

.github/labeler.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ modifies/internal:
4141
- ".dockerignore"
4242
- "docker/**"
4343
- ".editorconfig"
44-
- ".eslintrc.yaml"
44+
- ".eslintrc.cjs"
4545
- ".golangci.yml"
4646
- ".gitpod.yml"
4747
- ".markdownlint.yaml"
4848
- ".spectral.yaml"
4949
- "stylelint.config.js"
5050
- ".yamllint.yaml"
5151
- ".github/**"
52-
- ".gitea/"
52+
- ".gitea/**"
5353
- ".devcontainer/**"
5454
- "build.go"
5555
- "build/**"
@@ -73,9 +73,9 @@ modifies/go:
7373
modifies/frontend:
7474
- changed-files:
7575
- any-glob-to-any-file:
76-
- "**/*.js"
77-
- "**/*.ts"
78-
- "**/*.vue"
76+
- "*.js"
77+
- "*.ts"
78+
- "web_src/**"
7979

8080
docs-update-needed:
8181
- changed-files:

.github/workflows/files-changed.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ jobs:
5151
- "options/locale/locale_en-US.ini"
5252
5353
frontend:
54-
- "**/*.js"
54+
- "*.js"
55+
- "*.ts"
5556
- "web_src/**"
57+
- "tools/*.js"
58+
- "tools/*.ts"
5659
- "assets/emoji.json"
5760
- "package.json"
5861
- "package-lock.json"
5962
- "Makefile"
60-
- ".eslintrc.yaml"
61-
- "stylelint.config.js"
63+
- ".eslintrc.cjs"
6264
- ".npmrc"
6365
6466
docs:

.github/workflows/release-tag-version.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ jobs:
8888
# 1.2
8989
# 1.2.3
9090
tags: |
91+
type=semver,pattern={{version}}
9192
type=semver,pattern={{major}}
9293
type=semver,pattern={{major}}.{{minor}}
93-
type=semver,pattern={{version}}
9494
- name: Login to Docker Hub
9595
uses: docker/login-action@v3
9696
with:
@@ -126,9 +126,9 @@ jobs:
126126
# 1.2
127127
# 1.2.3
128128
tags: |
129+
type=semver,pattern={{version}}
129130
type=semver,pattern={{major}}
130131
type=semver,pattern={{major}}.{{minor}}
131-
type=semver,pattern={{version}}
132132
- name: Login to Docker Hub
133133
uses: docker/login-action@v3
134134
with:

cmd/web_acme.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,6 @@ func runACME(listenAddr string, m http.Handler) error {
5454
altTLSALPNPort = p
5555
}
5656

57-
// FIXME: this path is not right, it uses "AppWorkPath" incorrectly, and writes the data into "AppWorkPath/https"
58-
// Ideally it should migrate to AppDataPath write to "AppDataPath/https"
59-
certmagic.Default.Storage = &certmagic.FileStorage{Path: setting.AcmeLiveDirectory}
60-
magic := certmagic.NewDefault()
6157
// Try to use private CA root if provided, otherwise defaults to system's trust
6258
var certPool *x509.CertPool
6359
if setting.AcmeCARoot != "" {
@@ -67,7 +63,13 @@ func runACME(listenAddr string, m http.Handler) error {
6763
log.Warn("Failed to parse CA Root certificate, using default CA trust: %v", err)
6864
}
6965
}
70-
myACME := certmagic.NewACMEIssuer(magic, certmagic.ACMEIssuer{
66+
// FIXME: this path is not right, it uses "AppWorkPath" incorrectly, and writes the data into "AppWorkPath/https"
67+
// Ideally it should migrate to AppDataPath write to "AppDataPath/https"
68+
// And one more thing, no idea why we should set the global default variables here
69+
// But it seems that the current ACME code needs these global variables to make renew work.
70+
// Otherwise, "renew" will use incorrect storage path
71+
certmagic.Default.Storage = &certmagic.FileStorage{Path: setting.AcmeLiveDirectory}
72+
certmagic.DefaultACME = certmagic.ACMEIssuer{
7173
CA: setting.AcmeURL,
7274
TrustedRoots: certPool,
7375
Email: setting.AcmeEmail,
@@ -77,8 +79,10 @@ func runACME(listenAddr string, m http.Handler) error {
7779
ListenHost: setting.HTTPAddr,
7880
AltTLSALPNPort: altTLSALPNPort,
7981
AltHTTPPort: altHTTPPort,
80-
})
82+
}
8183

84+
magic := certmagic.NewDefault()
85+
myACME := certmagic.NewACMEIssuer(magic, certmagic.DefaultACME)
8286
magic.Issuers = []certmagic.Issuer{myACME}
8387

8488
// this obtains certificates or renews them if necessary

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,10 @@ require (
117117
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
118118
github.com/yuin/goldmark-meta v1.1.0
119119
gitlab.com/gitlab-org/api/client-go v0.123.0
120-
golang.org/x/crypto v0.33.0
120+
golang.org/x/crypto v0.35.0
121121
golang.org/x/image v0.24.0
122122
golang.org/x/net v0.35.0
123-
golang.org/x/oauth2 v0.26.0
123+
golang.org/x/oauth2 v0.27.0
124124
golang.org/x/sync v0.11.0
125125
golang.org/x/sys v0.30.0
126126
golang.org/x/text v0.22.0

go.sum

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,8 +831,9 @@ golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliY
831831
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
832832
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
833833
golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk=
834-
golang.org/x/crypto v0.33.0 h1:IOBPskki6Lysi0lo9qQvbxiQ+FvsCC/YWOecCHAixus=
835834
golang.org/x/crypto v0.33.0/go.mod h1:bVdXmD7IV/4GdElGPozy6U7lWdRXA4qyRVGJV57uQ5M=
835+
golang.org/x/crypto v0.35.0 h1:b15kiHdrGCHrP6LvwaQ3c03kgNhhiMgvlhxHQhmg2Xs=
836+
golang.org/x/crypto v0.35.0/go.mod h1:dy7dXNW32cAb/6/PRuTNsix8T+vJAqvuIy5Bli/x0YQ=
836837
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa h1:t2QcU6V556bFjYgu4L6C+6VrCPyJZ+eyRsABUPs1mz4=
837838
golang.org/x/exp v0.0.0-20250218142911-aa4b98e5adaa/go.mod h1:BHOTPb3L19zxehTsLoJXVaTktb06DFgmdW6Wb9s8jqk=
838839
golang.org/x/image v0.24.0 h1:AN7zRgVsbvmTfNyqIbbOraYL8mSwcKncEj8ofjgzcMQ=
@@ -868,8 +869,8 @@ golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
868869
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
869870
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
870871
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
871-
golang.org/x/oauth2 v0.26.0 h1:afQXWNNaeC4nvZ0Ed9XvCCzXM6UHJG7iCg0W4fPqSBE=
872-
golang.org/x/oauth2 v0.26.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
872+
golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M=
873+
golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8=
873874
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
874875
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
875876
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

models/activities/action.go

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,24 @@ func ActivityReadable(user, doer *user_model.User) bool {
454454
doer != nil && (doer.IsAdmin || user.ID == doer.ID)
455455
}
456456

457+
func FeedDateCond(opts GetFeedsOptions) builder.Cond {
458+
cond := builder.NewCond()
459+
if opts.Date == "" {
460+
return cond
461+
}
462+
463+
dateLow, err := time.ParseInLocation("2006-01-02", opts.Date, setting.DefaultUILocation)
464+
if err != nil {
465+
log.Warn("Unable to parse %s, filter not applied: %v", opts.Date, err)
466+
} else {
467+
dateHigh := dateLow.Add(86399000000000) // 23h59m59s
468+
469+
cond = cond.And(builder.Gte{"`action`.created_unix": dateLow.Unix()})
470+
cond = cond.And(builder.Lte{"`action`.created_unix": dateHigh.Unix()})
471+
}
472+
return cond
473+
}
474+
457475
func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.Cond, error) {
458476
cond := builder.NewCond()
459477

@@ -534,17 +552,7 @@ func ActivityQueryCondition(ctx context.Context, opts GetFeedsOptions) (builder.
534552
cond = cond.And(builder.Eq{"is_deleted": false})
535553
}
536554

537-
if opts.Date != "" {
538-
dateLow, err := time.ParseInLocation("2006-01-02", opts.Date, setting.DefaultUILocation)
539-
if err != nil {
540-
log.Warn("Unable to parse %s, filter not applied: %v", opts.Date, err)
541-
} else {
542-
dateHigh := dateLow.Add(86399000000000) // 23h59m59s
543-
544-
cond = cond.And(builder.Gte{"`action`.created_unix": dateLow.Unix()})
545-
cond = cond.And(builder.Lte{"`action`.created_unix": dateHigh.Unix()})
546-
}
547-
}
555+
cond = cond.And(FeedDateCond(opts))
548556

549557
return cond, nil
550558
}

models/activities/action_list.go

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,31 @@ func GetFeeds(ctx context.Context, opts GetFeedsOptions) (ActionList, int64, err
208208
return nil, 0, fmt.Errorf("need at least one of these filters: RequestedUser, RequestedTeam, RequestedRepo")
209209
}
210210

211-
cond, err := ActivityQueryCondition(ctx, opts)
212-
if err != nil {
213-
return nil, 0, err
211+
var err error
212+
var cond builder.Cond
213+
// if the actor is the requested user or is an administrator, we can skip the ActivityQueryCondition
214+
if opts.Actor != nil && opts.RequestedUser != nil && (opts.Actor.IsAdmin || opts.Actor.ID == opts.RequestedUser.ID) {
215+
cond = builder.Eq{
216+
"user_id": opts.RequestedUser.ID,
217+
}.And(
218+
FeedDateCond(opts),
219+
)
220+
221+
if !opts.IncludeDeleted {
222+
cond = cond.And(builder.Eq{"is_deleted": false})
223+
}
224+
225+
if !opts.IncludePrivate {
226+
cond = cond.And(builder.Eq{"is_private": false})
227+
}
228+
if opts.OnlyPerformedBy {
229+
cond = cond.And(builder.Eq{"act_user_id": opts.RequestedUser.ID})
230+
}
231+
} else {
232+
cond, err = ActivityQueryCondition(ctx, opts)
233+
if err != nil {
234+
return nil, 0, err
235+
}
214236
}
215237

216238
actions := make([]*Action, 0, opts.PageSize)

models/auth/access_token_scope.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package auth
55

66
import (
77
"fmt"
8+
"slices"
89
"strings"
910

1011
"code.gitea.io/gitea/models/perm"
@@ -14,7 +15,7 @@ import (
1415
type AccessTokenScopeCategory int
1516

1617
const (
17-
AccessTokenScopeCategoryActivityPub = iota
18+
AccessTokenScopeCategoryActivityPub AccessTokenScopeCategory = iota
1819
AccessTokenScopeCategoryAdmin
1920
AccessTokenScopeCategoryMisc // WARN: this is now just a placeholder, don't remove it which will change the following values
2021
AccessTokenScopeCategoryNotification
@@ -193,6 +194,14 @@ var accessTokenScopes = map[AccessTokenScopeLevel]map[AccessTokenScopeCategory]A
193194
},
194195
}
195196

197+
func GetAccessTokenCategories() (res []string) {
198+
for _, cat := range accessTokenScopes[Read] {
199+
res = append(res, strings.TrimPrefix(string(cat), "read:"))
200+
}
201+
slices.Sort(res)
202+
return res
203+
}
204+
196205
// GetRequiredScopes gets the specific scopes for a given level and categories
197206
func GetRequiredScopes(level AccessTokenScopeLevel, scopeCategories ...AccessTokenScopeCategory) []AccessTokenScope {
198207
scopes := make([]AccessTokenScope, 0, len(scopeCategories))
@@ -270,6 +279,9 @@ func (s AccessTokenScope) parse() (accessTokenScopeBitmap, error) {
270279

271280
// StringSlice returns the AccessTokenScope as a []string
272281
func (s AccessTokenScope) StringSlice() []string {
282+
if s == "" {
283+
return nil
284+
}
273285
return strings.Split(string(s), ",")
274286
}
275287

0 commit comments

Comments
 (0)