Добавил уведомление о решении конфликта в чужом МР
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c53e2cde5e
commit
d148e56cd4
@ -17,6 +17,7 @@ public class UpdateMrNotify extends MrNotify {
|
||||
private final Long allResolvedTasks;
|
||||
private final Long personTasks;
|
||||
private final Long personResolvedTasks;
|
||||
private final String comment;
|
||||
|
||||
@Builder
|
||||
private UpdateMrNotify(
|
||||
@ -24,21 +25,22 @@ public class UpdateMrNotify extends MrNotify {
|
||||
String name,
|
||||
String url,
|
||||
String author,
|
||||
String projectKey,
|
||||
String projectName,
|
||||
Long allTasks,
|
||||
Long allResolvedTasks,
|
||||
Long personTasks,
|
||||
Long personResolvedTasks
|
||||
Long personResolvedTasks,
|
||||
String comment
|
||||
) {
|
||||
super(mrId, projectKey, name, url);
|
||||
super(mrId, projectName, name, url);
|
||||
this.author = author;
|
||||
this.allTasks = allTasks;
|
||||
this.allResolvedTasks = allResolvedTasks;
|
||||
this.personTasks = personTasks;
|
||||
this.personResolvedTasks = personResolvedTasks;
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return TYPE;
|
||||
|
@ -283,17 +283,17 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
||||
|
||||
private void notifyAboutUpdate(MergeRequest oldMergeRequest, MergeRequest mergeRequest, Project project) {
|
||||
final Long botUserGitlabId = personInformation.getId();
|
||||
|
||||
if (
|
||||
!botUserGitlabId.equals(mergeRequest.getAuthor().getId()) // Автор MR не пользователь приложения
|
||||
&& !oldMergeRequest.getDateLastCommit().equals(mergeRequest.getDateLastCommit()) // Изменилась дата последнего коммита
|
||||
&& !mergeRequest.isConflict() // MR не находится в состоянии конфликта
|
||||
&& !botUserGitlabId.equals(oldMergeRequest.getAuthor().getId()) // и MR создан НЕ пользователем бота
|
||||
) {
|
||||
|
||||
long allTask = 0;
|
||||
long resolvedTask = 0;
|
||||
long allYouTasks = 0;
|
||||
long resolvedYouTask = 0;
|
||||
|
||||
final List<Discussion> discussions = discussionService.getAllByMergeRequestId(oldMergeRequest.getId());
|
||||
for (Discussion discussion : discussions) {
|
||||
if (checkNotNull(discussion.getResponsible())) {
|
||||
@ -310,19 +310,23 @@ public class MergeRequestsServiceImpl implements MergeRequestsService {
|
||||
}
|
||||
}
|
||||
}
|
||||
notifyService.send(
|
||||
UpdateMrNotify.builder()
|
||||
|
||||
final UpdateMrNotify.UpdateMrNotifyBuilder notifyBuilder = UpdateMrNotify.builder()
|
||||
.mrId(oldMergeRequest.getId())
|
||||
.author(oldMergeRequest.getAuthor().getName())
|
||||
.name(oldMergeRequest.getTitle())
|
||||
.projectKey(project.getName())
|
||||
.projectName(project.getName())
|
||||
.url(oldMergeRequest.getWebUrl())
|
||||
.allTasks(allTask)
|
||||
.allResolvedTasks(resolvedTask)
|
||||
.personTasks(allYouTasks)
|
||||
.personResolvedTasks(resolvedYouTask)
|
||||
.build()
|
||||
);
|
||||
.personResolvedTasks(resolvedYouTask);
|
||||
|
||||
if (oldMergeRequest.isConflict() && !mergeRequest.isConflict()) {
|
||||
notifyBuilder.comment("The conflict has been resolved");
|
||||
}
|
||||
|
||||
notifyService.send(notifyBuilder.build());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,7 @@ import static dev.struchkov.godfather.main.domain.keyboard.simple.SimpleKeyBoard
|
||||
import static dev.struchkov.godfather.simple.domain.BoxAnswer.boxAnswer;
|
||||
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.checkNotBlank;
|
||||
import static dev.struchkov.haiti.utils.Checker.checkNotNull;
|
||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||
|
||||
@ -27,11 +28,16 @@ public class UpdateMrNotifyGenerator implements NotifyBoxAnswerGenerator<UpdateM
|
||||
.append(Icons.HR)
|
||||
.append(notify.getTitle());
|
||||
|
||||
if (notify.getAllTasks() > 0) {
|
||||
if (checkNotBlank(notify.getComment())) {
|
||||
builder.append(Icons.HR)
|
||||
.append(notify.getComment());
|
||||
}
|
||||
|
||||
if (checkNotNull(notify.getAllTasks()) && notify.getAllTasks() > 0) {
|
||||
builder.append(Icons.HR)
|
||||
.append("All tasks: ").append(notify.getAllResolvedTasks()).append("/").append(notify.getAllTasks());
|
||||
|
||||
if (notify.getPersonTasks() > 0) {
|
||||
if (checkNotNull(notify.getPersonTasks()) && notify.getPersonTasks() > 0) {
|
||||
builder.append("\nYour tasks: ").append(notify.getPersonResolvedTasks()).append("/").append(notify.getPersonTasks());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user