Files
open-im-server/internal/api/user.go
T

60 lines
1.7 KiB
Go
Raw Normal View History

2023-02-28 14:20:26 +08:00
package api
2021-12-27 16:48:05 +08:00
import (
2023-06-20 17:03:20 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/a2r"
2023-05-06 10:27:07 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
2023-06-20 17:03:20 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
2023-03-16 10:46:06 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
2023-06-20 17:03:20 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
2023-03-16 10:46:06 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/user"
2023-06-20 22:12:01 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/rpcclient"
2022-08-17 14:57:57 +08:00
"github.com/gin-gonic/gin"
2021-12-27 16:48:05 +08:00
)
2023-06-20 22:12:01 +08:00
type UserApi rpcclient.User
2022-04-27 14:43:46 +08:00
2023-06-20 22:12:01 +08:00
func NewUserApi(discov discoveryregistry.SvcDiscoveryRegistry) UserApi {
return UserApi(*rpcclient.NewUser(discov))
2021-12-27 16:48:05 +08:00
}
2023-06-20 22:12:01 +08:00
func (u *UserApi) UserRegister(c *gin.Context) {
2023-06-20 21:15:23 +08:00
a2r.Call(user.UserClient.UserRegister, u.Client, c)
2023-03-03 18:08:26 +08:00
}
2023-06-20 22:12:01 +08:00
func (u *UserApi) UpdateUserInfo(c *gin.Context) {
2023-06-20 21:15:23 +08:00
a2r.Call(user.UserClient.UpdateUserInfo, u.Client, c)
2021-12-27 16:48:05 +08:00
}
2022-06-24 17:45:33 +08:00
2023-06-20 22:12:01 +08:00
func (u *UserApi) SetGlobalRecvMessageOpt(c *gin.Context) {
2023-06-20 21:15:23 +08:00
a2r.Call(user.UserClient.SetGlobalRecvMessageOpt, u.Client, c)
2022-06-16 19:33:35 +08:00
}
2022-01-13 11:10:29 +08:00
2023-06-20 22:12:01 +08:00
func (u *UserApi) GetUsersPublicInfo(c *gin.Context) {
2023-06-20 21:15:23 +08:00
a2r.Call(user.UserClient.GetDesignateUsers, u.Client, c)
2022-01-13 11:10:29 +08:00
}
2022-04-18 14:27:12 +08:00
2023-06-20 22:12:01 +08:00
func (u *UserApi) GetAllUsersID(c *gin.Context) {
2023-06-20 21:15:23 +08:00
a2r.Call(user.UserClient.GetDesignateUsers, u.Client, c)
2023-03-03 19:44:34 +08:00
}
2023-06-20 22:12:01 +08:00
func (u *UserApi) AccountCheck(c *gin.Context) {
2023-06-20 21:15:23 +08:00
a2r.Call(user.UserClient.AccountCheck, u.Client, c)
2023-03-03 19:44:34 +08:00
}
2023-02-28 11:38:05 +08:00
2023-06-20 22:12:01 +08:00
func (u *UserApi) GetUsers(c *gin.Context) {
2023-06-20 21:15:23 +08:00
a2r.Call(user.UserClient.GetPaginationUsers, u.Client, c)
2022-08-26 17:51:01 +08:00
}
2023-05-30 16:15:11 +08:00
2023-06-20 22:12:01 +08:00
func (u *UserApi) GetUsersOnlineStatus(c *gin.Context) {
2023-05-06 10:27:07 +08:00
params := apistruct.ManagementSendMsgReq{}
if err := c.BindJSON(&params); err != nil {
apiresp.GinError(c, errs.ErrArgs.WithDetail(err.Error()).Wrap())
return
}
if !tokenverify.IsAppManagerUid(c) {
apiresp.GinError(c, errs.ErrNoPermission.Wrap("only app manager can send message"))
return
}
}