Рабочая версия со сменой языка
This commit is contained in:
parent
24008c7989
commit
44949a650f
@ -3,3 +3,5 @@ main.no=No
|
|||||||
ui.lang_changed=Language changed successfully
|
ui.lang_changed=Language changed successfully
|
||||||
ui.monitor_private_projects=Start tracking private projects?
|
ui.monitor_private_projects=Start tracking private projects?
|
||||||
ui.monitor_project_private_success=Projects have been successfully added to tracking
|
ui.monitor_project_private_success=Projects have been successfully added to tracking
|
||||||
|
ui.monitor_owner_projects=Start tracking public projects that you own?
|
||||||
|
ui.setup_finished=Configuration completed successfully
|
@ -3,3 +3,5 @@ main.no=Нет
|
|||||||
ui.lang_changed=Язык успешно изменен
|
ui.lang_changed=Язык успешно изменен
|
||||||
ui.monitor_private_projects=Начать отслеживать приватные проекты?
|
ui.monitor_private_projects=Начать отслеживать приватные проекты?
|
||||||
ui.monitor_project_private_success=Проекты успешно добавлены в отслеживание
|
ui.monitor_project_private_success=Проекты успешно добавлены в отслеживание
|
||||||
|
ui.monitor_owner_projects=Начать отслеживать публичные проекты, владельцем которых вы являетесь?
|
||||||
|
ui.setup_finished=Настройка успешно завершена
|
@ -11,6 +11,7 @@ import org.springframework.context.MessageSource;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* // TODO: 16.01.2021 Добавить описание.
|
* // TODO: 16.01.2021 Добавить описание.
|
||||||
@ -43,11 +44,13 @@ public class AppSettingServiceImpl implements AppSettingService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getMessage(@NonNull String label) {
|
public String getMessage(@NonNull String label) {
|
||||||
return messageSource.getMessage(
|
final Locale value = appSettingRepository.findById(KEY)
|
||||||
label, null, appSettingRepository.findById(KEY)
|
|
||||||
.orElseThrow(() -> EXCEPTION)
|
.orElseThrow(() -> EXCEPTION)
|
||||||
.getAppLocale().getValue()
|
.getAppLocale().getValue();
|
||||||
|
final String message = messageSource.getMessage(
|
||||||
|
label, null, value
|
||||||
);
|
);
|
||||||
|
return message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,6 +12,7 @@ import org.sadtech.bot.gitlab.context.domain.notify.pullrequest.ConflictPrNotify
|
|||||||
import org.sadtech.bot.gitlab.context.domain.notify.pullrequest.NewPrNotify;
|
import org.sadtech.bot.gitlab.context.domain.notify.pullrequest.NewPrNotify;
|
||||||
import org.sadtech.bot.gitlab.context.domain.notify.pullrequest.StatusPrNotify;
|
import org.sadtech.bot.gitlab.context.domain.notify.pullrequest.StatusPrNotify;
|
||||||
import org.sadtech.bot.gitlab.context.repository.MergeRequestRepository;
|
import org.sadtech.bot.gitlab.context.repository.MergeRequestRepository;
|
||||||
|
import org.sadtech.bot.gitlab.context.service.AppSettingService;
|
||||||
import org.sadtech.bot.gitlab.context.service.MergeRequestsService;
|
import org.sadtech.bot.gitlab.context.service.MergeRequestsService;
|
||||||
import org.sadtech.bot.gitlab.context.service.NotifyService;
|
import org.sadtech.bot.gitlab.context.service.NotifyService;
|
||||||
import org.sadtech.bot.gitlab.context.service.PersonService;
|
import org.sadtech.bot.gitlab.context.service.PersonService;
|
||||||
@ -36,6 +37,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<Merge
|
|||||||
private final PersonService personService;
|
private final PersonService personService;
|
||||||
private final FilterService<MergeRequest, PullRequestFilter> filterService;
|
private final FilterService<MergeRequest, PullRequestFilter> filterService;
|
||||||
private final ProjectService projectService;
|
private final ProjectService projectService;
|
||||||
|
private final AppSettingService settingService;
|
||||||
|
|
||||||
private final PersonInformation personInformation;
|
private final PersonInformation personInformation;
|
||||||
|
|
||||||
@ -45,6 +47,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<Merge
|
|||||||
PersonService personService,
|
PersonService personService,
|
||||||
@Qualifier("mergeRequestFilterService") FilterService<MergeRequest, PullRequestFilter> filterService,
|
@Qualifier("mergeRequestFilterService") FilterService<MergeRequest, PullRequestFilter> filterService,
|
||||||
ProjectService projectService,
|
ProjectService projectService,
|
||||||
|
AppSettingService settingService,
|
||||||
PersonInformation personInformation
|
PersonInformation personInformation
|
||||||
) {
|
) {
|
||||||
super(mergeRequestRepository);
|
super(mergeRequestRepository);
|
||||||
@ -53,6 +56,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<Merge
|
|||||||
this.personService = personService;
|
this.personService = personService;
|
||||||
this.filterService = filterService;
|
this.filterService = filterService;
|
||||||
this.projectService = projectService;
|
this.projectService = projectService;
|
||||||
|
this.settingService = settingService;
|
||||||
this.personInformation = personInformation;
|
this.personInformation = personInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,6 +67,14 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<Merge
|
|||||||
|
|
||||||
final MergeRequest newMergeRequest = mergeRequestRepository.save(mergeRequest);
|
final MergeRequest newMergeRequest = mergeRequestRepository.save(mergeRequest);
|
||||||
|
|
||||||
|
if (!settingService.isFirstStart()) {
|
||||||
|
notifyNewPr(newMergeRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
return newMergeRequest;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void notifyNewPr(MergeRequest newMergeRequest) {
|
||||||
if (!personInformation.getId().equals(newMergeRequest.getAuthor().getId())) {
|
if (!personInformation.getId().equals(newMergeRequest.getAuthor().getId())) {
|
||||||
final String projectName = projectService.getById(newMergeRequest.getProjectId())
|
final String projectName = projectService.getById(newMergeRequest.getProjectId())
|
||||||
.orElseThrow(() -> new NotFoundException("Проект не найден"))
|
.orElseThrow(() -> new NotFoundException("Проект не найден"))
|
||||||
@ -80,7 +92,6 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<Merge
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return newMergeRequest;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
2
pom.xml
2
pom.xml
@ -91,7 +91,7 @@
|
|||||||
<haiti.context.version>0.0.2-SNAPSHOT</haiti.context.version>
|
<haiti.context.version>0.0.2-SNAPSHOT</haiti.context.version>
|
||||||
<haiti.database.version>0.0.3-SNAPSHOT</haiti.database.version>
|
<haiti.database.version>0.0.3-SNAPSHOT</haiti.database.version>
|
||||||
<haiti.filter.criteria.version>0.0.2-RELEASE</haiti.filter.criteria.version>
|
<haiti.filter.criteria.version>0.0.2-RELEASE</haiti.filter.criteria.version>
|
||||||
<sadtech.bot.telegram.core.version>0.0.1-RELEASE</sadtech.bot.telegram.core.version>
|
<sadtech.bot.telegram.core.version>0.0.2-SNAPSHOT</sadtech.bot.telegram.core.version>
|
||||||
<sadtech.bot.vsc.context.version>0.0.1-RELEASE</sadtech.bot.vsc.context.version>
|
<sadtech.bot.vsc.context.version>0.0.1-RELEASE</sadtech.bot.vsc.context.version>
|
||||||
|
|
||||||
<javax.persistance.version>2.2</javax.persistance.version>
|
<javax.persistance.version>2.2</javax.persistance.version>
|
||||||
|
@ -3,8 +3,8 @@ package org.sadtech.bot.gitlab.telegram.service.unit;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.sadtech.bot.gitlab.context.domain.entity.Task;
|
import org.sadtech.bot.gitlab.context.domain.entity.Task;
|
||||||
import org.sadtech.bot.gitlab.context.service.TaskService;
|
import org.sadtech.bot.gitlab.context.service.TaskService;
|
||||||
import org.sadtech.social.bot.service.usercode.ProcessingData;
|
|
||||||
import org.sadtech.social.core.domain.BoxAnswer;
|
import org.sadtech.social.core.domain.BoxAnswer;
|
||||||
|
import org.sadtech.social.core.domain.ProcessingData;
|
||||||
import org.sadtech.social.core.domain.content.Message;
|
import org.sadtech.social.core.domain.content.Message;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
@ -2,8 +2,8 @@ package org.sadtech.bot.gitlab.telegram.service.unit.pullrequest;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.sadtech.bot.gitlab.context.service.MergeRequestsService;
|
import org.sadtech.bot.gitlab.context.service.MergeRequestsService;
|
||||||
import org.sadtech.social.bot.service.usercode.ProcessingData;
|
|
||||||
import org.sadtech.social.core.domain.BoxAnswer;
|
import org.sadtech.social.core.domain.BoxAnswer;
|
||||||
|
import org.sadtech.social.core.domain.ProcessingData;
|
||||||
import org.sadtech.social.core.domain.content.Message;
|
import org.sadtech.social.core.domain.content.Message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,8 +2,8 @@ package org.sadtech.bot.gitlab.telegram.service.unit.pullrequest;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.sadtech.bot.gitlab.context.service.MergeRequestsService;
|
import org.sadtech.bot.gitlab.context.service.MergeRequestsService;
|
||||||
import org.sadtech.social.bot.service.usercode.ProcessingData;
|
|
||||||
import org.sadtech.social.core.domain.BoxAnswer;
|
import org.sadtech.social.core.domain.BoxAnswer;
|
||||||
|
import org.sadtech.social.core.domain.ProcessingData;
|
||||||
import org.sadtech.social.core.domain.content.Message;
|
import org.sadtech.social.core.domain.content.Message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +23,7 @@ public class PullRequestUnitConfig {
|
|||||||
AnswerProcessing<Message> needWorkPullRequest
|
AnswerProcessing<Message> needWorkPullRequest
|
||||||
) {
|
) {
|
||||||
return AnswerText.builder()
|
return AnswerText.builder()
|
||||||
.boxAnswer(
|
.boxAnswer(message ->
|
||||||
BoxAnswer.builder()
|
BoxAnswer.builder()
|
||||||
.message("Эта вкладка для работы с Pull Request")
|
.message("Эта вкладка для работы с Pull Request")
|
||||||
.keyBoard(
|
.keyBoard(
|
||||||
|
@ -40,7 +40,7 @@ public class UnitConfig {
|
|||||||
AnswerProcessing checkLanguage
|
AnswerProcessing checkLanguage
|
||||||
) {
|
) {
|
||||||
return AnswerText.builder()
|
return AnswerText.builder()
|
||||||
.boxAnswer(
|
.boxAnswer(message ->
|
||||||
BoxAnswer.builder()
|
BoxAnswer.builder()
|
||||||
.message("Hi :)\n\nLet's choose a language for.")
|
.message("Hi :)\n\nLet's choose a language for.")
|
||||||
.keyBoard(KeyBoards.verticalDuoMenuString("Русский", "English"))
|
.keyBoard(KeyBoards.verticalDuoMenuString("Русский", "English"))
|
||||||
@ -76,7 +76,7 @@ public class UnitConfig {
|
|||||||
AppSettingService settingService
|
AppSettingService settingService
|
||||||
) {
|
) {
|
||||||
return AnswerText.builder()
|
return AnswerText.builder()
|
||||||
.boxAnswer(
|
.boxAnswer(message ->
|
||||||
BoxAnswer.builder()
|
BoxAnswer.builder()
|
||||||
.message(settingService.getMessage("ui.monitor_private_projects"))
|
.message(settingService.getMessage("ui.monitor_private_projects"))
|
||||||
.keyBoard(KeyBoards.verticalDuoMenuString(
|
.keyBoard(KeyBoards.verticalDuoMenuString(
|
||||||
@ -92,26 +92,94 @@ public class UnitConfig {
|
|||||||
@Bean
|
@Bean
|
||||||
public AnswerCheck checkParserPrivateProject(
|
public AnswerCheck checkParserPrivateProject(
|
||||||
AppSettingService appSettingService,
|
AppSettingService appSettingService,
|
||||||
AnswerProcessing parserPrivateProject
|
AnswerProcessing parserPrivateProject,
|
||||||
|
AnswerText textParseOwnerProject
|
||||||
) {
|
) {
|
||||||
return AnswerCheck.builder()
|
return AnswerCheck.builder()
|
||||||
.check(
|
.check(
|
||||||
message -> appSettingService.getMessage("main.yes").equalsIgnoreCase(message.getText())
|
message -> appSettingService.getMessage("main.yes").equalsIgnoreCase(message.getText())
|
||||||
)
|
)
|
||||||
.unitTrue(parserPrivateProject)
|
.unitTrue(parserPrivateProject)
|
||||||
|
.unitFalse(textParseOwnerProject)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public AnswerProcessing parserPrivateProject(
|
public AnswerProcessing parserPrivateProject(
|
||||||
ProjectParser projectParser,
|
ProjectParser projectParser,
|
||||||
AppSettingService settingService
|
AppSettingService settingService,
|
||||||
|
AnswerText textParseOwnerProject
|
||||||
) {
|
) {
|
||||||
return AnswerProcessing.builder()
|
return AnswerProcessing.builder()
|
||||||
.processingData(message -> {
|
.processingData(message -> {
|
||||||
projectParser.parseAllPrivateProject();
|
projectParser.parseAllPrivateProject();
|
||||||
return BoxAnswer.of(settingService.getMessage("ui.monitor_project_private_success"));
|
return BoxAnswer.of(settingService.getMessage("ui.monitor_project_private_success"));
|
||||||
})
|
})
|
||||||
|
.nextUnit(textParseOwnerProject)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public AnswerText textParseOwnerProject(
|
||||||
|
AppSettingService settingService,
|
||||||
|
AnswerCheck checkParseOwnerProject
|
||||||
|
) {
|
||||||
|
return AnswerText.builder()
|
||||||
|
.boxAnswer(message ->
|
||||||
|
BoxAnswer.builder()
|
||||||
|
.message(settingService.getMessage("ui.monitor_owner_projects"))
|
||||||
|
.keyBoard(KeyBoards.verticalDuoMenuString(
|
||||||
|
settingService.getMessage("main.yes"), settingService.getMessage("main.no")
|
||||||
|
))
|
||||||
|
.build()
|
||||||
|
)
|
||||||
|
.activeType(UnitActiveType.AFTER)
|
||||||
|
.nextUnit(checkParseOwnerProject)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public AnswerCheck checkParseOwnerProject(
|
||||||
|
AppSettingService appSettingService,
|
||||||
|
AnswerProcessing parseOwnerProject,
|
||||||
|
AnswerProcessing endSetting
|
||||||
|
) {
|
||||||
|
return AnswerCheck.builder()
|
||||||
|
.check(
|
||||||
|
message -> appSettingService.getMessage("main.yes").equalsIgnoreCase(message.getText())
|
||||||
|
)
|
||||||
|
.unitTrue(parseOwnerProject)
|
||||||
|
.unitFalse(endSetting)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public AnswerProcessing parseOwnerProject(
|
||||||
|
ProjectParser projectParser,
|
||||||
|
AppSettingService settingService,
|
||||||
|
AnswerProcessing endSetting
|
||||||
|
) {
|
||||||
|
return AnswerProcessing.builder()
|
||||||
|
.processingData(message -> {
|
||||||
|
projectParser.parseAllProjectOwner();
|
||||||
|
return BoxAnswer.of(settingService.getMessage("ui.monitor_project_private_success"));
|
||||||
|
})
|
||||||
|
.nextUnit(endSetting)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public AnswerProcessing endSetting(
|
||||||
|
AppSettingService settingService
|
||||||
|
) {
|
||||||
|
return AnswerProcessing.builder()
|
||||||
|
.processingData(
|
||||||
|
message -> {
|
||||||
|
settingService.disableFirstStart();
|
||||||
|
return BoxAnswer.of(settingService.getMessage("ui.setup_finished"));
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.activeType(UnitActiveType.AFTER)
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user