mirror of
https://github.com/openimsdk/open-im-server.git
synced 2025-12-05 12:02:25 +08:00
fix: merge
This commit is contained in:
parent
57fe356414
commit
54db5c6fd4
@ -434,37 +434,37 @@ callback:
|
||||
timeout: ${CALLBACK_TIMEOUT}
|
||||
failedContinue: ${CALLBACK_FAILED_CONTINUE}
|
||||
afterGroupMsgRead:
|
||||
enable: false
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
enable: ${CALLBACK_ENABLE}
|
||||
timeout: ${CALLBACK_TIMEOUT}
|
||||
failedContinue: ${CALLBACK_FAILED_CONTINUE}
|
||||
afterGroupMsgRevoke:
|
||||
enable: false
|
||||
enable: ${CALLBACK_ENABLE}
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
afterJoinGroup:
|
||||
enable: false
|
||||
enable: ${CALLBACK_ENABLE}
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
beforeInviteUserToGroup:
|
||||
enable: false
|
||||
enable: ${CALLBACK_ENABLE}
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
|
||||
joinGroupAfter:
|
||||
enable: false
|
||||
enable: ${CALLBACK_ENABLE}
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
##TODO CALLBACK
|
||||
setGroupInfoAfter:
|
||||
enable: false
|
||||
enable: ${CALLBACK_ENABLE}
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
setGroupInfoBefore:
|
||||
enable: false
|
||||
enable: ${CALLBACK_ENABLE}
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
revokeMsgAfter:
|
||||
enable: false
|
||||
enable: ${CALLBACK_ENABLE}
|
||||
timeout: 5
|
||||
failedContinue: true
|
||||
addBlackBefore:
|
||||
|
||||
@ -16,6 +16,7 @@ package group
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
"time"
|
||||
|
||||
@ -192,6 +193,8 @@ func CallbackBeforeSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMe
|
||||
if resp.Ex != nil {
|
||||
req.Ex = wrapperspb.String(*resp.Ex)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func CallbackAfterSetGroupMemberInfo(ctx context.Context, req *group.SetGroupMemberInfo) (err error) {
|
||||
if !config.Config.Callback.CallbackBeforeSetGroupMemberInfo.Enable {
|
||||
return nil
|
||||
@ -297,5 +300,144 @@ func CallbackTransferGroupOwnerAfter(ctx context.Context, req *pbgroup.TransferG
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func CallbackBeforeInviteUserToGroup(ctx context.Context, req *group.InviteUserToGroupReq) (err error) {
|
||||
if !config.Config.Callback.CallbackBeforeInviteUserToGroup.Enable {
|
||||
return nil
|
||||
}
|
||||
|
||||
callbackReq := &callbackstruct.CallbackBeforeInviteUserToGroupReq{
|
||||
CallbackCommand: callbackstruct.CallbackBeforeInviteJoinGroupCommand,
|
||||
OperationID: mcontext.GetOperationID(ctx),
|
||||
GroupID: req.GroupID,
|
||||
Reason: req.Reason,
|
||||
InvitedUserIDs: req.InvitedUserIDs,
|
||||
}
|
||||
|
||||
resp := &callbackstruct.CallbackBeforeInviteUserToGroupResp{}
|
||||
err = http.CallBackPostReturn(
|
||||
ctx,
|
||||
config.Config.Callback.CallbackUrl,
|
||||
callbackReq,
|
||||
resp,
|
||||
config.Config.Callback.CallbackBeforeInviteUserToGroup,
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(resp.RefusedMembersAccount) > 0 {
|
||||
// Handle the scenario where certain members are refused
|
||||
// You might want to update the req.Members list or handle it as per your business logic
|
||||
}
|
||||
utils.StructFieldNotNilReplace(req, resp)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func CallbackAfterJoinGroup(ctx context.Context, req *group.JoinGroupReq) error {
|
||||
if !config.Config.Callback.CallbackAfterJoinGroup.Enable {
|
||||
return nil
|
||||
}
|
||||
callbackReq := &callbackstruct.CallbackAfterJoinGroupReq{
|
||||
CallbackCommand: callbackstruct.CallbackAfterJoinGroupCommand,
|
||||
OperationID: mcontext.GetOperationID(ctx),
|
||||
GroupID: req.GroupID,
|
||||
ReqMessage: req.ReqMessage,
|
||||
JoinSource: req.JoinSource,
|
||||
InviterUserID: req.InviterUserID,
|
||||
}
|
||||
resp := &callbackstruct.CallbackAfterJoinGroupResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackAfterJoinGroup); err != nil {
|
||||
if err == errs.ErrCallbackContinue {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func CallbackBeforeSetGroupInfo(ctx context.Context, req *group.SetGroupInfoReq) error {
|
||||
if !config.Config.Callback.CallbackBeforeSetGroupInfo.Enable {
|
||||
return nil
|
||||
}
|
||||
callbackReq := &callbackstruct.CallbackBeforeSetGroupInfoReq{
|
||||
CallbackCommand: callbackstruct.CallbackBeforeSetGroupInfoCommand,
|
||||
GroupID: req.GroupInfoForSet.GroupID,
|
||||
Notification: req.GroupInfoForSet.Notification,
|
||||
Introduction: req.GroupInfoForSet.Introduction,
|
||||
FaceURL: req.GroupInfoForSet.FaceURL,
|
||||
GroupName: req.GroupInfoForSet.GroupName,
|
||||
}
|
||||
|
||||
if req.GroupInfoForSet.Ex != nil {
|
||||
callbackReq.Ex = req.GroupInfoForSet.Ex.Value
|
||||
}
|
||||
log.ZDebug(ctx, "debug CallbackBeforeSetGroupInfo", callbackReq.Ex)
|
||||
if req.GroupInfoForSet.NeedVerification != nil {
|
||||
callbackReq.NeedVerification = req.GroupInfoForSet.NeedVerification.Value
|
||||
}
|
||||
if req.GroupInfoForSet.LookMemberInfo != nil {
|
||||
callbackReq.LookMemberInfo = req.GroupInfoForSet.LookMemberInfo.Value
|
||||
}
|
||||
if req.GroupInfoForSet.ApplyMemberFriend != nil {
|
||||
callbackReq.ApplyMemberFriend = req.GroupInfoForSet.ApplyMemberFriend.Value
|
||||
}
|
||||
resp := &callbackstruct.CallbackBeforeSetGroupInfoResp{}
|
||||
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackBeforeSetGroupInfo); err != nil {
|
||||
if err == errs.ErrCallbackContinue {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
if resp.Ex != nil {
|
||||
req.GroupInfoForSet.Ex = wrapperspb.String(*resp.Ex)
|
||||
}
|
||||
if resp.NeedVerification != nil {
|
||||
req.GroupInfoForSet.NeedVerification = wrapperspb.Int32(*resp.NeedVerification)
|
||||
}
|
||||
if resp.LookMemberInfo != nil {
|
||||
req.GroupInfoForSet.LookMemberInfo = wrapperspb.Int32(*resp.LookMemberInfo)
|
||||
}
|
||||
if resp.ApplyMemberFriend != nil {
|
||||
req.GroupInfoForSet.ApplyMemberFriend = wrapperspb.Int32(*resp.ApplyMemberFriend)
|
||||
}
|
||||
utils.StructFieldNotNilReplace(req, resp)
|
||||
return nil
|
||||
}
|
||||
func CallbackAfterSetGroupInfo(ctx context.Context, req *group.SetGroupInfoReq) error {
|
||||
if !config.Config.Callback.CallbackAfterSetGroupInfo.Enable {
|
||||
return nil
|
||||
}
|
||||
callbackReq := &callbackstruct.CallbackAfterSetGroupInfoReq{
|
||||
CallbackCommand: callbackstruct.CallbackAfterSetGroupInfoCommand,
|
||||
GroupID: req.GroupInfoForSet.GroupID,
|
||||
Notification: req.GroupInfoForSet.Notification,
|
||||
Introduction: req.GroupInfoForSet.Introduction,
|
||||
FaceURL: req.GroupInfoForSet.FaceURL,
|
||||
GroupName: req.GroupInfoForSet.GroupName,
|
||||
}
|
||||
if req.GroupInfoForSet.Ex != nil {
|
||||
callbackReq.Ex = &req.GroupInfoForSet.Ex.Value
|
||||
}
|
||||
if req.GroupInfoForSet.NeedVerification != nil {
|
||||
callbackReq.NeedVerification = &req.GroupInfoForSet.NeedVerification.Value
|
||||
}
|
||||
if req.GroupInfoForSet.LookMemberInfo != nil {
|
||||
callbackReq.LookMemberInfo = &req.GroupInfoForSet.LookMemberInfo.Value
|
||||
}
|
||||
if req.GroupInfoForSet.ApplyMemberFriend != nil {
|
||||
callbackReq.ApplyMemberFriend = &req.GroupInfoForSet.ApplyMemberFriend.Value
|
||||
}
|
||||
resp := &callbackstruct.CallbackAfterSetGroupInfoResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackAfterSetGroupInfo); err != nil {
|
||||
if err == errs.ErrCallbackContinue {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
utils.StructFieldNotNilReplace(req, resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -17,16 +17,14 @@ package msg
|
||||
import (
|
||||
"context"
|
||||
"github.com/OpenIMSDK/protocol/sdkws"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
"github.com/OpenIMSDK/protocol/constant"
|
||||
pbchat "github.com/OpenIMSDK/protocol/msg"
|
||||
"github.com/OpenIMSDK/tools/errs"
|
||||
"github.com/OpenIMSDK/tools/log"
|
||||
"github.com/OpenIMSDK/tools/mcontext"
|
||||
"github.com/OpenIMSDK/tools/utils"
|
||||
"google.golang.org/protobuf/proto"
|
||||
|
||||
cbapi "github.com/openimsdk/open-im-server/v3/pkg/callbackstruct"
|
||||
|
||||
"github.com/openimsdk/open-im-server/v3/pkg/common/config"
|
||||
@ -189,3 +187,23 @@ func CallbackSingleMsgRead(ctx context.Context, req *cbapi.CallbackSingleMsgRead
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func CallbackAfterRevokeMsg(ctx context.Context, req *pbchat.RevokeMsgReq) error {
|
||||
if !config.Config.Callback.CallbackAfterRevokeMsg.Enable {
|
||||
return nil
|
||||
}
|
||||
callbackReq := &cbapi.CallbackAfterRevokeMsgReq{
|
||||
CallbackCommand: cbapi.CallbackAfterRevokeMsgCommand,
|
||||
ConversationID: req.ConversationID,
|
||||
Seq: req.Seq,
|
||||
UserID: req.UserID,
|
||||
}
|
||||
resp := &cbapi.CallbackAfterSendGroupMsgResp{}
|
||||
if err := http.CallBackPostReturn(ctx, config.Config.Callback.CallbackUrl, callbackReq, resp, config.Config.Callback.CallbackAfterSetGroupInfo); err != nil {
|
||||
if err == errs.ErrCallbackContinue {
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
}
|
||||
utils.StructFieldNotNilReplace(req, resp)
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -35,17 +35,6 @@ type CallBackAddFriendReplyBeforeResp struct {
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackAfterAddFriendReq struct {
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
FromUserID string `json:"fromUserID" `
|
||||
ToUserID string `json:"toUserID"`
|
||||
ReqMsg string `json:"reqMsg"`
|
||||
}
|
||||
|
||||
type CallbackAfterAddFriendResp struct {
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackBeforeSetFriendRemarkReq struct {
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
OwnerUserID string `json:"ownerUserID"`
|
||||
|
||||
@ -132,33 +132,6 @@ type CallbackAfterUngroupReq struct {
|
||||
type CallbackAfterUngroupResp struct {
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackAfterSetGroupInfoReq struct {
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
GroupID string `json:"groupID"`
|
||||
GroupType *int32 `json:"groupType"`
|
||||
UserID string `json:"userID"`
|
||||
Name string `json:"name"`
|
||||
Notification string `json:"notification"`
|
||||
GroupUrl string `json:"groupUrl"`
|
||||
}
|
||||
|
||||
type CallbackAfterSetGroupInfoResp struct {
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackAfterRevokeMsgReq struct {
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
GroupID string `json:"groupID"`
|
||||
GroupType *int32 `json:"groupType"`
|
||||
UserID string `json:"userID"`
|
||||
Content string `json:"content"`
|
||||
}
|
||||
|
||||
type CallbackAfterRevokeMsgResp struct {
|
||||
CommonCallbackResp
|
||||
}
|
||||
|
||||
type CallbackQuitGroupReq struct {
|
||||
CallbackCommand `json:"callbackCommand"`
|
||||
GroupID string `json:"groupID"`
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user