Files
open-im-server/internal/rpc/msg/utils.go
T

38 lines
942 B
Go
Raw Normal View History

2023-02-13 10:33:54 +08:00
package msg
import (
2023-03-16 10:46:06 +08:00
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/config"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/constant"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
2023-02-13 19:31:17 +08:00
"github.com/go-redis/redis/v8"
"gorm.io/gorm"
2023-02-13 10:33:54 +08:00
)
2023-02-13 15:52:41 +08:00
func isMessageHasReadEnabled(msgData *sdkws.MsgData) bool {
2023-06-05 18:01:59 +08:00
switch {
case msgData.ContentType == constant.HasReadReceipt && msgData.SessionType == constant.SingleChatType:
2023-02-13 15:52:41 +08:00
if config.Config.SingleMessageHasReadReceiptEnable {
return true
} else {
return false
}
2023-06-05 18:01:59 +08:00
case msgData.ContentType == constant.HasReadReceipt && msgData.SessionType == constant.SuperGroupChatType:
2023-02-13 15:52:41 +08:00
if config.Config.GroupMessageHasReadReceiptEnable {
return true
} else {
return false
}
2023-02-13 10:33:54 +08:00
}
2023-02-13 15:52:41 +08:00
return true
2023-02-13 10:33:54 +08:00
}
2023-02-13 19:31:17 +08:00
func IsNotFound(err error) bool {
switch utils.Unwrap(err) {
case redis.Nil, gorm.ErrRecordNotFound:
return true
default:
return false
}
}