update dependencies

This commit is contained in:
Struchkov Mark 2024-01-19 20:23:30 +03:00
parent 2c19256fbe
commit 4eb678ce53
No known key found for this signature in database
GPG Key ID: A3F0AC3F0FA52F3C
22 changed files with 183 additions and 117 deletions

15
pom.xml
View File

@ -43,21 +43,22 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<godfather.telegram.version>0.0.51</godfather.telegram.version> <godfather.telegram.version>1.0.0-SNAPSHOT</godfather.telegram.version>
<haiti.utils.version>2.7.2</haiti.utils.version> <!-- https://mvnrepository.com/artifact/dev.struchkov.haiti/haiti-utils -->
<haiti.utils.fields.version>0.0.11</haiti.utils.fields.version> <haiti.utils.version>3.0.2</haiti.utils.version>
<haiti.utils.fields.version>1.1.1</haiti.utils.fields.version>
<haiti.filter.version>0.0.5</haiti.filter.version> <haiti.filter.version>0.0.5</haiti.filter.version>
<!-- https://mvnrepository.com/artifact/jakarta.persistence/jakarta.persistence-api --> <!-- https://mvnrepository.com/artifact/jakarta.persistence/jakarta.persistence-api -->
<jakarta.persistance.version>3.1.0</jakarta.persistance.version> <jakarta.persistance.version>3.2.0-M1</jakarta.persistance.version>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava --> <!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<google.guava.version>31.1-jre</google.guava.version> <google.guava.version>33.0.0-jre</google.guava.version>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin --> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
<plugin.maven.compiler.ver>3.10.1</plugin.maven.compiler.ver> <plugin.maven.compiler.ver>3.12.1</plugin.maven.compiler.ver>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-release-plugin --> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-release-plugin -->
<plugin.maven.release.ver>3.0.0-M7</plugin.maven.release.ver> <plugin.maven.release.ver>3.0.1</plugin.maven.release.ver>
</properties> </properties>
<dependencyManagement> <dependencyManagement>

View File

@ -21,7 +21,7 @@ public class ErrorHandlerService implements ErrorHandler {
private final TelegramSending telegramSending; private final TelegramSending telegramSending;
@Override @Override
public void handle(Message message, Exception e) { public void handle(Message message, Throwable e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
final BoxAnswer boxAnswer = boxAnswer(e.getMessage()); final BoxAnswer boxAnswer = boxAnswer(e.getMessage());
boxAnswer.setRecipientIfNull(personProperty.getTelegramId()); boxAnswer.setRecipientIfNull(personProperty.getTelegramId());

View File

@ -44,7 +44,7 @@ public class MessageSendTelegramService implements MessageSendService {
.map(generator -> { .map(generator -> {
final BoxAnswer answer = generator.generate(notify); final BoxAnswer answer = generator.generate(notify);
answer.setRecipientIfNull(personInformation.getTelegramId()); answer.setRecipientIfNull(personInformation.getTelegramId());
answer.setPayload(BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW, true); answer.addPayload(BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW, true);
return answer; return answer;
}) })
.ifPresent(sending::send); .ifPresent(sending::send);

View File

@ -22,8 +22,8 @@ import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW; import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW;
import static dev.struchkov.haiti.utils.Checker.checkNotBlank; import static dev.struchkov.haiti.utils.Checker.checkNotBlank;

View File

@ -9,10 +9,10 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_CONFIRMAT
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID;
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown; import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
@ -33,7 +33,7 @@ public class ConflictPrNotifyGenerator implements NotifyBoxAnswerGenerator<Confl
return boxAnswer( return boxAnswer(
notifyMessage, notifyMessage,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton(Icons.VIEW, DELETE_MESSAGE), simpleButton(Icons.VIEW, DELETE_MESSAGE),
urlButton(Icons.LINK, notify.getUrl()), urlButton(Icons.LINK, notify.getUrl()),
simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]") simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]")

View File

@ -9,10 +9,10 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_CONFIRMAT
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID;
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown; import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
@ -33,7 +33,7 @@ public class ConflictResolvePrNotifyGenerator implements NotifyBoxAnswerGenerato
return boxAnswer( return boxAnswer(
notifyMessage, notifyMessage,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton(Icons.VIEW, DELETE_MESSAGE), simpleButton(Icons.VIEW, DELETE_MESSAGE),
urlButton(Icons.LINK, notify.getUrl()), urlButton(Icons.LINK, notify.getUrl()),
simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]") simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]")

View File

@ -10,9 +10,9 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_CONFIRMAT
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID;
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Checker.checkNotBlank; import static dev.struchkov.haiti.utils.Checker.checkNotBlank;
import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Checker.checkNotNull;

View File

@ -12,10 +12,10 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_CONFIRMAT
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID;
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Checker.checkNotEmpty; import static dev.struchkov.haiti.utils.Checker.checkNotEmpty;
import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Checker.checkNotNull;
@ -62,7 +62,7 @@ public class NewMrForAssigneeNotifyGenerator implements NotifyBoxAnswerGenerator
return boxAnswer( return boxAnswer(
notifyMessage, notifyMessage,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton(Icons.VIEW, DELETE_MESSAGE), simpleButton(Icons.VIEW, DELETE_MESSAGE),
urlButton(Icons.LINK, notify.getUrl()), urlButton(Icons.LINK, notify.getUrl()),
simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]") simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]")

View File

@ -11,10 +11,10 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_CONFIRMAT
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID;
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Checker.checkNotNull;
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown; import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
@ -55,7 +55,7 @@ public class NewMrForReviewNotifyGenerator implements NotifyBoxAnswerGenerator<N
return boxAnswer( return boxAnswer(
notifyMessage, notifyMessage,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton(Icons.VIEW, DELETE_MESSAGE), simpleButton(Icons.VIEW, DELETE_MESSAGE),
urlButton(Icons.LINK, notify.getUrl()), urlButton(Icons.LINK, notify.getUrl()),
simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]") simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]")

View File

@ -11,10 +11,10 @@ import org.springframework.stereotype.Component;
import java.util.Optional; import java.util.Optional;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown; import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
@ -49,8 +49,8 @@ public class NewProjectNotifyGenerator implements NotifyBoxAnswerGenerator<NewPr
return boxAnswer( return boxAnswer(
notifyMessage, notifyMessage,
inlineKeyBoard( inlineKeyBoard(
simpleLine(urlButton(Icons.LINK, notify.getProjectUrl())), keyBoardLine(urlButton(Icons.LINK, notify.getProjectUrl())),
simpleLine( keyBoardLine(
simpleButton(Icons.NOTIFY, "[" + Const.BUTTON_ARG_ENABLE_NOTIFY_PROJECT_ID + ":" + notify.getProjectId() + "]"), simpleButton(Icons.NOTIFY, "[" + Const.BUTTON_ARG_ENABLE_NOTIFY_PROJECT_ID + ":" + notify.getProjectId() + "]"),
simpleButton(Icons.DISABLE_NOTIFY, DELETE_MESSAGE) simpleButton(Icons.DISABLE_NOTIFY, DELETE_MESSAGE)
) )

View File

@ -13,9 +13,9 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_CONFIRMAT
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID;
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Checker.checkNotBlank; import static dev.struchkov.haiti.utils.Checker.checkNotBlank;
import static dev.struchkov.haiti.utils.Checker.checkNotEmpty; import static dev.struchkov.haiti.utils.Checker.checkNotEmpty;

View File

@ -11,10 +11,10 @@ import org.springframework.stereotype.Service;
import java.util.Optional; import java.util.Optional;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
@Service @Service
@ -45,7 +45,7 @@ public class PipelineNotifyGenerator implements NotifyBoxAnswerGenerator<Pipelin
return boxAnswer( return boxAnswer(
builder.toString(), builder.toString(),
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton(Icons.VIEW, DELETE_MESSAGE), simpleButton(Icons.VIEW, DELETE_MESSAGE),
urlButton(Icons.LINK, notify.getWebUrl()) urlButton(Icons.LINK, notify.getWebUrl())
) )

View File

@ -6,10 +6,10 @@ import dev.struchkov.godfather.simple.domain.BoxAnswer;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown; import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
@ -31,7 +31,7 @@ public class StatusMrNotifyGenerator implements NotifyBoxAnswerGenerator<StatusM
return boxAnswer( return boxAnswer(
notifyMessage, notifyMessage,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton(Icons.VIEW, DELETE_MESSAGE), simpleButton(Icons.VIEW, DELETE_MESSAGE),
urlButton(Icons.LINK, notify.getUrl()) urlButton(Icons.LINK, notify.getUrl())
) )

View File

@ -6,9 +6,9 @@ import dev.struchkov.godfather.simple.domain.BoxAnswer;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Checker.checkNotBlank; import static dev.struchkov.haiti.utils.Checker.checkNotBlank;
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown; import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;

View File

@ -9,10 +9,10 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_CONFIRMAT
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_NOTIFY_MR_ID;
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_FALSE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton; import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Checker.checkNotBlank; import static dev.struchkov.haiti.utils.Checker.checkNotBlank;
import static dev.struchkov.haiti.utils.Checker.checkNotNull; import static dev.struchkov.haiti.utils.Checker.checkNotNull;
@ -55,7 +55,7 @@ public class UpdateMrNotifyGenerator implements NotifyBoxAnswerGenerator<UpdateM
return boxAnswer( return boxAnswer(
notifyMessage, notifyMessage,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton(Icons.VIEW, DELETE_MESSAGE), simpleButton(Icons.VIEW, DELETE_MESSAGE),
urlButton(Icons.LINK, notify.getUrl()), urlButton(Icons.LINK, notify.getUrl()),
simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]") simpleButton(Icons.DISABLE_NOTIFY, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + notify.getMrId() + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_FALSE + "]")

View File

@ -20,7 +20,7 @@ import dev.struchkov.godfather.telegram.domain.attachment.LinkAttachment;
import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard; import dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard;
import dev.struchkov.godfather.telegram.main.context.MailPayload; import dev.struchkov.godfather.telegram.main.context.MailPayload;
import dev.struchkov.godfather.telegram.main.core.util.Attachments; import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.starter.UnitConfiguration; import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import dev.struchkov.haiti.utils.Checker; import dev.struchkov.haiti.utils.Checker;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -37,13 +37,13 @@ import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.GET_ASSIGNEE_MERG
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.GET_TASKS; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.GET_TASKS;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.SETTINGS; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.SETTINGS;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_ADD_NEW_PROJECT; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_ADD_NEW_PROJECT;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.simple.core.util.TriggerChecks.clickButtonRaw; import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.simple.core.util.TriggerChecks.isLinks; import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.main.core.util.UnitTrigger.clickButtonRaw;
import static dev.struchkov.godfather.telegram.main.core.util.UnitTrigger.isLinks;
import static java.util.Collections.singleton; import static java.util.Collections.singleton;
/** /**
@ -53,7 +53,7 @@ import static java.util.Collections.singleton;
*/ */
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class MenuConfig implements UnitConfiguration { public class MenuConfig implements PersonUnitConfiguration {
private final GitlabProperty gitlabProperty; private final GitlabProperty gitlabProperty;
private final PersonInformation personInformation; private final PersonInformation personInformation;
@ -69,7 +69,7 @@ public class MenuConfig implements UnitConfiguration {
@Unit(value = ACCESS_ERROR, main = true) @Unit(value = ACCESS_ERROR, main = true)
public AnswerText<Mail> accessError() { public AnswerText<Mail> accessError() {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(mail -> !personInformation.getTelegramId().equals(mail.getPersonId())) .triggerCheck(mail -> !personInformation.getTelegramId().equals(mail.getFromPersonId()))
.answer(message -> { .answer(message -> {
final String messageText = new StringBuilder("\uD83D\uDEA8 *Attempted unauthorized access to the bot*") final String messageText = new StringBuilder("\uD83D\uDEA8 *Attempted unauthorized access to the bot*")
.append(Icons.HR) .append(Icons.HR)
@ -98,7 +98,7 @@ public class MenuConfig implements UnitConfiguration {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.priority(5) .priority(5)
.triggerCheck(mail -> { .triggerCheck(mail -> {
final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId()); final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
if (isAccess) { if (isAccess) {
final boolean firstStart = settingService.isFirstStart(); final boolean firstStart = settingService.isFirstStart();
return !firstStart; return !firstStart;
@ -112,7 +112,7 @@ public class MenuConfig implements UnitConfiguration {
At the moment, you can only add new repositories. But in future versions, the possibilities will expand. At the moment, you can only add new repositories. But in future versions, the possibilities will expand.
"""; """;
final InlineKeyBoard generalMenuKeyBoard = inlineKeyBoard( final InlineKeyBoard generalMenuKeyBoard = inlineKeyBoard(
simpleLine(simpleButton("Add repository", TEXT_ADD_NEW_PROJECT)) keyBoardLine(simpleButton("Add repository", TEXT_ADD_NEW_PROJECT))
// simpleLine( // simpleLine(
// simpleButton("My tasks", GET_TASKS), // simpleButton("My tasks", GET_TASKS),
// simpleButton("Merge Request", GET_ASSIGNEE_MERGE_REQUEST) // simpleButton("Merge Request", GET_ASSIGNEE_MERGE_REQUEST)
@ -135,7 +135,7 @@ public class MenuConfig implements UnitConfiguration {
) { ) {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(clickButtonRaw(TEXT_ADD_NEW_PROJECT)) .triggerCheck(clickButtonRaw(TEXT_ADD_NEW_PROJECT))
.answer(replaceBoxAnswer("Send me links to repositories you want to track")) .answer(() -> replaceBoxAnswer("Send me links to repositories you want to track"))
.next(addNewProject) .next(addNewProject)
.build(); .build();
} }
@ -165,7 +165,7 @@ public class MenuConfig implements UnitConfiguration {
public AnswerText<Mail> settings() { public AnswerText<Mail> settings() {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerPhrase(SETTINGS) .triggerPhrase(SETTINGS)
.answer(boxAnswer("This is the settings menu")) .answer(() -> boxAnswer("This is the settings menu"))
.build(); .build();
} }

View File

@ -10,7 +10,7 @@ import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.simple.domain.unit.AnswerText; import dev.struchkov.godfather.simple.domain.unit.AnswerText;
import dev.struchkov.godfather.telegram.domain.attachment.LinkAttachment; import dev.struchkov.godfather.telegram.domain.attachment.LinkAttachment;
import dev.struchkov.godfather.telegram.main.core.util.Attachments; import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.starter.UnitConfiguration; import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import dev.struchkov.haiti.utils.Checker; import dev.struchkov.haiti.utils.Checker;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -25,7 +25,7 @@ import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class AnswerNoteUnit implements UnitConfiguration { public class AnswerNoteUnit implements PersonUnitConfiguration {
private static final Pattern NOTE_LINK = Pattern.compile("#note_\\d+$"); private static final Pattern NOTE_LINK = Pattern.compile("#note_\\d+$");
@ -46,7 +46,7 @@ public class AnswerNoteUnit implements UnitConfiguration {
final boolean isLink = Attachments.findFirstLink(forwardMail.getAttachments()) final boolean isLink = Attachments.findFirstLink(forwardMail.getAttachments())
.isPresent(); .isPresent();
if (isLink) { if (isLink) {
final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId()); final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
final boolean firstStart = settingService.isFirstStart(); final boolean firstStart = settingService.isFirstStart();
return isAccess && !firstStart; return isAccess && !firstStart;
} }

View File

@ -8,7 +8,7 @@ import dev.struchkov.godfather.simple.domain.unit.AnswerText;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment; import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
import dev.struchkov.godfather.telegram.main.core.util.Attachments; import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
import dev.struchkov.godfather.telegram.starter.UnitConfiguration; import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -18,7 +18,7 @@ import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class DeleteMessageUnit implements UnitConfiguration { public class DeleteMessageUnit implements PersonUnitConfiguration {
private final TelegramSending telegramSending; private final TelegramSending telegramSending;
private final PersonInformation personInformation; private final PersonInformation personInformation;
@ -28,7 +28,7 @@ public class DeleteMessageUnit implements UnitConfiguration {
public AnswerText<Mail> deleteMessage() { public AnswerText<Mail> deleteMessage() {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(mail -> { .triggerCheck(mail -> {
final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId()); final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
if (isAccess) { if (isAccess) {
final boolean isFirstStart = settingService.isFirstStart(); final boolean isFirstStart = settingService.isFirstStart();
if (!isFirstStart) { if (!isFirstStart) {
@ -44,7 +44,7 @@ public class DeleteMessageUnit implements UnitConfiguration {
}) })
.answer(mail -> { .answer(mail -> {
final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow(); final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
telegramSending.deleteMessage(mail.getPersonId(), clickButton.getMessageId()); telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().getId());
}) })
.build(); .build();
} }

View File

@ -7,11 +7,11 @@ import dev.struchkov.bot.gitlab.context.utils.Icons;
import dev.struchkov.godfather.main.domain.annotation.Unit; import dev.struchkov.godfather.main.domain.annotation.Unit;
import dev.struchkov.godfather.main.domain.content.Mail; import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.simple.domain.unit.AnswerText; import dev.struchkov.godfather.simple.domain.unit.AnswerText;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonArg;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment; import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment.Arg;
import dev.struchkov.godfather.telegram.main.core.util.Attachments; import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
import dev.struchkov.godfather.telegram.starter.UnitConfiguration; import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -23,14 +23,14 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_N
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_TRUE; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_TRUE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DISABLE_NOTIFY_MR; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DISABLE_NOTIFY_MR;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class DisableNotifyMrUnit implements UnitConfiguration { public class DisableNotifyMrUnit implements PersonUnitConfiguration {
public static final String WARNING_ABOUT_DISABLE_NOTIFY = Icons.DISABLE_NOTIFY + """ public static final String WARNING_ABOUT_DISABLE_NOTIFY = Icons.DISABLE_NOTIFY + """
*Disabling notifications* *Disabling notifications*
@ -58,7 +58,7 @@ public class DisableNotifyMrUnit implements UnitConfiguration {
.flatMap(buttonClick -> buttonClick.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_MR_ID)) .flatMap(buttonClick -> buttonClick.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_MR_ID))
.isPresent(); .isPresent();
if (isDisableButtonClick) { if (isDisableButtonClick) {
final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId()); final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
final boolean isFirstStart = settingService.isFirstStart(); final boolean isFirstStart = settingService.isFirstStart();
return isAccess && !isFirstStart; return isAccess && !isFirstStart;
} }
@ -67,23 +67,23 @@ public class DisableNotifyMrUnit implements UnitConfiguration {
.answer(mail -> { .answer(mail -> {
final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow(); final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
final boolean confirmation = clickButton.getArgByType(BUTTON_ARG_CONFIRMATION) final boolean confirmation = clickButton.getArgByType(BUTTON_ARG_CONFIRMATION)
.map(Arg::getValue) .map(ButtonArg::getValue)
.map(BUTTON_VALUE_TRUE::equals) .map(BUTTON_VALUE_TRUE::equals)
.orElseThrow(); .orElseThrow();
final Long mrId = clickButton.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_MR_ID) final Long mrId = clickButton.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_MR_ID)
.map(Arg::getValue) .map(ButtonArg::getValue)
.map(Long::parseLong) .map(Long::parseLong)
.orElseThrow(); .orElseThrow();
if (confirmation) { if (confirmation) {
mergeRequestsService.notification(false, mrId); mergeRequestsService.notification(false, mrId);
scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getPersonId(), clickButton.getMessageId()), 5, TimeUnit.SECONDS); scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().getId()), 5, TimeUnit.SECONDS);
return replaceBoxAnswer(SUCCESSFULLY_DISABLED); return replaceBoxAnswer(SUCCESSFULLY_DISABLED);
} else { } else {
return replaceBoxAnswer( return replaceBoxAnswer(
WARNING_ABOUT_DISABLE_NOTIFY, WARNING_ABOUT_DISABLE_NOTIFY,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton(Icons.YES, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + mrId + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_TRUE + "]"), simpleButton(Icons.YES, "[" + BUTTON_ARG_DISABLE_NOTIFY_MR_ID + ":" + mrId + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_TRUE + "]"),
simpleButton(Icons.NO, DELETE_MESSAGE) simpleButton(Icons.NO, DELETE_MESSAGE)
) )

View File

@ -7,11 +7,11 @@ import dev.struchkov.bot.gitlab.context.utils.Icons;
import dev.struchkov.godfather.main.domain.annotation.Unit; import dev.struchkov.godfather.main.domain.annotation.Unit;
import dev.struchkov.godfather.main.domain.content.Mail; import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.simple.domain.unit.AnswerText; import dev.struchkov.godfather.simple.domain.unit.AnswerText;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonArg;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment; import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment.Arg;
import dev.struchkov.godfather.telegram.main.core.util.Attachments; import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
import dev.struchkov.godfather.telegram.starter.UnitConfiguration; import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -23,14 +23,14 @@ import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_ARG_DISABLE_N
import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_TRUE; import static dev.struchkov.bot.gitlab.telegram.utils.Const.BUTTON_VALUE_TRUE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DELETE_MESSAGE;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DISABLE_NOTIFY_THREAD; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.DISABLE_NOTIFY_THREAD;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class DisableNotifyThreadUnit implements UnitConfiguration { public class DisableNotifyThreadUnit implements PersonUnitConfiguration {
public static final String WARNING_ABOUT_DISABLE_NOTIFY = Icons.DISABLE_NOTIFY + """ public static final String WARNING_ABOUT_DISABLE_NOTIFY = Icons.DISABLE_NOTIFY + """
*Disabling notifications* *Disabling notifications*
@ -54,7 +54,7 @@ public class DisableNotifyThreadUnit implements UnitConfiguration {
.flatMap(buttonClick -> buttonClick.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID)) .flatMap(buttonClick -> buttonClick.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID))
.isPresent(); .isPresent();
if (isDisableButtonClick) { if (isDisableButtonClick) {
final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId()); final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
final boolean isFirstStart = settingService.isFirstStart(); final boolean isFirstStart = settingService.isFirstStart();
return isAccess && !isFirstStart; return isAccess && !isFirstStart;
} }
@ -63,23 +63,23 @@ public class DisableNotifyThreadUnit implements UnitConfiguration {
.answer(mail -> { .answer(mail -> {
final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow(); final ButtonClickAttachment clickButton = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
final boolean confirmation = clickButton.getArgByType(BUTTON_ARG_CONFIRMATION) final boolean confirmation = clickButton.getArgByType(BUTTON_ARG_CONFIRMATION)
.map(Arg::getValue) .map(ButtonArg::getValue)
.map(BUTTON_VALUE_TRUE::equals) .map(BUTTON_VALUE_TRUE::equals)
.orElseThrow(); .orElseThrow();
final String discussionId = clickButton.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID) final String discussionId = clickButton.getArgByType(BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID)
.map(Arg::getValue) .map(ButtonArg::getValue)
.map(String::valueOf) .map(String::valueOf)
.orElseThrow(); .orElseThrow();
if (confirmation) { if (confirmation) {
discussionService.notification(false, discussionId); discussionService.notification(false, discussionId);
scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getPersonId(), clickButton.getMessageId()), 5, TimeUnit.SECONDS); scheduledExecutorService.schedule(() -> telegramSending.deleteMessage(mail.getFromPersonId(), clickButton.getMessage().getId()), 5, TimeUnit.SECONDS);
return replaceBoxAnswer(SUCCESSFULLY_DISABLED); return replaceBoxAnswer(SUCCESSFULLY_DISABLED);
} else { } else {
return replaceBoxAnswer( return replaceBoxAnswer(
WARNING_ABOUT_DISABLE_NOTIFY, WARNING_ABOUT_DISABLE_NOTIFY,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton(Icons.YES, "[" + BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID + ":" + discussionId + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_TRUE + "]"), simpleButton(Icons.YES, "[" + BUTTON_ARG_DISABLE_NOTIFY_THREAD_ID + ":" + discussionId + ";" + BUTTON_ARG_CONFIRMATION + ":" + BUTTON_VALUE_TRUE + "]"),
simpleButton(Icons.NO, DELETE_MESSAGE) simpleButton(Icons.NO, DELETE_MESSAGE)
) )

View File

@ -9,11 +9,11 @@ import dev.struchkov.bot.gitlab.telegram.utils.UnitName;
import dev.struchkov.godfather.main.domain.annotation.Unit; import dev.struchkov.godfather.main.domain.annotation.Unit;
import dev.struchkov.godfather.main.domain.content.Mail; import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.simple.domain.unit.AnswerText; import dev.struchkov.godfather.simple.domain.unit.AnswerText;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonArg;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment; import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment.Arg;
import dev.struchkov.godfather.telegram.main.core.util.Attachments; import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
import dev.struchkov.godfather.telegram.starter.UnitConfiguration; import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -27,7 +27,7 @@ import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class EnableProjectNotify implements UnitConfiguration { public class EnableProjectNotify implements PersonUnitConfiguration {
private final ProjectService projectService; private final ProjectService projectService;
private final MergeRequestsService mergeRequestsService; private final MergeRequestsService mergeRequestsService;
@ -42,7 +42,7 @@ public class EnableProjectNotify implements UnitConfiguration {
public AnswerText<Mail> enableNotifyProject() { public AnswerText<Mail> enableNotifyProject() {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(mail -> { .triggerCheck(mail -> {
final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId()); final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
if (isAccess) { if (isAccess) {
final boolean isFirstStart = settingService.isFirstStart(); final boolean isFirstStart = settingService.isFirstStart();
if (!isFirstStart) { if (!isFirstStart) {
@ -57,7 +57,7 @@ public class EnableProjectNotify implements UnitConfiguration {
}).answer( }).answer(
mail -> { mail -> {
final ButtonClickAttachment buttonClick = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow(); final ButtonClickAttachment buttonClick = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
final Arg arg = buttonClick.getArgByType(BUTTON_ARG_ENABLE_NOTIFY_PROJECT_ID).orElseThrow(); final ButtonArg arg = buttonClick.getArgByType(BUTTON_ARG_ENABLE_NOTIFY_PROJECT_ID).orElseThrow();
final long projectId = Long.parseLong(arg.getValue()); final long projectId = Long.parseLong(arg.getValue());
final Set<Long> setProjectId = Set.of(projectId); final Set<Long> setProjectId = Set.of(projectId);
projectService.processing(true, setProjectId); projectService.processing(true, setProjectId);

View File

@ -13,13 +13,14 @@ import dev.struchkov.bot.gitlab.core.service.parser.PipelineParser;
import dev.struchkov.bot.gitlab.core.service.parser.ProjectParser; import dev.struchkov.bot.gitlab.core.service.parser.ProjectParser;
import dev.struchkov.godfather.main.domain.annotation.Unit; import dev.struchkov.godfather.main.domain.annotation.Unit;
import dev.struchkov.godfather.main.domain.content.Mail; import dev.struchkov.godfather.main.domain.content.Mail;
import dev.struchkov.godfather.main.domain.content.Message;
import dev.struchkov.godfather.simple.domain.BoxAnswer; import dev.struchkov.godfather.simple.domain.BoxAnswer;
import dev.struchkov.godfather.simple.domain.unit.AnswerText; import dev.struchkov.godfather.simple.domain.unit.AnswerText;
import dev.struchkov.godfather.simple.domain.unit.MainUnit; import dev.struchkov.godfather.simple.domain.unit.MainUnit;
import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment; import dev.struchkov.godfather.telegram.domain.attachment.ButtonClickAttachment;
import dev.struchkov.godfather.telegram.main.core.util.Attachments; import dev.struchkov.godfather.telegram.main.core.util.Attachments;
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending; import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
import dev.struchkov.godfather.telegram.starter.UnitConfiguration; import dev.struchkov.godfather.telegram.starter.PersonUnitConfiguration;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -42,16 +43,16 @@ import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PARSER_OWNER
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PARSER_PRIVATE_PROJECT; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PARSER_PRIVATE_PROJECT;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PRIVACY_SETTING; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PRIVACY_SETTING;
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PRIVACY_SETTING_THREAD_LEVEL; import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PRIVACY_SETTING_THREAD_LEVEL;
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoardLine.simpleLine;
import static dev.struchkov.godfather.main.domain.unit.UnitActiveType.AFTER; import static dev.struchkov.godfather.main.domain.unit.UnitActiveType.AFTER;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer; import static dev.struchkov.godfather.simple.domain.BoxAnswer.replaceBoxAnswer;
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard; import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.SimpleKeyBoardLine.keyBoardLine;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.SimpleButton.simpleButton;
import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW; import static dev.struchkov.godfather.telegram.main.context.BoxAnswerPayload.DISABLE_WEB_PAGE_PREVIEW;
import static dev.struchkov.godfather.telegram.main.core.util.InlineKeyBoards.verticalMenuButton; import static dev.struchkov.godfather.telegram.main.core.util.InlineKeyBoards.verticalMenuButton;
import static dev.struchkov.godfather.telegram.simple.core.util.TriggerChecks.clickButtonRaw; import static dev.struchkov.godfather.telegram.main.core.util.UnitTrigger.clickButtonRaw;
import static dev.struchkov.godfather.telegram.simple.core.util.TriggerChecks.isClickButton; import static dev.struchkov.godfather.telegram.main.core.util.UnitTrigger.isButtonClick;
import static java.text.MessageFormat.format; import static java.text.MessageFormat.format;
/** /**
@ -61,7 +62,7 @@ import static java.text.MessageFormat.format;
*/ */
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
public class InitSettingFlow implements UnitConfiguration { public class InitSettingFlow implements PersonUnitConfiguration {
private final TelegramSending sending; private final TelegramSending sending;
@ -88,7 +89,7 @@ public class InitSettingFlow implements UnitConfiguration {
) { ) {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(mail -> { .triggerCheck(mail -> {
final boolean isAccess = personInformation.getTelegramId().equals(mail.getPersonId()); final boolean isAccess = personInformation.getTelegramId().equals(mail.getFromPersonId());
if (isAccess) { if (isAccess) {
return settingService.isFirstStart(); return settingService.isFirstStart();
} }
@ -96,7 +97,7 @@ public class InitSettingFlow implements UnitConfiguration {
}) })
.answer( .answer(
BoxAnswer.builder().message( () -> BoxAnswer.builder().message(
""" """
Hello 👋 Hello 👋
@ -119,8 +120,10 @@ public class InitSettingFlow implements UnitConfiguration {
.payload(DISABLE_WEB_PAGE_PREVIEW, true) .payload(DISABLE_WEB_PAGE_PREVIEW, true)
.keyBoard( .keyBoard(
inlineKeyBoard( inlineKeyBoard(
simpleButton("\uD83D\uDE80 Start setting", TEXT_PARSER_PRIVATE_PROJECT) keyBoardLine(
simpleButton("\uD83D\uDE80 Start setting", TEXT_PARSER_PRIVATE_PROJECT)
// simpleButton("see guide", GUIDE_START) // simpleButton("see guide", GUIDE_START)
)
) )
) )
.build() .build()
@ -145,7 +148,7 @@ public class InitSettingFlow implements UnitConfiguration {
We'll set privacy levels later, don't worry 😌 We'll set privacy levels later, don't worry 😌
""", """,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton("Yes", "YES"), simpleButton("Yes", "YES"),
simpleButton("No", "NO") simpleButton("No", "NO")
) )
@ -163,7 +166,7 @@ public class InitSettingFlow implements UnitConfiguration {
) { ) {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(clickButtonRaw("NO")) .triggerCheck(clickButtonRaw("NO"))
.answer(replaceBoxAnswer("\uD83D\uDC4C I won't scan public projects.")) .answer(() -> replaceBoxAnswer("\uD83D\uDC4C I won't scan public projects."))
.<Integer>callBack( .<Integer>callBack(
sentBox -> scheduledExecutorService.schedule(() -> sending.deleteMessage(sentBox.getPersonId(), sentBox.getMessageId()), 10, TimeUnit.SECONDS) sentBox -> scheduledExecutorService.schedule(() -> sending.deleteMessage(sentBox.getPersonId(), sentBox.getMessageId()), 10, TimeUnit.SECONDS)
) )
@ -210,11 +213,18 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(clickButtonRaw("YES")) .triggerCheck(clickButtonRaw("YES"))
.answer(mail -> { .answer(mail -> {
final String personId = mail.getPersonId(); final String personId = mail.getFromPersonId();
final String messageId = Attachments.findFirstButtonClick(mail.getAttachments()) final String messageId = Attachments.findFirstButtonClick(mail.getAttachments())
.map(ButtonClickAttachment::getMessageId) .map(ButtonClickAttachment::getMessage)
.map(Mail::getId)
.orElseThrow(); .orElseThrow();
sending.replaceMessage(personId, messageId, boxAnswer(step1)); sending.send(
BoxAnswer.replaceBuilder()
.replaceMessageId(messageId)
.recipientPersonId(personId)
.message(step1)
.build()
);
final int oldCountProjects = projectService.getAllIds().size(); final int oldCountProjects = projectService.getAllIds().size();
@ -225,18 +235,36 @@ public class InitSettingFlow implements UnitConfiguration {
projectService.processing(true, projectIds); projectService.processing(true, projectIds);
final int projectCount = projectIds.size() - oldCountProjects; final int projectCount = projectIds.size() - oldCountProjects;
sending.replaceMessage(personId, messageId, boxAnswer(format(step2, projectCount))); sending.send(
BoxAnswer.replaceBuilder()
.replaceMessageId(messageId)
.recipientPersonId(personId)
.message(format(step2, projectCount))
.build()
);
final int oldCountMr = mergeRequestsService.getAllIds().size(); final int oldCountMr = mergeRequestsService.getAllIds().size();
mergeRequestParser.parsingNewMergeRequest(); mergeRequestParser.parsingNewMergeRequest();
final int mrCount = mergeRequestsService.getAllIds().size() - oldCountMr; final int mrCount = mergeRequestsService.getAllIds().size() - oldCountMr;
sending.replaceMessage(personId, messageId, boxAnswer(format(step3, projectCount, mrCount))); sending.send(
BoxAnswer.replaceBuilder()
.replaceMessageId(messageId)
.recipientPersonId(personId)
.message(format(step3, projectCount, mrCount))
.build()
);
final int oldCountPipelines = pipelineService.getAllIds().size(); final int oldCountPipelines = pipelineService.getAllIds().size();
pipelineParser.scanNewPipeline(); pipelineParser.scanNewPipeline();
final int pipelineCount = pipelineService.getAllIds().size() - oldCountPipelines; final int pipelineCount = pipelineService.getAllIds().size() - oldCountPipelines;
sending.replaceMessage(personId, messageId, boxAnswer(format(step4, projectCount, mrCount, pipelineCount))); sending.send(
BoxAnswer.replaceBuilder()
.replaceMessageId(messageId)
.recipientPersonId(personId)
.message(format(step4, projectCount, mrCount, pipelineCount))
.build()
);
final int oldCountThreads = discussionService.getAllIds().size(); final int oldCountThreads = discussionService.getAllIds().size();
discussionParser.scanNewDiscussion(); discussionParser.scanNewDiscussion();
@ -258,7 +286,7 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.activeType(AFTER) .activeType(AFTER)
.answer( .answer(
boxAnswer( () -> boxAnswer(
""" """
I only send notifications for repositories that have been put on track. However, I can notify you when new repositories are available. This will allow you to track new repositories you are interested in quickly. I only send notifications for repositories that have been put on track. However, I can notify you when new repositories are available. This will allow you to track new repositories you are interested in quickly.
@ -269,7 +297,7 @@ public class InitSettingFlow implements UnitConfiguration {
Don't worry, I will not scan these repositories and notify you about them in the future. Don't worry, I will not scan these repositories and notify you about them in the future.
""", """,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton("Yes", "YES"), simpleButton("Yes", "YES"),
simpleButton("No", "NO") simpleButton("No", "NO")
) )
@ -285,11 +313,17 @@ public class InitSettingFlow implements UnitConfiguration {
@Unit(TEXT_PARSER_PRIVATE_PROJECT) MainUnit<Mail> textParserPrivateProject @Unit(TEXT_PARSER_PRIVATE_PROJECT) MainUnit<Mail> textParserPrivateProject
) { ) {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(isClickButton()) .triggerCheck(isButtonClick())
.answer(mail -> { .answer(mail -> {
final ButtonClickAttachment buttonClick = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow(); final ButtonClickAttachment buttonClick = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
if ("YES".equals(buttonClick.getRawCallBackData())) { if ("YES".equals(buttonClick.getRawCallBackData())) {
sending.replaceMessage(mail.getPersonId(), mail.getId(), boxAnswer("I write down the available projects.\nThis may take a long time ⌛")); sending.send(
BoxAnswer.replaceBuilder()
.recipientPersonId(mail.getFromPersonId())
.replaceMessageId(mail.getId())
.message("I write down the available projects.\nThis may take a long time ⌛")
.build()
);
projectParser.parseAllProjectOwner(); projectParser.parseAllProjectOwner();
settingService.ownerProjectScan(true); settingService.ownerProjectScan(true);
} else { } else {
@ -316,7 +350,7 @@ public class InitSettingFlow implements UnitConfiguration {
If there are a lot of repositories, this might not be a good idea. Only track repositories in which you actively participate. This will reduce the number of requests to the GitLab API. If there are a lot of repositories, this might not be a good idea. Only track repositories in which you actively participate. This will reduce the number of requests to the GitLab API.
""", """,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton("Yes", "YES"), simpleButton("Yes", "YES"),
simpleButton("No", "NO") simpleButton("No", "NO")
) )
@ -368,11 +402,18 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(clickButtonRaw("YES")) .triggerCheck(clickButtonRaw("YES"))
.answer(mail -> { .answer(mail -> {
final String personId = mail.getPersonId(); final String personId = mail.getFromPersonId();
final String messageId = Attachments.findFirstButtonClick(mail.getAttachments()) final String messageId = Attachments.findFirstButtonClick(mail.getAttachments())
.map(ButtonClickAttachment::getMessageId) .map(ButtonClickAttachment::getMessage)
.map(Message::getId)
.orElseThrow(); .orElseThrow();
sending.replaceMessage(personId, messageId, boxAnswer(step1)); sending.send(
BoxAnswer.replaceBuilder()
.recipientPersonId(personId)
.replaceMessageId(messageId)
.message(step1)
.build()
);
projectParser.parseAllPrivateProject(); projectParser.parseAllPrivateProject();
final Set<Long> projectIds = projectService.getAllIds(); final Set<Long> projectIds = projectService.getAllIds();
@ -381,15 +422,33 @@ public class InitSettingFlow implements UnitConfiguration {
projectService.processing(true, projectIds); projectService.processing(true, projectIds);
final int projectCount = projectIds.size(); final int projectCount = projectIds.size();
sending.replaceMessage(personId, messageId, boxAnswer(format(step2, projectCount))); sending.send(
BoxAnswer.replaceBuilder()
.recipientPersonId(personId)
.replaceMessageId(messageId)
.message(format(step2, projectCount))
.build()
);
mergeRequestParser.parsingNewMergeRequest(); mergeRequestParser.parsingNewMergeRequest();
final int mrCount = mergeRequestsService.getAllIds().size(); final int mrCount = mergeRequestsService.getAllIds().size();
sending.replaceMessage(personId, messageId, boxAnswer(format(step3, projectCount, mrCount))); sending.send(
BoxAnswer.replaceBuilder()
.recipientPersonId(personId)
.replaceMessageId(messageId)
.message(format(step3, projectCount, mrCount))
.build()
);
pipelineParser.scanNewPipeline(); pipelineParser.scanNewPipeline();
final int pipelineCount = pipelineService.getAllIds().size(); final int pipelineCount = pipelineService.getAllIds().size();
sending.replaceMessage(personId, messageId, boxAnswer(format(step4, projectCount, mrCount, pipelineCount))); sending.send(
BoxAnswer.replaceBuilder()
.recipientPersonId(personId)
.replaceMessageId(messageId)
.message(format(step4, projectCount, mrCount, pipelineCount))
.build()
);
discussionParser.scanNewDiscussion(); discussionParser.scanNewDiscussion();
final int discussionCount = discussionService.getAllIds().size(); final int discussionCount = discussionService.getAllIds().size();
@ -409,7 +468,7 @@ public class InitSettingFlow implements UnitConfiguration {
) { ) {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerPhrase("NO") .triggerPhrase("NO")
.answer(replaceBoxAnswer("\uD83D\uDC4C I won't scan private projects.")) .answer(() -> replaceBoxAnswer("\uD83D\uDC4C I won't scan private projects."))
.<Integer>callBack( .<Integer>callBack(
sentBox -> scheduledExecutorService.schedule(() -> sending.deleteMessage(sentBox.getPersonId(), sentBox.getMessageId()), 10, TimeUnit.SECONDS) sentBox -> scheduledExecutorService.schedule(() -> sending.deleteMessage(sentBox.getPersonId(), sentBox.getMessageId()), 10, TimeUnit.SECONDS)
) )
@ -424,12 +483,12 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.activeType(AFTER) .activeType(AFTER)
.answer( .answer(
boxAnswer( () -> boxAnswer(
""" """
Do you want to enable automatic notification of new private projects available to you? Do you want to enable automatic notification of new private projects available to you?
""", """,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton("Yes", "YES"), simpleButton("Yes", "YES"),
simpleButton("No", "NO") simpleButton("No", "NO")
) )
@ -445,11 +504,17 @@ public class InitSettingFlow implements UnitConfiguration {
@Unit(TEXT_PRIVACY_SETTING) MainUnit<Mail> textPrivacySetting @Unit(TEXT_PRIVACY_SETTING) MainUnit<Mail> textPrivacySetting
) { ) {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.triggerCheck(isClickButton()) .triggerCheck(isButtonClick())
.answer(mail -> { .answer(mail -> {
final ButtonClickAttachment buttonClick = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow(); final ButtonClickAttachment buttonClick = Attachments.findFirstButtonClick(mail.getAttachments()).orElseThrow();
if ("YES".equals(buttonClick.getRawCallBackData())) { if ("YES".equals(buttonClick.getRawCallBackData())) {
sending.replaceMessage(mail.getPersonId(), mail.getId(), boxAnswer("I write down the available private projects.\nThis may take a long time ⌛")); sending.send(
BoxAnswer.replaceBuilder()
.recipientPersonId(mail.getFromPersonId())
.replaceMessageId(mail.getId())
.message("I write down the available private projects.\nThis may take a long time ⌛")
.build()
);
projectParser.parseAllPrivateProject(); projectParser.parseAllPrivateProject();
settingService.privateProjectScan(true); settingService.privateProjectScan(true);
} else { } else {
@ -468,13 +533,13 @@ public class InitSettingFlow implements UnitConfiguration {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.activeType(AFTER) .activeType(AFTER)
.answer( .answer(
replaceBoxAnswer(""" () -> replaceBoxAnswer("""
Each company and/or team has its own level of confidentiality. You probably don't want to trust any information to Telegram, because all messages will go through its servers. Also, your telegame account can be hacked. Each company and/or team has its own level of confidentiality. You probably don't want to trust any information to Telegram, because all messages will go through its servers. Also, your telegame account can be hacked.
So now we will set up the privacy of the notifications you receive. So now we will set up the privacy of the notifications you receive.
""", """,
inlineKeyBoard( inlineKeyBoard(
simpleLine( keyBoardLine(
simpleButton("\uD83E\uDD77 start setting up \uD83E\uDD77", "start setting up") simpleButton("\uD83E\uDD77 start setting up \uD83E\uDD77", "start setting up")
) )
) )
@ -490,7 +555,7 @@ public class InitSettingFlow implements UnitConfiguration {
) { ) {
return AnswerText.<Mail>builder() return AnswerText.<Mail>builder()
.answer( .answer(
replaceBoxAnswer(""" () -> replaceBoxAnswer("""
A lot of confidential information can be contained in notifications of posts in a thread. A lot of confidential information can be contained in notifications of posts in a thread.
Choose a privacy level: Choose a privacy level: