mirror of
https://github.com/openimsdk/open-im-server.git
synced 2026-09-04 14:48:15 +08:00
fix(core): trigger after-join webhooks for invited members (#3797)
This commit is contained in:
parent
a097864afb
commit
715c18ef5f
@ -287,6 +287,19 @@ func (s *groupServer) webhookAfterJoinGroup(ctx context.Context, after *config.A
|
|||||||
s.webhookClient.AsyncPost(ctx, cbReq.GetCallbackCommand(), cbReq, &callbackstruct.CallbackAfterJoinGroupResp{}, after)
|
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 {
|
func (s *groupServer) webhookBeforeSetGroupInfo(ctx context.Context, before *config.BeforeConfig, req *group.SetGroupInfoReq) error {
|
||||||
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
return webhook.WithCondition(ctx, before, func(ctx context.Context) error {
|
||||||
cbReq := &callbackstruct.CallbackBeforeSetGroupInfoReq{
|
cbReq := &callbackstruct.CallbackBeforeSetGroupInfoReq{
|
||||||
|
|||||||
@ -478,6 +478,9 @@ func (s *groupServer) InviteUserToGroup(ctx context.Context, req *pbgroup.Invite
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, joinReq := range afterJoinGroupRequests(groupMembers, req.Reason) {
|
||||||
|
s.webhookAfterJoinGroup(ctx, &s.config.WebhooksConfig.AfterJoinGroup, joinReq)
|
||||||
|
}
|
||||||
return &pbgroup.InviteUserToGroupResp{}, nil
|
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 {
|
if err := s.setMemberJoinSeq(ctx, req.GroupID, []string{req.FromUserID}); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
for _, joinReq := range afterJoinGroupRequests([]*model.GroupMember{member}, groupRequest.ReqMsg) {
|
||||||
|
s.webhookAfterJoinGroup(ctx, &s.config.WebhooksConfig.AfterJoinGroup, joinReq)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case constant.GroupResponseRefuse:
|
case constant.GroupResponseRefuse:
|
||||||
s.notification.GroupApplicationRejectedNotification(ctx, req)
|
s.notification.GroupApplicationRejectedNotification(ctx, req)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user