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/common/notification/msg_notification.go

49 lines
1.4 KiB

package notification
3 years ago
import (
"Open_IM/internal/rpc/msg"
3 years ago
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
2 years ago
sdkws "Open_IM/pkg/proto/sdkws"
3 years ago
"Open_IM/pkg/utils"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
func DeleteMessageNotification(opUserID, userID string, seqList []uint32, operationID string) {
2 years ago
DeleteMessageTips := sdkws.DeleteMessageTips{OpUserID: opUserID, UserID: userID, SeqList: seqList}
3 years ago
MessageNotification(operationID, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips)
}
func MessageNotification(operationID, sendID, recvID string, contentType int32, m proto.Message) {
log.Debug(operationID, utils.GetSelfFuncName(), "args: ", m.String(), contentType)
var err error
2 years ago
var tips sdkws.TipsComm
3 years ago
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)
var n msg.NotificationMsg
3 years ago
n.SendID = sendID
n.RecvID = recvID
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
}
msg.Notification(&n)
3 years ago
}