Merge remote-tracking branch 'origin/errcode' into errcode

This commit is contained in:
Gordon
2023-06-07 15:12:00 +08:00
16 changed files with 1444 additions and 1279 deletions
+5 -5
View File
@@ -12,11 +12,11 @@ import (
)
func NewAuth(discov discoveryregistry.SvcDiscoveryRegistry) *Auth {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImAuthName)
if err != nil {
// panic(err)
}
return &Auth{conn: conn, discov: discov}
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImAuthName)
// if err != nil {
// panic(err)
// }
return &Auth{discov: discov}
}
type Auth struct {
+5 -5
View File
@@ -12,11 +12,11 @@ import (
)
func NewConversation(discov discoveryregistry.SvcDiscoveryRegistry) *Conversation {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImConversationName)
if err != nil {
// panic(err)
}
return &Conversation{conn: conn, discov: discov}
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImConversationName)
// if err != nil {
// panic(err)
// }
return &Conversation{discov: discov}
}
type Conversation struct {
+5 -5
View File
@@ -13,11 +13,11 @@ import (
)
func NewFriend(discov discoveryregistry.SvcDiscoveryRegistry) *Friend {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImFriendName)
if err != nil {
// panic(err)
}
return &Friend{conn: conn, discov: discov}
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImFriendName)
// if err != nil {
// panic(err)
// }
return &Friend{discov: discov}
}
type Friend struct {
+5 -5
View File
@@ -13,11 +13,11 @@ import (
)
func NewGroup(discov discoveryregistry.SvcDiscoveryRegistry) *Group {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImGroupName)
if err != nil {
// panic(err)
}
return &Group{conn: conn, discov: discov}
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImGroupName)
// if err != nil {
// panic(err)
// }
return &Group{discov: discov}
}
type Group struct {
+5 -5
View File
@@ -22,11 +22,11 @@ import (
)
func NewMsg(discov discoveryregistry.SvcDiscoveryRegistry) *Message {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName)
if err != nil {
// panic(err)
}
return &Message{conn: conn, validate: validator.New(), discov: discov}
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImMsgName)
// if err != nil {
// panic(err)
// }
return &Message{validate: validator.New(), discov: discov}
}
type Message struct {
+5 -5
View File
@@ -18,11 +18,11 @@ import (
)
func NewThird(discov discoveryregistry.SvcDiscoveryRegistry) *Third {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
if err != nil {
// panic(err)
}
return &Third{conn: conn, discov: discov}
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImThirdName)
// if err != nil {
// panic(err)
// }
return &Third{discov: discov}
}
type Third struct {
+5 -7
View File
@@ -5,7 +5,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/apiresp"
"github.com/OpenIMSDK/Open-IM-Server/pkg/apistruct"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/log"
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
"google.golang.org/grpc"
@@ -18,12 +17,11 @@ import (
)
func NewUser(discov discoveryregistry.SvcDiscoveryRegistry) *User {
conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
if err != nil {
// panic(err)
}
log.ZInfo(context.Background(), "user rpc conn", "conn", conn)
return &User{conn: conn, discov: discov}
// conn, err := discov.GetConn(context.Background(), config.Config.RpcRegisterName.OpenImUserName)
// if err != nil {
// panic(err)
// }
return &User{discov: discov}
}
type User struct {
+26 -14
View File
@@ -26,7 +26,6 @@ import (
"github.com/OpenIMSDK/Open-IM-Server/pkg/common/tokenverify"
"github.com/OpenIMSDK/Open-IM-Server/pkg/discoveryregistry"
"github.com/OpenIMSDK/Open-IM-Server/pkg/errs"
pbConversation "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/conversation"
pbGroup "github.com/OpenIMSDK/Open-IM-Server/pkg/proto/group"
"github.com/OpenIMSDK/Open-IM-Server/pkg/proto/sdkws"
"github.com/OpenIMSDK/Open-IM-Server/pkg/utils"
@@ -926,21 +925,34 @@ func (s *groupServer) SetGroupInfo(ctx context.Context, req *pbGroup.SetGroupInf
} else {
tips.OpUser = s.groupMemberDB2PB(opMember, 0)
}
s.Notification.GroupInfoSetNotification(ctx, tips)
var num int
if req.GroupInfoForSet.Notification != "" {
args := &pbConversation.ModifyConversationFieldReq{
Conversation: &pbConversation.Conversation{
OwnerUserID: mcontext.GetOpUserID(ctx),
ConversationID: utils.GetConversationIDBySessionType(constant.GroupChatType, group.GroupID),
ConversationType: constant.SuperGroupChatType,
GroupID: group.GroupID,
},
FieldType: constant.FieldGroupAtType,
UserIDList: userIDs,
}
if err := s.conversationRpcClient.ModifyConversationField(ctx, args); err != nil {
log.ZWarn(ctx, "modifyConversationField failed", err, "args", args)
num++
s.Notification.GroupInfoSetAnnouncementNotification(ctx, &sdkws.GroupInfoSetAnnouncementTips{Group: tips.Group, OpUser: tips.OpUser})
//args := &pbConversation.ModifyConversationFieldReq{
// Conversation: &pbConversation.Conversation{
// OwnerUserID: mcontext.GetOpUserID(ctx),
// ConversationID: utils.GetConversationIDBySessionType(constant.GroupChatType, group.GroupID),
// ConversationType: constant.SuperGroupChatType,
// GroupID: group.GroupID,
// },
// FieldType: constant.FieldGroupAtType,
// UserIDList: userIDs,
//}
//if err := s.conversationRpcClient.ModifyConversationField(ctx, args); err != nil {
// log.ZWarn(ctx, "modifyConversationField failed", err, "args", args)
//}
}
switch len(data) - num {
case 0:
case 1:
if req.GroupInfoForSet.GroupName == "" {
s.Notification.GroupInfoSetNotification(ctx, tips)
} else {
s.Notification.GroupInfoSetNameNotification(ctx, &sdkws.GroupInfoSetNameTips{Group: tips.Group, OpUser: tips.OpUser})
}
default:
s.Notification.GroupInfoSetNotification(ctx, tips)
}
return resp, nil
}