[APIV4] GET /users/{user_id}/status - user status endpoint for apiV4 (#5824)
Этот коммит содержится в:
коммит произвёл
George Goldberg
родитель
28ad645153
Коммит
5bf6ae04df
40
api4/status.go
Обычный файл
40
api4/status.go
Обычный файл
@@ -0,0 +1,40 @@
|
||||
// Copyright (c) 2017 Mattermost, Inc. All Rights Reserved.
|
||||
// See License.txt for license information.
|
||||
|
||||
package api4
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
l4g "github.com/alecthomas/log4go"
|
||||
|
||||
"github.com/mattermost/platform/app"
|
||||
"github.com/mattermost/platform/model"
|
||||
"github.com/mattermost/platform/utils"
|
||||
)
|
||||
|
||||
func InitStatus() {
|
||||
l4g.Debug(utils.T("api.status.init.debug"))
|
||||
|
||||
BaseRoutes.User.Handle("/status", ApiHandler(getUserStatus)).Methods("GET")
|
||||
|
||||
}
|
||||
|
||||
func getUserStatus(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
c.RequireUserId()
|
||||
if c.Err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if statusMap, err := app.GetUserStatusesByIds([]string{c.Params.UserId}); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
} else {
|
||||
if len(statusMap) == 0 {
|
||||
c.Err = model.NewAppError("UserStatus", "api.status.user_not_found.app_error", nil, "", http.StatusNotFound)
|
||||
return
|
||||
} else {
|
||||
w.Write([]byte(statusMap[0].ToJson()))
|
||||
}
|
||||
}
|
||||
}
|
||||
Ссылка в новой задаче
Block a user