Обновил внешний вид уведомления о назначении ревьювером

This commit is contained in:
Struchkov Mark 2023-01-17 11:22:15 +03:00
parent 3fd2aa717d
commit ea65a98778
Signed by: upagge
GPG Key ID: D3018BE7BA428CA6
3 changed files with 32 additions and 4 deletions

View File

@ -10,6 +10,8 @@ public class NewMrForReview extends NewMrNotify {
public static final String TYPE = "NewMrForReview"; public static final String TYPE = "NewMrForReview";
private final String assignee;
@Builder @Builder
private NewMrForReview( private NewMrForReview(
String title, String title,
@ -19,7 +21,8 @@ public class NewMrForReview extends NewMrNotify {
String projectName, String projectName,
String targetBranch, String targetBranch,
String sourceBranch, String sourceBranch,
Set<String> labels Set<String> labels,
String assignee
) { ) {
super( super(
title, title,
@ -31,6 +34,7 @@ public class NewMrForReview extends NewMrNotify {
sourceBranch, sourceBranch,
labels labels
); );
this.assignee = assignee;
} }
@Override @Override

View File

@ -123,6 +123,7 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
.url(mergeRequest.getWebUrl()) .url(mergeRequest.getWebUrl())
.targetBranch(mergeRequest.getTargetBranch()) .targetBranch(mergeRequest.getTargetBranch())
.sourceBranch(mergeRequest.getSourceBranch()) .sourceBranch(mergeRequest.getSourceBranch())
.assignee(mergeRequest.getAssignee().getName())
.build() .build()
); );
} }

View File

@ -9,6 +9,11 @@ import java.util.stream.Collectors;
import static dev.struchkov.bot.gitlab.context.utils.Icons.link; 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;
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.telegram.domain.keyboard.InlineKeyBoard.inlineKeyBoard;
import static dev.struchkov.godfather.telegram.domain.keyboard.button.UrlButton.urlButton;
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown; import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
@Component @Component
@ -21,7 +26,7 @@ public class NewMrForReviewNotifyGenerator implements NotifyBoxAnswerGenerator<N
.collect(Collectors.joining(" ")); .collect(Collectors.joining(" "));
final StringBuilder builder = new StringBuilder(Icons.FUN).append(" *New merge request for review | ").append(escapeMarkdown(notify.getProjectName())).append("*") final StringBuilder builder = new StringBuilder(Icons.FUN).append(" *New merge request for review*")
.append(Icons.HR) .append(Icons.HR)
.append(link(notify.getType(), notify.getUrl())); .append(link(notify.getType(), notify.getUrl()));
@ -29,12 +34,30 @@ public class NewMrForReviewNotifyGenerator implements NotifyBoxAnswerGenerator<N
builder.append("\n\n").append(labelText); builder.append("\n\n").append(labelText);
} }
builder.append(Icons.HR) builder.append(Icons.HR);
if (checkNotNull(notify.getProjectName())) {
builder.append("Project").append(": ").append(escapeMarkdown(notify.getProjectName()));
}
builder
.append(Icons.TREE).append(": ").append(notify.getSourceBranch()).append(Icons.ARROW).append(notify.getTargetBranch()).append("\n") .append(Icons.TREE).append(": ").append(notify.getSourceBranch()).append(Icons.ARROW).append(notify.getTargetBranch()).append("\n")
.append(Icons.AUTHOR).append(": ").append(notify.getAuthor()); .append(Icons.AUTHOR).append(": ").append(notify.getAuthor());
if (checkNotNull(notify.getAssignee())) {
builder.append(Icons.ASSIGNEE).append(": ").append(notify.getAssignee());
}
final String notifyMessage = builder.toString(); final String notifyMessage = builder.toString();
return boxAnswer(notifyMessage); return boxAnswer(
notifyMessage,
inlineKeyBoard(
simpleLine(
simpleButton(Icons.VIEW, "DELETE_MESSAGE"),
urlButton(Icons.LINK, notify.getUrl())
)
)
);
} }
@Override @Override