diff --git a/gitlab-app/src/main/resources/application.yml b/gitlab-app/src/main/resources/application.yml index 45c05c8..200117b 100644 --- a/gitlab-app/src/main/resources/application.yml +++ b/gitlab-app/src/main/resources/application.yml @@ -21,8 +21,8 @@ telegram-config: bot-token: ${TELEGRAM_BOT_TOKEN} proxy-config: enable: ${PROXY_ENABLE:false} - host: ${PROXY_HOST:host} - port: ${PROXY_PORT:8080} + host: ${PROXY_HOST:} + port: ${PROXY_PORT:} type: ${PROXY_TYPE:SOCKS5} user: ${PROXY_USERNAME:} password: ${PROXY_PASSWORD:} diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/UnitConfig.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/UnitConfig.java index 431e79e..875d5ea 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/UnitConfig.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/unit/UnitConfig.java @@ -1,11 +1,13 @@ package dev.struchkov.bot.gitlab.telegram.unit; +import dev.struchkov.bot.gitlab.context.domain.PersonInformation; import dev.struchkov.bot.gitlab.context.domain.entity.Note; import dev.struchkov.bot.gitlab.context.service.AppSettingService; import dev.struchkov.bot.gitlab.context.service.DiscussionService; import dev.struchkov.bot.gitlab.context.service.NoteService; import dev.struchkov.bot.gitlab.context.service.NotifyService; import dev.struchkov.bot.gitlab.core.service.parser.ProjectParser; +import dev.struchkov.bot.gitlab.telegram.utils.UnitName; import dev.struchkov.godfather.main.core.unit.UnitActiveType; import dev.struchkov.godfather.main.domain.BoxAnswer; import dev.struchkov.godfather.main.domain.annotation.Unit; @@ -53,6 +55,8 @@ public class UnitConfig { private static final Pattern NOTE_LINK = Pattern.compile("#note_\\d+$"); + private final PersonInformation personInformation; + private final AppSettingService settingService; private final NoteService noteService; private final DiscussionService discussionService; @@ -60,7 +64,17 @@ public class UnitConfig { private final ProjectParser projectParser; - @Unit(value = CHECK_FIRST_START, main = true) + @Unit(value = UnitName.AUTHORIZATION, main = true) + public AnswerCheck auth( + @Unit(CHECK_FIRST_START) MainUnit checkFirstStart + ) { + return AnswerCheck.builder() + .check(mail -> personInformation.getTelegramId().equals(mail.getPersonId())) + .unitTrue(checkFirstStart) + .build(); + } + + @Unit(value = CHECK_FIRST_START) public AnswerCheck checkFirstStart( @Unit(TEXT_PARSER_PRIVATE_PROJECT) MainUnit textParserPrivateProject, @Unit(CHECK_MENU_OR_ANSWER) MainUnit checkMenuOrAnswer diff --git a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/utils/UnitName.java b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/utils/UnitName.java index 1ad66c1..4ee9588 100644 --- a/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/utils/UnitName.java +++ b/telegram-bot/src/main/java/dev/struchkov/bot/gitlab/telegram/utils/UnitName.java @@ -4,7 +4,6 @@ import static dev.struchkov.haiti.utils.Exceptions.utilityClass; public final class UnitName { - public static final String SETTINGS_LANGUAGE = "settingsLanguage"; public static final String GENERAL_MENU = "generalMenu"; public static final String TEXT_ADD_NEW_PROJECT = "textAddNewProject"; public static final String ADD_NEW_PROJECT = "addNewProject"; @@ -21,6 +20,7 @@ public final class UnitName { public static final String CHECK_PARSE_OWNER_PROJECT = "checkParseOwnerProject"; public static final String PARSE_OWNER_PROJECT = "parseOwnerProject"; public static final String END_SETTING = "endSetting"; + public static final String AUTHORIZATION = "AUTHORIZATION"; private UnitName() { utilityClass();