Рефакторинг старта приложения.
This commit is contained in:
parent
b87e516fc0
commit
695a4703dc
@ -37,4 +37,12 @@ public enum AssigneeChanged {
|
|||||||
return AssigneeChanged.NOT_CHANGED;
|
return AssigneeChanged.NOT_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getNewStatus(boolean oldStatus) {
|
||||||
|
return switch (this) {
|
||||||
|
case BECOME -> true;
|
||||||
|
case DELETED -> false;
|
||||||
|
case NOT_CHANGED, NOT_AFFECT_USER -> oldStatus;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -35,4 +35,12 @@ public enum ReviewerChanged {
|
|||||||
return ReviewerChanged.NOT_CHANGED;
|
return ReviewerChanged.NOT_CHANGED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean getNewStatus(boolean oldStatus) {
|
||||||
|
return switch (this) {
|
||||||
|
case BECOME -> true;
|
||||||
|
case DELETED -> false;
|
||||||
|
case NOT_AFFECT_USER, NOT_CHANGED -> oldStatus;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -99,7 +99,13 @@ public class MergeRequest {
|
|||||||
private String sourceBranch;
|
private String sourceBranch;
|
||||||
|
|
||||||
@Column(name = "notification")
|
@Column(name = "notification")
|
||||||
private Boolean notification;
|
private boolean notification;
|
||||||
|
|
||||||
|
@Column(name = "is_assignee")
|
||||||
|
private boolean userAssignee;
|
||||||
|
|
||||||
|
@Column(name = "is_reviewer")
|
||||||
|
private boolean userReviewer;
|
||||||
|
|
||||||
@ElementCollection
|
@ElementCollection
|
||||||
@CollectionTable(name = "merge_request_label", joinColumns = @JoinColumn(name = "merge_request_id"))
|
@CollectionTable(name = "merge_request_label", joinColumns = @JoinColumn(name = "merge_request_id"))
|
||||||
|
@ -12,4 +12,8 @@ public interface NotifyService {
|
|||||||
|
|
||||||
<T extends Notify> void send(T notify);
|
<T extends Notify> void send(T notify);
|
||||||
|
|
||||||
|
void enableAllNotify();
|
||||||
|
|
||||||
|
void disableAllNotify();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -52,50 +52,37 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public MergeRequest create(@NonNull MergeRequest mergeRequest) {
|
public MergeRequest create(@NonNull MergeRequest mergeRequest) {
|
||||||
mergeRequest.setNotification(true);
|
final boolean botUserReviewer = isBotUserReviewer(mergeRequest);
|
||||||
|
final boolean botUserAssignee = isBotUserAssigneeAndNotAuthor(mergeRequest);
|
||||||
|
|
||||||
final MergeRequest newMergeRequest = repository.save(mergeRequest);
|
mergeRequest.setNotification(botUserReviewer || botUserAssignee);
|
||||||
|
mergeRequest.setUserAssignee(botUserAssignee);
|
||||||
|
mergeRequest.setUserReviewer(botUserReviewer);
|
||||||
|
|
||||||
notifyNewMergeRequest(newMergeRequest);
|
final MergeRequest savedMergeRequest = repository.save(mergeRequest);
|
||||||
|
|
||||||
return newMergeRequest;
|
if (botUserReviewer || botUserAssignee) {
|
||||||
|
if (!mergeRequest.isConflict()) {
|
||||||
|
final String projectName = projectService.getByIdOrThrow(savedMergeRequest.getProjectId()).getName();
|
||||||
|
if (botUserReviewer) sendNotifyAboutNewMr(savedMergeRequest, projectName);
|
||||||
|
if (botUserAssignee) sendNotifyAboutAssignee(mergeRequest, projectName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return savedMergeRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private boolean isBotUserAssigneeAndNotAuthor(MergeRequest mergeRequest) {
|
||||||
* Уведомление о новом MergeRequest.
|
|
||||||
*
|
|
||||||
* @param savedMergeRequest сохраненный в базу новый MergeRequest.
|
|
||||||
*/
|
|
||||||
private void notifyNewMergeRequest(MergeRequest savedMergeRequest) {
|
|
||||||
notifyUserAboutNewPullRequestIfHeIsReviewer(savedMergeRequest);
|
|
||||||
notifyUserAboutNewPullRequestIfHeIsAssignee(savedMergeRequest);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void notifyUserAboutNewPullRequestIfHeIsAssignee(MergeRequest savedMergeRequest) {
|
|
||||||
final Long gitlabUserId = personInformation.getId();
|
final Long gitlabUserId = personInformation.getId();
|
||||||
final Person assignee = savedMergeRequest.getAssignee();
|
final Person assignee = mergeRequest.getAssignee();
|
||||||
final Person author = savedMergeRequest.getAuthor();
|
final Person author = mergeRequest.getAuthor();
|
||||||
|
|
||||||
if (checkNotNull(assignee)) {
|
if (checkNotNull(assignee)) {
|
||||||
if (gitlabUserId.equals(assignee.getId()) && !isAuthorSameAssignee(author, assignee)) {
|
if (gitlabUserId.equals(assignee.getId()) && !isAuthorSameAssignee(author, assignee)) {
|
||||||
final String projectName = projectService.getByIdOrThrow(savedMergeRequest.getProjectId()).getName();
|
return true;
|
||||||
if (!savedMergeRequest.isConflict()) {
|
|
||||||
//TODO [05.12.2022|uPagge]: Заменить уведомление. Нужно создать новое уведомление, если пользователя назначали ответственным
|
|
||||||
notifyService.send(
|
|
||||||
NewPrNotify.builder()
|
|
||||||
.projectName(projectName)
|
|
||||||
.labels(savedMergeRequest.getLabels())
|
|
||||||
.author(author.getName())
|
|
||||||
.description(savedMergeRequest.getDescription())
|
|
||||||
.title(savedMergeRequest.getTitle())
|
|
||||||
.url(savedMergeRequest.getWebUrl())
|
|
||||||
.targetBranch(savedMergeRequest.getTargetBranch())
|
|
||||||
.sourceBranch(savedMergeRequest.getSourceBranch())
|
|
||||||
.build()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -107,33 +94,46 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
return author.getId().equals(assignee.getId());
|
return author.getId().equals(assignee.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void notifyUserAboutNewPullRequestIfHeIsReviewer(MergeRequest savedMergeRequest) {
|
private boolean isBotUserReviewer(MergeRequest savedMergeRequest) {
|
||||||
final List<Person> reviewers = savedMergeRequest.getReviewers();
|
final List<Person> reviewers = savedMergeRequest.getReviewers();
|
||||||
final Long gitlabUserId = personInformation.getId();
|
final Long botUserGitlabId = personInformation.getId();
|
||||||
|
|
||||||
if (checkNotEmpty(reviewers)) {
|
if (checkNotEmpty(reviewers)) {
|
||||||
final boolean isUserInReviewers = reviewers.stream()
|
for (Person reviewer : reviewers) {
|
||||||
.anyMatch(reviewer -> gitlabUserId.equals(reviewer.getId()));
|
if (botUserGitlabId.equals(reviewer.getId())) {
|
||||||
if (isUserInReviewers) {
|
return true;
|
||||||
final String projectName = projectService.getByIdOrThrow(savedMergeRequest.getProjectId()).getName();
|
|
||||||
if (!savedMergeRequest.isConflict()) {
|
|
||||||
sendNotifyAboutNewMr(savedMergeRequest, projectName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNotifyAboutNewMr(MergeRequest savedMergeRequest, String projectName) {
|
private void sendNotifyAboutNewMr(MergeRequest mergeRequest, String projectName) {
|
||||||
notifyService.send(
|
notifyService.send(
|
||||||
NewPrNotify.builder()
|
NewPrNotify.builder()
|
||||||
.projectName(projectName)
|
.projectName(projectName)
|
||||||
.labels(savedMergeRequest.getLabels())
|
.labels(mergeRequest.getLabels())
|
||||||
.author(savedMergeRequest.getAuthor().getName())
|
.author(mergeRequest.getAuthor().getName())
|
||||||
.description(savedMergeRequest.getDescription())
|
.description(mergeRequest.getDescription())
|
||||||
.title(savedMergeRequest.getTitle())
|
.title(mergeRequest.getTitle())
|
||||||
.url(savedMergeRequest.getWebUrl())
|
.url(mergeRequest.getWebUrl())
|
||||||
.targetBranch(savedMergeRequest.getTargetBranch())
|
.targetBranch(mergeRequest.getTargetBranch())
|
||||||
.sourceBranch(savedMergeRequest.getSourceBranch())
|
.sourceBranch(mergeRequest.getSourceBranch())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void sendNotifyAboutAssignee(MergeRequest mergeRequest, String projectName) {
|
||||||
|
notifyService.send(
|
||||||
|
NewPrNotify.builder()
|
||||||
|
.projectName(projectName)
|
||||||
|
.labels(mergeRequest.getLabels())
|
||||||
|
.author(mergeRequest.getAuthor().getName())
|
||||||
|
.description(mergeRequest.getDescription())
|
||||||
|
.title(mergeRequest.getTitle())
|
||||||
|
.url(mergeRequest.getWebUrl())
|
||||||
|
.targetBranch(mergeRequest.getTargetBranch())
|
||||||
|
.sourceBranch(mergeRequest.getSourceBranch())
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -144,35 +144,37 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
final MergeRequest oldMergeRequest = repository.findById(mergeRequest.getId())
|
final MergeRequest oldMergeRequest = repository.findById(mergeRequest.getId())
|
||||||
.orElseThrow(notFoundException("MergeRequest не найден"));
|
.orElseThrow(notFoundException("MergeRequest не найден"));
|
||||||
|
|
||||||
final Boolean notification = oldMergeRequest.getNotification();
|
mergeRequest.setNotification(oldMergeRequest.isNotification());
|
||||||
if (checkNotNull(notification)) {
|
|
||||||
mergeRequest.setNotification(oldMergeRequest.getNotification());
|
|
||||||
}
|
|
||||||
|
|
||||||
final Long gitlabUserId = personInformation.getId();
|
final Long gitlabUserId = personInformation.getId();
|
||||||
final AssigneeChanged assigneeChanged = AssigneeChanged.valueOf(gitlabUserId, oldMergeRequest.getAssignee(), mergeRequest.getAssignee());
|
final AssigneeChanged assigneeChanged = AssigneeChanged.valueOf(gitlabUserId, oldMergeRequest.getAssignee(), mergeRequest.getAssignee());
|
||||||
final ReviewerChanged reviewerChanged = ReviewerChanged.valueOf(gitlabUserId, oldMergeRequest.getReviewers(), mergeRequest.getReviewers());
|
final ReviewerChanged reviewerChanged = ReviewerChanged.valueOf(gitlabUserId, oldMergeRequest.getReviewers(), mergeRequest.getReviewers());
|
||||||
|
|
||||||
final boolean isChangedMr =
|
mergeRequest.setUserAssignee(assigneeChanged.getNewStatus(oldMergeRequest.isUserAssignee()));
|
||||||
!oldMergeRequest.getUpdatedDate().equals(mergeRequest.getUpdatedDate())
|
mergeRequest.setUserReviewer(reviewerChanged.getNewStatus(oldMergeRequest.isUserReviewer()));
|
||||||
|| oldMergeRequest.isConflict() != mergeRequest.isConflict();
|
|
||||||
|
final boolean isChangedMr = !oldMergeRequest.getUpdatedDate().equals(mergeRequest.getUpdatedDate())
|
||||||
|
|| oldMergeRequest.isConflict() != mergeRequest.isConflict();
|
||||||
final boolean isChangedLinkedEntity = reviewerChanged.isChanged() || assigneeChanged.isChanged();
|
final boolean isChangedLinkedEntity = reviewerChanged.isChanged() || assigneeChanged.isChanged();
|
||||||
|
|
||||||
if (isChangedMr || isChangedLinkedEntity) {
|
if (isChangedMr || isChangedLinkedEntity) {
|
||||||
final Project project = projectService.getByIdOrThrow(mergeRequest.getProjectId());
|
final MergeRequest savedMergeRequest = repository.save(mergeRequest);
|
||||||
|
|
||||||
if (TRUE.equals(notification) && isChangedMr) {
|
if (oldMergeRequest.isNotification()) {
|
||||||
notifyAboutStatus(oldMergeRequest, mergeRequest, project);
|
final Project project = projectService.getByIdOrThrow(mergeRequest.getProjectId());
|
||||||
notifyAboutConflict(oldMergeRequest, mergeRequest, project);
|
|
||||||
notifyAboutUpdate(oldMergeRequest, mergeRequest, project);
|
if (isChangedMr) {
|
||||||
|
notifyAboutStatus(oldMergeRequest, savedMergeRequest, project);
|
||||||
|
notifyAboutConflict(oldMergeRequest, savedMergeRequest, project);
|
||||||
|
notifyAboutUpdate(oldMergeRequest, savedMergeRequest, project);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isChangedLinkedEntity) {
|
||||||
|
notifyReviewer(reviewerChanged, savedMergeRequest, project);
|
||||||
|
notifyAssignee(assigneeChanged, savedMergeRequest, project);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return savedMergeRequest;
|
||||||
if (TRUE.equals(notification) && isChangedLinkedEntity) {
|
|
||||||
notifyReviewer(reviewerChanged, mergeRequest, project);
|
|
||||||
notifyAssignee(assigneeChanged, mergeRequest, project);
|
|
||||||
}
|
|
||||||
|
|
||||||
return repository.save(mergeRequest);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldMergeRequest;
|
return oldMergeRequest;
|
||||||
|
@ -10,11 +10,24 @@ import org.springframework.stereotype.Service;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class NotifyServiceImpl implements NotifyService {
|
public class NotifyServiceImpl implements NotifyService {
|
||||||
|
|
||||||
|
private boolean enableAllNotify = true;
|
||||||
private final MessageSendService messageSendService;
|
private final MessageSendService messageSendService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <T extends Notify> void send(T notify) {
|
public <T extends Notify> void send(T notify) {
|
||||||
messageSendService.send(notify);
|
if (enableAllNotify) {
|
||||||
|
messageSendService.send(notify);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enableAllNotify() {
|
||||||
|
enableAllNotify = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disableAllNotify() {
|
||||||
|
enableAllNotify = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import dev.struchkov.bot.gitlab.context.service.PersonService;
|
|||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -34,12 +35,14 @@ public class PersonServiceImpl implements PersonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
public Person getByIdOrThrown(@NonNull Long personId) {
|
public Person getByIdOrThrown(@NonNull Long personId) {
|
||||||
return repository.findById(personId)
|
return repository.findById(personId)
|
||||||
.orElseThrow(notFoundException("Пользователь не найден"));
|
.orElseThrow(notFoundException("Пользователь не найден"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
public ExistContainer<Person, Long> existsById(Set<Long> personIds) {
|
public ExistContainer<Person, Long> existsById(Set<Long> personIds) {
|
||||||
final List<Person> existsEntity = repository.findAllById(personIds);
|
final List<Person> existsEntity = repository.findAllById(personIds);
|
||||||
final Set<Long> existsIds = existsEntity.stream().map(Person::getId).collect(Collectors.toSet());
|
final Set<Long> existsIds = existsEntity.stream().map(Person::getId).collect(Collectors.toSet());
|
||||||
@ -54,6 +57,7 @@ public class PersonServiceImpl implements PersonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public List<Person> createAll(List<Person> newPersons) {
|
public List<Person> createAll(List<Person> newPersons) {
|
||||||
return newPersons.stream()
|
return newPersons.stream()
|
||||||
.map(this::create)
|
.map(this::create)
|
||||||
|
@ -66,6 +66,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional
|
||||||
public List<Project> createAll(List<Project> newProjects) {
|
public List<Project> createAll(List<Project> newProjects) {
|
||||||
return newProjects.stream()
|
return newProjects.stream()
|
||||||
.map(this::create)
|
.map(this::create)
|
||||||
@ -78,6 +79,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@Transactional(readOnly = true)
|
||||||
public ExistContainer<Project, Long> existsById(Set<Long> projectIds) {
|
public ExistContainer<Project, Long> existsById(Set<Long> projectIds) {
|
||||||
final List<Project> existsEntity = repository.findAllById(projectIds);
|
final List<Project> existsEntity = repository.findAllById(projectIds);
|
||||||
final Set<Long> existsIds = existsEntity.stream().map(Project::getId).collect(Collectors.toSet());
|
final Set<Long> existsIds = existsEntity.stream().map(Project::getId).collect(Collectors.toSet());
|
||||||
|
@ -15,7 +15,6 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.core.convert.ConversionService;
|
import org.springframework.core.convert.ConversionService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -47,12 +46,10 @@ public class ProjectParser {
|
|||||||
private final GitlabProperty gitlabProperty;
|
private final GitlabProperty gitlabProperty;
|
||||||
private final PersonProperty personProperty;
|
private final PersonProperty personProperty;
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void parseAllPrivateProject() {
|
public void parseAllPrivateProject() {
|
||||||
parseProjects(PRIVATE);
|
parseProjects(PRIVATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
|
||||||
public void parseAllProjectOwner() {
|
public void parseAllProjectOwner() {
|
||||||
parseProjects(OWNER);
|
parseProjects(OWNER);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd">
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd">
|
||||||
|
|
||||||
<include file="v.1.0.0/changelog.xml" relativeToChangelogFile="true"/>
|
<include file="v.2.0.0/changelog.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="v.1.1.3/changelog.xml" relativeToChangelogFile="true"/>
|
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
@ -1,22 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<databaseChangeLog
|
|
||||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd">
|
|
||||||
|
|
||||||
<changeSet id="2022-12-05-create-table-reviewers" author="uPagge">
|
|
||||||
<createTable tableName="merge_request_reviewer">
|
|
||||||
<column name="merge_request_id" type="int">
|
|
||||||
<constraints nullable="false" foreignKeyName="fk_merge_request_reviewer_merge_request_id"
|
|
||||||
references="merge_request(id)" deleteCascade="true"/>
|
|
||||||
</column>
|
|
||||||
<column name="person_id" type="int">
|
|
||||||
<constraints nullable="false" foreignKeyName="fk_merge_request_reviewer_person_id"
|
|
||||||
references="person(id)" deleteCascade="true"/>
|
|
||||||
</column>
|
|
||||||
</createTable>
|
|
||||||
|
|
||||||
<addPrimaryKey tableName="merge_request_reviewer" columnNames="merge_request_id, person_id"/>
|
|
||||||
</changeSet>
|
|
||||||
|
|
||||||
</databaseChangeLog>
|
|
@ -1,12 +0,0 @@
|
|||||||
<databaseChangeLog
|
|
||||||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
|
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd">
|
|
||||||
|
|
||||||
<changeSet id="2022-12-05-add-tab-v-1-0-0" author="uPagge">
|
|
||||||
<tagDatabase tag="v.1.1.3"/>
|
|
||||||
</changeSet>
|
|
||||||
|
|
||||||
<include file="2022-12-05-add-reviewers.xml" relativeToChangelogFile="true"/>
|
|
||||||
|
|
||||||
</databaseChangeLog>
|
|
@ -96,10 +96,15 @@
|
|||||||
<column name="notification" type="boolean">
|
<column name="notification" type="boolean">
|
||||||
<constraints nullable="false"/>
|
<constraints nullable="false"/>
|
||||||
</column>
|
</column>
|
||||||
|
<column name="is_assignee" type="boolean">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
|
<column name="is_reviewer" type="boolean">
|
||||||
|
<constraints nullable="false"/>
|
||||||
|
</column>
|
||||||
<column name="date_last_commit" type="datetime"/>
|
<column name="date_last_commit" type="datetime"/>
|
||||||
</createTable>
|
</createTable>
|
||||||
|
|
||||||
|
|
||||||
<createIndex tableName="merge_request" indexName="i_merge_request_project_id">
|
<createIndex tableName="merge_request" indexName="i_merge_request_project_id">
|
||||||
<column name="project_id"/>
|
<column name="project_id"/>
|
||||||
</createIndex>
|
</createIndex>
|
||||||
@ -112,12 +117,7 @@
|
|||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
<changeSet id="2022-12-03-create-table-labels" author="uPagge">
|
<changeSet id="2022-12-03-create-table-labels" author="uPagge">
|
||||||
<createSequence sequenceName="seq_merge_request" startValue="1" incrementBy="1" cacheSize="20"/>
|
|
||||||
|
|
||||||
<createTable tableName="merge_request_label">
|
<createTable tableName="merge_request_label">
|
||||||
<column name="id" type="int" defaultValueSequenceNext="seq_merge_request">
|
|
||||||
<constraints nullable="false" primaryKey="true"/>
|
|
||||||
</column>
|
|
||||||
<column name="merge_request_id" type="int">
|
<column name="merge_request_id" type="int">
|
||||||
<constraints nullable="false" foreignKeyName="merge_request_label_merge_request_id"
|
<constraints nullable="false" foreignKeyName="merge_request_label_merge_request_id"
|
||||||
references="merge_request(id)" deleteCascade="true"/>
|
references="merge_request(id)" deleteCascade="true"/>
|
||||||
@ -236,4 +236,19 @@
|
|||||||
</createIndex>
|
</createIndex>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="2022-12-05-create-table-reviewers" author="uPagge">
|
||||||
|
<createTable tableName="merge_request_reviewer">
|
||||||
|
<column name="merge_request_id" type="int">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_merge_request_reviewer_merge_request_id"
|
||||||
|
references="merge_request(id)" deleteCascade="true"/>
|
||||||
|
</column>
|
||||||
|
<column name="person_id" type="int">
|
||||||
|
<constraints nullable="false" foreignKeyName="fk_merge_request_reviewer_person_id"
|
||||||
|
references="person(id)" deleteCascade="true"/>
|
||||||
|
</column>
|
||||||
|
</createTable>
|
||||||
|
|
||||||
|
<addPrimaryKey tableName="merge_request_reviewer" columnNames="merge_request_id, person_id"/>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
@ -19,9 +19,11 @@ import dev.struchkov.godfather.telegram.domain.config.TelegramConnectConfig;
|
|||||||
import dev.struchkov.godfather.telegram.main.context.TelegramConnect;
|
import dev.struchkov.godfather.telegram.main.context.TelegramConnect;
|
||||||
import dev.struchkov.godfather.telegram.simple.consumer.EventDistributorService;
|
import dev.struchkov.godfather.telegram.simple.consumer.EventDistributorService;
|
||||||
import dev.struchkov.godfather.telegram.simple.context.service.EventDistributor;
|
import dev.struchkov.godfather.telegram.simple.context.service.EventDistributor;
|
||||||
|
import dev.struchkov.godfather.telegram.simple.context.service.SenderStorageService;
|
||||||
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
|
import dev.struchkov.godfather.telegram.simple.context.service.TelegramSending;
|
||||||
import dev.struchkov.godfather.telegram.simple.core.MailAutoresponderTelegram;
|
import dev.struchkov.godfather.telegram.simple.core.MailAutoresponderTelegram;
|
||||||
import dev.struchkov.godfather.telegram.simple.core.TelegramConnectBot;
|
import dev.struchkov.godfather.telegram.simple.core.TelegramConnectBot;
|
||||||
|
import dev.struchkov.godfather.telegram.simple.core.service.SenderMapStorageService;
|
||||||
import dev.struchkov.godfather.telegram.simple.sender.TelegramSender;
|
import dev.struchkov.godfather.telegram.simple.sender.TelegramSender;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
@ -76,13 +78,20 @@ public class TelegramBotConfig {
|
|||||||
return autoresponder;
|
return autoresponder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
public SenderStorageService senderStorageService() {
|
||||||
|
return new SenderMapStorageService();
|
||||||
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public TelegramSending sending(
|
public TelegramSending sending(
|
||||||
TelegramConnect telegramConnect,
|
TelegramConnect telegramConnect,
|
||||||
|
SenderStorageService senderStorageService,
|
||||||
ReplaceUrlLocalhost replaceUrlLocalhost
|
ReplaceUrlLocalhost replaceUrlLocalhost
|
||||||
) {
|
) {
|
||||||
final TelegramSender telegramSender = new TelegramSender(telegramConnect);
|
final TelegramSender telegramSender = new TelegramSender(telegramConnect);
|
||||||
telegramSender.setSendPreProcessing(replaceUrlLocalhost);
|
telegramSender.setSendPreProcessing(replaceUrlLocalhost);
|
||||||
|
telegramSender.setSenderRepository(senderStorageService);
|
||||||
return telegramSender;
|
return telegramSender;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@ 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.core.service.parser.ProjectParser;
|
import dev.struchkov.bot.gitlab.core.service.parser.ProjectParser;
|
||||||
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;
|
||||||
@ -36,6 +37,7 @@ import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.PARSE_OWNER_PROJE
|
|||||||
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_PARSE_OWNER_PROJECT;
|
import static dev.struchkov.bot.gitlab.telegram.utils.UnitName.TEXT_PARSE_OWNER_PROJECT;
|
||||||
import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
||||||
|
import static dev.struchkov.godfather.main.domain.BoxAnswer.replaceBoxAnswer;
|
||||||
import static dev.struchkov.godfather.main.domain.keyboard.button.SimpleButton.simpleButton;
|
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.keyboard.simple.SimpleKeyBoardLine.simpleLine;
|
||||||
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
|
import static dev.struchkov.godfather.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
|
||||||
@ -54,6 +56,8 @@ public class UnitConfig {
|
|||||||
private final AppSettingService settingService;
|
private final AppSettingService settingService;
|
||||||
private final NoteService noteService;
|
private final NoteService noteService;
|
||||||
private final DiscussionService discussionService;
|
private final DiscussionService discussionService;
|
||||||
|
private final NotifyService notifyService;
|
||||||
|
|
||||||
private final ProjectParser projectParser;
|
private final ProjectParser projectParser;
|
||||||
|
|
||||||
@Unit(value = CHECK_FIRST_START, main = true)
|
@Unit(value = CHECK_FIRST_START, main = true)
|
||||||
@ -109,7 +113,7 @@ public class UnitConfig {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return boxAnswer("Ошибка");
|
return boxAnswer("Error");
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.build();
|
.build();
|
||||||
@ -120,8 +124,7 @@ public class UnitConfig {
|
|||||||
@Unit(CHECK_PARSER_PRIVATE_PROJECT) MainUnit<Mail> checkParserPrivateProject
|
@Unit(CHECK_PARSER_PRIVATE_PROJECT) MainUnit<Mail> checkParserPrivateProject
|
||||||
) {
|
) {
|
||||||
return AnswerText.<Mail>builder()
|
return AnswerText.<Mail>builder()
|
||||||
.answer(
|
.answer(() -> boxAnswer(
|
||||||
boxAnswer(
|
|
||||||
"Start tracking private projects?",
|
"Start tracking private projects?",
|
||||||
inlineKeyBoard(
|
inlineKeyBoard(
|
||||||
simpleLine(
|
simpleLine(
|
||||||
@ -143,6 +146,7 @@ public class UnitConfig {
|
|||||||
) {
|
) {
|
||||||
return AnswerCheck.<Mail>builder()
|
return AnswerCheck.<Mail>builder()
|
||||||
.check(mail -> "YES".equalsIgnoreCase(mail.getText()))
|
.check(mail -> "YES".equalsIgnoreCase(mail.getText()))
|
||||||
|
.intermediateAnswerIfTrue(replaceBoxAnswer("Scanning of private projects has begun. Wait..."))
|
||||||
.unitTrue(parserPrivateProject)
|
.unitTrue(parserPrivateProject)
|
||||||
.unitFalse(textParseOwnerProject)
|
.unitFalse(textParseOwnerProject)
|
||||||
.build();
|
.build();
|
||||||
@ -154,8 +158,9 @@ public class UnitConfig {
|
|||||||
) {
|
) {
|
||||||
return AnswerText.<Mail>builder()
|
return AnswerText.<Mail>builder()
|
||||||
.answer(() -> {
|
.answer(() -> {
|
||||||
|
notifyService.disableAllNotify();
|
||||||
projectParser.parseAllPrivateProject();
|
projectParser.parseAllPrivateProject();
|
||||||
return boxAnswer("Projects have been successfully added to tracking");
|
return replaceBoxAnswer("Projects have been successfully added to tracking");
|
||||||
})
|
})
|
||||||
.next(textParseOwnerProject)
|
.next(textParseOwnerProject)
|
||||||
.build();
|
.build();
|
||||||
@ -189,6 +194,7 @@ public class UnitConfig {
|
|||||||
) {
|
) {
|
||||||
return AnswerCheck.<Mail>builder()
|
return AnswerCheck.<Mail>builder()
|
||||||
.check(message -> "YES".equalsIgnoreCase(message.getText()))
|
.check(message -> "YES".equalsIgnoreCase(message.getText()))
|
||||||
|
.intermediateAnswerIfTrue(replaceBoxAnswer("Scanning of public projects has begun. Wait..."))
|
||||||
.unitTrue(parseOwnerProject)
|
.unitTrue(parseOwnerProject)
|
||||||
.unitFalse(endSetting)
|
.unitFalse(endSetting)
|
||||||
.build();
|
.build();
|
||||||
@ -201,7 +207,7 @@ public class UnitConfig {
|
|||||||
return AnswerText.<Mail>builder()
|
return AnswerText.<Mail>builder()
|
||||||
.answer(() -> {
|
.answer(() -> {
|
||||||
projectParser.parseAllProjectOwner();
|
projectParser.parseAllProjectOwner();
|
||||||
return boxAnswer("Projects have been successfully added to tracking");
|
return replaceBoxAnswer("Projects have been successfully added to tracking");
|
||||||
})
|
})
|
||||||
.next(endSetting)
|
.next(endSetting)
|
||||||
.build();
|
.build();
|
||||||
@ -213,7 +219,8 @@ public class UnitConfig {
|
|||||||
.answer(
|
.answer(
|
||||||
() -> {
|
() -> {
|
||||||
settingService.disableFirstStart();
|
settingService.disableFirstStart();
|
||||||
return boxAnswer("""
|
notifyService.enableAllNotify();
|
||||||
|
return replaceBoxAnswer("""
|
||||||
Configuration completed successfully
|
Configuration completed successfully
|
||||||
Developer: [uPagge](https://mark.struchkov.dev)
|
Developer: [uPagge](https://mark.struchkov.dev)
|
||||||
""");
|
""");
|
||||||
|
Loading…
Reference in New Issue
Block a user