workMoments

This commit is contained in:
wangchuxiao
2022-04-21 10:43:31 +08:00
parent 2e6c42c8ac
commit 62e605a443
7 changed files with 325 additions and 236 deletions
+17 -7
View File
@@ -4,28 +4,38 @@ import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
pbOffice "Open_IM/pkg/proto/office"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
func WorkMomentSendNotification(operationID, sendID, recvID string, notificationMsg *pbOffice.WorkMomentNotificationMsg) {
log.NewInfo(operationID, utils.GetSelfFuncName(), recvID)
bytes, err := proto.Marshal(notificationMsg)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "proto marshal failed", err.Error())
}
WorkMomentNotification(operationID, sendID, recvID, bytes)
WorkMomentNotification(operationID, sendID, recvID, notificationMsg)
}
func WorkMomentNotification(operationID, sendID, recvID string, content []byte) {
func WorkMomentNotification(operationID, sendID, recvID string, m proto.Message) {
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
var tips open_im_sdk.TipsComm
var err error
tips.JsonDetail, _ = marshaler.MarshalToString(m)
n := &NotificationMsg{
SendID: sendID,
RecvID: recvID,
Content: content,
MsgFrom: constant.UserMsgType,
ContentType: constant.WorkMomentNotification,
SessionType: constant.UserMsgType,
OperationID: operationID,
}
n.Content, err = proto.Marshal(m)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "proto marshal falied", err.Error())
return
}
Notification(n)
}