conversation opt

pull/137/head
wangchuxiao 3 years ago
parent a8334a22f8
commit 648a852ba7

@ -6,7 +6,7 @@ import (
)
func main() {
rpcPort := flag.Int("port", 10300, "rpc listening port")
rpcPort := flag.Int("port", 10301, "rpc listening port")
flag.Parse()
rpcServer := rpcChat.NewRpcChatServer(*rpcPort)
rpcServer.Run()

@ -6,7 +6,7 @@ import (
)
func main() {
rpcPort := flag.Int("port", 10100, "rpc listening port")
rpcPort := flag.Int("port", 10101, "rpc listening port")
flag.Parse()
rpcServer := user.NewUserServer(*rpcPort)
rpcServer.Run()

@ -8,10 +8,10 @@ etcd:
etcdAddr: [ 127.0.0.1:2379 ]
mysql:
dbMysqlAddress: [ 43.128.5.63:13306 ]
dbMysqlAddress: [ 127.0.0.1:13306 ]
dbMysqlUserName: root
dbMysqlPassword: openIM
dbMysqlDatabaseName: openIMtest1
dbMysqlDatabaseName: openIM
dbTableName: eMsg
dbMsgTableNum: 1
dbMaxOpenConns: 20
@ -19,7 +19,7 @@ mysql:
dbMaxLifeTime: 120
mongo:
dbAddress: [ 43.128.5.63:37017 ]
dbAddress: [ 127.0.0.1:37017 ]
dbDirect: false
dbTimeout: 10
dbDatabase: openIM
@ -30,7 +30,7 @@ mongo:
dbRetainChatRecords: 7
redis:
dbAddress: 43.128.5.63:16379
dbAddress: 127.0.0.1:16379
dbMaxIdle: 128
dbMaxActive: 0
dbIdleTimeout: 120
@ -426,7 +426,18 @@ notification:
defaultTips:
tips: "Remove a blocked user"
#####################conversation#########################
conversationOptUpdate:
conversation:
reliabilityLevel: 2
unreadCount: false
offlinePush:
switch: true
title: "conversation opt update"
desc: "conversation opt update"
ext: "conversation opt update"
defaultTips:
tips: "conversation opt update"

@ -324,7 +324,7 @@ func GetUserReqGroupApplicationList(c *gin.Context) {
}
req := &rpc.GetUserReqApplicationListReq{}
utils.CopyStructFields(req, params)
//ok, req.OpUserID = token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
//ok, req.OpUserID := token_verify.GetUserIDFromToken(c.Request.Header.Get("token"))
//if !ok {
// log.NewError(req.OperationID, "GetUserIDFromToken false ", c.Request.Header.Get("token"))
// c.JSON(http.StatusInternalServerError, gin.H{"errCode": 500, "errMsg": "GetUserIDFromToken failed"})

@ -155,7 +155,7 @@ func AddUser(c *gin.Context) {
reqPb pb.AddUserReq
)
if err := c.BindJSON(&req); err != nil {
log.NewError("0", "BindJSON failed ", err.Error())
log.NewError(reqPb.OperationID, utils.GetSelfFuncName(), "BindJSON failed ", err.Error())
openIMHttp.RespHttp200(c, constant.ErrArgs, nil)
return
}
@ -183,7 +183,6 @@ func BlockUser(c *gin.Context) {
return
}
utils.CopyStructFields(&reqPb, &req)
fmt.Println(reqPb, req)
etcdConn := getcdv3.GetConn(config.Config.Etcd.EtcdSchema, strings.Join(config.Config.Etcd.EtcdAddr, ","), config.Config.RpcRegisterName.OpenImUserName)
client := pb.NewUserClient(etcdConn)
fmt.Println(reqPb)

@ -0,0 +1,54 @@
package msg
import (
"Open_IM/pkg/common/config"
"Open_IM/pkg/common/constant"
"Open_IM/pkg/common/log"
open_im_sdk "Open_IM/pkg/proto/sdk_ws"
"Open_IM/pkg/utils"
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
)
func conversationNotification(contentType int32, m proto.Message, operationID, userID string) {
var err error
var tips open_im_sdk.TipsComm
tips.Detail, err = proto.Marshal(m)
if err != nil {
log.Error(operationID, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), m.String())
return
}
marshaler := jsonpb.Marshaler{
OrigName: true,
EnumsAsInts: false,
EmitDefaults: false,
}
tips.JsonDetail, _ = marshaler.MarshalToString(m)
cn := config.Config.Notification
switch contentType {
case constant.ConversationOptChangeNotification:
tips.DefaultTips = cn.ConversationOptUpdate.DefaultTips.Tips
}
var n NotificationMsg
n.SendID = userID
n.RecvID = userID
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, utils.GetSelfFuncName(), "Marshal failed ", err.Error(), tips.String())
return
}
Notification(&n)
}
// 客户端调用设置opt接口后调用
func SetReceiveMessageOptNotification(operationID, opUserID, userID string) {
log.NewInfo(operationID, utils.GetSelfFuncName(), "operation user: ", opUserID, "operation id: ", userID)
conversationUpdateTips := open_im_sdk.ConversationUpdateTips{
UserID: userID,
}
conversationNotification(constant.ConversationOptChangeNotification, &conversationUpdateTips, operationID, userID)
}

@ -136,6 +136,7 @@ func (rpc *rpcChat) SendMsg(_ context.Context, pb *pbChat.SendMsgReq) (*pbChat.S
isSend := modifyMessageByUserMessageReceiveOpt(pb.MsgData.RecvID, pb.MsgData.SendID, constant.SingleChatType, pb)
if isSend {
msgToMQ.MsgData = pb.MsgData
log.NewInfo(msgToMQ.OperationID, msgToMQ)
err1 := rpc.sendMsgToKafka(&msgToMQ, msgToMQ.MsgData.RecvID)
if err1 != nil {
log.NewError(msgToMQ.OperationID, "kafka send msg err:RecvID", msgToMQ.MsgData.RecvID, msgToMQ.String())
@ -434,7 +435,13 @@ func Notification(n *NotificationMsg) {
ex = config.Config.Notification.BlackDeleted.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.BlackDeleted.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.BlackDeleted.Conversation.UnreadCount
case constant.ConversationOptChangeNotification:
pushSwitch = config.Config.Notification.ConversationOptUpdate.OfflinePush.PushSwitch
title = config.Config.Notification.ConversationOptUpdate.OfflinePush.Title
desc = config.Config.Notification.ConversationOptUpdate.OfflinePush.Desc
ex = config.Config.Notification.ConversationOptUpdate.OfflinePush.Ext
reliabilityLevel = config.Config.Notification.ConversationOptUpdate.Conversation.ReliabilityLevel
unReadCount = config.Config.Notification.ConversationOptUpdate.Conversation.UnreadCount
}
switch reliabilityLevel {
case constant.UnreliableNotification:

@ -111,6 +111,7 @@ func (s *userServer) SetReceiveMessageOpt(ctx context.Context, req *pbUser.SetRe
for _, v := range req.ConversationIDList {
resp.ConversationOptResultList = append(resp.ConversationOptResultList, &pbUser.OptResult{ConversationID: v, Result: req.Opt})
}
chat.SetReceiveMessageOptNotification(req.OperationID, req.OpUserID, req.FromUserID)
log.NewInfo(req.OperationID, "SetReceiveMessageOpt rpc return ", resp.String())
return &resp, nil
}

@ -278,6 +278,11 @@ type config struct {
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"blackDeleted"`
ConversationOptUpdate struct{
Conversation PConversation `yaml:"conversation"`
OfflinePush POfflinePush `yaml:"offlinePush"`
DefaultTips PDefaultTips `yaml:"defaultTips"`
} `yaml:"conversationOptUpdate"`
}
Demo struct {
Port []int `yaml:"openImDemoPort"`

@ -57,6 +57,8 @@ const (
UserInfoUpdatedNotification = 1303 //SetSelfInfoTip = 204
ConversationOptChangeNotification = 1300 // change conversation opt
GroupCreatedNotification = 1501
GroupInfoSetNotification = 1502
JoinGroupApplicationNotification = 1503

@ -2783,6 +2783,54 @@ func (x *UserInfoUpdatedTips) GetUserID() string {
return ""
}
//////////////////////conversation/////////////////////
type ConversationUpdateTips struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
UserID string `protobuf:"bytes,1,opt,name=UserID,proto3" json:"UserID,omitempty"`
}
func (x *ConversationUpdateTips) Reset() {
*x = ConversationUpdateTips{}
if protoimpl.UnsafeEnabled {
mi := &file_sdk_ws_ws_proto_msgTypes[37]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *ConversationUpdateTips) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*ConversationUpdateTips) ProtoMessage() {}
func (x *ConversationUpdateTips) ProtoReflect() protoreflect.Message {
mi := &file_sdk_ws_ws_proto_msgTypes[37]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use ConversationUpdateTips.ProtoReflect.Descriptor instead.
func (*ConversationUpdateTips) Descriptor() ([]byte, []int) {
return file_sdk_ws_ws_proto_rawDescGZIP(), []int{37}
}
func (x *ConversationUpdateTips) GetUserID() string {
if x != nil {
return x.UserID
}
return ""
}
///cms
type RequestPagination struct {
state protoimpl.MessageState
@ -2796,7 +2844,7 @@ type RequestPagination struct {
func (x *RequestPagination) Reset() {
*x = RequestPagination{}
if protoimpl.UnsafeEnabled {
mi := &file_sdk_ws_ws_proto_msgTypes[37]
mi := &file_sdk_ws_ws_proto_msgTypes[38]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -2809,7 +2857,7 @@ func (x *RequestPagination) String() string {
func (*RequestPagination) ProtoMessage() {}
func (x *RequestPagination) ProtoReflect() protoreflect.Message {
mi := &file_sdk_ws_ws_proto_msgTypes[37]
mi := &file_sdk_ws_ws_proto_msgTypes[38]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -2822,7 +2870,7 @@ func (x *RequestPagination) ProtoReflect() protoreflect.Message {
// Deprecated: Use RequestPagination.ProtoReflect.Descriptor instead.
func (*RequestPagination) Descriptor() ([]byte, []int) {
return file_sdk_ws_ws_proto_rawDescGZIP(), []int{37}
return file_sdk_ws_ws_proto_rawDescGZIP(), []int{38}
}
func (x *RequestPagination) GetPageNumber() int32 {
@ -2851,7 +2899,7 @@ type ResponsePagination struct {
func (x *ResponsePagination) Reset() {
*x = ResponsePagination{}
if protoimpl.UnsafeEnabled {
mi := &file_sdk_ws_ws_proto_msgTypes[38]
mi := &file_sdk_ws_ws_proto_msgTypes[39]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
@ -2864,7 +2912,7 @@ func (x *ResponsePagination) String() string {
func (*ResponsePagination) ProtoMessage() {}
func (x *ResponsePagination) ProtoReflect() protoreflect.Message {
mi := &file_sdk_ws_ws_proto_msgTypes[38]
mi := &file_sdk_ws_ws_proto_msgTypes[39]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
@ -2877,7 +2925,7 @@ func (x *ResponsePagination) ProtoReflect() protoreflect.Message {
// Deprecated: Use ResponsePagination.ProtoReflect.Descriptor instead.
func (*ResponsePagination) Descriptor() ([]byte, []int) {
return file_sdk_ws_ws_proto_rawDescGZIP(), []int{38}
return file_sdk_ws_ws_proto_rawDescGZIP(), []int{39}
}
func (x *ResponsePagination) GetCurrentPage() int32 {
@ -3341,21 +3389,24 @@ var file_sdk_ws_ws_proto_rawDesc = []byte{
0x44, 0x52, 0x0c, 0x66, 0x72, 0x6f, 0x6d, 0x54, 0x6f, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22,
0x2d, 0x0a, 0x13, 0x55, 0x73, 0x65, 0x72, 0x49, 0x6e, 0x66, 0x6f, 0x55, 0x70, 0x64, 0x61, 0x74,
0x65, 0x64, 0x54, 0x69, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0x53,
0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74,
0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d, 0x62, 0x65,
0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d,
0x62, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x68, 0x6f, 0x77, 0x4e, 0x75, 0x6d, 0x62, 0x65,
0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x68, 0x6f, 0x77, 0x4e, 0x75, 0x6d,
0x62, 0x65, 0x72, 0x22, 0x56, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x50,
0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x43, 0x75, 0x72,
0x72, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b,
0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x53,
0x68, 0x6f, 0x77, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52,
0x0a, 0x53, 0x68, 0x6f, 0x77, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x42, 0x1c, 0x5a, 0x1a, 0x2e,
0x2f, 0x73, 0x64, 0x6b, 0x5f, 0x77, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x5f, 0x61,
0x70, 0x69, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x44, 0x22, 0x30,
0x0a, 0x16, 0x43, 0x6f, 0x6e, 0x76, 0x65, 0x72, 0x73, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x70,
0x64, 0x61, 0x74, 0x65, 0x54, 0x69, 0x70, 0x73, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72,
0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x44,
0x22, 0x53, 0x0a, 0x11, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x50, 0x61, 0x67, 0x69, 0x6e,
0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e, 0x75, 0x6d,
0x62, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x70, 0x61, 0x67, 0x65, 0x4e,
0x75, 0x6d, 0x62, 0x65, 0x72, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x68, 0x6f, 0x77, 0x4e, 0x75, 0x6d,
0x62, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x68, 0x6f, 0x77, 0x4e,
0x75, 0x6d, 0x62, 0x65, 0x72, 0x22, 0x56, 0x0a, 0x12, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x50, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x20, 0x0a, 0x0b, 0x43,
0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05,
0x52, 0x0b, 0x43, 0x75, 0x72, 0x72, 0x65, 0x6e, 0x74, 0x50, 0x61, 0x67, 0x65, 0x12, 0x1e, 0x0a,
0x0a, 0x53, 0x68, 0x6f, 0x77, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x06, 0x20, 0x01, 0x28,
0x05, 0x52, 0x0a, 0x53, 0x68, 0x6f, 0x77, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x42, 0x1c, 0x5a,
0x1a, 0x2e, 0x2f, 0x73, 0x64, 0x6b, 0x5f, 0x77, 0x73, 0x3b, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72,
0x5f, 0x61, 0x70, 0x69, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
}
var (
@ -3370,7 +3421,7 @@ func file_sdk_ws_ws_proto_rawDescGZIP() []byte {
return file_sdk_ws_ws_proto_rawDescData
}
var file_sdk_ws_ws_proto_msgTypes = make([]protoimpl.MessageInfo, 40)
var file_sdk_ws_ws_proto_msgTypes = make([]protoimpl.MessageInfo, 41)
var file_sdk_ws_ws_proto_goTypes = []interface{}{
(*GroupInfo)(nil), // 0: server_api_params.GroupInfo
(*GroupMemberFullInfo)(nil), // 1: server_api_params.GroupMemberFullInfo
@ -3409,9 +3460,10 @@ var file_sdk_ws_ws_proto_goTypes = []interface{}{
(*BlackDeletedTips)(nil), // 34: server_api_params.BlackDeletedTips
(*FriendInfoChangedTips)(nil), // 35: server_api_params.FriendInfoChangedTips
(*UserInfoUpdatedTips)(nil), // 36: server_api_params.UserInfoUpdatedTips
(*RequestPagination)(nil), // 37: server_api_params.RequestPagination
(*ResponsePagination)(nil), // 38: server_api_params.ResponsePagination
nil, // 39: server_api_params.MsgData.OptionsEntry
(*ConversationUpdateTips)(nil), // 37: server_api_params.ConversationUpdateTips
(*RequestPagination)(nil), // 38: server_api_params.RequestPagination
(*ResponsePagination)(nil), // 39: server_api_params.ResponsePagination
nil, // 40: server_api_params.MsgData.OptionsEntry
}
var file_sdk_ws_ws_proto_depIdxs = []int32{
3, // 0: server_api_params.FriendInfo.friendUser:type_name -> server_api_params.UserInfo
@ -3419,7 +3471,7 @@ var file_sdk_ws_ws_proto_depIdxs = []int32{
2, // 2: server_api_params.GroupRequest.userInfo:type_name -> server_api_params.PublicUserInfo
0, // 3: server_api_params.GroupRequest.groupInfo:type_name -> server_api_params.GroupInfo
13, // 4: server_api_params.PullMessageBySeqListResp.list:type_name -> server_api_params.MsgData
39, // 5: server_api_params.MsgData.options:type_name -> server_api_params.MsgData.OptionsEntry
40, // 5: server_api_params.MsgData.options:type_name -> server_api_params.MsgData.OptionsEntry
14, // 6: server_api_params.MsgData.offlinePushInfo:type_name -> server_api_params.OfflinePushInfo
0, // 7: server_api_params.GroupCreatedTips.group:type_name -> server_api_params.GroupInfo
1, // 8: server_api_params.GroupCreatedTips.opUser:type_name -> server_api_params.GroupMemberFullInfo
@ -3913,7 +3965,7 @@ func file_sdk_ws_ws_proto_init() {
}
}
file_sdk_ws_ws_proto_msgTypes[37].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RequestPagination); i {
switch v := v.(*ConversationUpdateTips); i {
case 0:
return &v.state
case 1:
@ -3925,6 +3977,18 @@ func file_sdk_ws_ws_proto_init() {
}
}
file_sdk_ws_ws_proto_msgTypes[38].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*RequestPagination); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_sdk_ws_ws_proto_msgTypes[39].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*ResponsePagination); i {
case 0:
return &v.state
@ -3943,7 +4007,7 @@ func file_sdk_ws_ws_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_sdk_ws_ws_proto_rawDesc,
NumEnums: 0,
NumMessages: 40,
NumMessages: 41,
NumExtensions: 0,
NumServices: 0,
},

@ -332,6 +332,14 @@ message UserInfoUpdatedTips{
string userID = 1;
}
//////////////////////conversation/////////////////////
message ConversationUpdateTips{
string UserID = 1;
}
///cms
message RequestPagination {
int32 pageNumber = 1;

Loading…
Cancel
Save