mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-09-04 22:53:17 +08:00
fix(core): trigger after-join webhooks for invited members
This commit is contained in:
parent
a097864afb
commit
3683d9b039
@ -287,6 +287,19 @@ func (s *groupServer) webhookAfterJoinGroup(ctx context.Context, after *config.A
|
||||
s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, &callbackstruct.CallbackAfterJoinGroupResp{}, after)
|
||||
}
|
||||
|
||||
func afterJoinGroupRequests(members []*model.GroupMember, reqMessage string) []*group.JoinGroupReq {
|
||||
requests := make([]*group.JoinGroupReq, 0, len(members))
|
||||
for _, member := range members {
|
||||
requests = append(requests, &group.JoinGroupReq{
|
||||
GroupID: member.GroupID,
|
||||
ReqMessage: reqMessage,
|
||||
JoinSource: member.JoinSource,
|
||||
InviterUserID: member.UserID,
|
||||
})
|
||||
}
|
||||
return requests
|
||||
}
|
||||
|
||||
func (s *groupServer) webhookBeforeSetGroupInfo(ctx context.Context, before *config.BeforeConfig, req *group.SetGroupInfoReq) error {
|
||||
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
||||
cbReq := &callbackstruct.CallbackBeforeSetGroupInfoReq{
|
||||
|
||||
@ -478,6 +478,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
for _, joinReq := range afterJoinGroupRequests(groupMembers, req.Reason) {
|
||||
s.webhookAfterJoinGroup(ctx, &s.config.WebhooksConfig.AfterJoinGroup, joinReq)
|
||||
}
|
||||
return &pbgroup.InviteUserToGroupResp{}, nil
|
||||
}
|
||||
|
||||
@ -898,6 +901,9 @@ func (s *groupServer) GroupApplicationResponse(ctx context.Context, req *pbgroup
|
||||
if err := s.setMemberJoinSeq(ctx, req.GroupID, []string{req.FromUserID}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, joinReq := range afterJoinGroupRequests([]*model.GroupMember{member}, groupRequest.ReqMsg) {
|
||||
s.webhookAfterJoinGroup(ctx, &s.config.WebhooksConfig.AfterJoinGroup, joinReq)
|
||||
}
|
||||
}
|
||||
case constant.GroupResponseRefuse:
|
||||
s.notification.GroupApplicationRejectedNotification(ctx, req)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user