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) {
13371337type SearchUserOptions struct {
13381338 Keyword string
13391339 Type UserType
1340+ UID int64
13401341 OrderBy SearchOrderBy
13411342 Page int
13421343 PageSize int // Can be smaller than or equal to setting.UI.ExplorePagingNum
@@ -1355,9 +1356,14 @@ func (opts *SearchUserOptions) toConds() builder.Cond {
13551356 if opts .SearchByEmail {
13561357 keywordCond = keywordCond .Or (builder.Like {"LOWER(email)" , lowerKeyword })
13571358 }
1359+
13581360 cond = cond .And (keywordCond )
13591361 }
13601362
1363+ if opts .UID > 0 {
1364+ cond = cond .And (builder.Eq {"id" : opts .UID })
1365+ }
1366+
13611367 if ! opts .IsActive .IsNone () {
13621368 cond = cond .And (builder.Eq {"is_active" : opts .IsActive .IsTrue ()})
13631369 }
Original file line number Diff line number Diff line change @@ -27,6 +27,10 @@ func Search(ctx *context.APIContext) {
2727 // in: query
2828 // description: keyword
2929 // type: string
30+ // - name: uid
31+ // in: query
32+ // description: ID of the user to search for
33+ // type: integer
3034 // - name: limit
3135 // in: query
3236 // description: maximum number of users to return
@@ -45,6 +49,7 @@ func Search(ctx *context.APIContext) {
4549 // "$ref": "#/definitions/User"
4650 opts := & models.SearchUserOptions {
4751 Keyword : strings .Trim (ctx .Query ("q" ), " " ),
52+ UID : com .StrTo (ctx .Query ("uid" )).MustInt64 (),
4853 Type : models .UserTypeIndividual ,
4954 PageSize : com .StrTo (ctx .Query ("limit" )).MustInt (),
5055 }
Original file line number Diff line number Diff line change 52035203 "name": "q",
52045204 "in": "query"
52055205 },
5206+ {
5207+ "type": "integer",
5208+ "description": "ID of the user to search for",
5209+ "name": "uid",
5210+ "in": "query"
5211+ },
52065212 {
52075213 "type": "integer",
52085214 "description": "maximum number of users to return",
You can’t perform that action at this time.
0 commit comments