organization

This commit is contained in:
skiffer-git
2022-04-19 16:40:57 +08:00
committed by Xinwei Xiong(cubxxw-openim)
parent 4adb409fc5
commit 0122c4f9ce
9 changed files with 430 additions and 263 deletions
@@ -122,6 +122,10 @@ func GetSubDepartment(c *gin.Context) {
c.JSON(http.StatusOK, apiResp)
}
func GetAllDepartment(c *gin.Context) {
}
func DeleteDepartment(c *gin.Context) {
params := api.DeleteDepartmentReq{}
if err := c.BindJSON(&params); err != nil {
@@ -0,0 +1,75 @@
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 {
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)
}
+1
View File
@@ -562,6 +562,7 @@ func Notification(n *NotificationMsg) {
ex = config.Config.Notification.GroupMemberCancelMuted.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.GroupMemberCancelMuted.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.GroupMemberCancelMuted.Conversation.UnreadCount
}
switch reliabilityLevel {
case constant.UnreliableNotification:
+10
View File
@@ -1,6 +1,7 @@
package organization
import (
chat "Open_IM/internal/rpc/msg"
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/db"
@@ -97,6 +98,7 @@ func (s *organizationServer) CreateDepartment(ctx context.Context, req *rpc.Crea
resp := &rpc.CreateDepartmentResp{DepartmentInfo: &open_im_sdk.Department{}}
utils.CopyStructFields(resp.DepartmentInfo, createdDepartment)
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@@ -120,6 +122,7 @@ func (s *organizationServer) UpdateDepartment(ctx context.Context, req *rpc.Upda
resp := &rpc.UpdateDepartmentResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@@ -159,6 +162,7 @@ func (s *organizationServer) DeleteDepartment(ctx context.Context, req *rpc.Dele
log.Debug(req.OperationID, "DeleteDepartment ", req.DepartmentID)
resp := &rpc.DeleteDepartmentResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@@ -182,6 +186,7 @@ func (s *organizationServer) CreateOrganizationUser(ctx context.Context, req *rp
log.Debug(req.OperationID, "CreateOrganizationUser ", organizationUser)
resp := &rpc.CreateOrganizationUserResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@@ -209,6 +214,7 @@ func (s *organizationServer) UpdateOrganizationUser(ctx context.Context, req *rp
log.Debug(req.OperationID, "UpdateOrganizationUser ", organizationUser)
resp := &rpc.UpdateOrganizationUserResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@@ -240,6 +246,7 @@ func (s *organizationServer) CreateDepartmentMember(ctx context.Context, req *rp
resp := &rpc.CreateDepartmentMemberResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@@ -298,6 +305,7 @@ func (s *organizationServer) UpdateUserInDepartment(ctx context.Context, req *rp
}
resp := &rpc.UpdateUserInDepartmentResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@@ -318,6 +326,7 @@ func (s *organizationServer) DeleteUserInDepartment(ctx context.Context, req *rp
log.Debug(req.OperationID, "DeleteUserInDepartment success ", req.DepartmentID, req.UserID)
resp := &rpc.DeleteUserInDepartmentResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}
@@ -337,6 +346,7 @@ func (s *organizationServer) DeleteOrganizationUser(ctx context.Context, req *rp
log.Debug(req.OperationID, "DeleteOrganizationUser success ", req.UserID)
resp := &rpc.DeleteOrganizationUserResp{}
log.NewInfo(req.OperationID, utils.GetSelfFuncName(), " rpc return ", *resp)
chat.OrganizationNotificationToAll(req.OpUserID, req.OperationID)
return resp, nil
}