(c *context.APIContext)
| 11 | ) |
| 12 | |
| 13 | func Search(c *context.APIContext) { |
| 14 | pageSize := c.QueryInt("limit") |
| 15 | if pageSize <= 0 { |
| 16 | pageSize = 10 |
| 17 | } |
| 18 | users, _, err := database.Handle.Users().SearchByName(c.Req.Context(), c.Query("q"), 1, pageSize, "") |
| 19 | if err != nil { |
| 20 | c.JSON(http.StatusInternalServerError, map[string]any{ |
| 21 | "ok": false, |
| 22 | "error": err.Error(), |
| 23 | }) |
| 24 | return |
| 25 | } |
| 26 | |
| 27 | results := make([]*api.User, len(users)) |
| 28 | for i := range users { |
| 29 | results[i] = &api.User{ |
| 30 | ID: users[i].ID, |
| 31 | UserName: users[i].Name, |
| 32 | AvatarUrl: users[i].AvatarURL(), |
| 33 | FullName: markup.Sanitize(users[i].FullName), |
| 34 | } |
| 35 | if c.IsLogged { |
| 36 | results[i].Email = users[i].Email |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | c.JSONSuccess(map[string]any{ |
| 41 | "ok": true, |
| 42 | "data": results, |
| 43 | }) |
| 44 | } |
| 45 | |
| 46 | func GetInfo(c *context.APIContext) { |
| 47 | u, err := database.Handle.Users().GetByUsername(c.Req.Context(), c.Params(":username")) |
nothing calls this directly
no test coverage detected