mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-04-26 11:36:44 +08:00
sg recv opt
This commit is contained in:
parent
f9b39e91ee
commit
8f2e9f5261
@ -249,7 +249,13 @@ func MsgToSuperGroupUser(pushMsg *pbPush.PushMsgReq) {
|
|||||||
} else {
|
} else {
|
||||||
needOfflinePushUserIDList = onlineFailedUserIDList
|
needOfflinePushUserIDList = onlineFailedUserIDList
|
||||||
}
|
}
|
||||||
|
if pushMsg.MsgData.ContentType != constant.SignalingNotification {
|
||||||
|
notNotificationUserIDList, err := db.DB.GetSuperGroupUserReceiveNotNotifyMessageIDList(pushMsg.MsgData.GroupID)
|
||||||
|
if err != nil {
|
||||||
|
log.NewError(pushMsg.OperationID, utils.GetSelfFuncName(), "GetSuperGroupUserReceiveNotNotifyMessageIDList failed", pushMsg.MsgData.GroupID)
|
||||||
|
}
|
||||||
|
needOfflinePushUserIDList = utils.RemoveFromSlice(needOfflinePushUserIDList, notNotificationUserIDList)
|
||||||
|
}
|
||||||
if offlinePusher == nil {
|
if offlinePusher == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,16 @@ func (rpc *rpcConversation) ModifyConversationField(c context.Context, req *pbCo
|
|||||||
}
|
}
|
||||||
if req.Conversation.ConversationType == constant.SuperGroupChatType {
|
if req.Conversation.ConversationType == constant.SuperGroupChatType {
|
||||||
if req.Conversation.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
if req.Conversation.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
||||||
if err = db.DB.SetSuperGroupUserNotRecvOfflineMsgOpt(req.Conversation.GroupID, v); err != nil {
|
if err = db.DB.SetSuperGroupUserReceiveNotNotifyMessage(req.Conversation.GroupID, v); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, v)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, v)
|
||||||
|
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err = db.DB.ReduceSuperGroupUserNotRecvOfflineMsgOpt(req.Conversation.GroupID, v); err != nil {
|
if err = db.DB.SetSuperGroupUserReceiveNotifyMessage(req.Conversation.GroupID, v); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, v)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, v)
|
||||||
|
resp.CommonResp = &pbConversation.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,6 +163,22 @@ func (s *userServer) BatchSetConversations(ctx context.Context, req *pbUser.Batc
|
|||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v.ConversationType == constant.SuperGroupChatType {
|
||||||
|
if v.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
||||||
|
if err := db.DB.SetSuperGroupUserReceiveNotNotifyMessage(v.GroupID, v.OwnerUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), v.GroupID, v.OwnerUserID)
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if err := db.DB.SetSuperGroupUserReceiveNotifyMessage(v.GroupID, v.OwnerUserID); err != nil {
|
||||||
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), v.GroupID, err.Error())
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
isUpdate, err := imdb.SetConversation(conversation)
|
isUpdate, err := imdb.SetConversation(conversation)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "SetConversation error", err.Error())
|
||||||
@ -266,12 +282,16 @@ func (s *userServer) SetConversation(ctx context.Context, req *pbUser.SetConvers
|
|||||||
}
|
}
|
||||||
if req.Conversation.ConversationType == constant.SuperGroupChatType {
|
if req.Conversation.ConversationType == constant.SuperGroupChatType {
|
||||||
if req.Conversation.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
if req.Conversation.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
||||||
if err = db.DB.SetSuperGroupUserNotRecvOfflineMsgOpt(req.Conversation.GroupID, v); err != nil {
|
if err = db.DB.SetSuperGroupUserReceiveNotNotifyMessage(req.Conversation.GroupID, req.Conversation.OwnerUserID); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, v)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, req.Conversation.OwnerUserID)
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err = db.DB.ReduceSuperGroupUserNotRecvOfflineMsgOpt(req.Conversation.GroupID, v); err != nil {
|
if err = db.DB.SetSuperGroupUserReceiveNotifyMessage(req.Conversation.GroupID, req.Conversation.OwnerUserID); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, v)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), req.Conversation.GroupID, err.Error())
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: err.Error()}
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -341,12 +361,16 @@ func (s *userServer) SetRecvMsgOpt(ctx context.Context, req *pbUser.SetRecvMsgOp
|
|||||||
case "super_group":
|
case "super_group":
|
||||||
conversation.GroupID = stringList[1]
|
conversation.GroupID = stringList[1]
|
||||||
if req.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
if req.RecvMsgOpt == constant.ReceiveNotNotifyMessage {
|
||||||
if err := db.DB.SetSuperGroupUserNotRecvOfflineMsgOpt(conversation.GroupID, req.OwnerUserID); err != nil {
|
if err := db.DB.SetSuperGroupUserReceiveNotNotifyMessage(conversation.GroupID, req.OwnerUserID); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), conversation.GroupID, req.OwnerUserID)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), conversation.GroupID, req.OwnerUserID)
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if err := db.DB.ReduceSuperGroupUserNotRecvOfflineMsgOpt(conversation.GroupID, req.OwnerUserID); err != nil {
|
if err := db.DB.SetSuperGroupUserReceiveNotifyMessage(conversation.GroupID, req.OwnerUserID); err != nil {
|
||||||
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), conversation.GroupID, req.OwnerUserID)
|
log.NewError(req.OperationID, utils.GetSelfFuncName(), "cache failed, rpc return", err.Error(), conversation.GroupID, req.OwnerUserID)
|
||||||
|
resp.CommonResp = &pbUser.CommonResp{ErrCode: constant.ErrDB.ErrCode, ErrMsg: constant.ErrDB.ErrMsg}
|
||||||
|
return resp, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,17 +168,17 @@ func (d *DataBases) GetSingleConversationRecvMsgOpt(userID, conversationID strin
|
|||||||
return utils.StringToInt(result), err
|
return utils.StringToInt(result), err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) SetSuperGroupUserNotRecvOfflineMsgOpt(groupID, userID string) error {
|
func (d *DataBases) SetSuperGroupUserReceiveNotNotifyMessage(groupID, userID string) error {
|
||||||
key := superGroupUserNotRecvOfflineMsgOptTemp + groupID
|
key := superGroupUserNotRecvOfflineMsgOptTemp + groupID
|
||||||
return d.RDB.SAdd(context.Background(), key, userID).Err()
|
return d.RDB.SAdd(context.Background(), key, userID).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) ReduceSuperGroupUserNotRecvOfflineMsgOpt(groupID, userID string) error {
|
func (d *DataBases) SetSuperGroupUserReceiveNotifyMessage(groupID, userID string) error {
|
||||||
key := superGroupUserNotRecvOfflineMsgOptTemp + groupID
|
key := superGroupUserNotRecvOfflineMsgOptTemp + groupID
|
||||||
return d.RDB.SRem(context.Background(), key, userID).Err()
|
return d.RDB.SRem(context.Background(), key, userID).Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DataBases) GetSuperGroupUserNotRecvOfflineMsgIDList(groupID string) ([]string, error) {
|
func (d *DataBases) GetSuperGroupUserReceiveNotNotifyMessageIDList(groupID string) ([]string, error) {
|
||||||
key := superGroupUserNotRecvOfflineMsgOptTemp + groupID
|
key := superGroupUserNotRecvOfflineMsgOptTemp + groupID
|
||||||
userIDs, _ := d.RDB.SMembers(context.Background(), key).Result()
|
userIDs, _ := d.RDB.SMembers(context.Background(), key).Result()
|
||||||
return userIDs, nil
|
return userIDs, nil
|
||||||
|
@ -119,6 +119,22 @@ func DifferenceString(slice1, slice2 []string) []string {
|
|||||||
}
|
}
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RemoveFromSlice(slice1, slice2 []string) []string {
|
||||||
|
for _, v1 := range slice1 {
|
||||||
|
for i2, v2 := range slice2 {
|
||||||
|
if v2 == v1 {
|
||||||
|
if i2 != len(slice2)-1 {
|
||||||
|
slice2 = append(slice2[:i2], slice2[i2+1:]...)
|
||||||
|
} else {
|
||||||
|
slice2 = append(slice2[:i2])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return slice2
|
||||||
|
}
|
||||||
|
|
||||||
func OperationIDGenerator() string {
|
func OperationIDGenerator() string {
|
||||||
return strconv.FormatInt(time.Now().UnixNano()+int64(rand.Uint32()), 10)
|
return strconv.FormatInt(time.Now().UnixNano()+int64(rand.Uint32()), 10)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user