mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-10-27 05:52:29 +08:00
refactor: update groupinfoEx field.
This commit is contained in:
parent
620a1a9aeb
commit
6b3a653e8f
2
go.mod
2
go.mod
@ -12,7 +12,7 @@ require (
|
||||
github.com/gorilla/websocket v1.5.1
|
||||
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
|
||||
github.com/mitchellh/mapstructure v1.5.0
|
||||
github.com/openimsdk/protocol v0.0.72-alpha.23
|
||||
github.com/openimsdk/protocol v0.0.72-alpha.24
|
||||
github.com/openimsdk/tools v0.0.50-alpha.12
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/prometheus/client_golang v1.18.0
|
||||
|
||||
4
go.sum
4
go.sum
@ -322,8 +322,8 @@ github.com/onsi/gomega v1.25.0 h1:Vw7br2PCDYijJHSfBOWhov+8cAnUf8MfMaIOV323l6Y=
|
||||
github.com/onsi/gomega v1.25.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
||||
github.com/openimsdk/gomake v0.0.14-alpha.5 h1:VY9c5x515lTfmdhhPjMvR3BBRrRquAUCFsz7t7vbv7Y=
|
||||
github.com/openimsdk/gomake v0.0.14-alpha.5/go.mod h1:PndCozNc2IsQIciyn9mvEblYWZwJmAI+06z94EY+csI=
|
||||
github.com/openimsdk/protocol v0.0.72-alpha.23 h1:XHJHO6Isqe6CBXHOZ43/Vbowm/ZLWor5B84t9b7SccA=
|
||||
github.com/openimsdk/protocol v0.0.72-alpha.23/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
|
||||
github.com/openimsdk/protocol v0.0.72-alpha.24 h1:1Dl8TEZVXhdmve+ewoLkJa2wbFBIHqPgjvr9u/J66JM=
|
||||
github.com/openimsdk/protocol v0.0.72-alpha.24/go.mod h1:OZQA9FR55lseYoN2Ql1XAHYKHJGu7OMNkUbuekrKCM8=
|
||||
github.com/openimsdk/tools v0.0.50-alpha.12 h1:rV3BxgqN+F79vZvdoQ+97Eob8ScsRVEM8D+Wrcl23uo=
|
||||
github.com/openimsdk/tools v0.0.50-alpha.12/go.mod h1:h1cYmfyaVtgFbKmb1Cfsl8XwUOMTt8ubVUQrdGtsUh4=
|
||||
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
||||
|
||||
@ -363,26 +363,26 @@ func (s *groupServer) webhookBeforeSetGroupInfoEx(ctx context.Context, before *c
|
||||
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
||||
cbReq := &callbackstruct.CallbackBeforeSetGroupInfoExReq{
|
||||
CallbackCommand: callbackstruct.CallbackBeforeSetGroupInfoExCommand,
|
||||
GroupID: req.GroupInfoForSet.GroupID,
|
||||
GroupName: req.GroupInfoForSet.GroupName,
|
||||
Notification: req.GroupInfoForSet.Notification,
|
||||
Introduction: req.GroupInfoForSet.Introduction,
|
||||
FaceURL: req.GroupInfoForSet.FaceURL,
|
||||
GroupID: req.GroupID,
|
||||
GroupName: req.GroupName,
|
||||
Notification: req.Notification,
|
||||
Introduction: req.Introduction,
|
||||
FaceURL: req.FaceURL,
|
||||
}
|
||||
|
||||
if req.GroupInfoForSet.Ex != nil {
|
||||
cbReq.Ex = req.GroupInfoForSet.Ex
|
||||
if req.Ex != nil {
|
||||
cbReq.Ex = req.Ex
|
||||
}
|
||||
log.ZDebug(ctx, "debug CallbackBeforeSetGroupInfoEX", "ex", cbReq.Ex)
|
||||
|
||||
if req.GroupInfoForSet.NeedVerification != nil {
|
||||
cbReq.NeedVerification = req.GroupInfoForSet.NeedVerification
|
||||
if req.NeedVerification != nil {
|
||||
cbReq.NeedVerification = req.NeedVerification
|
||||
}
|
||||
if req.GroupInfoForSet.LookMemberInfo != nil {
|
||||
cbReq.LookMemberInfo = req.GroupInfoForSet.LookMemberInfo
|
||||
if req.LookMemberInfo != nil {
|
||||
cbReq.LookMemberInfo = req.LookMemberInfo
|
||||
}
|
||||
if req.GroupInfoForSet.ApplyMemberFriend != nil {
|
||||
cbReq.ApplyMemberFriend = req.GroupInfoForSet.ApplyMemberFriend
|
||||
if req.ApplyMemberFriend != nil {
|
||||
cbReq.ApplyMemberFriend = req.ApplyMemberFriend
|
||||
}
|
||||
|
||||
resp := &callbackstruct.CallbackBeforeSetGroupInfoExResp{}
|
||||
@ -391,14 +391,14 @@ func (s *groupServer) webhookBeforeSetGroupInfoEx(ctx context.Context, before *c
|
||||
return err
|
||||
}
|
||||
|
||||
datautil.NotNilReplace(&req.GroupInfoForSet.GroupID, &resp.GroupID)
|
||||
datautil.NotNilReplace(&req.GroupInfoForSet.GroupName, &resp.GroupName)
|
||||
datautil.NotNilReplace(&req.GroupInfoForSet.FaceURL, &resp.FaceURL)
|
||||
datautil.NotNilReplace(&req.GroupInfoForSet.Introduction, &resp.Introduction)
|
||||
datautil.NotNilReplace(&req.GroupInfoForSet.Ex, &resp.Ex)
|
||||
datautil.NotNilReplace(&req.GroupInfoForSet.NeedVerification, &resp.NeedVerification)
|
||||
datautil.NotNilReplace(&req.GroupInfoForSet.LookMemberInfo, &resp.LookMemberInfo)
|
||||
datautil.NotNilReplace(&req.GroupInfoForSet.ApplyMemberFriend, &resp.ApplyMemberFriend)
|
||||
datautil.NotNilReplace(&req.GroupID, &resp.GroupID)
|
||||
datautil.NotNilReplace(&req.GroupName, &resp.GroupName)
|
||||
datautil.NotNilReplace(&req.FaceURL, &resp.FaceURL)
|
||||
datautil.NotNilReplace(&req.Introduction, &resp.Introduction)
|
||||
datautil.NotNilReplace(&req.Ex, &resp.Ex)
|
||||
datautil.NotNilReplace(&req.NeedVerification, &resp.NeedVerification)
|
||||
datautil.NotNilReplace(&req.LookMemberInfo, &resp.LookMemberInfo)
|
||||
datautil.NotNilReplace(&req.ApplyMemberFriend, &resp.ApplyMemberFriend)
|
||||
|
||||
return nil
|
||||
})
|
||||
@ -407,24 +407,24 @@ func (s *groupServer) webhookBeforeSetGroupInfoEx(ctx context.Context, before *c
|
||||
func (s *groupServer) webhookAfterSetGroupInfoEx(ctx context.Context, after *config.AfterConfig, req *group.SetGroupInfoExReq) {
|
||||
cbReq := &callbackstruct.CallbackAfterSetGroupInfoExReq{
|
||||
CallbackCommand: callbackstruct.CallbackAfterSetGroupInfoExCommand,
|
||||
GroupID: req.GroupInfoForSet.GroupID,
|
||||
GroupName: req.GroupInfoForSet.GroupName,
|
||||
Notification: req.GroupInfoForSet.Notification,
|
||||
Introduction: req.GroupInfoForSet.Introduction,
|
||||
FaceURL: req.GroupInfoForSet.FaceURL,
|
||||
GroupID: req.GroupID,
|
||||
GroupName: req.GroupName,
|
||||
Notification: req.Notification,
|
||||
Introduction: req.Introduction,
|
||||
FaceURL: req.FaceURL,
|
||||
}
|
||||
|
||||
if req.GroupInfoForSet.Ex != nil {
|
||||
cbReq.Ex = req.GroupInfoForSet.Ex
|
||||
if req.Ex != nil {
|
||||
cbReq.Ex = req.Ex
|
||||
}
|
||||
if req.GroupInfoForSet.NeedVerification != nil {
|
||||
cbReq.NeedVerification = req.GroupInfoForSet.NeedVerification
|
||||
if req.NeedVerification != nil {
|
||||
cbReq.NeedVerification = req.NeedVerification
|
||||
}
|
||||
if req.GroupInfoForSet.LookMemberInfo != nil {
|
||||
cbReq.LookMemberInfo = req.GroupInfoForSet.LookMemberInfo
|
||||
if req.LookMemberInfo != nil {
|
||||
cbReq.LookMemberInfo = req.LookMemberInfo
|
||||
}
|
||||
if req.GroupInfoForSet.ApplyMemberFriend != nil {
|
||||
cbReq.ApplyMemberFriend = req.GroupInfoForSet.ApplyMemberFriend
|
||||
if req.ApplyMemberFriend != nil {
|
||||
cbReq.ApplyMemberFriend = req.ApplyMemberFriend
|
||||
}
|
||||
|
||||
s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, &callbackstruct.CallbackAfterSetGroupInfoExResp{}, after)
|
||||
|
||||
@ -54,10 +54,10 @@ func UpdateGroupInfoMap(ctx context.Context, group *sdkws.GroupInfoForSet) map[s
|
||||
return m
|
||||
}
|
||||
|
||||
func UpdateGroupInfoExMap(ctx context.Context, group *sdkws.GroupInfoForSetEx) map[string]any {
|
||||
func UpdateGroupInfoExMap(ctx context.Context, group *pbgroup.SetGroupInfoExReq) map[string]any {
|
||||
m := make(map[string]any)
|
||||
|
||||
if group.GroupName != "" {
|
||||
if group.GroupName != nil {
|
||||
m["group_name"] = group.GroupName
|
||||
}
|
||||
if group.Notification != nil {
|
||||
|
||||
@ -1064,7 +1064,7 @@ func (g *groupServer) SetGroupInfoEx(ctx context.Context, req *pbgroup.SetGroupI
|
||||
if !authverify.IsAppManagerUid(ctx, g.config.Share.IMAdminUserID) {
|
||||
var err error
|
||||
|
||||
opMember, err = g.db.TakeGroupMember(ctx, req.GroupInfoForSet.GroupID, mcontext.GetOpUserID(ctx))
|
||||
opMember, err = g.db.TakeGroupMember(ctx, req.GroupID, mcontext.GetOpUserID(ctx))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1082,7 +1082,7 @@ func (g *groupServer) SetGroupInfoEx(ctx context.Context, req *pbgroup.SetGroupI
|
||||
return nil, err
|
||||
}
|
||||
|
||||
group, err := g.db.TakeGroup(ctx, req.GroupInfoForSet.GroupID)
|
||||
group, err := g.db.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1104,7 +1104,7 @@ func (g *groupServer) SetGroupInfoEx(ctx context.Context, req *pbgroup.SetGroupI
|
||||
return nil, err
|
||||
}
|
||||
|
||||
updatedData := UpdateGroupInfoExMap(ctx, req.GroupInfoForSet)
|
||||
updatedData := UpdateGroupInfoExMap(ctx, req)
|
||||
if len(updatedData) == 0 {
|
||||
return &pbgroup.SetGroupInfoExResp{}, nil
|
||||
}
|
||||
@ -1113,7 +1113,7 @@ func (g *groupServer) SetGroupInfoEx(ctx context.Context, req *pbgroup.SetGroupI
|
||||
return nil, err
|
||||
}
|
||||
|
||||
group, err = g.db.TakeGroup(ctx, req.GroupInfoForSet.GroupID)
|
||||
group, err = g.db.TakeGroup(ctx, req.GroupID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -1129,18 +1129,18 @@ func (g *groupServer) SetGroupInfoEx(ctx context.Context, req *pbgroup.SetGroupI
|
||||
}
|
||||
|
||||
num := len(updatedData)
|
||||
if req.GroupInfoForSet.Notification != nil {
|
||||
if req.Notification != nil {
|
||||
num--
|
||||
|
||||
if req.GroupInfoForSet.Notification.Value != "" {
|
||||
if req.Notification.Value != "" {
|
||||
func() {
|
||||
conversation := &pbconversation.ConversationReq{
|
||||
ConversationID: msgprocessor.GetConversationIDBySessionType(constant.ReadGroupChatType, req.GroupInfoForSet.GroupID),
|
||||
ConversationID: msgprocessor.GetConversationIDBySessionType(constant.ReadGroupChatType, req.GroupID),
|
||||
ConversationType: constant.ReadGroupChatType,
|
||||
GroupID: req.GroupInfoForSet.GroupID,
|
||||
GroupID: req.GroupID,
|
||||
}
|
||||
|
||||
resp, err := g.GetGroupMemberUserIDs(ctx, &pbgroup.GetGroupMemberUserIDsReq{GroupID: req.GroupInfoForSet.GroupID})
|
||||
resp, err := g.GetGroupMemberUserIDs(ctx, &pbgroup.GetGroupMemberUserIDsReq{GroupID: req.GroupID})
|
||||
if err != nil {
|
||||
log.ZWarn(ctx, "GetGroupMemberIDs is failed.", err)
|
||||
return
|
||||
@ -1157,7 +1157,7 @@ func (g *groupServer) SetGroupInfoEx(ctx context.Context, req *pbgroup.SetGroupI
|
||||
}
|
||||
}
|
||||
|
||||
if req.GroupInfoForSet.GroupName != "" {
|
||||
if req.GroupName != nil {
|
||||
num--
|
||||
g.notification.GroupInfoSetNameNotification(ctx, &sdkws.GroupInfoSetNameTips{Group: tips.Group, OpUser: tips.OpUser})
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ type CallbackBeforeSetGroupInfoExReq struct {
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
OperationID string `json:"operationID"`
|
||||
GroupID string `json:"groupID"`
|
||||
GroupName string `json:"groupName"`
|
||||
GroupName *wrapperspb.StringValue `json:"groupName"`
|
||||
Notification *wrapperspb.StringValue `json:"notification"`
|
||||
Introduction *wrapperspb.StringValue `json:"introduction"`
|
||||
FaceURL *wrapperspb.StringValue `json:"faceURL"`
|
||||
@ -261,7 +261,7 @@ type CallbackBeforeSetGroupInfoExReq struct {
|
||||
type CallbackBeforeSetGroupInfoExResp struct {
|
||||
CommonCallbackResp
|
||||
GroupID string `json:"groupID"`
|
||||
GroupName string `json:"groupName"`
|
||||
GroupName *wrapperspb.StringValue `json:"groupName"`
|
||||
Notification *wrapperspb.StringValue `json:"notification"`
|
||||
Introduction *wrapperspb.StringValue `json:"introduction"`
|
||||
FaceURL *wrapperspb.StringValue `json:"faceURL"`
|
||||
@ -275,7 +275,7 @@ type CallbackAfterSetGroupInfoExReq struct {
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
OperationID string `json:"operationID"`
|
||||
GroupID string `json:"groupID"`
|
||||
GroupName string `json:"groupName"`
|
||||
GroupName *wrapperspb.StringValue `json:"groupName"`
|
||||
Notification *wrapperspb.StringValue `json:"notification"`
|
||||
Introduction *wrapperspb.StringValue `json:"introduction"`
|
||||
FaceURL *wrapperspb.StringValue `json:"faceURL"`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user