File tree Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Expand file tree Collapse file tree 3 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1337,6 +1337,7 @@ func GetUser(user *User) (bool, error) {
1337
1337
type SearchUserOptions struct {
1338
1338
Keyword string
1339
1339
Type UserType
1340
+ UID int64
1340
1341
OrderBy SearchOrderBy
1341
1342
Page int
1342
1343
PageSize int // Can be smaller than or equal to setting.UI.ExplorePagingNum
@@ -1355,9 +1356,14 @@ func (opts *SearchUserOptions) toConds() builder.Cond {
1355
1356
if opts .SearchByEmail {
1356
1357
keywordCond = keywordCond .Or (builder.Like {"LOWER(email)" , lowerKeyword })
1357
1358
}
1359
+
1358
1360
cond = cond .And (keywordCond )
1359
1361
}
1360
1362
1363
+ if opts .UID > 0 {
1364
+ cond = cond .And (builder.Eq {"id" : opts .UID })
1365
+ }
1366
+
1361
1367
if ! opts .IsActive .IsNone () {
1362
1368
cond = cond .And (builder.Eq {"is_active" : opts .IsActive .IsTrue ()})
1363
1369
}
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ func Search(ctx *context.APIContext) {
27
27
// in: query
28
28
// description: keyword
29
29
// type: string
30
+ // - name: uid
31
+ // in: query
32
+ // description: ID of the user to search for
33
+ // type: integer
30
34
// - name: limit
31
35
// in: query
32
36
// description: maximum number of users to return
@@ -45,6 +49,7 @@ func Search(ctx *context.APIContext) {
45
49
// "$ref": "#/definitions/User"
46
50
opts := & models.SearchUserOptions {
47
51
Keyword : strings .Trim (ctx .Query ("q" ), " " ),
52
+ UID : com .StrTo (ctx .Query ("uid" )).MustInt64 (),
48
53
Type : models .UserTypeIndividual ,
49
54
PageSize : com .StrTo (ctx .Query ("limit" )).MustInt (),
50
55
}
Original file line number Diff line number Diff line change 5203
5203
"name": "q",
5204
5204
"in": "query"
5205
5205
},
5206
+ {
5207
+ "type": "integer",
5208
+ "description": "ID of the user to search for",
5209
+ "name": "uid",
5210
+ "in": "query"
5211
+ },
5206
5212
{
5207
5213
"type": "integer",
5208
5214
"description": "maximum number of users to return",
You can’t perform that action at this time.
0 commit comments