mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-05-07 02:26:00 +08:00
Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d687d269e0 | |||
| f19c9d8e37 | |||
| b2bb86d84a | |||
| 15a09c90ab | |||
| 0d59d42460 | |||
| 9200de758a | |||
| 80249852a3 | |||
| 0dd3d96920 | |||
| ef0ce13f95 | |||
| bf67a56fe1 | |||
| 9c4517ac05 | |||
| 17bc9596da | |||
| 3fdc5104ed | |||
| 9eee94e5ec | |||
| 46c26b8dff | |||
| 7f90eb55a9 | |||
| 83917d193f | |||
| 80c985ae12 | |||
| b465caa4d7 | |||
| 7b07257f55 | |||
| fda2958b78 | |||
| 906fb726a7 | |||
| 59c6635fb7 | |||
| 489e4fcac0 | |||
| b37aa92a72 | |||
| 2f7f45aea2 | |||
| cb31569ca5 | |||
| 3f2d771190 | |||
| 6db9e2c7a9 | |||
| b85750da69 | |||
| 7ec5d76843 | |||
| 5f59019279 | |||
| 8f1732155a | |||
| 270e14dcfc | |||
| 43bdd4126a | |||
| 8a226a78ae | |||
| 5379603d0f | |||
| 95091e7e65 | |||
| a02e0c367b | |||
| cb707f0959 | |||
| 2c4449898e | |||
| 607d97fb9d | |||
| f2977b6837 | |||
| 4a0e949569 | |||
| 40a4952fe2 | |||
| 4ce4548ca1 | |||
| 6fc15d4f7a | |||
| 687614d3f4 | |||
| d7532347ad | |||
| 85bd38d6d4 | |||
| 9d6b1536d2 |
@@ -18,9 +18,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"runtime"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -46,16 +43,6 @@ 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")
|
||||||
@@ -92,7 +79,6 @@ 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.17
|
github.com/OpenIMSDK/protocol v0.0.18
|
||||||
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.17 h1:ixjKUVGlTW+jQK5cPaKV//6l4bk9DAlbjDhocztYSbU=
|
github.com/OpenIMSDK/protocol v0.0.18 h1:hXukFiDMLZx7s+hDCQePIK9ABiHyNlobNL4MppvOuMY=
|
||||||
github.com/OpenIMSDK/protocol v0.0.17/go.mod h1:F25dFrwrIx3lkNoiuf6FkCfxuwf8L4Z8UIsdTHP/r0Y=
|
github.com/OpenIMSDK/protocol v0.0.18/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,3 +88,7 @@ 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)
|
||||||
|
}
|
||||||
|
|||||||
+1
-6
@@ -170,12 +170,7 @@ 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:
|
||||||
text, ok := req.Content["text"].(string)
|
data = apistruct.TextElem{}
|
||||||
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,6 +106,7 @@ 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,6 +133,18 @@ 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
|
||||||
@@ -141,24 +153,45 @@ 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
|
||||||
@@ -171,19 +204,25 @@ 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
|
||||||
}
|
}
|
||||||
for _, userID := range req.UserIDs {
|
if len(req.UserIDs) != 1 || unequal > 0 {
|
||||||
c.conversationNotificationSender.ConversationSetPrivateNotification(ctx, userID, req.Conversation.UserID, req.Conversation.IsPrivateChat.Value, req.Conversation.ConversationID)
|
for _, userID := range req.UserIDs {
|
||||||
|
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++
|
||||||
|
}
|
||||||
}
|
}
|
||||||
err := c.conversationDatabase.SetUsersConversationFiledTx(ctx, req.UserIDs, &conversation, m)
|
if err := c.conversationDatabase.SetUsersConversationFiledTx(ctx, req.UserIDs, &conversation, m); err != nil {
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
for _, v := range req.UserIDs {
|
if len(req.UserIDs) != 1 || unequal > 0 {
|
||||||
c.conversationNotificationSender.ConversationChangeNotification(ctx, v, []string{req.Conversation.ConversationID})
|
for _, v := range req.UserIDs {
|
||||||
|
c.conversationNotificationSender.ConversationChangeNotification(ctx, v, []string{req.Conversation.ConversationID})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return &pbconversation.SetConversationsResp{}, nil
|
return &pbconversation.SetConversationsResp{}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ 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"
|
||||||
@@ -357,3 +359,66 @@ 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,7 +128,9 @@ 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)
|
||||||
msg.SendTime = utils.GetCurrentTimestampByMill()
|
if msg.SendTime == 0 {
|
||||||
|
msg.SendTime = utils.GetCurrentTimestampByMill()
|
||||||
|
}
|
||||||
switch msg.ContentType {
|
switch msg.ContentType {
|
||||||
case constant.Text:
|
case constant.Text:
|
||||||
fallthrough
|
fallthrough
|
||||||
|
|||||||
@@ -72,11 +72,8 @@ type CustomElem struct {
|
|||||||
Description string `mapstructure:"description"`
|
Description string `mapstructure:"description"`
|
||||||
Extension string `mapstructure:"extension"`
|
Extension string `mapstructure:"extension"`
|
||||||
}
|
}
|
||||||
type TextElem struct {
|
|
||||||
Text string `mapstructure:"text" validate:"required"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type TextContentElem struct {
|
type TextElem 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 = nil
|
onlineStatus.PlatformIDs = []int32{}
|
||||||
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,6 +36,7 @@ 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)
|
||||||
}
|
}
|
||||||
@@ -102,3 +103,7 @@ 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,6 +17,8 @@ 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"
|
||||||
@@ -103,3 +105,7 @@ 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,10 +43,7 @@ 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(
|
FindOwnerBlacks(ctx context.Context, ownerUserID string, pageNumber, showNumber int32) (blacks []*BlackModel, total int64, err error)
|
||||||
ctx context.Context,
|
FindOwnerBlackInfos(ctx context.Context, ownerUserID string, userIDs []string) (blacks []*BlackModel, err error)
|
||||||
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,7 +250,11 @@ 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)
|
||||||
options := config.GetOptionsByNotification(s.contentTypeConf[contentType])
|
optionsConfig := 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