Skip to content

Commit fd12c9e

Browse files
authored
Merge branch 'main' into run-emoji-processor-on-whole-of-data
2 parents c17207d + ffbf35b commit fd12c9e

Some content is hidden

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

72 files changed

+570
-248
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,4 @@ Norwin Roosen <[email protected]> (@noerw)
4242
Kyle Dumont <[email protected]> (@kdumontnu)
4343
Patrick Schratz <[email protected]> (@pat-s)
4444
Janis Estelmann <[email protected]> (@KN4CK3R)
45+
Steven Kriegler <[email protected]> (@justusbunsi)

custom/conf/app.example.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1155,20 +1155,20 @@ PATH =
11551155
;STARTUP_TIMEOUT = 30s
11561156
;;
11571157
;; Issue indexer queue, currently support: channel, levelqueue or redis, default is levelqueue (deprecated - use [queue.issue_indexer])
1158-
;ISSUE_INDEXER_QUEUE_TYPE = levelqueue
1158+
;ISSUE_INDEXER_QUEUE_TYPE = levelqueue; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11591159
;;
11601160
;; When ISSUE_INDEXER_QUEUE_TYPE is levelqueue, this will be the path where the queue will be saved.
11611161
;; This can be overridden by `ISSUE_INDEXER_QUEUE_CONN_STR`.
11621162
;; default is queues/common
1163-
;ISSUE_INDEXER_QUEUE_DIR = queues/common
1163+
;ISSUE_INDEXER_QUEUE_DIR = queues/common; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11641164
;;
11651165
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string.
11661166
;; When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of
11671167
;; the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
1168-
;ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"
1168+
;ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=127.0.0.1:6379 db=0"; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11691169
;;
11701170
;; Batch queue number, default is 20
1171-
;ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20
1171+
;ISSUE_INDEXER_QUEUE_BATCH_NUMBER = 20; **DEPRECATED** use settings in `[queue.issue_indexer]`.
11721172

11731173
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11741174
;; Repository Indexer settings
@@ -1197,7 +1197,7 @@ PATH =
11971197
;REPO_INDEXER_EXCLUDE =
11981198
;;
11991199
;;
1200-
;UPDATE_BUFFER_LEN = 20
1200+
;UPDATE_BUFFER_LEN = 20; **DEPRECATED** use settings in `[queue.issue_indexer]`.
12011201
;MAX_FILE_SIZE = 1048576
12021202

12031203
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
270270
- `SSH_AUTHORIZED_PRINCIPALS_ALLOW`: **off** or **username, email**: \[off, username, email, anything\]: Specify the principals values that users are allowed to use as principal. When set to `anything` no checks are done on the principal string. When set to `off` authorized principal are not allowed to be set.
271271
- `SSH_CREATE_AUTHORIZED_PRINCIPALS_FILE`: **false/true**: Gitea will create a authorized_principals file by default when it is not using the internal ssh server and `SSH_AUTHORIZED_PRINCIPALS_ALLOW` is not `off`.
272272
- `SSH_AUTHORIZED_PRINCIPALS_BACKUP`: **false/true**: Enable SSH Authorized Principals Backup when rewriting all keys, default is true if `SSH_AUTHORIZED_PRINCIPALS_ALLOW` is not `off`.
273+
- `SSH_AUTHORIZED_KEYS_COMMAND_TEMPLATE`: **{{.AppPath}} --config={{.CustomConf}} serv key-{{.Key.ID}}**: Set the template for the command to passed on authorized keys. Possible keys are: AppPath, AppWorkPath, CustomConf, CustomPath, Key - where Key is a `models.PublicKey` and the others are strings which are shellquoted.
273274
- `SSH_SERVER_CIPHERS`: **aes128-ctr, aes192-ctr, aes256-ctr, [email protected], arcfour256, arcfour128**: For the built-in SSH server, choose the ciphers to support for SSH connections, for system SSH this setting has no effect.
274275
- `SSH_SERVER_KEY_EXCHANGES`: **diffie-hellman-group1-sha1, diffie-hellman-group14-sha1, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, [email protected]**: For the built-in SSH server, choose the key exchange algorithms to support for SSH connections, for system SSH this setting has no effect.
275276
- `SSH_SERVER_MACS`: **[email protected], hmac-sha2-256, hmac-sha1, hmac-sha1-96**: For the built-in SSH server, choose the MACs to support for SSH connections, for system SSH this setting has no effect
@@ -355,10 +356,10 @@ relation to port exhaustion.
355356
- `ISSUE_INDEXER_NAME`: **gitea_issues**: Issue indexer name, available when ISSUE_INDEXER_TYPE is elasticsearch
356357
- `ISSUE_INDEXER_PATH`: **indexers/issues.bleve**: Index file used for issue search; available when ISSUE_INDEXER_TYPE is bleve and elasticsearch.
357358
- The next 4 configuration values are deprecated and should be set in `queue.issue_indexer` however are kept for backwards compatibility:
358-
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`.
359-
- `ISSUE_INDEXER_QUEUE_DIR`: **queues/common**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved. (Previously this was `indexers/issues.queue`.)
360-
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string. When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`.
361-
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number.
359+
- `ISSUE_INDEXER_QUEUE_TYPE`: **levelqueue**: Issue indexer queue, currently supports:`channel`, `levelqueue`, `redis`. **DEPRECATED** use settings in `[queue.issue_indexer]`.
360+
- `ISSUE_INDEXER_QUEUE_DIR`: **queues/common**: When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this will be the path where the queue will be saved. **DEPRECATED** use settings in `[queue.issue_indexer]`.
361+
- `ISSUE_INDEXER_QUEUE_CONN_STR`: **addrs=127.0.0.1:6379 db=0**: When `ISSUE_INDEXER_QUEUE_TYPE` is `redis`, this will store the redis connection string. When `ISSUE_INDEXER_QUEUE_TYPE` is `levelqueue`, this is a directory or additional options of the form `leveldb://path/to/db?option=value&....`, and overrides `ISSUE_INDEXER_QUEUE_DIR`. **DEPRECATED** use settings in `[queue.issue_indexer]`.
362+
- `ISSUE_INDEXER_QUEUE_BATCH_NUMBER`: **20**: Batch queue number. **DEPRECATED** use settings in `[queue.issue_indexer]`.
362363

363364
- `REPO_INDEXER_ENABLED`: **false**: Enables code search (uses a lot of disk space, about 6 times more than the repository size).
364365
- `REPO_INDEXER_TYPE`: **bleve**: Code search engine type, could be `bleve` or `elasticsearch`.
@@ -369,7 +370,7 @@ relation to port exhaustion.
369370
- `REPO_INDEXER_INCLUDE`: **empty**: A comma separated list of glob patterns (see https://github.com/gobwas/glob) to **include** in the index. Use `**.txt` to match any files with .txt extension. An empty list means include all files.
370371
- `REPO_INDEXER_EXCLUDE`: **empty**: A comma separated list of glob patterns (see https://github.com/gobwas/glob) to **exclude** from the index. Files that match this list will not be indexed, even if they match in `REPO_INDEXER_INCLUDE`.
371372
- `REPO_INDEXER_EXCLUDE_VENDORED`: **true**: Exclude vendored files from index.
372-
- `UPDATE_BUFFER_LEN`: **20**: Buffer length of index request.
373+
- `UPDATE_BUFFER_LEN`: **20**: Buffer length of index request. **DEPRECATED** use settings in `[queue.issue_indexer]`.
373374
- `MAX_FILE_SIZE`: **1048576**: Maximum size in bytes of files to be indexed.
374375
- `STARTUP_TIMEOUT`: **30s**: If the indexer takes longer than this timeout to start - fail. (This timeout will be added to the hammer time above for child processes - as bleve will not start until the previous parent is shutdown.) Set to zero to never timeout.
375376

models/issue.go

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,9 +1127,18 @@ func sortIssuesSession(sess *xorm.Session, sortType string, priorityRepoID int64
11271127
sess.Desc("issue.priority")
11281128
case "nearduedate":
11291129
// 253370764800 is 01/01/9999 @ 12:00am (UTC)
1130-
sess.OrderBy("CASE WHEN issue.deadline_unix = 0 THEN 253370764800 ELSE issue.deadline_unix END ASC")
1130+
sess.Join("LEFT", "milestone", "issue.milestone_id = milestone.id").
1131+
OrderBy("CASE " +
1132+
"WHEN issue.deadline_unix = 0 AND (milestone.deadline_unix = 0 OR milestone.deadline_unix IS NULL) THEN 253370764800 " +
1133+
"WHEN milestone.deadline_unix = 0 OR milestone.deadline_unix IS NULL THEN issue.deadline_unix " +
1134+
"WHEN milestone.deadline_unix < issue.deadline_unix OR issue.deadline_unix = 0 THEN milestone.deadline_unix " +
1135+
"ELSE issue.deadline_unix END ASC")
11311136
case "farduedate":
1132-
sess.Desc("issue.deadline_unix")
1137+
sess.Join("LEFT", "milestone", "issue.milestone_id = milestone.id").
1138+
OrderBy("CASE " +
1139+
"WHEN milestone.deadline_unix IS NULL THEN issue.deadline_unix " +
1140+
"WHEN milestone.deadline_unix < issue.deadline_unix OR issue.deadline_unix = 0 THEN milestone.deadline_unix " +
1141+
"ELSE issue.deadline_unix END DESC")
11331142
case "priorityrepo":
11341143
sess.OrderBy("CASE WHEN issue.repo_id = " + strconv.FormatInt(priorityRepoID, 10) + " THEN 1 ELSE 2 END, issue.created_unix DESC")
11351144
default:

models/issue_comment.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ func updateCommentInfos(e *xorm.Session, opts *CreateCommentOptions, comment *Co
762762
}
763763
}
764764
fallthrough
765+
case CommentTypeReview:
766+
fallthrough
765767
case CommentTypeComment:
766768
if _, err = e.Exec("UPDATE `issue` SET num_comments=num_comments+1 WHERE id=?", opts.Issue.ID); err != nil {
767769
return err

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,8 @@ var migrations = []Migration{
317317
NewMigration("Add issue resource index table", addIssueResourceIndexTable),
318318
// v183 -> v184
319319
NewMigration("Create PushMirror table", createPushMirrorTable),
320+
// v184 -> v185
321+
NewMigration("Rename Task errors to message", renameTaskErrorsToMessage),
320322
}
321323

322324
// GetCurrentDBVersion returns the current db version

models/migrations/v180.go

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
package migrations
66

77
import (
8-
"code.gitea.io/gitea/models"
9-
"code.gitea.io/gitea/modules/migrations/base"
10-
"code.gitea.io/gitea/modules/structs"
118
"code.gitea.io/gitea/modules/util"
129

1310
jsoniter "github.com/json-iterator/go"
@@ -16,20 +13,38 @@ import (
1613
)
1714

1815
func deleteMigrationCredentials(x *xorm.Engine) (err error) {
16+
// Task represents a task
17+
type Task struct {
18+
ID int64
19+
DoerID int64 `xorm:"index"` // operator
20+
OwnerID int64 `xorm:"index"` // repo owner id, when creating, the repoID maybe zero
21+
RepoID int64 `xorm:"index"`
22+
Type int
23+
Status int `xorm:"index"`
24+
StartTime int64
25+
EndTime int64
26+
PayloadContent string `xorm:"TEXT"`
27+
Errors string `xorm:"TEXT"` // if task failed, saved the error reason
28+
Created int64 `xorm:"created"`
29+
}
30+
31+
const TaskTypeMigrateRepo = 0
32+
const TaskStatusStopped = 2
33+
1934
const batchSize = 100
2035

2136
// only match migration tasks, that are not pending or running
2237
cond := builder.Eq{
23-
"type": structs.TaskTypeMigrateRepo,
38+
"type": TaskTypeMigrateRepo,
2439
}.And(builder.Gte{
25-
"status": structs.TaskStatusStopped,
40+
"status": TaskStatusStopped,
2641
})
2742

2843
sess := x.NewSession()
2944
defer sess.Close()
3045

3146
for start := 0; ; start += batchSize {
32-
tasks := make([]*models.Task, 0, batchSize)
47+
tasks := make([]*Task, 0, batchSize)
3348
if err = sess.Limit(batchSize, start).Where(cond, 0).Find(&tasks); err != nil {
3449
return
3550
}
@@ -55,7 +70,41 @@ func deleteMigrationCredentials(x *xorm.Engine) (err error) {
5570
}
5671

5772
func removeCredentials(payload string) (string, error) {
58-
var opts base.MigrateOptions
73+
// MigrateOptions defines the way a repository gets migrated
74+
// this is for internal usage by migrations module and func who interact with it
75+
type MigrateOptions struct {
76+
// required: true
77+
CloneAddr string `json:"clone_addr" binding:"Required"`
78+
CloneAddrEncrypted string `json:"clone_addr_encrypted,omitempty"`
79+
AuthUsername string `json:"auth_username"`
80+
AuthPassword string `json:"-"`
81+
AuthPasswordEncrypted string `json:"auth_password_encrypted,omitempty"`
82+
AuthToken string `json:"-"`
83+
AuthTokenEncrypted string `json:"auth_token_encrypted,omitempty"`
84+
// required: true
85+
UID int `json:"uid" binding:"Required"`
86+
// required: true
87+
RepoName string `json:"repo_name" binding:"Required"`
88+
Mirror bool `json:"mirror"`
89+
LFS bool `json:"lfs"`
90+
LFSEndpoint string `json:"lfs_endpoint"`
91+
Private bool `json:"private"`
92+
Description string `json:"description"`
93+
OriginalURL string
94+
GitServiceType int
95+
Wiki bool
96+
Issues bool
97+
Milestones bool
98+
Labels bool
99+
Releases bool
100+
Comments bool
101+
PullRequests bool
102+
ReleaseAssets bool
103+
MigrateToRepoID int64
104+
MirrorInterval string `json:"mirror_interval"`
105+
}
106+
107+
var opts MigrateOptions
59108
json := jsoniter.ConfigCompatibleWithStandardLibrary
60109
err := json.Unmarshal([]byte(payload), &opts)
61110
if err != nil {

models/migrations/v184.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright 2021 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"fmt"
9+
10+
"code.gitea.io/gitea/modules/setting"
11+
12+
"xorm.io/xorm"
13+
)
14+
15+
func renameTaskErrorsToMessage(x *xorm.Engine) error {
16+
type Task struct {
17+
Errors string `xorm:"TEXT"` // if task failed, saved the error reason
18+
Type int
19+
Status int `xorm:"index"`
20+
}
21+
22+
sess := x.NewSession()
23+
defer sess.Close()
24+
if err := sess.Begin(); err != nil {
25+
return err
26+
}
27+
28+
if err := sess.Sync2(new(Task)); err != nil {
29+
return fmt.Errorf("error on Sync2: %v", err)
30+
}
31+
32+
switch {
33+
case setting.Database.UseMySQL:
34+
if _, err := sess.Exec("ALTER TABLE `task` CHANGE errors message text"); err != nil {
35+
return err
36+
}
37+
case setting.Database.UseMSSQL:
38+
if _, err := sess.Exec("sp_rename 'task.errors', 'message', 'COLUMN'"); err != nil {
39+
return err
40+
}
41+
default:
42+
if _, err := sess.Exec("ALTER TABLE `task` RENAME COLUMN errors TO message"); err != nil {
43+
return err
44+
}
45+
}
46+
return sess.Commit()
47+
}

models/notification.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type FindNotificationOptions struct {
7474
RepoID int64
7575
IssueID int64
7676
Status []NotificationStatus
77+
Source []NotificationSource
7778
UpdatedAfterUnix int64
7879
UpdatedBeforeUnix int64
7980
}
@@ -93,6 +94,9 @@ func (opts *FindNotificationOptions) ToCond() builder.Cond {
9394
if len(opts.Status) > 0 {
9495
cond = cond.And(builder.In("notification.status", opts.Status))
9596
}
97+
if len(opts.Source) > 0 {
98+
cond = cond.And(builder.In("notification.source", opts.Source))
99+
}
96100
if opts.UpdatedAfterUnix != 0 {
97101
cond = cond.And(builder.Gte{"notification.updated_unix": opts.UpdatedAfterUnix})
98102
}
@@ -111,13 +115,13 @@ func (opts *FindNotificationOptions) ToSession(e Engine) *xorm.Session {
111115
return sess
112116
}
113117

114-
func getNotifications(e Engine, options FindNotificationOptions) (nl NotificationList, err error) {
118+
func getNotifications(e Engine, options *FindNotificationOptions) (nl NotificationList, err error) {
115119
err = options.ToSession(e).OrderBy("notification.updated_unix DESC").Find(&nl)
116120
return
117121
}
118122

119123
// GetNotifications returns all notifications that fit to the given options.
120-
func GetNotifications(opts FindNotificationOptions) (NotificationList, error) {
124+
func GetNotifications(opts *FindNotificationOptions) (NotificationList, error) {
121125
return getNotifications(x, opts)
122126
}
123127

models/review.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ func IsContentEmptyErr(err error) bool {
347347
}
348348

349349
// SubmitReview creates a review out of the existing pending review or creates a new one if no pending review exist
350-
func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content, commitID string, stale bool) (*Review, *Comment, error) {
350+
func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content, commitID string, stale bool, attachmentUUIDs []string) (*Review, *Comment, error) {
351351
sess := x.NewSession()
352352
defer sess.Close()
353353
if err := sess.Begin(); err != nil {
@@ -419,12 +419,13 @@ func SubmitReview(doer *User, issue *Issue, reviewType ReviewType, content, comm
419419
}
420420

421421
comm, err := createComment(sess, &CreateCommentOptions{
422-
Type: CommentTypeReview,
423-
Doer: doer,
424-
Content: review.Content,
425-
Issue: issue,
426-
Repo: issue.Repo,
427-
ReviewID: review.ID,
422+
Type: CommentTypeReview,
423+
Doer: doer,
424+
Content: review.Content,
425+
Issue: issue,
426+
Repo: issue.Repo,
427+
ReviewID: review.ID,
428+
Attachments: attachmentUUIDs,
428429
})
429430
if err != nil || comm == nil {
430431
return nil, nil, err

models/ssh_key.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ import (
3838

3939
const (
4040
tplCommentPrefix = `# gitea public key`
41-
tplCommand = "%s --config=%s serv key-%d"
4241
tplPublicKey = tplCommentPrefix + "\n" + `command=%s,no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s` + "\n"
4342

4443
authorizedPrincipalsFile = "authorized_principals"
@@ -88,7 +87,16 @@ func (key *PublicKey) OmitEmail() string {
8887

8988
// AuthorizedString returns formatted public key string for authorized_keys file.
9089
func (key *PublicKey) AuthorizedString() string {
91-
return fmt.Sprintf(tplPublicKey, util.ShellEscape(fmt.Sprintf(tplCommand, util.ShellEscape(setting.AppPath), util.ShellEscape(setting.CustomConf), key.ID)), key.Content)
90+
sb := &strings.Builder{}
91+
_ = setting.SSH.AuthorizedKeysCommandTemplateTemplate.Execute(sb, map[string]interface{}{
92+
"AppPath": util.ShellEscape(setting.AppPath),
93+
"AppWorkPath": util.ShellEscape(setting.AppWorkPath),
94+
"CustomConf": util.ShellEscape(setting.CustomConf),
95+
"CustomPath": util.ShellEscape(setting.CustomPath),
96+
"Key": key,
97+
})
98+
99+
return fmt.Sprintf(tplPublicKey, util.ShellEscape(sb.String()), key.Content)
92100
}
93101

94102
func extractTypeFromBase64Key(key string) (string, error) {

models/task.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,16 @@ type Task struct {
3232
StartTime timeutil.TimeStamp
3333
EndTime timeutil.TimeStamp
3434
PayloadContent string `xorm:"TEXT"`
35-
Errors string `xorm:"TEXT"` // if task failed, saved the error reason
35+
Message string `xorm:"TEXT"` // if task failed, saved the error reason
3636
Created timeutil.TimeStamp `xorm:"created"`
3737
}
3838

39+
// TranslatableMessage represents JSON struct that can be translated with a Locale
40+
type TranslatableMessage struct {
41+
Format string
42+
Args []interface{} `json:"omitempty"`
43+
}
44+
3945
// LoadRepo loads repository of the task
4046
func (task *Task) LoadRepo() error {
4147
return task.loadRepo(x)

models/token.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,15 @@ func GetAccessTokenBySHA(token string) (*AccessToken, error) {
5757
if token == "" {
5858
return nil, ErrAccessTokenEmpty{}
5959
}
60-
if len(token) < 8 {
60+
// A token is defined as being SHA1 sum these are 40 hexadecimal bytes long
61+
if len(token) != 40 {
6162
return nil, ErrAccessTokenNotExist{token}
6263
}
64+
for _, x := range []byte(token) {
65+
if x < '0' || (x > '9' && x < 'a') || x > 'f' {
66+
return nil, ErrAccessTokenNotExist{token}
67+
}
68+
}
6369
var tokens []AccessToken
6470
lastEight := token[len(token)-8:]
6571
err := x.Table(&AccessToken{}).Where("token_last_eight = ?", lastEight).Find(&tokens)

0 commit comments

Comments
 (0)