Добавил unit с авторизацией

This commit is contained in:
Struchkov Mark 2022-12-13 20:35:14 +03:00
parent 34c3370483
commit 1623fc8f8b
3 changed files with 18 additions and 4 deletions

View File

@ -21,8 +21,8 @@ telegram-config:
bot-token: ${TELEGRAM_BOT_TOKEN} bot-token: ${TELEGRAM_BOT_TOKEN}
proxy-config: proxy-config:
enable: ${PROXY_ENABLE:false} enable: ${PROXY_ENABLE:false}
host: ${PROXY_HOST:host} host: ${PROXY_HOST:}
port: ${PROXY_PORT:8080} port: ${PROXY_PORT:}
type: ${PROXY_TYPE:SOCKS5} type: ${PROXY_TYPE:SOCKS5}
user: ${PROXY_USERNAME:} user: ${PROXY_USERNAME:}
password: ${PROXY_PASSWORD:} password: ${PROXY_PASSWORD:}

View File

@ -1,11 +1,13 @@
package dev.struchkov.bot.gitlab.telegram.unit; 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.domain.entity.Note;
import dev.struchkov.bot.gitlab.context.service.AppSettingService; import dev.struchkov.bot.gitlab.context.service.AppSettingService;
import dev.struchkov.bot.gitlab.context.service.DiscussionService; import dev.struchkov.bot.gitlab.context.service.DiscussionService;
import dev.struchkov.bot.gitlab.context.service.NoteService; import dev.struchkov.bot.gitlab.context.service.NoteService;
import dev.struchkov.bot.gitlab.context.service.NotifyService; import dev.struchkov.bot.gitlab.context.service.NotifyService;
import dev.struchkov.bot.gitlab.core.service.parser.ProjectParser; 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.core.unit.UnitActiveType;
import dev.struchkov.godfather.main.domain.BoxAnswer; import dev.struchkov.godfather.main.domain.BoxAnswer;
import dev.struchkov.godfather.main.domain.annotation.Unit; 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 static final Pattern NOTE_LINK = Pattern.compile("#note_\\d+$");
private final PersonInformation personInformation;
private final AppSettingService settingService; private final AppSettingService settingService;
private final NoteService noteService; private final NoteService noteService;
private final DiscussionService discussionService; private final DiscussionService discussionService;
@ -60,7 +64,17 @@ public class UnitConfig {
private final ProjectParser projectParser; private final ProjectParser projectParser;
@Unit(value = CHECK_FIRST_START, main = true) @Unit(value = UnitName.AUTHORIZATION, main = true)
public AnswerCheck<Mail> auth(
@Unit(CHECK_FIRST_START) MainUnit<Mail> checkFirstStart
) {
return AnswerCheck.<Mail>builder()
.check(mail -> personInformation.getTelegramId().equals(mail.getPersonId()))
.unitTrue(checkFirstStart)
.build();
}
@Unit(value = CHECK_FIRST_START)
public AnswerCheck<Mail> checkFirstStart( public AnswerCheck<Mail> checkFirstStart(
@Unit(TEXT_PARSER_PRIVATE_PROJECT) MainUnit<Mail> textParserPrivateProject, @Unit(TEXT_PARSER_PRIVATE_PROJECT) MainUnit<Mail> textParserPrivateProject,
@Unit(CHECK_MENU_OR_ANSWER) MainUnit<Mail> checkMenuOrAnswer @Unit(CHECK_MENU_OR_ANSWER) MainUnit<Mail> checkMenuOrAnswer

View File

@ -4,7 +4,6 @@ import static dev.struchkov.haiti.utils.Exceptions.utilityClass;
public final class UnitName { public final class UnitName {
public static final String SETTINGS_LANGUAGE = "settingsLanguage";
public static final String GENERAL_MENU = "generalMenu"; public static final String GENERAL_MENU = "generalMenu";
public static final String TEXT_ADD_NEW_PROJECT = "textAddNewProject"; public static final String TEXT_ADD_NEW_PROJECT = "textAddNewProject";
public static final String ADD_NEW_PROJECT = "addNewProject"; 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 CHECK_PARSE_OWNER_PROJECT = "checkParseOwnerProject";
public static final String PARSE_OWNER_PROJECT = "parseOwnerProject"; public static final String PARSE_OWNER_PROJECT = "parseOwnerProject";
public static final String END_SETTING = "endSetting"; public static final String END_SETTING = "endSetting";
public static final String AUTHORIZATION = "AUTHORIZATION";
private UnitName() { private UnitName() {
utilityClass(); utilityClass();