fix(core): trigger after-join webhooks for invited members

This commit is contained in:
dsx137 2026-08-31 11:24:58 +08:00
parent a097864afb
commit 3683d9b039
2 changed files with 19 additions and 0 deletions

View File

@ -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{

View File

@ -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)