diff --git a/pom.xml b/pom.xml
index 61dfeee..202ed98 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,7 +44,7 @@
UTF-8
UTF-8
- 0.0.39
+ 0.0.40
2.2
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/config/TelegramBotConfig.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/config/TelegramBotConfig.java
index f54b5f7..2931996 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/config/TelegramBotConfig.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/config/TelegramBotConfig.java
@@ -19,11 +19,10 @@ import dev.struchkov.godfather.telegram.domain.config.TelegramConnectConfig;
import dev.struchkov.godfather.telegram.main.context.TelegramConnect;
import dev.struchkov.godfather.telegram.simple.consumer.EventDistributorService;
import dev.struchkov.godfather.telegram.simple.context.service.EventDistributor;
-import dev.struchkov.godfather.telegram.simple.context.service.SenderStorageService;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
import dev.struchkov.godfather.telegram.simple.core.MailAutoresponderTelegram;
import dev.struchkov.godfather.telegram.simple.core.TelegramConnectBot;
-import dev.struchkov.godfather.telegram.simple.core.service.SenderMapStorageService;
+import dev.struchkov.godfather.telegram.simple.core.service.SenderMapRepository;
import dev.struchkov.godfather.telegram.simple.sender.TelegramSender;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
@@ -78,20 +77,14 @@ public class TelegramBotConfig {
return autoresponder;
}
- @Bean
- public SenderStorageService senderStorageService() {
- return new SenderMapStorageService();
- }
-
@Bean
public TelegramSending sending(
TelegramConnect telegramConnect,
- SenderStorageService senderStorageService,
ReplaceUrlLocalhost replaceUrlLocalhost
) {
final TelegramSender telegramSender = new TelegramSender(telegramConnect);
- telegramSender.setSendPreProcessing(replaceUrlLocalhost);
- telegramSender.setSenderRepository(senderStorageService);
+ telegramSender.addPreSendProcess(replaceUrlLocalhost);
+ telegramSender.setSenderRepository(new SenderMapRepository());
return telegramSender;
}
diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/ReplaceUrlLocalhost.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/ReplaceUrlLocalhost.java
index be4b2d6..4d184b3 100644
--- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/ReplaceUrlLocalhost.java
+++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/service/ReplaceUrlLocalhost.java
@@ -1,10 +1,13 @@
package dev.struchkov.bot.gitlab.telegram.service;
import dev.struchkov.bot.gitlab.core.config.properties.GitlabProperty;
-import dev.struchkov.godfather.telegram.simple.sender.SendPreProcessing;
+import dev.struchkov.godfather.main.domain.BoxAnswer;
+import dev.struchkov.godfather.simple.context.service.PreSendProcessing;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
+import static dev.struchkov.haiti.utils.Checker.checkNotNull;
+
/**
* Заменяет урл, который назначает гитлаб на любой другой перед отправкой сообщения. Потому что иногда у self-host гитлабов урлы, которые не преобразуются телеграммом в ссылки. В этом случае имеет смысл менять их на ip.
*
@@ -12,16 +15,16 @@ import org.springframework.stereotype.Component;
*/
@Component
@RequiredArgsConstructor
-public class ReplaceUrlLocalhost implements SendPreProcessing {
+public class ReplaceUrlLocalhost implements PreSendProcessing {
private final GitlabProperty property;
@Override
- public String pretreatment(String s) {
- if (property.getReplaceUrl() != null && !"${GITLAB_REPLACE_URL}".equals(property.getReplaceUrl())) {
- return s.replace(property.getReplaceUrl(), property.getBaseUrl());
+ public BoxAnswer pretreatment(BoxAnswer boxAnswer) {
+ if (checkNotNull(property.getReplaceUrl()) && !"${GITLAB_REPLACE_URL}".equals(property.getReplaceUrl())) {
+ boxAnswer.setMessage(boxAnswer.getMessage().replace(property.getReplaceUrl(), property.getBaseUrl()));
}
- return s;
+ return boxAnswer;
}
}