redis add message receive opt

This commit is contained in:
Gordon 2021-12-06 16:06:19 +08:00
parent a8575b4fc7
commit 70eaa7d968
2 changed files with 17 additions and 15 deletions

View File

@ -89,6 +89,11 @@ const (
OnlineStatus = "online" OnlineStatus = "online"
OfflineStatus = "offline" OfflineStatus = "offline"
//MsgReceiveOpt
ReceiveMessage = 0
NotReceiveMessage = 1
ReceiveNotNotifyMessage = 2
) )
var ContentType2PushContent = map[int64]string{ var ContentType2PushContent = map[int64]string{

View File

@ -9,9 +9,9 @@ import (
const ( const (
userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq userIncrSeq = "REDIS_USER_INCR_SEQ:" // user incr seq
appleDeviceToken = "DEVICE_TOKEN" appleDeviceToken = "DEVICE_TOKEN"
lastGetSeq = "LAST_GET_SEQ"
userMinSeq = "REDIS_USER_MIN_SEQ:" userMinSeq = "REDIS_USER_MIN_SEQ:"
uidPidToken = "UID_PID_TOKEN_STATUS:" uidPidToken = "UID_PID_TOKEN_STATUS:"
conversationReceiveMessageOpt = "CON_RECV_MSG_OPT:"
) )
func (d *DataBases) Exec(cmd string, key interface{}, args ...interface{}) (interface{}, error) { 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)...) _, err := d.Exec("hmset", key, redis.Args{}.Add().AddFlat(m)...)
return err return err
} }
func (d *DataBases) SetConversationMsgOpt(userID, conversationID string, opt int) error {
//Check exists userid and platform class from redis key := conversationReceiveMessageOpt + userID
func (d *DataBases) ExistsUserIDAndPlatform(userID, platformClass string) (int64, error) { _, err1 := d.Exec("HSet", key, conversationID, opt)
key := userID + platformClass return err1
return redis.Int64(d.Exec("EXISTS", key))
} }
func (d *DataBases) GetConversationMsgOpt(userID, conversationID string) (int, error) {
//Get platform class Token key := conversationReceiveMessageOpt + userID
func (d *DataBases) GetPlatformToken(userID, platformClass string) (string, error) { return redis.Int(d.Exec("HGet", key, conversationID))
key := userID + platformClass
return redis.String(d.Exec("GET", key))
} }