mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-04 00:55:59 +08:00
management system add api
This commit is contained in:
@@ -66,10 +66,6 @@ func UserSendMsg(c *gin.Context) {
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if !utils.VerifyToken(token, params.SendID) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err"})
|
||||
return
|
||||
}
|
||||
|
||||
log.InfoByKv("Ws call success to sendMsgReq", params.OperationID, "Parameters", params)
|
||||
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
)
|
||||
|
||||
type paramsImportFriendReq struct {
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UID string `json:"uid" binding:"required"`
|
||||
OwnerUid string `json:"ownerUid"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
UIDList []string `json:"uidList" binding:"required"`
|
||||
OwnerUid string `json:"ownerUid" binding:"required"`
|
||||
}
|
||||
|
||||
type paramsAddFriend struct {
|
||||
@@ -36,20 +36,19 @@ func ImportFriend(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
req := &pbFriend.ImportFriendReq{
|
||||
Uid: params.UID,
|
||||
UidList: params.UIDList,
|
||||
OperationID: params.OperationID,
|
||||
OwnerUid: params.OwnerUid,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "api add friend is server")
|
||||
RpcResp, err := client.ImportFriend(context.Background(), req)
|
||||
if err != nil {
|
||||
log.Error(req.Token, req.OperationID, "err=%s,ImportFriend failed", err)
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed"})
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "cImportFriend failed" + err.Error()})
|
||||
return
|
||||
}
|
||||
log.InfoByArgs("ImportFriend success,args=%s", RpcResp.String())
|
||||
resp := gin.H{"errCode": RpcResp.ErrorCode, "errMsg": RpcResp.ErrorMsg}
|
||||
resp := gin.H{"errCode": RpcResp.CommonResp.ErrorCode, "errMsg": RpcResp.CommonResp.ErrorMsg, "failedUidList": RpcResp.FailedUidList}
|
||||
c.JSON(http.StatusOK, resp)
|
||||
log.InfoByArgs("ImportFriend success return,get args=%s,return args=%s", req.String(), RpcResp.String())
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
type InviteUserToGroupReq struct {
|
||||
GroupID string `json:"groupID"`
|
||||
GroupID string `json:"groupID" binding:"required"`
|
||||
UidList []string `json:"uidList" binding:"required"`
|
||||
Reason string `json:"reason"`
|
||||
OperationID string `json:"operationID" binding:"required"`
|
||||
@@ -46,6 +46,7 @@ func KickGroupMember(c *gin.Context) {
|
||||
OperationID: params.OperationID,
|
||||
GroupID: params.GroupID,
|
||||
Token: c.Request.Header.Get("token"),
|
||||
|
||||
UidListInfo: params.UidListInfo,
|
||||
}
|
||||
log.Info(req.Token, req.OperationID, "recv req: ", req.String())
|
||||
|
||||
@@ -103,9 +103,10 @@ func ManagementSendMsg(c *gin.Context) {
|
||||
}
|
||||
|
||||
token := c.Request.Header.Get("token")
|
||||
if !utils.VerifyToken(token, config.Config.AppManagerUid) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "token validate err,not authorized", "sendTime": 0, "MsgID": ""})
|
||||
if !utils.IsContain(params.SendID, config.Config.Manager.AppManagerUid) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"errCode": 400, "errMsg": "not appManager", "sendTime": 0, "MsgID": ""})
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
log.InfoByKv("Ws call success to ManagementSendMsgReq", params.OperationID, "Parameters", params)
|
||||
|
||||
@@ -86,6 +86,7 @@ func main() {
|
||||
chatGroup.POST("/pull_msg", apiChat.UserPullMsg)
|
||||
chatGroup.POST("/send_msg", apiChat.UserSendMsg)
|
||||
}
|
||||
//Manager
|
||||
managementGroup := r.Group("/manager")
|
||||
{
|
||||
managementGroup.POST("/delete_user", manage.DeleteUser)
|
||||
|
||||
Reference in New Issue
Block a user