api4/user: Deduplicate userids for getUsersByIds endpoint (#24344)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2023-08-24 15:14:01 +03:00
коммит произвёл GitHub
родитель 4145fd2f4e
Коммит 639d73b3e7
3 изменённых файлов: 18 добавлений и 3 удалений

Просмотреть файл

@@ -231,13 +231,17 @@ func localGetUsers(c *Context, w http.ResponseWriter, r *http.Request) {
}
func localGetUsersByIds(c *Context, w http.ResponseWriter, r *http.Request) {
userIds := model.ArrayFromJSON(r.Body)
userIDs := model.ArrayFromJSON(r.Body)
if len(userIds) == 0 {
if len(userIDs) == 0 {
c.SetInvalidParam("user_ids")
return
}
// we remove the duplicate IDs as it can bring a significant load to the
// database.
userIDs = model.RemoveDuplicateStrings(userIDs)
sinceString := r.URL.Query().Get("since")
options := &store.UserGetByIdsOpts{
@@ -253,7 +257,7 @@ func localGetUsersByIds(c *Context, w http.ResponseWriter, r *http.Request) {
options.Since = since
}
users, appErr := c.App.GetUsersByIds(userIds, options)
users, appErr := c.App.GetUsersByIds(userIDs, options)
if appErr != nil {
c.Err = appErr
return