Поправил уведомление о назначении в качестве ответсвенного
This commit is contained in:
parent
f2bd5247ae
commit
ec48b5ee1d
@ -4,14 +4,14 @@ import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class ConflictPrNotify extends PrNotify {
|
||||
public class ConflictMrNotify extends MrNotify {
|
||||
|
||||
public static final String TYPE = "ConflictPrNotify";
|
||||
|
||||
private final String sourceBranch;
|
||||
|
||||
@Builder
|
||||
private ConflictPrNotify(
|
||||
private ConflictMrNotify(
|
||||
String name,
|
||||
String url,
|
||||
String projectKey,
|
@ -4,13 +4,13 @@ import dev.struchkov.bot.gitlab.context.domain.notify.Notify;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public abstract class PrNotify implements Notify {
|
||||
public abstract class MrNotify implements Notify {
|
||||
|
||||
protected final String projectName;
|
||||
protected final String title;
|
||||
protected final String url;
|
||||
|
||||
protected PrNotify(
|
||||
protected MrNotify(
|
||||
String projectName,
|
||||
String title,
|
||||
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;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@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;
|
||||
private final String author;
|
||||
private final String targetBranch;
|
||||
private final String sourceBranch;
|
||||
private final Set<String> labels;
|
||||
|
||||
@Builder
|
||||
private NewPrNotify(
|
||||
protected NewMrNotify(
|
||||
String title,
|
||||
String url,
|
||||
String description,
|
||||
@ -35,9 +31,4 @@ public class NewPrNotify extends PrNotify {
|
||||
this.labels = labels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
}
|
@ -5,7 +5,7 @@ import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class StatusPrNotify extends PrNotify {
|
||||
public class StatusMrNotify extends MrNotify {
|
||||
|
||||
public static final String TYPE = "StatusPrNotify";
|
||||
|
||||
@ -13,7 +13,7 @@ public class StatusPrNotify extends PrNotify {
|
||||
private final MergeRequestState newStatus;
|
||||
|
||||
@Builder
|
||||
private StatusPrNotify(
|
||||
private StatusMrNotify(
|
||||
String name,
|
||||
String url,
|
||||
String projectName,
|
@ -4,7 +4,7 @@ import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public class UpdatePrNotify extends PrNotify {
|
||||
public class UpdateMrNotify extends MrNotify {
|
||||
|
||||
public static final String TYPE = "UpdatePrNotify";
|
||||
|
||||
@ -15,7 +15,7 @@ public class UpdatePrNotify extends PrNotify {
|
||||
private final Long personResolvedTasks;
|
||||
|
||||
@Builder
|
||||
private UpdatePrNotify(
|
||||
private UpdateMrNotify(
|
||||
String name,
|
||||
String url,
|
||||
String author,
|
@ -17,6 +17,7 @@ public class Icons {
|
||||
public static final String ARROW = " ➜ ";
|
||||
public static final String DANGEROUS = "⚠️";
|
||||
public static final String PEN = "✏️";
|
||||
public static final String ASSIGNEE = "\uD83C\uDF96";
|
||||
public static final String BUILD = "\uD83D\uDEE0";
|
||||
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.Person;
|
||||
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.NewPrNotify;
|
||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.StatusPrNotify;
|
||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.UpdatePrNotify;
|
||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.ConflictMrNotify;
|
||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.NewMrForAssignee;
|
||||
import dev.struchkov.bot.gitlab.context.domain.notify.mergerequest.NewMrForReview;
|
||||
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.service.DiscussionService;
|
||||
import dev.struchkov.bot.gitlab.context.service.MergeRequestsService;
|
||||
@ -67,7 +68,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
||||
if (botUserReviewer || botUserAssignee) {
|
||||
if (!mergeRequest.isConflict()) {
|
||||
final String projectName = projectService.getByIdOrThrow(savedMergeRequest.getProjectId()).getName();
|
||||
if (botUserReviewer) sendNotifyAboutNewMr(savedMergeRequest, projectName);
|
||||
if (botUserReviewer) sendNotifyNewMrReview(savedMergeRequest, projectName);
|
||||
if (botUserAssignee) sendNotifyAboutAssignee(mergeRequest, projectName);
|
||||
}
|
||||
}
|
||||
@ -111,9 +112,9 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void sendNotifyAboutNewMr(MergeRequest mergeRequest, String projectName) {
|
||||
private void sendNotifyNewMrReview(MergeRequest mergeRequest, String projectName) {
|
||||
notifyService.send(
|
||||
NewPrNotify.builder()
|
||||
NewMrForReview.builder()
|
||||
.projectName(projectName)
|
||||
.labels(mergeRequest.getLabels())
|
||||
.author(mergeRequest.getAuthor().getName())
|
||||
@ -128,7 +129,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
||||
|
||||
private void sendNotifyAboutAssignee(MergeRequest mergeRequest, String projectName) {
|
||||
notifyService.send(
|
||||
NewPrNotify.builder()
|
||||
NewMrForAssignee.builder()
|
||||
.projectName(projectName)
|
||||
.labels(mergeRequest.getLabels())
|
||||
.author(mergeRequest.getAuthor().getName())
|
||||
@ -185,15 +186,14 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
||||
//TODO [05.12.2022|uPagge]: Добавить уведомление, если происходит удаление
|
||||
private void notifyAssignee(AssigneeChanged assigneeChanged, MergeRequest mergeRequest, Project project) {
|
||||
switch (assigneeChanged) {
|
||||
case BECOME -> sendNotifyAboutNewMr(mergeRequest, project.getName());
|
||||
case BECOME -> sendNotifyAboutAssignee(mergeRequest, project.getName());
|
||||
}
|
||||
}
|
||||
|
||||
//TODO [05.12.2022|uPagge]: Добавить уведомление, если происходит удаление ревьювера
|
||||
//TODO [05.12.2022|uPagge]: Заменить тип уведомления на самостоятельный
|
||||
private void notifyReviewer(ReviewerChanged reviewerChanged, MergeRequest mergeRequest, Project project) {
|
||||
switch (reviewerChanged) {
|
||||
case BECOME -> sendNotifyAboutNewMr(mergeRequest, project.getName());
|
||||
case BECOME -> sendNotifyNewMrReview(mergeRequest, project.getName());
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,7 +284,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
||||
}
|
||||
}
|
||||
notifyService.send(
|
||||
UpdatePrNotify.builder()
|
||||
UpdateMrNotify.builder()
|
||||
.author(oldMergeRequest.getAuthor().getName())
|
||||
.name(oldMergeRequest.getTitle())
|
||||
.projectKey(project.getName())
|
||||
@ -306,7 +306,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
||||
&& gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // и MR создан пользователем бота
|
||||
) {
|
||||
notifyService.send(
|
||||
ConflictPrNotify.builder()
|
||||
ConflictMrNotify.builder()
|
||||
.sourceBranch(oldMergeRequest.getSourceBranch())
|
||||
.name(mergeRequest.getTitle())
|
||||
.url(mergeRequest.getWebUrl())
|
||||
@ -325,7 +325,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
||||
&& gitlabUserId.equals(oldMergeRequest.getAuthor().getId()) // создатель MR является пользователем бота
|
||||
) {
|
||||
notifyService.send(
|
||||
StatusPrNotify.builder()
|
||||
StatusMrNotify.builder()
|
||||
.name(newMergeRequest.getTitle())
|
||||
.url(oldMergeRequest.getWebUrl())
|
||||
.projectName(project.getName())
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.godfather.main.domain.BoxAnswer;
|
||||
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;
|
||||
|
||||
@Component
|
||||
public class ConflictPrNotifyGenerator implements NotifyBoxAnswerGenerator<ConflictPrNotify> {
|
||||
public class ConflictPrNotifyGenerator implements NotifyBoxAnswerGenerator<ConflictMrNotify> {
|
||||
|
||||
@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("*")
|
||||
.append(Icons.HR)
|
||||
@ -25,7 +25,7 @@ public class ConflictPrNotifyGenerator implements NotifyBoxAnswerGenerator<Confl
|
||||
|
||||
@Override
|
||||
public String getNotifyType() {
|
||||
return ConflictPrNotify.TYPE;
|
||||
return ConflictMrNotify.TYPE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
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.godfather.main.domain.BoxAnswer;
|
||||
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;
|
||||
|
||||
@Component
|
||||
public class NewPrNotifyGenerator implements NotifyBoxAnswerGenerator<NewPrNotify> {
|
||||
public class NewMrForReviewNotifyGenerator implements NotifyBoxAnswerGenerator<NewMrForReview> {
|
||||
|
||||
@Override
|
||||
public BoxAnswer generate(NewPrNotify notify) {
|
||||
public BoxAnswer generate(NewMrForReview notify) {
|
||||
final String labelText = notify.getLabels().stream()
|
||||
.map(label -> "#" + label)
|
||||
.collect(Collectors.joining(" "));
|
||||
@ -39,7 +39,7 @@ public class NewPrNotifyGenerator implements NotifyBoxAnswerGenerator<NewPrNotif
|
||||
|
||||
@Override
|
||||
public String getNotifyType() {
|
||||
return NewPrNotify.TYPE;
|
||||
return NewMrForReview.TYPE;
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
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.godfather.main.domain.BoxAnswer;
|
||||
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;
|
||||
|
||||
@Component
|
||||
public class StatusPrNotifyGenerator implements NotifyBoxAnswerGenerator<StatusPrNotify> {
|
||||
public class StatusPrNotifyGenerator implements NotifyBoxAnswerGenerator<StatusMrNotify> {
|
||||
|
||||
@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("*")
|
||||
.append(Icons.HR)
|
||||
@ -27,7 +27,7 @@ public class StatusPrNotifyGenerator implements NotifyBoxAnswerGenerator<StatusP
|
||||
|
||||
@Override
|
||||
public String getNotifyType() {
|
||||
return StatusPrNotify.TYPE;
|
||||
return StatusMrNotify.TYPE;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
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.Smile;
|
||||
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;
|
||||
|
||||
@Component
|
||||
public class UpdatePrNotifyGenerator implements NotifyBoxAnswerGenerator<UpdatePrNotify> {
|
||||
public class UpdatePrNotifyGenerator implements NotifyBoxAnswerGenerator<UpdateMrNotify> {
|
||||
|
||||
@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("*")
|
||||
.append(Smile.HR.getValue())
|
||||
@ -38,7 +38,7 @@ public class UpdatePrNotifyGenerator implements NotifyBoxAnswerGenerator<UpdateP
|
||||
|
||||
@Override
|
||||
public String getNotifyType() {
|
||||
return UpdatePrNotify.TYPE;
|
||||
return UpdateMrNotify.TYPE;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user