Files
open-im-server/internal/common/notification/msg.go
T

43 lines
1.1 KiB
Go
Raw Normal View History

2023-02-13 09:14:50 +08:00
package notification
import (
2023-02-23 19:15:30 +08:00
"OpenIM/pkg/common/constant"
"OpenIM/pkg/proto/sdkws"
2023-02-14 10:34:34 +08:00
"context"
2023-02-13 09:14:50 +08:00
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
2023-02-20 10:49:39 +08:00
func (c *Check) DeleteMessageNotification(ctx context.Context, userID string, seqs []int64, operationID string) {
DeleteMessageTips := sdkws.DeleteMessageTips{UserID: userID, Seqs: seqs}
2023-02-14 10:57:52 +08:00
c.MessageNotification(ctx, userID, userID, constant.DeleteMessageNotification, &DeleteMessageTips)
2023-02-13 09:14:50 +08:00
}
2023-02-14 10:57:52 +08:00
func (c *Check) MessageNotification(ctx context.Context, sendID, recvID string, contentType int32, m proto.Message) {
2023-02-13 09:14:50 +08:00
var err error
var tips sdkws.TipsComm
tips.Detail, err = proto.Marshal(m)
if err != nil {
return
}
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
tips.JsonDetail, _ = marshaler.MarshalToString(m)
2023-02-13 18:44:53 +08:00
var n NotificationMsg
2023-02-13 09:14:50 +08:00
n.SendID = sendID
n.RecvID = recvID
n.ContentType = contentType
n.SessionType = constant.SingleChatType
n.MsgFrom = constant.SysMsgType
n.Content, err = proto.Marshal(&tips)
if err != nil {
return
}
2023-02-14 10:57:52 +08:00
c.Notification(ctx, &n)
2023-02-13 09:14:50 +08:00
}