diff --git a/pkg/common/constant/constant.go b/pkg/common/constant/constant.go index 42a4d07c3..9115e6cf5 100644 --- a/pkg/common/constant/constant.go +++ b/pkg/common/constant/constant.go @@ -89,6 +89,11 @@ const ( OnlineStatus = "online" OfflineStatus = "offline" + + //MsgReceiveOpt + ReceiveMessage = 0 + NotReceiveMessage = 1 + ReceiveNotNotifyMessage = 2 ) var ContentType2PushContent = map[int64]string{ diff --git a/pkg/common/db/redisModel.go b/pkg/common/db/redisModel.go index d991408ef..362eec15d 100644 --- a/pkg/common/db/redisModel.go +++ b/pkg/common/db/redisModel.go @@ -7,11 +7,11 @@ import ( ) const ( - userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq - appleDeviceToken = "DEVICE_TOKEN" - lastGetSeq = "LAST_GET_SEQ" - userMinSeq = "REDIS_USER_MIN_SEQ:" - uidPidToken = "UID_PID_TOKEN_STATUS:" + userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq + appleDeviceToken = "DEVICE_TOKEN" + userMinSeq = "REDIS_USER_MIN_SEQ:" + uidPidToken = "UID_PID_TOKEN_STATUS:" + conversationReceiveMessageOpt = "CON_RECV_MSG_OPT:" ) func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error) { @@ -91,15 +91,12 @@ func (d *DataBases) SetTokenMapByUidPid(userID string, platformID int32, m map[s _, err := d.Exec("hmset", key, redis.Args{}.Add().AddFlat(m)...) return err } - -//Check exists userid and platform class from redis -func (d *DataBases) ExistsUserIDAndPlatform(userID, platformClass string) (int64, error) { - key := userID + platformClass - return redis.Int64(d.Exec("EXISTS", key)) +func (d *DataBases) SetConversationMsgOpt(userID, conversationID string, opt int) error { + key := conversationReceiveMessageOpt + userID + _, err1 := d.Exec("HSet", key, conversationID, opt) + return err1 } - -//Get platform class Token -func (d *DataBases) GetPlatformToken(userID, platformClass string) (string, error) { - key := userID + platformClass - return redis.String(d.Exec("GET", key)) +func (d *DataBases) GetConversationMsgOpt(userID, conversationID string) (int, error) { + key := conversationReceiveMessageOpt + userID + return redis.Int(d.Exec("HGet", key, conversationID)) }