mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 10:35:59 +08:00
Compare commits
42 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d187f53c79 | |||
| 5134fdf7e7 | |||
| 347f6f3382 | |||
| 103aa98e95 | |||
| 77733fdb2b | |||
| 3c796b7405 | |||
| fa263b9a87 | |||
| 108c4b1a50 | |||
| e4eb8ffd6e | |||
| ca72ce2d6f | |||
| 475ad26abd | |||
| cffefbd242 | |||
| cc5fa648de | |||
| 263ab752dd | |||
| cf0ef7652a | |||
| 709d772233 | |||
| c9df323da4 | |||
| 22df23cf8b | |||
| 0031aeca02 | |||
| 67e6e789ec | |||
| 9fdb85d354 | |||
| 8b2bfba89b | |||
| 2934535c18 | |||
| 9b9bfae857 | |||
| 32edd4b17c | |||
| d5651ae1d8 | |||
| 8aad2cf300 | |||
| 4bf4eb5464 | |||
| e66e490ae6 | |||
| 1d6d163da0 | |||
| 8e1bb9abb9 | |||
| d26e2594f2 | |||
| 5893181226 | |||
| e2b581f2cc | |||
| 2531091742 | |||
| 9d42a2abc2 | |||
| 0ff8402c83 | |||
| 76484e09ac | |||
| 8c2e7c1fdc | |||
| d62fedcabb | |||
| 4d89bba8c0 | |||
| 8da0c53523 |
@@ -18,6 +18,9 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -43,6 +46,16 @@ func main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func startPprof() {
|
||||||
|
runtime.GOMAXPROCS(1)
|
||||||
|
runtime.SetMutexProfileFraction(1)
|
||||||
|
runtime.SetBlockProfileRate(1)
|
||||||
|
if err := http.ListenAndServe(":6060", nil); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
func run(port int) error {
|
func run(port int) error {
|
||||||
if port == 0 {
|
if port == 0 {
|
||||||
return fmt.Errorf("port is empty")
|
return fmt.Errorf("port is empty")
|
||||||
@@ -79,6 +92,7 @@ func run(port int) error {
|
|||||||
}
|
}
|
||||||
fmt.Println("start api server, address: ", address, ", OpenIM version: ", config.Version)
|
fmt.Println("start api server, address: ", address, ", OpenIM version: ", config.Version)
|
||||||
log.ZInfo(context.Background(), "start server success", "address", address, "version", config.Version)
|
log.ZInfo(context.Background(), "start server success", "address", address, "version", config.Version)
|
||||||
|
go startPprof()
|
||||||
err = router.Run(address)
|
err = router.Run(address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.ZError(context.Background(), "api run failed ", err, "address", address)
|
log.ZError(context.Background(), "api run failed ", err, "address", address)
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ require (
|
|||||||
require github.com/google/uuid v1.3.0
|
require github.com/google/uuid v1.3.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/OpenIMSDK/protocol v0.0.18
|
github.com/OpenIMSDK/protocol v0.0.17
|
||||||
github.com/OpenIMSDK/tools v0.0.14
|
github.com/OpenIMSDK/tools v0.0.14
|
||||||
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
|
github.com/aliyun/aliyun-oss-go-sdk v2.2.8+incompatible
|
||||||
github.com/go-redis/redis v6.15.9+incompatible
|
github.com/go-redis/redis v6.15.9+incompatible
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ cloud.google.com/go/storage v1.30.1/go.mod h1:NfxhC0UJE1aXSx7CIIbCf7y9HKT7Biccwk
|
|||||||
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
|
firebase.google.com/go v3.13.0+incompatible h1:3TdYC3DDi6aHn20qoRkxwGqNgdjtblwVAyRLQwGn/+4=
|
||||||
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
|
firebase.google.com/go v3.13.0+incompatible/go.mod h1:xlah6XbEyW6tbfSklcfe5FHJIwjt8toICdV5Wh9ptHs=
|
||||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||||
github.com/OpenIMSDK/protocol v0.0.18 h1:hXukFiDMLZx7s+hDCQePIK9ABiHyNlobNL4MppvOuMY=
|
github.com/OpenIMSDK/protocol v0.0.17 h1:ixjKUVGlTW+jQK5cPaKV//6l4bk9DAlbjDhocztYSbU=
|
||||||
github.com/OpenIMSDK/protocol v0.0.18/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
github.com/OpenIMSDK/protocol v0.0.17/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
||||||
github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ=
|
github.com/OpenIMSDK/tools v0.0.14 h1:WLof/+WxyPyRST+QkoTKubYCiV73uCLiL8pgnpH/yKQ=
|
||||||
github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
|
github.com/OpenIMSDK/tools v0.0.14/go.mod h1:eg+q4A34Qmu73xkY0mt37FHGMCMfC6CtmOnm0kFEGFI=
|
||||||
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
|
github.com/QcloudApi/qcloud_sign_golang v0.0.0-20141224014652-e4130a326409/go.mod h1:1pk82RBxDY/JZnPQrtqHlUFfCctgdorsd9M06fMynOM=
|
||||||
|
|||||||
@@ -88,7 +88,3 @@ func (o *FriendApi) IsFriend(c *gin.Context) {
|
|||||||
func (o *FriendApi) GetFriendIDs(c *gin.Context) {
|
func (o *FriendApi) GetFriendIDs(c *gin.Context) {
|
||||||
a2r.Call(friend.FriendClient.GetFriendIDs, o.Client, c)
|
a2r.Call(friend.FriendClient.GetFriendIDs, o.Client, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (o *FriendApi) GetSpecifiedFriendsInfo(c *gin.Context) {
|
|
||||||
a2r.Call(friend.FriendClient.GetSpecifiedFriendsInfo, o.Client, c)
|
|
||||||
}
|
|
||||||
|
|||||||
+6
-1
@@ -170,7 +170,12 @@ func (m *MessageApi) getSendMsgReq(c *gin.Context, req apistruct.SendMsg) (sendM
|
|||||||
log.ZDebug(c, "getSendMsgReq", "req", req.Content)
|
log.ZDebug(c, "getSendMsgReq", "req", req.Content)
|
||||||
switch req.ContentType {
|
switch req.ContentType {
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
data = apistruct.TextElem{}
|
text, ok := req.Content["text"].(string)
|
||||||
|
if !ok {
|
||||||
|
return nil, errs.ErrArgs.WithDetail("text is not string")
|
||||||
|
}
|
||||||
|
data = apistruct.TextContentElem{Content: text}
|
||||||
|
log.ZDebug(c, "getSendMsgReq", "data", data)
|
||||||
case constant.Picture:
|
case constant.Picture:
|
||||||
data = apistruct.PictureElem{}
|
data = apistruct.PictureElem{}
|
||||||
case constant.Voice:
|
case constant.Voice:
|
||||||
|
|||||||
@@ -106,7 +106,6 @@ func NewGinRouter(discov discoveryregistry.SvcDiscoveryRegistry, rdb redis.Unive
|
|||||||
friendRouterGroup.POST("/import_friend", f.ImportFriends)
|
friendRouterGroup.POST("/import_friend", f.ImportFriends)
|
||||||
friendRouterGroup.POST("/is_friend", f.IsFriend)
|
friendRouterGroup.POST("/is_friend", f.IsFriend)
|
||||||
friendRouterGroup.POST("/get_friend_id", f.GetFriendIDs)
|
friendRouterGroup.POST("/get_friend_id", f.GetFriendIDs)
|
||||||
friendRouterGroup.POST("/get_specified_friends_info", f.GetSpecifiedFriendsInfo)
|
|
||||||
}
|
}
|
||||||
g := NewGroupApi(*groupRpc)
|
g := NewGroupApi(*groupRpc)
|
||||||
groupRouterGroup := r.Group("/group", ParseToken)
|
groupRouterGroup := r.Group("/group", ParseToken)
|
||||||
|
|||||||
@@ -133,18 +133,6 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
var unequal int
|
|
||||||
var conv tablerelation.ConversationModel
|
|
||||||
if len(req.UserIDs) == 1 {
|
|
||||||
cs, err := c.conversationDatabase.FindConversations(ctx, req.UserIDs[0], []string{req.Conversation.ConversationID})
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if len(cs) == 0 {
|
|
||||||
return nil, errs.ErrRecordNotFound.Wrap("conversation not found")
|
|
||||||
}
|
|
||||||
conv = *cs[0]
|
|
||||||
}
|
|
||||||
var conversation tablerelation.ConversationModel
|
var conversation tablerelation.ConversationModel
|
||||||
conversation.ConversationID = req.Conversation.ConversationID
|
conversation.ConversationID = req.Conversation.ConversationID
|
||||||
conversation.ConversationType = req.Conversation.ConversationType
|
conversation.ConversationType = req.Conversation.ConversationType
|
||||||
@@ -153,45 +141,24 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
m := make(map[string]interface{})
|
m := make(map[string]interface{})
|
||||||
if req.Conversation.RecvMsgOpt != nil {
|
if req.Conversation.RecvMsgOpt != nil {
|
||||||
m["recv_msg_opt"] = req.Conversation.RecvMsgOpt.Value
|
m["recv_msg_opt"] = req.Conversation.RecvMsgOpt.Value
|
||||||
if req.Conversation.RecvMsgOpt.Value != conv.RecvMsgOpt {
|
|
||||||
unequal++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if req.Conversation.AttachedInfo != nil {
|
if req.Conversation.AttachedInfo != nil {
|
||||||
m["attached_info"] = req.Conversation.AttachedInfo.Value
|
m["attached_info"] = req.Conversation.AttachedInfo.Value
|
||||||
if req.Conversation.AttachedInfo.Value != conv.AttachedInfo {
|
|
||||||
unequal++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if req.Conversation.Ex != nil {
|
if req.Conversation.Ex != nil {
|
||||||
m["ex"] = req.Conversation.Ex.Value
|
m["ex"] = req.Conversation.Ex.Value
|
||||||
if req.Conversation.Ex.Value != conv.Ex {
|
|
||||||
unequal++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if req.Conversation.IsPinned != nil {
|
if req.Conversation.IsPinned != nil {
|
||||||
m["is_pinned"] = req.Conversation.IsPinned.Value
|
m["is_pinned"] = req.Conversation.IsPinned.Value
|
||||||
if req.Conversation.IsPinned.Value != conv.IsPinned {
|
|
||||||
unequal++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if req.Conversation.GroupAtType != nil {
|
if req.Conversation.GroupAtType != nil {
|
||||||
m["group_at_type"] = req.Conversation.GroupAtType.Value
|
m["group_at_type"] = req.Conversation.GroupAtType.Value
|
||||||
if req.Conversation.GroupAtType.Value != conv.GroupAtType {
|
|
||||||
unequal++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if req.Conversation.MsgDestructTime != nil {
|
if req.Conversation.MsgDestructTime != nil {
|
||||||
m["msg_destruct_time"] = req.Conversation.MsgDestructTime.Value
|
m["msg_destruct_time"] = req.Conversation.MsgDestructTime.Value
|
||||||
if req.Conversation.MsgDestructTime.Value != conv.MsgDestructTime {
|
|
||||||
unequal++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if req.Conversation.IsMsgDestruct != nil {
|
if req.Conversation.IsMsgDestruct != nil {
|
||||||
m["is_msg_destruct"] = req.Conversation.IsMsgDestruct.Value
|
m["is_msg_destruct"] = req.Conversation.IsMsgDestruct.Value
|
||||||
if req.Conversation.IsMsgDestruct.Value != conv.IsMsgDestruct {
|
|
||||||
unequal++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if req.Conversation.IsPrivateChat != nil && req.Conversation.ConversationType != constant.SuperGroupChatType {
|
if req.Conversation.IsPrivateChat != nil && req.Conversation.ConversationType != constant.SuperGroupChatType {
|
||||||
var conversations []*tablerelation.ConversationModel
|
var conversations []*tablerelation.ConversationModel
|
||||||
@@ -204,25 +171,19 @@ func (c *conversationServer) SetConversations(ctx context.Context, req *pbconver
|
|||||||
if err := c.conversationDatabase.SyncPeerUserPrivateConversationTx(ctx, conversations); err != nil {
|
if err := c.conversationDatabase.SyncPeerUserPrivateConversationTx(ctx, conversations); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(req.UserIDs) != 1 || unequal > 0 {
|
for _, userID := range req.UserIDs {
|
||||||
for _, userID := range req.UserIDs {
|
c.conversationNotificationSender.ConversationSetPrivateNotification(ctx, userID, req.Conversation.UserID, req.Conversation.IsPrivateChat.Value, req.Conversation.ConversationID)
|
||||||
c.conversationNotificationSender.ConversationSetPrivateNotification(ctx, userID, req.Conversation.UserID, req.Conversation.IsPrivateChat.Value, req.Conversation.ConversationID)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if req.Conversation.BurnDuration != nil {
|
if req.Conversation.BurnDuration != nil {
|
||||||
m["burn_duration"] = req.Conversation.BurnDuration.Value
|
m["burn_duration"] = req.Conversation.BurnDuration.Value
|
||||||
if req.Conversation.BurnDuration.Value != conv.BurnDuration {
|
|
||||||
unequal++
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if err := c.conversationDatabase.SetUsersConversationFiledTx(ctx, req.UserIDs, &conversation, m); err != nil {
|
err := c.conversationDatabase.SetUsersConversationFiledTx(ctx, req.UserIDs, &conversation, m)
|
||||||
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if len(req.UserIDs) != 1 || unequal > 0 {
|
for _, v := range req.UserIDs {
|
||||||
for _, v := range req.UserIDs {
|
c.conversationNotificationSender.ConversationChangeNotification(ctx, v, []string{req.Conversation.ConversationID})
|
||||||
c.conversationNotificationSender.ConversationChangeNotification(ctx, v, []string{req.Conversation.ConversationID})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return &pbconversation.SetConversationsResp{}, nil
|
return &pbconversation.SetConversationsResp{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ package friend
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/protocol/sdkws"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
"github.com/OpenIMSDK/Open-IM-Server/pkg/authverify"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/log"
|
"github.com/OpenIMSDK/tools/log"
|
||||||
@@ -359,66 +357,3 @@ func (s *friendServer) GetFriendIDs(
|
|||||||
}
|
}
|
||||||
return resp, nil
|
return resp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *friendServer) GetSpecifiedFriendsInfo(ctx context.Context, req *pbfriend.GetSpecifiedFriendsInfoReq) (*pbfriend.GetSpecifiedFriendsInfoResp, error) {
|
|
||||||
if len(req.UserIDList) == 0 {
|
|
||||||
return nil, errs.ErrArgs.Wrap("userIDList is empty")
|
|
||||||
}
|
|
||||||
if utils.Duplicate(req.UserIDList) {
|
|
||||||
return nil, errs.ErrArgs.Wrap("userIDList repeated")
|
|
||||||
}
|
|
||||||
userMap, err := s.userRpcClient.GetUsersInfoMap(ctx, req.UserIDList)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
friends, err := s.friendDatabase.FindFriendsWithError(ctx, req.OwnerUserID, req.UserIDList)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
blacks, err := s.blackDatabase.FindBlackInfos(ctx, req.OwnerUserID, req.UserIDList)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
friendMap := utils.SliceToMap(friends, func(e *tablerelation.FriendModel) string {
|
|
||||||
return e.FriendUserID
|
|
||||||
})
|
|
||||||
blackMap := utils.SliceToMap(blacks, func(e *tablerelation.BlackModel) string {
|
|
||||||
return e.BlockUserID
|
|
||||||
})
|
|
||||||
resp := &pbfriend.GetSpecifiedFriendsInfoResp{
|
|
||||||
Infos: make([]*pbfriend.GetSpecifiedFriendsInfoInfo, 0, len(req.UserIDList)),
|
|
||||||
}
|
|
||||||
for _, userID := range req.UserIDList {
|
|
||||||
user := userMap[userID]
|
|
||||||
if user == nil {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
var friendInfo *sdkws.FriendInfo
|
|
||||||
if friend := friendMap[userID]; friend != nil {
|
|
||||||
friendInfo = &sdkws.FriendInfo{
|
|
||||||
OwnerUserID: friend.OwnerUserID,
|
|
||||||
Remark: friend.Remark,
|
|
||||||
CreateTime: friend.CreateTime.UnixMilli(),
|
|
||||||
AddSource: friend.AddSource,
|
|
||||||
OperatorUserID: friend.OperatorUserID,
|
|
||||||
Ex: friend.Ex,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var blackInfo *sdkws.BlackInfo
|
|
||||||
if black := blackMap[userID]; black != nil {
|
|
||||||
blackInfo = &sdkws.BlackInfo{
|
|
||||||
OwnerUserID: black.OwnerUserID,
|
|
||||||
CreateTime: black.CreateTime.UnixMilli(),
|
|
||||||
AddSource: black.AddSource,
|
|
||||||
OperatorUserID: black.OperatorUserID,
|
|
||||||
Ex: black.Ex,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
resp.Infos = append(resp.Infos, &pbfriend.GetSpecifiedFriendsInfoInfo{
|
|
||||||
UserInfo: user,
|
|
||||||
FriendInfo: friendInfo,
|
|
||||||
BlackInfo: blackInfo,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return resp, nil
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -128,9 +128,7 @@ func (m *msgServer) messageVerification(ctx context.Context, data *msg.SendMsgRe
|
|||||||
|
|
||||||
func (m *msgServer) encapsulateMsgData(msg *sdkws.MsgData) {
|
func (m *msgServer) encapsulateMsgData(msg *sdkws.MsgData) {
|
||||||
msg.ServerMsgID = GetMsgID(msg.SendID)
|
msg.ServerMsgID = GetMsgID(msg.SendID)
|
||||||
if msg.SendTime == 0 {
|
msg.SendTime = utils.GetCurrentTimestampByMill()
|
||||||
msg.SendTime = utils.GetCurrentTimestampByMill()
|
|
||||||
}
|
|
||||||
switch msg.ContentType {
|
switch msg.ContentType {
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|||||||
@@ -72,8 +72,11 @@ type CustomElem struct {
|
|||||||
Description string `mapstructure:"description"`
|
Description string `mapstructure:"description"`
|
||||||
Extension string `mapstructure:"extension"`
|
Extension string `mapstructure:"extension"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type TextElem struct {
|
type TextElem struct {
|
||||||
|
Text string `mapstructure:"text" validate:"required"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type TextContentElem struct {
|
||||||
Content string `json:"content" validate:"required"`
|
Content string `json:"content" validate:"required"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+1
-1
@@ -244,7 +244,7 @@ func (u *UserCacheRedis) SetUserStatus(ctx context.Context, list []*user.OnlineS
|
|||||||
}
|
}
|
||||||
if newPlatformIDs == nil {
|
if newPlatformIDs == nil {
|
||||||
onlineStatus.Status = constant.Offline
|
onlineStatus.Status = constant.Offline
|
||||||
onlineStatus.PlatformIDs = []int32{}
|
onlineStatus.PlatformIDs = nil
|
||||||
newjsonData, err := json.Marshal(&onlineStatus)
|
newjsonData, err := json.Marshal(&onlineStatus)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errs.Wrap(err)
|
return errs.Wrap(err)
|
||||||
|
|||||||
@@ -36,7 +36,6 @@ type BlackDatabase interface {
|
|||||||
pageNumber, showNumber int32,
|
pageNumber, showNumber int32,
|
||||||
) (blacks []*relation.BlackModel, total int64, err error)
|
) (blacks []*relation.BlackModel, total int64, err error)
|
||||||
FindBlackIDs(ctx context.Context, ownerUserID string) (blackIDs []string, err error)
|
FindBlackIDs(ctx context.Context, ownerUserID string) (blackIDs []string, err error)
|
||||||
FindBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error)
|
|
||||||
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
|
// CheckIn 检查user2是否在user1的黑名单列表中(inUser1Blacks==true) 检查user1是否在user2的黑名单列表中(inUser2Blacks==true)
|
||||||
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
|
CheckIn(ctx context.Context, userID1, userID2 string) (inUser1Blacks bool, inUser2Blacks bool, err error)
|
||||||
}
|
}
|
||||||
@@ -103,7 +102,3 @@ func (b *blackDatabase) CheckIn(
|
|||||||
func (b *blackDatabase) FindBlackIDs(ctx context.Context, ownerUserID string) (blackIDs []string, err error) {
|
func (b *blackDatabase) FindBlackIDs(ctx context.Context, ownerUserID string) (blackIDs []string, err error) {
|
||||||
return b.cache.GetBlackIDs(ctx, ownerUserID)
|
return b.cache.GetBlackIDs(ctx, ownerUserID)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *blackDatabase) FindBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error) {
|
|
||||||
return b.black.FindOwnerBlackInfos(ctx, ownerUserID, userIDs)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -17,8 +17,6 @@ package relation
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/errs"
|
|
||||||
|
|
||||||
"github.com/OpenIMSDK/tools/ormutil"
|
"github.com/OpenIMSDK/tools/ormutil"
|
||||||
|
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@@ -105,7 +103,3 @@ func (b *BlackGorm) FindBlackUserIDs(ctx context.Context, ownerUserID string) (b
|
|||||||
"",
|
"",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *BlackGorm) FindOwnerBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*relation.BlackModel, err error) {
|
|
||||||
return blacks, errs.Wrap(b.db(ctx).Where("owner_user_id = ? and block_user_id in ?", ownerUserID, userIDs).Find(&blacks).Error)
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -43,7 +43,10 @@ type BlackModelInterface interface {
|
|||||||
Update(ctx context.Context, blacks []*BlackModel) (err error)
|
Update(ctx context.Context, blacks []*BlackModel) (err error)
|
||||||
Find(ctx context.Context, blacks []*BlackModel) (blackList []*BlackModel, err error)
|
Find(ctx context.Context, blacks []*BlackModel) (blackList []*BlackModel, err error)
|
||||||
Take(ctx context.Context, ownerUserID, blockUserID string) (black *BlackModel, err error)
|
Take(ctx context.Context, ownerUserID, blockUserID string) (black *BlackModel, err error)
|
||||||
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*BlackModel, total int64, err error)
|
FindOwnerBlacks(
|
||||||
FindOwnerBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*BlackModel, err error)
|
ctx context.Context,
|
||||||
|
ownerUserID string,
|
||||||
|
pageNumber, showNumber int32,
|
||||||
|
) (blacks []*BlackModel, total int64, err error)
|
||||||
FindBlackUserIDs(ctx context.Context, ownerUserID string) (blackUserIDs []string, err error)
|
FindBlackUserIDs(ctx context.Context, ownerUserID string) (blackUserIDs []string, err error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -250,11 +250,7 @@ func (s *NotificationSender) NotificationWithSesstionType(ctx context.Context, s
|
|||||||
}
|
}
|
||||||
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
msg.CreateTime = utils.GetCurrentTimestampByMill()
|
||||||
msg.ClientMsgID = utils.GetMsgID(sendID)
|
msg.ClientMsgID = utils.GetMsgID(sendID)
|
||||||
optionsConfig := s.contentTypeConf[contentType]
|
options := config.GetOptionsByNotification(s.contentTypeConf[contentType])
|
||||||
if sesstionType == constant.SuperGroupChatType && contentType == constant.HasReadReceipt {
|
|
||||||
optionsConfig.ReliabilityLevel = constant.UnreliableNotification
|
|
||||||
}
|
|
||||||
options := config.GetOptionsByNotification(optionsConfig)
|
|
||||||
msg.Options = options
|
msg.Options = options
|
||||||
offlineInfo.Title = title
|
offlineInfo.Title = title
|
||||||
offlineInfo.Desc = desc
|
offlineInfo.Desc = desc
|
||||||
|
|||||||
Reference in New Issue
Block a user