Compare commits
3 Commits
03b8675c78
...
b6fd20cd05
Author | SHA1 | Date | |
---|---|---|---|
b6fd20cd05 | |||
ec48b5ee1d | |||
f2bd5247ae |
@ -4,14 +4,14 @@ import lombok.Builder;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class ConflictPrNotify extends PrNotify {
|
public class ConflictMrNotify extends MrNotify {
|
||||||
|
|
||||||
public static final String TYPE = "ConflictPrNotify";
|
public static final String TYPE = "ConflictPrNotify";
|
||||||
|
|
||||||
private final String sourceBranch;
|
private final String sourceBranch;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
private ConflictPrNotify(
|
private ConflictMrNotify(
|
||||||
String name,
|
String name,
|
||||||
String url,
|
String url,
|
||||||
String projectKey,
|
String projectKey,
|
@ -4,13 +4,13 @@ import dev.struchkov.bot.gitlab.context.domain.notify.Notify;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public abstract class PrNotify implements Notify {
|
public abstract class MrNotify implements Notify {
|
||||||
|
|
||||||
protected final String projectName;
|
protected final String projectName;
|
||||||
protected final String title;
|
protected final String title;
|
||||||
protected final String url;
|
protected final String url;
|
||||||
|
|
||||||
protected PrNotify(
|
protected MrNotify(
|
||||||
String projectName,
|
String projectName,
|
||||||
String title,
|
String title,
|
||||||
String url
|
String url
|
@ -0,0 +1,41 @@
|
|||||||
|
package dev.struchkov.bot.gitlab.context.domain.notify.mergerequest;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class NewMrForAssignee extends NewMrNotify {
|
||||||
|
|
||||||
|
public static final String TYPE = "NewMrForAssignee";
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
private NewMrForAssignee(
|
||||||
|
String title,
|
||||||
|
String url,
|
||||||
|
String description,
|
||||||
|
String author,
|
||||||
|
String projectName,
|
||||||
|
String targetBranch,
|
||||||
|
String sourceBranch,
|
||||||
|
Set<String> labels
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
title,
|
||||||
|
url,
|
||||||
|
description,
|
||||||
|
author,
|
||||||
|
projectName,
|
||||||
|
targetBranch,
|
||||||
|
sourceBranch,
|
||||||
|
labels
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package dev.struchkov.bot.gitlab.context.domain.notify.mergerequest;
|
||||||
|
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class NewMrForReview extends NewMrNotify {
|
||||||
|
|
||||||
|
public static final String TYPE = "NewMrForReview";
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
private NewMrForReview(
|
||||||
|
String title,
|
||||||
|
String url,
|
||||||
|
String description,
|
||||||
|
String author,
|
||||||
|
String projectName,
|
||||||
|
String targetBranch,
|
||||||
|
String sourceBranch,
|
||||||
|
Set<String> labels
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
title,
|
||||||
|
url,
|
||||||
|
description,
|
||||||
|
author,
|
||||||
|
projectName,
|
||||||
|
targetBranch,
|
||||||
|
sourceBranch,
|
||||||
|
labels
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,23 +1,19 @@
|
|||||||
package dev.struchkov.bot.gitlab.context.domain.notify.mergerequest;
|
package dev.struchkov.bot.gitlab.context.domain.notify.mergerequest;
|
||||||
|
|
||||||
import lombok.Builder;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class NewPrNotify extends PrNotify {
|
public abstract class NewMrNotify extends MrNotify {
|
||||||
|
|
||||||
public static final String TYPE = "NewPrNotify";
|
protected final String description;
|
||||||
|
protected final String author;
|
||||||
|
protected final String targetBranch;
|
||||||
|
protected final String sourceBranch;
|
||||||
|
protected final Set<String> labels;
|
||||||
|
|
||||||
private final String description;
|
protected NewMrNotify(
|
||||||
private final String author;
|
|
||||||
private final String targetBranch;
|
|
||||||
private final String sourceBranch;
|
|
||||||
private final Set<String> labels;
|
|
||||||
|
|
||||||
@Builder
|
|
||||||
private NewPrNotify(
|
|
||||||
String title,
|
String title,
|
||||||
String url,
|
String url,
|
||||||
String description,
|
String description,
|
||||||
@ -35,9 +31,4 @@ public class NewPrNotify extends PrNotify {
|
|||||||
this.labels = labels;
|
this.labels = labels;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getType() {
|
|
||||||
return TYPE;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import lombok.Builder;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class StatusPrNotify extends PrNotify {
|
public class StatusMrNotify extends MrNotify {
|
||||||
|
|
||||||
public static final String TYPE = "StatusPrNotify";
|
public static final String TYPE = "StatusPrNotify";
|
||||||
|
|
||||||
@ -13,7 +13,7 @@ public class StatusPrNotify extends PrNotify {
|
|||||||
private final MergeRequestState newStatus;
|
private final MergeRequestState newStatus;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
private StatusPrNotify(
|
private StatusMrNotify(
|
||||||
String name,
|
String name,
|
||||||
String url,
|
String url,
|
||||||
String projectName,
|
String projectName,
|
@ -4,7 +4,7 @@ import lombok.Builder;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class UpdatePrNotify extends PrNotify {
|
public class UpdateMrNotify extends MrNotify {
|
||||||
|
|
||||||
public static final String TYPE = "UpdatePrNotify";
|
public static final String TYPE = "UpdatePrNotify";
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ public class UpdatePrNotify extends PrNotify {
|
|||||||
private final Long personResolvedTasks;
|
private final Long personResolvedTasks;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
private UpdatePrNotify(
|
private UpdateMrNotify(
|
||||||
String name,
|
String name,
|
||||||
String url,
|
String url,
|
||||||
String author,
|
String author,
|
@ -17,6 +17,7 @@ public class Icons {
|
|||||||
public static final String ARROW = " ➜ ";
|
public static final String ARROW = " ➜ ";
|
||||||
public static final String DANGEROUS = "⚠️";
|
public static final String DANGEROUS = "⚠️";
|
||||||
public static final String PEN = "✏️";
|
public static final String PEN = "✏️";
|
||||||
|
public static final String ASSIGNEE = "\uD83C\uDF96";
|
||||||
public static final String BUILD = "\uD83D\uDEE0";
|
public static final String BUILD = "\uD83D\uDEE0";
|
||||||
public static final String LINK = "\uD83D\uDD17";
|
public static final String LINK = "\uD83D\uDD17";
|
||||||
|
|
||||||
|
@ -11,10 +11,11 @@ import dev.struchkov.bot.gitlab.context.domain.entity.MergeRequest;
|
|||||||
import dev.struchkov.bot.gitlab.context.domain.entity.MergeRequestForDiscussion;
|
import dev.struchkov.bot.gitlab.context.domain.entity.MergeRequestForDiscussion;
|
||||||
import dev.struchkov.bot.gitlab.context.domain.entity.Person;
|
import dev.struchkov.bot.gitlab.context.domain.entity.Person;
|
||||||
import dev.struchkov.bot.gitlab.context.domain.entity.Project;
|
import dev.struchkov.bot.gitlab.context.domain.entity.Project;
|
||||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.ConflictPrNotify;
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.ConflictMrNotify;
|
||||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.NewPrNotify;
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.NewMrForAssignee;
|
||||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.StatusPrNotify;
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.NewMrForReview;
|
||||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.UpdatePrNotify;
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.StatusMrNotify;
|
||||||
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.UpdateMrNotify;
|
||||||
import dev.struchkov.bot.gitlab.context.repository.MergeRequestRepository;
|
import dev.struchkov.bot.gitlab.context.repository.MergeRequestRepository;
|
||||||
import dev.struchkov.bot.gitlab.context.service.DiscussionService;
|
import dev.struchkov.bot.gitlab.context.service.DiscussionService;
|
||||||
import dev.struchkov.bot.gitlab.context.service.MergeRequestsService;
|
import dev.struchkov.bot.gitlab.context.service.MergeRequestsService;
|
||||||
@ -67,7 +68,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
if (botUserReviewer || botUserAssignee) {
|
if (botUserReviewer || botUserAssignee) {
|
||||||
if (!mergeRequest.isConflict()) {
|
if (!mergeRequest.isConflict()) {
|
||||||
final String projectName = projectService.getByIdOrThrow(savedMergeRequest.getProjectId()).getName();
|
final String projectName = projectService.getByIdOrThrow(savedMergeRequest.getProjectId()).getName();
|
||||||
if (botUserReviewer) sendNotifyAboutNewMr(savedMergeRequest, projectName);
|
if (botUserReviewer) sendNotifyNewMrReview(savedMergeRequest, projectName);
|
||||||
if (botUserAssignee) sendNotifyAboutAssignee(mergeRequest, projectName);
|
if (botUserAssignee) sendNotifyAboutAssignee(mergeRequest, projectName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,9 +112,9 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendNotifyAboutNewMr(MergeRequest mergeRequest, String projectName) {
|
private void sendNotifyNewMrReview(MergeRequest mergeRequest, String projectName) {
|
||||||
notifyService.send(
|
notifyService.send(
|
||||||
NewPrNotify.builder()
|
NewMrForReview.builder()
|
||||||
.projectName(projectName)
|
.projectName(projectName)
|
||||||
.labels(mergeRequest.getLabels())
|
.labels(mergeRequest.getLabels())
|
||||||
.author(mergeRequest.getAuthor().getName())
|
.author(mergeRequest.getAuthor().getName())
|
||||||
@ -128,7 +129,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
|
|
||||||
private void sendNotifyAboutAssignee(MergeRequest mergeRequest, String projectName) {
|
private void sendNotifyAboutAssignee(MergeRequest mergeRequest, String projectName) {
|
||||||
notifyService.send(
|
notifyService.send(
|
||||||
NewPrNotify.builder()
|
NewMrForAssignee.builder()
|
||||||
.projectName(projectName)
|
.projectName(projectName)
|
||||||
.labels(mergeRequest.getLabels())
|
.labels(mergeRequest.getLabels())
|
||||||
.author(mergeRequest.getAuthor().getName())
|
.author(mergeRequest.getAuthor().getName())
|
||||||
@ -156,28 +157,26 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
mergeRequest.setUserAssignee(assigneeChanged.getNewStatus(oldMergeRequest.isUserAssignee()));
|
mergeRequest.setUserAssignee(assigneeChanged.getNewStatus(oldMergeRequest.isUserAssignee()));
|
||||||
mergeRequest.setUserReviewer(reviewerChanged.getNewStatus(oldMergeRequest.isUserReviewer()));
|
mergeRequest.setUserReviewer(reviewerChanged.getNewStatus(oldMergeRequest.isUserReviewer()));
|
||||||
|
|
||||||
final boolean isChangedMr = !oldMergeRequest.getUpdatedDate().equals(mergeRequest.getUpdatedDate())
|
final boolean isChangedMr = !oldMergeRequest.getUpdatedDate().equals(mergeRequest.getUpdatedDate()) || oldMergeRequest.isConflict() != mergeRequest.isConflict();
|
||||||
|| 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 MergeRequest savedMergeRequest = repository.save(mergeRequest);
|
|
||||||
|
|
||||||
if (oldMergeRequest.isNotification()) {
|
if (oldMergeRequest.isNotification()) {
|
||||||
final Project project = projectService.getByIdOrThrow(mergeRequest.getProjectId());
|
final Project project = projectService.getByIdOrThrow(mergeRequest.getProjectId());
|
||||||
|
|
||||||
if (isChangedMr) {
|
if (isChangedMr) {
|
||||||
notifyAboutStatus(oldMergeRequest, savedMergeRequest, project);
|
notifyAboutStatus(oldMergeRequest, mergeRequest, project);
|
||||||
notifyAboutConflict(oldMergeRequest, savedMergeRequest, project);
|
notifyAboutConflict(oldMergeRequest, mergeRequest, project);
|
||||||
notifyAboutUpdate(oldMergeRequest, savedMergeRequest, project);
|
notifyAboutUpdate(oldMergeRequest, mergeRequest, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isChangedLinkedEntity) {
|
if (isChangedLinkedEntity) {
|
||||||
notifyReviewer(reviewerChanged, savedMergeRequest, project);
|
notifyReviewer(reviewerChanged, mergeRequest, project);
|
||||||
notifyAssignee(assigneeChanged, savedMergeRequest, project);
|
notifyAssignee(assigneeChanged, mergeRequest, project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return savedMergeRequest;
|
return repository.save(mergeRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
return oldMergeRequest;
|
return oldMergeRequest;
|
||||||
@ -187,15 +186,14 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
//TODO [05.12.2022|uPagge]: Добавить уведомление, если происходит удаление
|
//TODO [05.12.2022|uPagge]: Добавить уведомление, если происходит удаление
|
||||||
private void notifyAssignee(AssigneeChanged assigneeChanged, MergeRequest mergeRequest, Project project) {
|
private void notifyAssignee(AssigneeChanged assigneeChanged, MergeRequest mergeRequest, Project project) {
|
||||||
switch (assigneeChanged) {
|
switch (assigneeChanged) {
|
||||||
case BECOME -> sendNotifyAboutNewMr(mergeRequest, project.getName());
|
case BECOME -> sendNotifyAboutAssignee(mergeRequest, project.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO [05.12.2022|uPagge]: Добавить уведомление, если происходит удаление ревьювера
|
//TODO [05.12.2022|uPagge]: Добавить уведомление, если происходит удаление ревьювера
|
||||||
//TODO [05.12.2022|uPagge]: Заменить тип уведомления на самостоятельный
|
|
||||||
private void notifyReviewer(ReviewerChanged reviewerChanged, MergeRequest mergeRequest, Project project) {
|
private void notifyReviewer(ReviewerChanged reviewerChanged, MergeRequest mergeRequest, Project project) {
|
||||||
switch (reviewerChanged) {
|
switch (reviewerChanged) {
|
||||||
case BECOME -> sendNotifyAboutNewMr(mergeRequest, project.getName());
|
case BECOME -> sendNotifyNewMrReview(mergeRequest, project.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +259,8 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
!botUserGitlabId.equals(mergeRequest.getAuthor().getId()) // Автор MR не пользователь приложения
|
!botUserGitlabId.equals(mergeRequest.getAuthor().getId()) // Автор MR не пользователь приложения
|
||||||
&& !oldMergeRequest.getDateLastCommit().equals(mergeRequest.getDateLastCommit()) // Изменилась дата последнего коммита
|
&& !oldMergeRequest.getDateLastCommit().equals(mergeRequest.getDateLastCommit()) // Изменилась дата последнего коммита
|
||||||
&& !mergeRequest.isConflict() // MR не находится в состоянии конфликта
|
&& !mergeRequest.isConflict() // MR не находится в состоянии конфликта
|
||||||
) {
|
) {
|
||||||
|
|
||||||
long allTask = 0;
|
long allTask = 0;
|
||||||
@ -286,7 +284,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyService.send(
|
notifyService.send(
|
||||||
UpdatePrNotify.builder()
|
UpdateMrNotify.builder()
|
||||||
.author(oldMergeRequest.getAuthor().getName())
|
.author(oldMergeRequest.getAuthor().getName())
|
||||||
.name(oldMergeRequest.getTitle())
|
.name(oldMergeRequest.getTitle())
|
||||||
.projectKey(project.getName())
|
.projectKey(project.getName())
|
||||||
@ -304,11 +302,11 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
final Long gitlabUserId = personInformation.getId();
|
final Long gitlabUserId = personInformation.getId();
|
||||||
if (
|
if (
|
||||||
!oldMergeRequest.isConflict() // У старого MR не было конфликта
|
!oldMergeRequest.isConflict() // У старого MR не было конфликта
|
||||||
&& mergeRequest.isConflict() // А у нового есть
|
&& mergeRequest.isConflict() // А у нового есть
|
||||||
&& gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // и MR создан пользователем бота
|
&& gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // и MR создан пользователем бота
|
||||||
) {
|
) {
|
||||||
notifyService.send(
|
notifyService.send(
|
||||||
ConflictPrNotify.builder()
|
ConflictMrNotify.builder()
|
||||||
.sourceBranch(oldMergeRequest.getSourceBranch())
|
.sourceBranch(oldMergeRequest.getSourceBranch())
|
||||||
.name(mergeRequest.getTitle())
|
.name(mergeRequest.getTitle())
|
||||||
.url(mergeRequest.getWebUrl())
|
.url(mergeRequest.getWebUrl())
|
||||||
@ -324,10 +322,10 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
|||||||
final Long gitlabUserId = personInformation.getId();
|
final Long gitlabUserId = personInformation.getId();
|
||||||
if (
|
if (
|
||||||
!oldStatus.equals(newStatus) // статус изменился
|
!oldStatus.equals(newStatus) // статус изменился
|
||||||
&& gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // создатель MR является пользователем бота
|
&& gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // создатель MR является пользователем бота
|
||||||
) {
|
) {
|
||||||
notifyService.send(
|
notifyService.send(
|
||||||
StatusPrNotify.builder()
|
StatusMrNotify.builder()
|
||||||
.name(newMergeRequest.getTitle())
|
.name(newMergeRequest.getTitle())
|
||||||
.url(oldMergeRequest.getWebUrl())
|
.url(oldMergeRequest.getWebUrl())
|
||||||
.projectName(project.getName())
|
.projectName(project.getName())
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.struchkov.bot.gitlab.telegram.service.notify;
|
package dev.struchkov.bot.gitlab.telegram.service.notify;
|
||||||
|
|
||||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.ConflictPrNotify;
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.ConflictMrNotify;
|
||||||
import dev.struchkov.bot.gitlab.context.utils.Icons;
|
import dev.struchkov.bot.gitlab.context.utils.Icons;
|
||||||
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -10,10 +10,10 @@ import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
|||||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class ConflictPrNotifyGenerator implements NotifyBoxAnswerGenerator<ConflictPrNotify> {
|
public class ConflictPrNotifyGenerator implements NotifyBoxAnswerGenerator<ConflictMrNotify> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoxAnswer generate(ConflictPrNotify notify) {
|
public BoxAnswer generate(ConflictMrNotify notify) {
|
||||||
|
|
||||||
final StringBuilder builder = new StringBuilder(Icons.DANGEROUS).append(" *Attention! MergeRequest conflict | ").append(escapeMarkdown(notify.getProjectName())).append("*")
|
final StringBuilder builder = new StringBuilder(Icons.DANGEROUS).append(" *Attention! MergeRequest conflict | ").append(escapeMarkdown(notify.getProjectName())).append("*")
|
||||||
.append(Icons.HR)
|
.append(Icons.HR)
|
||||||
@ -25,7 +25,7 @@ public class ConflictPrNotifyGenerator implements NotifyBoxAnswerGenerator<Confl
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNotifyType() {
|
public String getNotifyType() {
|
||||||
return ConflictPrNotify.TYPE;
|
return ConflictMrNotify.TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public class NewCommentNotifyGenerator implements NotifyBoxAnswerGenerator<NewCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoxAnswer generate(NewCommentNotify notify) {
|
public BoxAnswer generate(NewCommentNotify notify) {
|
||||||
final StringBuilder builder = new StringBuilder(Smile.COMMENT.getValue()).append(" [New answer in discussion](").append(notify.getUrl()).append(")\n--- --- --- ---");
|
final StringBuilder builder = new StringBuilder(Smile.COMMENT.getValue()).append(" [New answer in discussion](").append(notify.getUrl()).append(")");
|
||||||
|
|
||||||
if (checkNotNull(notify.getDiscussionMessage())) {
|
if (checkNotNull(notify.getDiscussionMessage())) {
|
||||||
builder.append("\n-- -- discussion first message -- --\n")
|
builder.append("\n-- -- discussion first message -- --\n")
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
package dev.struchkov.bot.gitlab.telegram.service.notify;
|
||||||
|
|
||||||
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.NewMrForAssignee;
|
||||||
|
import dev.struchkov.bot.gitlab.context.utils.Icons;
|
||||||
|
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import static dev.struchkov.bot.gitlab.context.utils.Icons.link;
|
||||||
|
import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
||||||
|
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class NewMrForAssigneeNotifyGenerator implements NotifyBoxAnswerGenerator<NewMrForAssignee> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BoxAnswer generate(NewMrForAssignee notify) {
|
||||||
|
final String labelText = notify.getLabels().stream()
|
||||||
|
.map(label -> "#" + label)
|
||||||
|
.collect(Collectors.joining(" "));
|
||||||
|
|
||||||
|
|
||||||
|
final StringBuilder builder = new StringBuilder(Icons.ASSIGNEE).append(" *You have become responsible | ").append(escapeMarkdown(notify.getProjectName())).append("*")
|
||||||
|
.append(Icons.HR)
|
||||||
|
.append(link(notify.getType(), notify.getUrl()));
|
||||||
|
|
||||||
|
if (!labelText.isEmpty()) {
|
||||||
|
builder.append("\n\n").append(labelText);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.append(Icons.HR)
|
||||||
|
.append(Icons.TREE).append(": ").append(notify.getSourceBranch()).append(Icons.ARROW).append(notify.getTargetBranch()).append("\n")
|
||||||
|
.append(Icons.AUTHOR).append(": ").append(notify.getAuthor());
|
||||||
|
|
||||||
|
final String notifyMessage = builder.toString();
|
||||||
|
return boxAnswer(notifyMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNotifyType() {
|
||||||
|
return NewMrForAssignee.TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package dev.struchkov.bot.gitlab.telegram.service.notify;
|
package dev.struchkov.bot.gitlab.telegram.service.notify;
|
||||||
|
|
||||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.NewPrNotify;
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.NewMrForReview;
|
||||||
import dev.struchkov.bot.gitlab.context.utils.Icons;
|
import dev.struchkov.bot.gitlab.context.utils.Icons;
|
||||||
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -12,10 +12,10 @@ import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
|||||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class NewPrNotifyGenerator implements NotifyBoxAnswerGenerator<NewPrNotify> {
|
public class NewMrForReviewNotifyGenerator implements NotifyBoxAnswerGenerator<NewMrForReview> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoxAnswer generate(NewPrNotify notify) {
|
public BoxAnswer generate(NewMrForReview notify) {
|
||||||
final String labelText = notify.getLabels().stream()
|
final String labelText = notify.getLabels().stream()
|
||||||
.map(label -> "#" + label)
|
.map(label -> "#" + label)
|
||||||
.collect(Collectors.joining(" "));
|
.collect(Collectors.joining(" "));
|
||||||
@ -39,7 +39,7 @@ public class NewPrNotifyGenerator implements NotifyBoxAnswerGenerator<NewPrNotif
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNotifyType() {
|
public String getNotifyType() {
|
||||||
return NewPrNotify.TYPE;
|
return NewMrForReview.TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package dev.struchkov.bot.gitlab.telegram.service.notify;
|
package dev.struchkov.bot.gitlab.telegram.service.notify;
|
||||||
|
|
||||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.StatusPrNotify;
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.StatusMrNotify;
|
||||||
import dev.struchkov.bot.gitlab.context.utils.Icons;
|
import dev.struchkov.bot.gitlab.context.utils.Icons;
|
||||||
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -9,10 +9,10 @@ import static dev.struchkov.bot.gitlab.context.utils.Icons.link;
|
|||||||
import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class StatusPrNotifyGenerator implements NotifyBoxAnswerGenerator<StatusPrNotify> {
|
public class StatusPrNotifyGenerator implements NotifyBoxAnswerGenerator<StatusMrNotify> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoxAnswer generate(StatusPrNotify notify) {
|
public BoxAnswer generate(StatusMrNotify notify) {
|
||||||
|
|
||||||
final StringBuilder builder = new StringBuilder(Icons.PEN).append(" *MergeRequest status changed | ").append(notify.getProjectName()).append("*")
|
final StringBuilder builder = new StringBuilder(Icons.PEN).append(" *MergeRequest status changed | ").append(notify.getProjectName()).append("*")
|
||||||
.append(Icons.HR)
|
.append(Icons.HR)
|
||||||
@ -27,7 +27,7 @@ public class StatusPrNotifyGenerator implements NotifyBoxAnswerGenerator<StatusP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNotifyType() {
|
public String getNotifyType() {
|
||||||
return StatusPrNotify.TYPE;
|
return StatusMrNotify.TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.struchkov.bot.gitlab.telegram.service.notify;
|
package dev.struchkov.bot.gitlab.telegram.service.notify;
|
||||||
|
|
||||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.UpdatePrNotify;
|
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.UpdateMrNotify;
|
||||||
import dev.struchkov.bot.gitlab.context.utils.Icons;
|
import dev.struchkov.bot.gitlab.context.utils.Icons;
|
||||||
import dev.struchkov.bot.gitlab.context.utils.Smile;
|
import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||||
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
import dev.struchkov.godfather.main.domain.BoxAnswer;
|
||||||
@ -11,10 +11,10 @@ import static dev.struchkov.godfather.main.domain.BoxAnswer.boxAnswer;
|
|||||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class UpdatePrNotifyGenerator implements NotifyBoxAnswerGenerator<UpdatePrNotify> {
|
public class UpdatePrNotifyGenerator implements NotifyBoxAnswerGenerator<UpdateMrNotify> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BoxAnswer generate(UpdatePrNotify notify) {
|
public BoxAnswer generate(UpdateMrNotify notify) {
|
||||||
|
|
||||||
final StringBuilder builder = new StringBuilder(Icons.UPDATE).append(" *MergeRequest update | ").append(escapeMarkdown(notify.getProjectName())).append("*")
|
final StringBuilder builder = new StringBuilder(Icons.UPDATE).append(" *MergeRequest update | ").append(escapeMarkdown(notify.getProjectName())).append("*")
|
||||||
.append(Smile.HR.getValue())
|
.append(Smile.HR.getValue())
|
||||||
@ -38,7 +38,7 @@ public class UpdatePrNotifyGenerator implements NotifyBoxAnswerGenerator<UpdateP
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getNotifyType() {
|
public String getNotifyType() {
|
||||||
return UpdatePrNotify.TYPE;
|
return UpdateMrNotify.TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user