mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-06 04:15:46 +08:00
Merge branch 'tuoyun' of github.com:OpenIMSDK/Open-IM-Server into tuoyun
This commit is contained in:
commit
9df4a79827
@ -1 +1 @@
|
|||||||
Subproject commit fd87b4bfc3ee7e9f4c50140b884eb4505d00bc44
|
Subproject commit 539290887aff41515b291b7ecf174af25887f870
|
@ -159,6 +159,7 @@ func main() {
|
|||||||
organizationGroup.POST("/update_department", organization.UpdateDepartment)
|
organizationGroup.POST("/update_department", organization.UpdateDepartment)
|
||||||
organizationGroup.POST("/get_sub_department", organization.GetSubDepartment)
|
organizationGroup.POST("/get_sub_department", organization.GetSubDepartment)
|
||||||
organizationGroup.POST("/delete_department", organization.DeleteDepartment)
|
organizationGroup.POST("/delete_department", organization.DeleteDepartment)
|
||||||
|
organizationGroup.POST("/get_all_department", organization.GetAllDepartment)
|
||||||
|
|
||||||
organizationGroup.POST("/create_organization_user", organization.CreateOrganizationUser)
|
organizationGroup.POST("/create_organization_user", organization.CreateOrganizationUser)
|
||||||
organizationGroup.POST("/update_organization_user", organization.UpdateOrganizationUser)
|
organizationGroup.POST("/update_organization_user", organization.UpdateOrganizationUser)
|
||||||
@ -170,6 +171,7 @@ func main() {
|
|||||||
|
|
||||||
organizationGroup.POST("/get_department_member", organization.GetDepartmentMember)
|
organizationGroup.POST("/get_department_member", organization.GetDepartmentMember)
|
||||||
organizationGroup.POST("/delete_user_in_department", organization.DeleteUserInDepartment)
|
organizationGroup.POST("/delete_user_in_department", organization.DeleteUserInDepartment)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
go apiThird.MinioInit()
|
go apiThird.MinioInit()
|
||||||
|
@ -446,6 +446,20 @@ notification:
|
|||||||
tips: "group member info set"
|
tips: "group member info set"
|
||||||
|
|
||||||
|
|
||||||
|
organizationChanged:
|
||||||
|
conversation:
|
||||||
|
reliabilityLevel: 2
|
||||||
|
unreadCount: false
|
||||||
|
offlinePush:
|
||||||
|
switch: false
|
||||||
|
title: "organizationChanged title"
|
||||||
|
desc: "organizationChanged desc"
|
||||||
|
ext: "organizationChanged ext"
|
||||||
|
defaultTips:
|
||||||
|
tips: "organization changed"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#############################friend#################################
|
#############################friend#################################
|
||||||
|
|
||||||
friendApplicationAdded:
|
friendApplicationAdded:
|
||||||
|
@ -134,12 +134,7 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(config.Config.Manager.AppManagerUid) == 0 {
|
|
||||||
log.NewError(req.OperationID, "Manager == 0")
|
|
||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "Manager == 0"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
req.OpUserID = config.Config.Manager.AppManagerUid[0]
|
|
||||||
log.NewInfo(params.OperationID, "GetUsersOnlineStatus args ", req.String())
|
log.NewInfo(params.OperationID, "GetUsersOnlineStatus args ", req.String())
|
||||||
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||||
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||||
|
@ -122,6 +122,10 @@ func GetSubDepartment(c *gin.Context) {
|
|||||||
c.JSON(http.StatusOK, apiResp)
|
c.JSON(http.StatusOK, apiResp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetAllDepartment(c *gin.Context) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func DeleteDepartment(c *gin.Context) {
|
func DeleteDepartment(c *gin.Context) {
|
||||||
params := api.DeleteDepartmentReq{}
|
params := api.DeleteDepartmentReq{}
|
||||||
if err := c.BindJSON(¶ms); err != nil {
|
if err := c.BindJSON(¶ms); err != nil {
|
||||||
|
@ -145,6 +145,13 @@ func GetUsersOnlineStatus(c *gin.Context) {
|
|||||||
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(config.Config.Manager.AppManagerUid) == 0 {
|
||||||
|
log.NewError(req.OperationID, "Manager == 0")
|
||||||
|
c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "Manager == 0"})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.OpUserID = config.Config.Manager.AppManagerUid[0]
|
||||||
|
|
||||||
log.NewInfo(params.OperationID, "GetUsersOnlineStatus args ", req.String())
|
log.NewInfo(params.OperationID, "GetUsersOnlineStatus args ", req.String())
|
||||||
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
var wsResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||||
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
var respResult []*pbRelay.GetUsersOnlineStatusResp_SuccessResult
|
||||||
|
76
internal/rpc/msg/organization_notification.go
Normal file
76
internal/rpc/msg/organization_notification.go
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package msg
|
||||||
|
|
||||||
|
import (
|
||||||
|
"Open_IM/pkg/common/constant"
|
||||||
|
imdb "Open_IM/pkg/common/db/mysql_model/im_mysql_model"
|
||||||
|
"Open_IM/pkg/common/log"
|
||||||
|
utils2 "Open_IM/pkg/common/utils"
|
||||||
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
|
"github.com/golang/protobuf/jsonpb"
|
||||||
|
"github.com/golang/protobuf/proto"
|
||||||
|
)
|
||||||
|
|
||||||
|
func OrganizationNotificationToAll(opUserID string, operationID string) {
|
||||||
|
err, userIDList := imdb.GetAllOrganizationUserID()
|
||||||
|
if err != nil {
|
||||||
|
log.Error(operationID, "GetAllOrganizationUserID failed ", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
tips := open_im_sdk.OrganizationChangedTips{OpUser: &open_im_sdk.UserInfo{}}
|
||||||
|
|
||||||
|
user, err := imdb.GetUserByUserID(opUserID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(operationID, "GetUserByUserID failed ", err.Error(), opUserID)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
utils2.UserDBCopyOpenIM(tips.OpUser, user)
|
||||||
|
|
||||||
|
for _, v := range userIDList {
|
||||||
|
log.Debug(operationID, "OrganizationNotification", opUserID, v, constant.OrganizationChangedNotification, &tips, operationID)
|
||||||
|
OrganizationNotification(opUserID, v, constant.OrganizationChangedNotification, &tips, operationID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func OrganizationNotification(opUserID string, recvUserID string, contentType int32, m proto.Message, operationID string) {
|
||||||
|
log.Info(operationID, utils.GetSelfFuncName(), "args: ", contentType, opUserID)
|
||||||
|
var err error
|
||||||
|
var tips open_im_sdk.TipsComm
|
||||||
|
tips.Detail, err = proto.Marshal(m)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(operationID, "Marshal failed ", err.Error(), m.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
marshaler := jsonpb.Marshaler{
|
||||||
|
OrigName: true,
|
||||||
|
EnumsAsInts: false,
|
||||||
|
EmitDefaults: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
tips.JsonDetail, _ = marshaler.MarshalToString(m)
|
||||||
|
|
||||||
|
switch contentType {
|
||||||
|
case constant.OrganizationChangedNotification:
|
||||||
|
tips.DefaultTips = "OrganizationChangedNotification"
|
||||||
|
|
||||||
|
default:
|
||||||
|
log.Error(operationID, "contentType failed ", contentType)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var n NotificationMsg
|
||||||
|
n.SendID = opUserID
|
||||||
|
n.RecvID = recvUserID
|
||||||
|
n.ContentType = contentType
|
||||||
|
n.SessionType = constant.SingleChatType
|
||||||
|
n.MsgFrom = constant.SysMsgType
|
||||||
|
n.OperationID = operationID
|
||||||
|
n.Content, err = proto.Marshal(&tips)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(operationID, "Marshal failed ", err.Error(), tips.String())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Notification(&n)
|
||||||
|
}
|
@ -562,6 +562,23 @@ func Notification(n *NotificationMsg) {
|
|||||||
ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext
|
ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext
|
||||||
reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel
|
reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel
|
||||||
unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount
|
unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount
|
||||||
|
|
||||||
|
case constant.GroupMemberInfoSetNotification:
|
||||||
|
pushSwitch = config.Config.Notification.GroupMemberInfoSet.OfflinePush.PushSwitch
|
||||||
|
title = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Title
|
||||||
|
desc = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Desc
|
||||||
|
ex = config.Config.Notification.GroupMemberInfoSet.OfflinePush.Ext
|
||||||
|
reliabilityLevel = config.Config.Notification.GroupMemberInfoSet.Conversation.ReliabilityLevel
|
||||||
|
unReadCount = config.Config.Notification.GroupMemberInfoSet.Conversation.UnreadCount
|
||||||
|
|
||||||
|
case constant.OrganizationChangedNotification:
|
||||||
|
pushSwitch = config.Config.Notification.OrganizationChanged.OfflinePush.PushSwitch
|
||||||
|
title = config.Config.Notification.OrganizationChanged.OfflinePush.Title
|
||||||
|
desc = config.Config.Notification.OrganizationChanged.OfflinePush.Desc
|
||||||
|
ex = config.Config.Notification.OrganizationChanged.OfflinePush.Ext
|
||||||
|
reliabilityLevel = config.Config.Notification.OrganizationChanged.Conversation.ReliabilityLevel
|
||||||
|
unReadCount = config.Config.Notification.OrganizationChanged.Conversation.UnreadCount
|
||||||
|
|
||||||
}
|
}
|
||||||
switch reliabilityLevel {
|
switch reliabilityLevel {
|
||||||
case constant.UnreliableNotification:
|
case constant.UnreliableNotification:
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package organization
|
package organization
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
chat "Open_IM/internal/rpc/msg"
|
||||||
"Open_IM/pkg/common/config"
|
"Open_IM/pkg/common/config"
|
||||||
"Open_IM/pkg/common/constant"
|
"Open_IM/pkg/common/constant"
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
@ -8,16 +9,16 @@ import (
|
|||||||
"Open_IM/pkg/common/log"
|
"Open_IM/pkg/common/log"
|
||||||
"Open_IM/pkg/common/token_verify"
|
"Open_IM/pkg/common/token_verify"
|
||||||
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
"Open_IM/pkg/grpc-etcdv3/getcdv3"
|
||||||
|
"Open_IM/pkg/proto/auth"
|
||||||
rpc "Open_IM/pkg/proto/organization"
|
rpc "Open_IM/pkg/proto/organization"
|
||||||
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
|
||||||
"Open_IM/pkg/utils"
|
"Open_IM/pkg/utils"
|
||||||
"time"
|
|
||||||
|
|
||||||
"context"
|
"context"
|
||||||
"google.golang.org/grpc"
|
"google.golang.org/grpc"
|
||||||
"net"
|
"net"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type organizationServer struct {
|
type organizationServer struct {
|
||||||
@ -97,6 +98,7 @@ func (s *organizationServer) CreateDepartment(ctx context.Context, req *rpc.Crea
|
|||||||
resp := &rpc.CreateDepartmentResp{DepartmentInfo: &open_im_sdk.Department{}}
|
resp := &rpc.CreateDepartmentResp{DepartmentInfo: &open_im_sdk.Department{}}
|
||||||
utils.CopyStructFields(resp.DepartmentInfo, createdDepartment)
|
utils.CopyStructFields(resp.DepartmentInfo, createdDepartment)
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
||||||
|
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +122,7 @@ func (s *organizationServer) UpdateDepartment(ctx context.Context, req *rpc.Upda
|
|||||||
|
|
||||||
resp := &rpc.UpdateDepartmentResp{}
|
resp := &rpc.UpdateDepartmentResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
||||||
|
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,6 +140,16 @@ func (s *organizationServer) GetSubDepartment(ctx context.Context, req *rpc.GetS
|
|||||||
v1 := open_im_sdk.Department{}
|
v1 := open_im_sdk.Department{}
|
||||||
utils.CopyStructFields(&v1, v)
|
utils.CopyStructFields(&v1, v)
|
||||||
log.Debug(req.OperationID, "src ", v, "dst ", v1)
|
log.Debug(req.OperationID, "src ", v, "dst ", v1)
|
||||||
|
err, v1.MemberNum = imdb.GetDepartmentMemberNum(v1.DepartmentID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "GetDepartmentMemberNum failed ", err.Error(), v1.DepartmentID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
err, v1.SubDepartmentNum = imdb.GetSubDepartmentNum(v1.DepartmentID)
|
||||||
|
if err != nil {
|
||||||
|
log.Error(req.OperationID, "GetSubDepartmentNum failed ", err.Error(), v1.DepartmentID)
|
||||||
|
continue
|
||||||
|
}
|
||||||
resp.DepartmentList = append(resp.DepartmentList, &v1)
|
resp.DepartmentList = append(resp.DepartmentList, &v1)
|
||||||
}
|
}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
||||||
@ -159,10 +172,29 @@ func (s *organizationServer) DeleteDepartment(ctx context.Context, req *rpc.Dele
|
|||||||
log.Debug(req.OperationID, "DeleteDepartment ", req.DepartmentID)
|
log.Debug(req.OperationID, "DeleteDepartment ", req.DepartmentID)
|
||||||
resp := &rpc.DeleteDepartmentResp{}
|
resp := &rpc.DeleteDepartmentResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp)
|
||||||
|
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *organizationServer) CreateOrganizationUser(ctx context.Context, req *rpc.CreateOrganizationUserReq) (*rpc.CreateOrganizationUserResp, error) {
|
func (s *organizationServer) CreateOrganizationUser(ctx context.Context, req *rpc.CreateOrganizationUserReq) (*rpc.CreateOrganizationUserResp, error) {
|
||||||
|
authReq := &pbAuth.UserRegisterReq{UserInfo: &open_im_sdk.UserInfo{}}
|
||||||
|
utils.CopyStructFields(authReq.UserInfo, req.OrganizationUser)
|
||||||
|
authReq.OperationID = req.OperationID
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||||
|
client := pbAuth.NewAuthClient(etcdConn)
|
||||||
|
|
||||||
|
reply, err := client.UserRegister(context.Background(), authReq)
|
||||||
|
if err != nil {
|
||||||
|
errMsg := "UserRegister failed " + err.Error()
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
return &rpc.CreateOrganizationUserResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
|
||||||
|
}
|
||||||
|
if reply.CommonResp.ErrCode != 0 {
|
||||||
|
errMsg := "UserRegister failed " + reply.CommonResp.ErrMsg
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
return &rpc.CreateOrganizationUserResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
|
||||||
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||||
if !token_verify.IsManagerUserID(req.OpUserID) {
|
if !token_verify.IsManagerUserID(req.OpUserID) {
|
||||||
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
|
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
|
||||||
@ -173,7 +205,7 @@ func (s *organizationServer) CreateOrganizationUser(ctx context.Context, req *rp
|
|||||||
utils.CopyStructFields(&organizationUser, req.OrganizationUser)
|
utils.CopyStructFields(&organizationUser, req.OrganizationUser)
|
||||||
organizationUser.Birth = utils.UnixSecondToTime(int64(req.OrganizationUser.Birth))
|
organizationUser.Birth = utils.UnixSecondToTime(int64(req.OrganizationUser.Birth))
|
||||||
log.Debug(req.OperationID, "src ", *req.OrganizationUser, "dst ", organizationUser)
|
log.Debug(req.OperationID, "src ", *req.OrganizationUser, "dst ", organizationUser)
|
||||||
err := imdb.CreateOrganizationUser(&organizationUser)
|
err = imdb.CreateOrganizationUser(&organizationUser)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " " + "CreateOrganizationUser failed " + err.Error()
|
errMsg := req.OperationID + " " + "CreateOrganizationUser failed " + err.Error()
|
||||||
log.Error(req.OperationID, errMsg, organizationUser)
|
log.Error(req.OperationID, errMsg, organizationUser)
|
||||||
@ -182,10 +214,29 @@ func (s *organizationServer) CreateOrganizationUser(ctx context.Context, req *rp
|
|||||||
log.Debug(req.OperationID, "CreateOrganizationUser ", organizationUser)
|
log.Debug(req.OperationID, "CreateOrganizationUser ", organizationUser)
|
||||||
resp := &rpc.CreateOrganizationUserResp{}
|
resp := &rpc.CreateOrganizationUserResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
||||||
|
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *organizationServer) UpdateOrganizationUser(ctx context.Context, req *rpc.UpdateOrganizationUserReq) (*rpc.UpdateOrganizationUserResp, error) {
|
func (s *organizationServer) UpdateOrganizationUser(ctx context.Context, req *rpc.UpdateOrganizationUserReq) (*rpc.UpdateOrganizationUserResp, error) {
|
||||||
|
authReq := &pbAuth.UserRegisterReq{UserInfo: &open_im_sdk.UserInfo{}}
|
||||||
|
utils.CopyStructFields(authReq.UserInfo, req.OrganizationUser)
|
||||||
|
authReq.OperationID = req.OperationID
|
||||||
|
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImAuthName)
|
||||||
|
client := pbAuth.NewAuthClient(etcdConn)
|
||||||
|
|
||||||
|
reply, err := client.UserRegister(context.Background(), authReq)
|
||||||
|
if err != nil {
|
||||||
|
errMsg := "UserRegister failed " + err.Error()
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
return &rpc.UpdateOrganizationUserResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
|
||||||
|
}
|
||||||
|
if reply.CommonResp.ErrCode != 0 {
|
||||||
|
errMsg := "UserRegister failed " + reply.CommonResp.ErrMsg
|
||||||
|
log.NewError(req.OperationID, errMsg)
|
||||||
|
return &rpc.UpdateOrganizationUserResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: errMsg}, nil
|
||||||
|
}
|
||||||
|
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc args ", req.String())
|
||||||
if !token_verify.IsManagerUserID(req.OpUserID) {
|
if !token_verify.IsManagerUserID(req.OpUserID) {
|
||||||
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
|
errMsg := req.OperationID + " " + req.OpUserID + " is not app manager"
|
||||||
@ -200,7 +251,7 @@ func (s *organizationServer) UpdateOrganizationUser(ctx context.Context, req *rp
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Debug(req.OperationID, "src ", *req.OrganizationUser, "dst ", organizationUser)
|
log.Debug(req.OperationID, "src ", *req.OrganizationUser, "dst ", organizationUser)
|
||||||
err := imdb.UpdateOrganizationUser(&organizationUser, nil)
|
err = imdb.UpdateOrganizationUser(&organizationUser, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errMsg := req.OperationID + " " + "CreateOrganizationUser failed " + err.Error()
|
errMsg := req.OperationID + " " + "CreateOrganizationUser failed " + err.Error()
|
||||||
log.Error(req.OperationID, errMsg, organizationUser)
|
log.Error(req.OperationID, errMsg, organizationUser)
|
||||||
@ -209,6 +260,7 @@ func (s *organizationServer) UpdateOrganizationUser(ctx context.Context, req *rp
|
|||||||
log.Debug(req.OperationID, "UpdateOrganizationUser ", organizationUser)
|
log.Debug(req.OperationID, "UpdateOrganizationUser ", organizationUser)
|
||||||
resp := &rpc.UpdateOrganizationUserResp{}
|
resp := &rpc.UpdateOrganizationUserResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp)
|
||||||
|
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,6 +292,7 @@ func (s *organizationServer) CreateDepartmentMember(ctx context.Context, req *rp
|
|||||||
|
|
||||||
resp := &rpc.CreateDepartmentMemberResp{}
|
resp := &rpc.CreateDepartmentMemberResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
||||||
|
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,6 +351,7 @@ func (s *organizationServer) UpdateUserInDepartment(ctx context.Context, req *rp
|
|||||||
}
|
}
|
||||||
resp := &rpc.UpdateUserInDepartmentResp{}
|
resp := &rpc.UpdateUserInDepartmentResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
||||||
|
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,6 +372,7 @@ func (s *organizationServer) DeleteUserInDepartment(ctx context.Context, req *rp
|
|||||||
log.Debug(req.OperationID, "DeleteUserInDepartment success ", req.DepartmentID, req.UserID)
|
log.Debug(req.OperationID, "DeleteUserInDepartment success ", req.DepartmentID, req.UserID)
|
||||||
resp := &rpc.DeleteUserInDepartmentResp{}
|
resp := &rpc.DeleteUserInDepartmentResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
||||||
|
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,6 +392,7 @@ func (s *organizationServer) DeleteOrganizationUser(ctx context.Context, req *rp
|
|||||||
log.Debug(req.OperationID, "DeleteOrganizationUser success ", req.UserID)
|
log.Debug(req.OperationID, "DeleteOrganizationUser success ", req.UserID)
|
||||||
resp := &rpc.DeleteOrganizationUserResp{}
|
resp := &rpc.DeleteOrganizationUserResp{}
|
||||||
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
|
||||||
|
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +309,11 @@ type config struct {
|
|||||||
OfflinePush POfflinePush `yaml:"offlinePush"`
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||||
} `yaml:"groupMemberInfoSet"`
|
} `yaml:"groupMemberInfoSet"`
|
||||||
|
OrganizationChanged struct {
|
||||||
|
Conversation PConversation `yaml:"conversation"`
|
||||||
|
OfflinePush POfflinePush `yaml:"offlinePush"`
|
||||||
|
DefaultTips PDefaultTips `yaml:"defaultTips"`
|
||||||
|
} `yaml:"organizationChanged"`
|
||||||
|
|
||||||
////////////////////////user///////////////////////
|
////////////////////////user///////////////////////
|
||||||
UserInfoUpdated struct {
|
UserInfoUpdated struct {
|
||||||
|
@ -2,6 +2,7 @@ package im_mysql_model
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"Open_IM/pkg/common/db"
|
"Open_IM/pkg/common/db"
|
||||||
|
"Open_IM/pkg/utils"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -44,7 +45,12 @@ func GetSubDepartmentList(departmentID string) (error, []db.Department) {
|
|||||||
return err, nil
|
return err, nil
|
||||||
}
|
}
|
||||||
var departmentList []db.Department
|
var departmentList []db.Department
|
||||||
err = dbConn.Table("departments").Where("parent_id=?", departmentID).Find(&departmentList).Error
|
if departmentID == "-1" {
|
||||||
|
err = dbConn.Table("departments").Find(&departmentList).Error
|
||||||
|
} else {
|
||||||
|
err = dbConn.Table("departments").Where("parent_id=?", departmentID).Find(&departmentList).Error
|
||||||
|
}
|
||||||
|
|
||||||
return err, departmentList
|
return err, departmentList
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,9 +187,52 @@ func GetDepartmentMemberList(departmentID string) (error, []db.DepartmentMember)
|
|||||||
return err, nil
|
return err, nil
|
||||||
}
|
}
|
||||||
var departmentMemberList []db.DepartmentMember
|
var departmentMemberList []db.DepartmentMember
|
||||||
err = dbConn.Table("department_members").Where("department_id=?", departmentID).Find(&departmentMemberList).Error
|
if departmentID == "-1" {
|
||||||
|
err = dbConn.Table("department_members").Find(&departmentMemberList).Error
|
||||||
|
} else {
|
||||||
|
err = dbConn.Table("department_members").Where("department_id=?", departmentID).Find(&departmentMemberList).Error
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err, nil
|
return err, nil
|
||||||
}
|
}
|
||||||
return err, departmentMemberList
|
return err, departmentMemberList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetAllOrganizationUserID() (error, []string) {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return err, nil
|
||||||
|
}
|
||||||
|
var OrganizationUser db.OrganizationUser
|
||||||
|
var result []string
|
||||||
|
return dbConn.Model(&OrganizationUser).Pluck("user_id", &result).Error, result
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetDepartmentMemberNum(departmentID string) (error, uint32) {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "DefaultGormDB failed"), 0
|
||||||
|
}
|
||||||
|
var number uint32
|
||||||
|
err = dbConn.Table("department_members").Where("department_id=?", departmentID).Count(&number).Error
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, ""), 0
|
||||||
|
}
|
||||||
|
return nil, number
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetSubDepartmentNum(departmentID string) (error, uint32) {
|
||||||
|
dbConn, err := db.DB.MysqlDB.DefaultGormDB()
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, "DefaultGormDB failed"), 0
|
||||||
|
}
|
||||||
|
var number uint32
|
||||||
|
err = dbConn.Table("departments").Where("parent_id=?", departmentID).Count(&number).Error
|
||||||
|
if err != nil {
|
||||||
|
return utils.Wrap(err, ""), 0
|
||||||
|
}
|
||||||
|
return nil, number
|
||||||
|
|
||||||
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -358,6 +358,13 @@ message GroupMemberInfoSetTips{
|
|||||||
GroupMemberFullInfo changedUser = 4;
|
GroupMemberFullInfo changedUser = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message OrganizationChangedTips{
|
||||||
|
UserInfo opUser = 2;
|
||||||
|
int64 operationTime = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////friend/////////////////////
|
//////////////////////friend/////////////////////
|
||||||
//message FriendInfo{
|
//message FriendInfo{
|
||||||
// UserInfo OwnerUser = 1;
|
// UserInfo OwnerUser = 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user