Skip to content

Commit

Permalink
Merge branch 'main' of github.com:openimsdk/open-im-server into fix/s…
Browse files Browse the repository at this point in the history
…tatus-interf
  • Loading branch information
mo3et committed Sep 29, 2024
2 parents 5333129 + 0892c1c commit 630ae48
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/webhooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,9 @@ beforeAddFriendAgree:
enable: false
timeout: 5
failedContinue: true
afterAddFriendAgree:
enable: false
timeout: 5
afterDeleteFriend:
enable: false
timeout: 5
Expand Down
12 changes: 12 additions & 0 deletions internal/rpc/relation/callback.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,18 @@ func (s *friendServer) webhookBeforeAddFriendAgree(ctx context.Context, before *
})
}

func (s *friendServer) webhookAfterAddFriendAgree(ctx context.Context, after *config.AfterConfig, req *relation.RespondFriendApplyReq) {
cbReq := &cbapi.CallbackAfterAddFriendAgreeReq{
CallbackCommand: cbapi.CallbackAfterAddFriendAgreeCommand,
FromUserID: req.FromUserID,
ToUserID: req.ToUserID,
HandleMsg: req.HandleMsg,
HandleResult: req.HandleResult,
}
resp := &cbapi.CallbackAfterAddFriendAgreeResp{}
s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, resp, after)
}

func (s *friendServer) webhookBeforeImportFriends(ctx context.Context, before *config.BeforeConfig, req *relation.ImportFriendReq) error {
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
cbReq := &cbapi.CallbackBeforeImportFriendsReq{
Expand Down
1 change: 1 addition & 0 deletions internal/rpc/relation/friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ func (s *friendServer) RespondFriendApply(ctx context.Context, req *relation.Res
if err != nil {
return nil, err
}
s.webhookAfterAddFriendAgree(ctx, &s.config.WebhooksConfig.AfterAddFriendAgree, req)
s.notificationSender.FriendApplicationAgreedNotification(ctx, req)
return resp, nil
}
Expand Down
1 change: 1 addition & 0 deletions pkg/callbackstruct/constant.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
CallbackBeforeAddBlackCommand = "callbackBeforeAddBlackCommand"
CallbackAfterAddFriendCommand = "callbackAfterAddFriendCommand"
CallbackBeforeAddFriendAgreeCommand = "callbackBeforeAddFriendAgreeCommand"
CallbackAfterAddFriendAgreeCommand = "callbackAfterAddFriendAgreeCommand"
CallbackAfterDeleteFriendCommand = "callbackAfterDeleteFriendCommand"
CallbackBeforeImportFriendsCommand = "callbackBeforeImportFriendsCommand"
CallbackAfterImportFriendsCommand = "callbackAfterImportFriendsCommand"
Expand Down
12 changes: 12 additions & 0 deletions pkg/callbackstruct/friend.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ type CallbackBeforeAddFriendAgreeResp struct {
CommonCallbackResp
}

type CallbackAfterAddFriendAgreeReq struct {
CallbackCommand `json:"callbackCommand"`
FromUserID string `json:"fromUserID" `
ToUserID string `json:"blackUserID"`
HandleResult int32 `json:"HandleResult"`
HandleMsg string `json:"HandleMsg"`
}

type CallbackAfterAddFriendAgreeResp struct {
CommonCallbackResp
}

type CallbackAfterDeleteFriendReq struct {
CallbackCommand `json:"callbackCommand"`
OwnerUserID string `json:"ownerUserID" `
Expand Down
1 change: 1 addition & 0 deletions pkg/common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@ type Webhooks struct {
BeforeAddBlack BeforeConfig `mapstructure:"beforeAddBlack"`
AfterAddFriend AfterConfig `mapstructure:"afterAddFriend"`
BeforeAddFriendAgree BeforeConfig `mapstructure:"beforeAddFriendAgree"`
AfterAddFriendAgree AfterConfig `mapstructure:"afterAddFriendAgree"`
AfterDeleteFriend AfterConfig `mapstructure:"afterDeleteFriend"`
BeforeImportFriends BeforeConfig `mapstructure:"beforeImportFriends"`
AfterImportFriends AfterConfig `mapstructure:"afterImportFriends"`
Expand Down

0 comments on commit 630ae48

Please sign in to comment.