去除webhook中url参数拼接的botname,改成拼接installer_id
This commit is contained in:
parent
1060e348a2
commit
e782d477c5
|
|
@ -26,6 +26,7 @@ import org.springframework.transaction.TransactionDefinition;
|
|||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -235,12 +236,12 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
}
|
||||
//当Webhook发生变化,对所有安装此Bot的仓库进行更新webhook
|
||||
//更新Webhook
|
||||
Webhook webhook = getWebhook(insetBotLimitEvents);
|
||||
List<InstallBot> installBotList = installMapper.selectList(Wrappers.<InstallBot>lambdaQuery()
|
||||
.eq(InstallBot::getBotId,botInputVO.getBotId()));
|
||||
try {
|
||||
if (!Objects.isNull(installBotList)) {
|
||||
for (InstallBot installBot : installBotList) {
|
||||
Webhook webhook = getWebhook(insetBotLimitEvents, installBot.getInstallerId());
|
||||
Object[] objects = new Object[]{installBot.getRepoOwner(), installBot.getStoreRepo()};
|
||||
Response response = api.updateWebhook(installBot.getInstallerId(), objects,installBot.getWebhookId(), webhook);
|
||||
|
||||
|
|
@ -679,13 +680,14 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
List<BotLimitEvent> botLimitEvents = botLimitMapper.selectList(Wrappers.<BotLimitEvent>lambdaQuery()
|
||||
.eq(BotLimitEvent::getBotId, installMarketBotRequest.getBotId()));
|
||||
assert botLimitEvents != null && botLimitEvents.size() > 0;
|
||||
Webhook webhook = getWebhook(botLimitEvents);
|
||||
|
||||
//批量插入installBot表,添加webhook
|
||||
for (InstallBot installBot : installBotList) {
|
||||
//插入表
|
||||
installMapper.insert(installBot);
|
||||
|
||||
Webhook webhook = getWebhook(botLimitEvents, installBot.getInstallerId());
|
||||
|
||||
//先获取webhookId构造webhook
|
||||
Object[] objects = new Object[]{installBot.getRepoOwner(), installBot.getStoreRepo()};
|
||||
Response response = api.addWebhook(installMarketBotRequest.getUserId(), objects, webhook);
|
||||
|
|
@ -745,7 +747,7 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
}
|
||||
}
|
||||
|
||||
private Webhook getWebhook(List<BotLimitEvent> limitEvents){
|
||||
private Webhook getWebhook(List<BotLimitEvent> limitEvents, Integer installerId){
|
||||
|
||||
assert !Objects.isNull(limitEvents);
|
||||
Webhook webhook = new Webhook();
|
||||
|
|
@ -767,7 +769,8 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
webhook.setEvents(objects);
|
||||
webhook.setActive(true);
|
||||
webhook.setContent_type("json");
|
||||
webhook.setUrl(bot.getWebhook() + "?botname=" + bot.getBotName());
|
||||
String webhookUri = UriComponentsBuilder.fromUriString(bot.getWebhook()).queryParam("installer_id", installerId).build().toString();
|
||||
webhook.setUrl(webhookUri);
|
||||
webhook.setHttp_method("POST");
|
||||
webhook.setBranch_filter("*");
|
||||
return webhook;
|
||||
|
|
@ -834,11 +837,13 @@ public class UserService extends AbstractUserBot implements IUserService {
|
|||
List<BotLimitEvent> botLimitEvents = botLimitMapper.selectList(Wrappers.<BotLimitEvent>lambdaQuery()
|
||||
.eq(BotLimitEvent::getBotId,updateInstallBotRequest.getBotId()));
|
||||
|
||||
Webhook webhook = getWebhook(botLimitEvents);
|
||||
|
||||
for (Integer store : storeList){
|
||||
InstallBot installBot = getInstallBot(updateInstallBotRequest,store);
|
||||
installMapper.insert(installBot);
|
||||
|
||||
Webhook webhook = getWebhook(botLimitEvents, installBot.getInstallerId());
|
||||
|
||||
Object[] objects = new Object[]{installBot.getRepoOwner(),installBot.getStoreRepo()};
|
||||
try {
|
||||
Response response = api.addWebhook(updateInstallBotRequest.getUserId(),objects,webhook);
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class GitLinkApiTest {
|
|||
|
||||
@Test
|
||||
public void activeBotAuthTest(){
|
||||
Response response = api.activeBotAuth(84993,800,"auth_active");
|
||||
Response response = api.activeBotAuth(84993,802,"auth_active");
|
||||
System.out.println(response.getData());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue