You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Open-IM-Server/internal/rpc/msg/work_moments_notification.go

46 lines
1.3 KiB

3 years ago
package msg
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
3 years ago
pbOffice "Open_IM/pkg/proto/office"
3 years ago
sdk "Open_IM/pkg/proto/sdk_ws"
3 years ago
"Open_IM/pkg/utils"
3 years ago
"github.com/golang/protobuf/jsonpb"
3 years ago
"github.com/golang/protobuf/proto"
3 years ago
)
3 years ago
func WorkMomentSendNotification(operationID, sendID, recvID string, notificationMsg *pbOffice.WorkMomentNotificationMsg) {
3 years ago
log.NewInfo(operationID, utils.GetSelfFuncName(), sendID, recvID, notificationMsg)
3 years ago
if sendID == recvID {
return
}
3 years ago
WorkMomentNotification(operationID, sendID, recvID, notificationMsg)
3 years ago
}
3 years ago
func WorkMomentNotification(operationID, sendID, recvID string, m proto.Message) {
3 years ago
var tips sdk.TipsComm
var err error
3 years ago
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
3 years ago
tips.JsonDetail, _ = marshaler.MarshalToString(m)
3 years ago
n := &NotificationMsg{
SendID: sendID,
RecvID: recvID,
MsgFrom: constant.UserMsgType,
ContentType: constant.WorkMomentNotification,
3 years ago
SessionType: constant.SingleChatType,
3 years ago
OperationID: operationID,
3 years ago
}
3 years ago
n.Content, err = proto.Marshal(&tips)
if err != nil {
log.NewError(operationID, utils.GetSelfFuncName(), "proto.Marshal failed")
return
}
log.NewInfo(operationID, utils.GetSelfFuncName(), string(n.Content))
3 years ago
Notification(n)
3 years ago
}