Files
open-im-server/internal/rpc/msg/work_moments_notification.go
T

43 lines
1.2 KiB
Go
Raw Normal View History

2022-04-18 19:24:36 +08:00
package msg
import (
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
2022-04-20 16:25:33 +08:00
pbOffice "Open_IM/pkg/proto/office"
2022-04-22 16:41:41 +08:00
sdk "Open_IM/pkg/proto/sdk_ws"
2022-04-18 19:24:36 +08:00
"Open_IM/pkg/utils"
2022-04-21 10:43:31 +08:00
"github.com/golang/protobuf/jsonpb"
2022-04-20 16:25:33 +08:00
"github.com/golang/protobuf/proto"
2022-04-18 19:24:36 +08:00
)
2022-04-26 14:43:55 +08:00
func WorkMomentSendNotification(operationID, recvID string, notificationMsg *pbOffice.WorkMomentNotificationMsg) {
log.NewInfo(operationID, utils.GetSelfFuncName(), recvID, notificationMsg)
WorkMomentNotification(operationID, recvID, recvID, notificationMsg)
2022-04-20 16:25:33 +08:00
}
2022-04-21 10:43:31 +08:00
func WorkMomentNotification(operationID, sendID, recvID string, m proto.Message) {
2022-04-22 16:41:41 +08:00
var tips sdk.TipsComm
var err error
2022-04-21 10:43:31 +08:00
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
2022-04-22 16:41:41 +08:00
tips.JsonDetail, _ = marshaler.MarshalToString(m)
2022-04-20 16:25:33 +08:00
n := &NotificationMsg{
SendID: sendID,
RecvID: recvID,
MsgFrom: constant.UserMsgType,
ContentType: constant.WorkMomentNotification,
2022-04-21 16:14:26 +08:00
SessionType: constant.SingleChatType,
2022-04-20 16:25:33 +08:00
OperationID: operationID,
2022-04-18 19:24:36 +08:00
}
2022-04-22 16:41:41 +08:00
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))
2022-04-20 16:25:33 +08:00
Notification(n)
2022-04-18 19:24:36 +08:00
}