Change -> Notify
This commit is contained in:
parent
8b0fadc1f7
commit
3f4a310ae5
@ -2,7 +2,6 @@ package org.sadtech.bot.vcs.core.config.properties;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.sadtech.bot.vcs.core.scheduler.SchedulerComments;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change;
|
||||
package org.sadtech.bot.vcs.core.domain.notify;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
@ -9,9 +9,9 @@ import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
|
||||
public abstract class Change {
|
||||
public abstract class Notify {
|
||||
|
||||
protected final ChangeType type;
|
||||
protected final NotifyType type;
|
||||
protected final LocalDateTime localDateTime = LocalDateTime.now();
|
||||
protected final Set<Long> telegramIds;
|
||||
|
||||
@ -19,7 +19,7 @@ public abstract class Change {
|
||||
@EqualsAndHashCode.Include
|
||||
protected Long id;
|
||||
|
||||
protected Change(ChangeType type, Set<Long> telegramIds) {
|
||||
protected Notify(NotifyType type, Set<Long> telegramIds) {
|
||||
this.type = type;
|
||||
this.telegramIds = telegramIds;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change;
|
||||
package org.sadtech.bot.vcs.core.domain.notify;
|
||||
|
||||
public enum ChangeType {
|
||||
public enum NotifyType {
|
||||
|
||||
STATUS_PR,
|
||||
UPDATE_PR,
|
@ -1,11 +1,11 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.comment;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.comment;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.Answer;
|
||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
@ -15,20 +15,20 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class AnswerCommentChange extends Change {
|
||||
public class AnswerCommentNotify extends Notify {
|
||||
|
||||
private final String youMessage;
|
||||
private final String url;
|
||||
private final List<Answer> answers;
|
||||
|
||||
@Builder
|
||||
protected AnswerCommentChange(
|
||||
protected AnswerCommentNotify(
|
||||
Set<Long> telegramIds,
|
||||
String youMessage,
|
||||
String url,
|
||||
List<Answer> answers
|
||||
) {
|
||||
super(ChangeType.NEW_ANSWERS_COMMENT, telegramIds);
|
||||
super(NotifyType.NEW_ANSWERS_COMMENT, telegramIds);
|
||||
this.youMessage = youMessage;
|
||||
this.url = url;
|
||||
this.answers = answers;
|
@ -1,10 +1,10 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.comment;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.comment;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
@ -12,20 +12,20 @@ import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class CommentChange extends Change {
|
||||
public class CommentNotify extends Notify {
|
||||
|
||||
private final String authorName;
|
||||
private final String message;
|
||||
private final String url;
|
||||
|
||||
@Builder
|
||||
private CommentChange(
|
||||
private CommentNotify(
|
||||
Set<Long> telegramIds,
|
||||
String url,
|
||||
String authorName,
|
||||
String message
|
||||
) {
|
||||
super(ChangeType.NEW_COMMENT, telegramIds);
|
||||
super(NotifyType.NEW_COMMENT, telegramIds);
|
||||
this.authorName = authorName;
|
||||
this.message = message;
|
||||
this.url = url;
|
@ -1,23 +1,23 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.pullrequest;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.pullrequest;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
public class ConflictPrChange extends PrChange {
|
||||
public class ConflictPrNotify extends PrNotify {
|
||||
|
||||
@Builder
|
||||
private ConflictPrChange(
|
||||
private ConflictPrNotify(
|
||||
Set<Long> telegramIds,
|
||||
String name,
|
||||
String url
|
||||
) {
|
||||
super(ChangeType.CONFLICT_PR, telegramIds, name, url);
|
||||
super(NotifyType.CONFLICT_PR, telegramIds, name, url);
|
||||
}
|
||||
|
||||
@Override
|
@ -1,9 +1,9 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.pullrequest;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.pullrequest;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
@ -11,19 +11,19 @@ import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class NewPrChange extends PrChange {
|
||||
public class NewPrNotify extends PrNotify {
|
||||
|
||||
private final String description;
|
||||
private final String author;
|
||||
|
||||
@Builder
|
||||
private NewPrChange(
|
||||
private NewPrNotify(
|
||||
Set<Long> telegramIds,
|
||||
String title,
|
||||
String url,
|
||||
String description,
|
||||
String author) {
|
||||
super(ChangeType.NEW_PR, telegramIds, title, url);
|
||||
super(NotifyType.NEW_PR, telegramIds, title, url);
|
||||
this.description = description;
|
||||
this.author = author;
|
||||
}
|
@ -1,20 +1,20 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.pullrequest;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.pullrequest;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public abstract class PrChange extends Change {
|
||||
public abstract class PrNotify extends Notify {
|
||||
|
||||
protected final String title;
|
||||
protected final String url;
|
||||
|
||||
protected PrChange(ChangeType type, Set<Long> telegramIds, String title, String url) {
|
||||
protected PrNotify(NotifyType type, Set<Long> telegramIds, String title, String url) {
|
||||
super(type, telegramIds);
|
||||
this.title = title;
|
||||
this.url = url;
|
@ -1,9 +1,9 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.pullrequest;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.pullrequest;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
import org.sadtech.bot.vcs.core.domain.util.ReviewerChange;
|
||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
||||
|
||||
@ -18,17 +18,17 @@ import static org.sadtech.bot.vcs.core.domain.util.ReviewerChange.Type.OLD;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class ReviewersPrChange extends PrChange {
|
||||
public class ReviewersPrNotify extends PrNotify {
|
||||
|
||||
private final List<ReviewerChange> reviewerChanges;
|
||||
|
||||
@Builder
|
||||
private ReviewersPrChange(
|
||||
private ReviewersPrNotify(
|
||||
Set<Long> telegramIds,
|
||||
String title,
|
||||
String url,
|
||||
List<ReviewerChange> reviewerChanges) {
|
||||
super(ChangeType.REVIEWERS, telegramIds, title, url);
|
||||
super(NotifyType.REVIEWERS, telegramIds, title, url);
|
||||
this.reviewerChanges = reviewerChanges;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.pullrequest;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.pullrequest;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.PullRequestStatus;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
@ -12,19 +12,19 @@ import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class StatusPrChange extends PrChange {
|
||||
public class StatusPrNotify extends PrNotify {
|
||||
|
||||
private final PullRequestStatus oldStatus;
|
||||
private final PullRequestStatus newStatus;
|
||||
|
||||
@Builder
|
||||
private StatusPrChange(
|
||||
private StatusPrNotify(
|
||||
Set<Long> telegramIds,
|
||||
String name,
|
||||
String url,
|
||||
PullRequestStatus oldStatus,
|
||||
PullRequestStatus newStatus) {
|
||||
super(ChangeType.STATUS_PR, telegramIds, name, url);
|
||||
super(NotifyType.STATUS_PR, telegramIds, name, url);
|
||||
this.oldStatus = oldStatus;
|
||||
this.newStatus = newStatus;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.pullrequest;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.pullrequest;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
@ -11,16 +11,16 @@ import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class UpdatePrChange extends PrChange {
|
||||
public class UpdatePrNotify extends PrNotify {
|
||||
|
||||
private final String author;
|
||||
|
||||
@Builder
|
||||
private UpdatePrChange(
|
||||
private UpdatePrNotify(
|
||||
Set<Long> telegramIds,
|
||||
String name,
|
||||
String url, String author) {
|
||||
super(ChangeType.UPDATE_PR, telegramIds, name, url);
|
||||
super(NotifyType.UPDATE_PR, telegramIds, name, url);
|
||||
this.author = author;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.task;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.task;
|
||||
|
||||
import lombok.Builder;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
@ -12,16 +12,16 @@ import java.util.Set;
|
||||
*
|
||||
* @author upagge 10.09.2020
|
||||
*/
|
||||
public class TaskCloseChange extends TaskChange {
|
||||
public class TaskCloseNotify extends TaskNotify {
|
||||
|
||||
@Builder
|
||||
protected TaskCloseChange(
|
||||
protected TaskCloseNotify(
|
||||
Set<Long> telegramIds,
|
||||
String authorName,
|
||||
String url,
|
||||
String messageTask
|
||||
) {
|
||||
super(ChangeType.RESOLVED_TASK, telegramIds, authorName, url, messageTask);
|
||||
super(NotifyType.RESOLVED_TASK, telegramIds, authorName, url, messageTask);
|
||||
}
|
||||
|
||||
@Override
|
@ -1,8 +1,8 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.task;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.task;
|
||||
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
@ -14,16 +14,16 @@ import java.util.Set;
|
||||
* @author upagge 10.09.2020
|
||||
*/
|
||||
@Getter
|
||||
public class TaskNewChange extends TaskChange {
|
||||
public class TaskNewNotify extends TaskNotify {
|
||||
|
||||
@Builder
|
||||
protected TaskNewChange(
|
||||
protected TaskNewNotify(
|
||||
Set<Long> telegramIds,
|
||||
String authorName,
|
||||
String url,
|
||||
String messageTask
|
||||
) {
|
||||
super(ChangeType.NEW_TASK, telegramIds, authorName, url, messageTask);
|
||||
super(NotifyType.NEW_TASK, telegramIds, authorName, url, messageTask);
|
||||
}
|
||||
|
||||
@Override
|
@ -1,22 +1,22 @@
|
||||
package org.sadtech.bot.vcs.core.domain.change.task;
|
||||
package org.sadtech.bot.vcs.core.domain.notify.task;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public abstract class TaskChange extends Change {
|
||||
public abstract class TaskNotify extends Notify {
|
||||
|
||||
protected final String authorName;
|
||||
protected final String url;
|
||||
protected final String messageTask;
|
||||
|
||||
protected TaskChange(
|
||||
ChangeType type,
|
||||
protected TaskNotify(
|
||||
NotifyType type,
|
||||
Set<Long> telegramIds,
|
||||
String authorName,
|
||||
String url,
|
@ -12,8 +12,8 @@ import org.sadtech.bot.vcs.core.domain.ReviewerStatus;
|
||||
@Getter
|
||||
public class ReviewerChange {
|
||||
|
||||
private String name;
|
||||
private Type type;
|
||||
private final String name;
|
||||
private final Type type;
|
||||
private ReviewerStatus status;
|
||||
private ReviewerStatus oldStatus;
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
package org.sadtech.bot.vcs.core.repository;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ChangeRepository {
|
||||
|
||||
<T extends Change> T add(@NonNull T change);
|
||||
|
||||
List<Change> getAll();
|
||||
|
||||
void deleteAll(@NonNull List<Change> changes);
|
||||
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package org.sadtech.bot.vcs.core.repository;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface NotifyRepository {
|
||||
|
||||
<T extends Notify> T add(@NonNull T notify);
|
||||
|
||||
List<Notify> getAll();
|
||||
|
||||
void deleteAll(@NonNull List<Notify> notifies);
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package org.sadtech.bot.vcs.core.repository.impl;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
||||
import org.sadtech.bot.vcs.core.repository.ChangeRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class ChangeRepositoryImpl implements ChangeRepository {
|
||||
|
||||
private final List<Change> list = new ArrayList<>();
|
||||
private long count = 0;
|
||||
|
||||
@Override
|
||||
public <T extends Change> T add(@NonNull T change) {
|
||||
change.setId(count++);
|
||||
list.add(change);
|
||||
return change;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Change> getAll() {
|
||||
return new ArrayList<>(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(@NonNull List<Change> changes) {
|
||||
list.removeAll(changes);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.sadtech.bot.vcs.core.repository.impl;
|
||||
|
||||
import lombok.NonNull;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||
import org.sadtech.bot.vcs.core.repository.NotifyRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class NotifyRepositoryImpl implements NotifyRepository {
|
||||
|
||||
private final List<Notify> list = new ArrayList<>();
|
||||
private long count = 0;
|
||||
|
||||
@Override
|
||||
public <T extends Notify> T add(@NonNull T notify) {
|
||||
notify.setId(count++);
|
||||
list.add(notify);
|
||||
return notify;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notify> getAll() {
|
||||
return new ArrayList<>(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteAll(@NonNull List<Notify> notifies) {
|
||||
list.removeAll(notifies);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -23,7 +23,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SchedulerNotification {
|
||||
public class NotificationScheduler {
|
||||
|
||||
private static final Set<String> tksLoginNotify = new HashSet<>(Arrays.asList(
|
||||
"mstruchkov", "dganin", "emukhin", "ktorgaeva", "imescheryakov", "kkeglev"
|
@ -2,8 +2,8 @@ package org.sadtech.bot.vcs.core.scheduler;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.sadtech.bot.vcs.core.domain.MessageSend;
|
||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
||||
import org.sadtech.bot.vcs.core.service.ChangeService;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||
import org.sadtech.bot.vcs.core.service.NotifyService;
|
||||
import org.sadtech.bot.vcs.core.service.MessageSendService;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -19,10 +19,10 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SchedulerChangeParsing {
|
||||
public class NotifyParsingScheduler {
|
||||
|
||||
private final MessageSendService messageSendService;
|
||||
private final ChangeService changeService;
|
||||
private final NotifyService notifyService;
|
||||
|
||||
/**
|
||||
* Проверяет наличие новых изменений. Если изменения найдены, то создает новое сообщение и отправляет
|
||||
@ -30,12 +30,12 @@ public class SchedulerChangeParsing {
|
||||
*/
|
||||
@Scheduled(cron = "*/15 * * * * *")
|
||||
public void parsing() {
|
||||
final List<Change> newChange = changeService.getNew().stream()
|
||||
.filter(change -> change.getTelegramIds() != null && !change.getTelegramIds().isEmpty())
|
||||
final List<Notify> newNotify = notifyService.getNew().stream()
|
||||
.filter(notify -> notify.getTelegramIds() != null && !notify.getTelegramIds().isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
for (Change change : newChange) {
|
||||
final String message = change.generateMessage();
|
||||
change.getTelegramIds().forEach(
|
||||
for (Notify notify : newNotify) {
|
||||
final String message = notify.generateMessage();
|
||||
notify.getTelegramIds().forEach(
|
||||
telegramId -> messageSendService.add(
|
||||
MessageSend.builder()
|
||||
.telegramId(telegramId)
|
@ -1,224 +0,0 @@
|
||||
package org.sadtech.bot.vcs.core.scheduler;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* Шедулер отвечает за работу с комментариями. Поиск новых комментариев, проверка старых. Так как таски в
|
||||
* битбакете реализуются через комментарии, то <b>этот шедулер так же работает с тасками</b>.
|
||||
*
|
||||
* @author upagge
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SchedulerComments {
|
||||
|
||||
// private static final Pattern PATTERN = Pattern.compile("@[\\w]+");
|
||||
//
|
||||
// private final CommentService commentService;
|
||||
// private final PullRequestsService pullRequestsService;
|
||||
// private final PersonService personService;
|
||||
// private final ChangeService changeService;
|
||||
// private final ExecutorScanner executorScanner;
|
||||
// private final TaskService taskService;
|
||||
// private final ConversionService conversionService;
|
||||
//
|
||||
// private final BitbucketProperty bitbucketProperty;
|
||||
// private final CommentSchedulerProperty commentSchedulerProperty;
|
||||
//
|
||||
// /**
|
||||
// * Сканирует появление новых комментариев
|
||||
// */
|
||||
// @Scheduled(cron = "0 */3 * * * *")
|
||||
// public void newComments() {
|
||||
// long commentId = commentService.getLastCommentId() + 1;
|
||||
// int count = 0;
|
||||
// do {
|
||||
// final List<DataScan> dataScans = generatingLinksToPossibleComments(commentId);
|
||||
// executorScanner.registration(dataScans);
|
||||
// final List<ResultScan> resultScans = executorScanner.getResult();
|
||||
// if (!resultScans.isEmpty()) {
|
||||
// final List<Comment> comments = getCommentsByResultScan(resultScans);
|
||||
// final List<Comment> newComments = commentService.createAll(comments);
|
||||
// checkNewTask(newComments);
|
||||
// notificationPersonal(newComments);
|
||||
// count = 0;
|
||||
// }
|
||||
// } while (count++ < commentSchedulerProperty.getNoCommentCount());
|
||||
// }
|
||||
//
|
||||
// private List<Comment> getCommentsByResultScan(List<ResultScan> resultScans) {
|
||||
// return resultScans.stream()
|
||||
// .map(result -> conversionService.convert(result, Comment.class))
|
||||
// .collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// private List<DataScan> generatingLinksToPossibleComments(@NonNull Long commentId) {
|
||||
// List<DataScan> commentUrls = new ArrayList<>();
|
||||
// for (int i = 0; i < 5; i++) {
|
||||
// int page = 0;
|
||||
// Page<PullRequest> pullRequestPage = pullRequestsService.getAll(
|
||||
// Pagination.of(page, commentSchedulerProperty.getCommentCount())
|
||||
// );
|
||||
// while (pullRequestPage.hasContent()) {
|
||||
// long finalCommentId = commentId;
|
||||
// commentUrls.addAll(pullRequestPage.getContent().stream()
|
||||
// .map(
|
||||
// pullRequest -> new DataScan(
|
||||
// getCommentUrl(finalCommentId, pullRequest),
|
||||
// pullRequest.getId()
|
||||
// )
|
||||
// )
|
||||
// .collect(Collectors.toList()));
|
||||
// pullRequestPage = pullRequestsService.getAll(
|
||||
// Pagination.of(++page, commentSchedulerProperty.getCommentCount())
|
||||
// );
|
||||
// }
|
||||
// commentId++;
|
||||
// }
|
||||
// return commentUrls;
|
||||
// }
|
||||
//
|
||||
//
|
||||
// private void checkNewTask(CommentJson commentJson, String urlPr, String authorLoginPr) {
|
||||
// if (Severity.BLOCKER.equals(commentJson.getSeverity())) {
|
||||
// final Task task = new Task();
|
||||
// task.setStatus(Converter.taskStatus(commentJson.getState()));
|
||||
// task.setComment(commentService.getProxyById(commentJson.getId()).orElseThrow(() -> new NotFoundException("Неожиданная ошибка")));
|
||||
//
|
||||
// taskService.create(task);
|
||||
//
|
||||
// if (TaskStatus.OPEN.equals(task.getStatus())) {
|
||||
// changeService.add(
|
||||
// TaskChange.builder()
|
||||
// .type(ChangeType.NEW_TASK)
|
||||
// .authorName(commentJson.getAuthor().getDisplayName())
|
||||
// .messageTask(commentJson.getText())
|
||||
// .telegramIds(personService.getAllTelegramIdByLogin(Collections.singleton(authorLoginPr)))
|
||||
// .url(urlPr)
|
||||
// .build()
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//
|
||||
// /**
|
||||
// * Проверяет состояние старых комментариев
|
||||
// */
|
||||
// @Scheduled(cron = "0 */1 * * * *")
|
||||
// public void oldComments() {
|
||||
// @NonNull final List<Comment> comments = commentService.getAllBetweenDate(
|
||||
// LocalDateTime.now().minusDays(10), LocalDateTime.now()
|
||||
// );
|
||||
// for (Comment comment : comments) {
|
||||
// final Optional<CommentJson> optCommentJson = Utils.urlToJson(
|
||||
// comment.getUrl(),
|
||||
// bitbucketProperty.getToken(),
|
||||
// CommentJson.class
|
||||
// );
|
||||
// if (optCommentJson.isPresent()) {
|
||||
// final CommentJson commentJson = optCommentJson.get();
|
||||
// checkNewAnswers(comment, commentJson);
|
||||
// checkOldTask(comment, commentJson);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void checkOldTask(Comment comment, CommentJson commentJson) {
|
||||
// final Task task = comment.getTask();
|
||||
// if (task == null) {
|
||||
// checkNewTask(commentJson, comment.getPrUrl(), commentJson.getAuthor().getName());
|
||||
// } else {
|
||||
// if (Severity.NORMAL.equals(commentJson.getSeverity())) {
|
||||
// taskService.deleteById(comment.getId());
|
||||
//
|
||||
// changeService.add(
|
||||
// TaskChange.builder()
|
||||
// .type(ChangeType.DELETED_TASK)
|
||||
// .telegramIds(personService.getAllTelegramIdByLogin(Collections.singleton(commentJson.getAuthor().getName())))
|
||||
// .authorName(commentJson.getAuthor().getDisplayName())
|
||||
// .url(comment.getPrUrl())
|
||||
// .messageTask(commentJson.getText())
|
||||
// .build()
|
||||
// );
|
||||
// } else {
|
||||
// final TaskStatus taskStatus = task.getStatus();
|
||||
// final TaskStatus newTaskStatus = Converter.taskStatus(commentJson.getState());
|
||||
// task.setStatus(newTaskStatus);
|
||||
// taskService.update(task);
|
||||
// if (!taskStatus.equals(newTaskStatus)) {
|
||||
// changeService.add(
|
||||
// TaskChange.builder()
|
||||
// .type(TaskStatus.RESOLVED.equals(newTaskStatus) ? ChangeType.RESOLVED_TASK : ChangeType.OPEN_TASK)
|
||||
// .authorName(commentJson.getAuthor().getDisplayName())
|
||||
// .url(comment.getPrUrl())
|
||||
// .messageTask(commentJson.getText())
|
||||
// .telegramIds(
|
||||
// TaskStatus.RESOLVED.equals(newTaskStatus)
|
||||
// ? personService.getAllTelegramIdByLogin(Collections.singleton(commentJson.getAuthor().getName()))
|
||||
// : personService.getAllTelegramIdByLogin(Collections.singleton(commentJson.getAuthor().getName()))
|
||||
// )
|
||||
// .build()
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void checkNewAnswers(Comment comment, CommentJson commentJson) {
|
||||
// final Set<Long> oldAnswerIds = comment.getAnswers();
|
||||
// final List<CommentJson> newAnswers = commentJson.getComments().stream()
|
||||
// .filter(answerJson -> !oldAnswerIds.contains(answerJson.getId()))
|
||||
// .collect(Collectors.toList());
|
||||
// if (!newAnswers.isEmpty()) {
|
||||
// changeService.add(
|
||||
// AnswerCommentChange.builder()
|
||||
// .telegramIds(
|
||||
// personService.getTelegramIdByLogin(commentJson.getAuthor().getName())
|
||||
// .map(Collections::singleton)
|
||||
// .orElse(Collections.emptySet())
|
||||
// )
|
||||
// .url(comment.getPrUrl())
|
||||
// .youMessage(commentJson.getText())
|
||||
// .answers(
|
||||
// newAnswers.stream()
|
||||
// .map(json -> Answer.of(json.getAuthor().getName(), json.getText()))
|
||||
// .collect(Collectors.toList())
|
||||
// )
|
||||
// .build()
|
||||
// );
|
||||
// comment.getAnswers().addAll(newAnswers.stream().map(CommentJson::getId).collect(Collectors.toList()));
|
||||
// commentService.save(comment);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private String getCommentUrl(long commentId, PullRequest pullRequest) {
|
||||
// return bitbucketProperty.getUrlPullRequestComment()
|
||||
// .replace("{projectKey}", pullRequest.getProjectKey())
|
||||
// .replace("{repositorySlug}", pullRequest.getRepositorySlug())
|
||||
// .replace("{pullRequestId}", pullRequest.getBitbucketId().toString())
|
||||
// .replace("{commentId}", String.valueOf(commentId));
|
||||
// }
|
||||
//
|
||||
// private void notificationPersonal(@NonNull Comment comment) {
|
||||
// Matcher matcher = PATTERN.matcher(comment.getMessage());
|
||||
// Set<String> recipientsLogins = new HashSet<>();
|
||||
// while (matcher.find()) {
|
||||
// final String login = matcher.group(0).replace("@", "");
|
||||
// recipientsLogins.add(login);
|
||||
// }
|
||||
// final Set<Long> recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins);
|
||||
// changeService.add(
|
||||
// CommentChange.builder()
|
||||
// .authorName(comment.getAuthor().getLogin())
|
||||
// .url(comment.getPullRequest())
|
||||
// .telegramIds(recipientsIds)
|
||||
// .message(comment.getMessage())
|
||||
// .build()
|
||||
// );
|
||||
// }
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
package org.sadtech.bot.vcs.core.service;
|
||||
|
||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -8,15 +8,15 @@ import java.util.List;
|
||||
* Сервис по работе с изменениями в битбакете.
|
||||
*
|
||||
* @author upagge
|
||||
* @see Change
|
||||
* @see Notify
|
||||
*/
|
||||
public interface ChangeService {
|
||||
public interface NotifyService {
|
||||
|
||||
<T extends Change> void save(T task);
|
||||
<T extends Notify> void save(T notify);
|
||||
|
||||
/**
|
||||
* Позволяет получить новые изменения.
|
||||
*/
|
||||
List<Change> getNew();
|
||||
List<Notify> getNew();
|
||||
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
package org.sadtech.bot.vcs.core.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
||||
import org.sadtech.bot.vcs.core.repository.ChangeRepository;
|
||||
import org.sadtech.bot.vcs.core.service.ChangeService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ChangeServiceImpl implements ChangeService {
|
||||
|
||||
private final ChangeRepository changeRepository;
|
||||
|
||||
@Override
|
||||
public <T extends Change> void save(T change) {
|
||||
changeRepository.add(change);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Change> getNew() {
|
||||
final List<Change> changes = changeRepository.getAll();
|
||||
changeRepository.deleteAll(changes);
|
||||
return changes;
|
||||
}
|
||||
|
||||
}
|
@ -3,13 +3,13 @@ package org.sadtech.bot.vcs.core.service.impl;
|
||||
import lombok.NonNull;
|
||||
import org.sadtech.basic.core.service.AbstractSimpleManagerService;
|
||||
import org.sadtech.bot.vcs.core.domain.Answer;
|
||||
import org.sadtech.bot.vcs.core.domain.change.comment.AnswerCommentChange;
|
||||
import org.sadtech.bot.vcs.core.domain.change.comment.CommentChange;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.comment.AnswerCommentNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.comment.CommentNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.entity.Comment;
|
||||
import org.sadtech.bot.vcs.core.domain.entity.Task;
|
||||
import org.sadtech.bot.vcs.core.exception.NotFoundException;
|
||||
import org.sadtech.bot.vcs.core.repository.CommentRepository;
|
||||
import org.sadtech.bot.vcs.core.service.ChangeService;
|
||||
import org.sadtech.bot.vcs.core.service.NotifyService;
|
||||
import org.sadtech.bot.vcs.core.service.CommentService;
|
||||
import org.sadtech.bot.vcs.core.service.PersonService;
|
||||
import org.sadtech.bot.vcs.core.service.TaskService;
|
||||
@ -33,7 +33,7 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
|
||||
|
||||
private final CommentRepository commentRepository;
|
||||
private final PersonService personService;
|
||||
private final ChangeService changeService;
|
||||
private final NotifyService notifyService;
|
||||
private final TaskService taskService;
|
||||
|
||||
private final ConversionService conversionService;
|
||||
@ -41,14 +41,14 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
|
||||
public CommentServiceImpl(
|
||||
CommentRepository commentRepository,
|
||||
PersonService personService,
|
||||
ChangeService changeService,
|
||||
NotifyService notifyService,
|
||||
@Lazy TaskService taskService,
|
||||
ConversionService conversionService
|
||||
) {
|
||||
super(commentRepository);
|
||||
this.personService = personService;
|
||||
this.commentRepository = commentRepository;
|
||||
this.changeService = changeService;
|
||||
this.notifyService = notifyService;
|
||||
this.taskService = taskService;
|
||||
this.conversionService = conversionService;
|
||||
}
|
||||
@ -79,8 +79,8 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
|
||||
recipientsLogins.add(login);
|
||||
}
|
||||
final Set<Long> recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins);
|
||||
changeService.save(
|
||||
CommentChange.builder()
|
||||
notifyService.save(
|
||||
CommentNotify.builder()
|
||||
.authorName(comment.getAuthor())
|
||||
.url(comment.getUrl())
|
||||
.telegramIds(recipientsIds)
|
||||
@ -132,8 +132,8 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
|
||||
.collect(Collectors.toList());
|
||||
oldComment.getAnswers().clear();
|
||||
oldComment.setAnswers(existsNewAnswersIds);
|
||||
changeService.save(
|
||||
AnswerCommentChange.builder()
|
||||
notifyService.save(
|
||||
AnswerCommentNotify.builder()
|
||||
.telegramIds(
|
||||
personService.getAllTelegramIdByLogin(Collections.singleton(newComment.getAuthor()))
|
||||
)
|
||||
|
@ -0,0 +1,29 @@
|
||||
package org.sadtech.bot.vcs.core.service.impl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||
import org.sadtech.bot.vcs.core.repository.NotifyRepository;
|
||||
import org.sadtech.bot.vcs.core.service.NotifyService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class NotifyServiceImpl implements NotifyService {
|
||||
|
||||
private final NotifyRepository notifyRepository;
|
||||
|
||||
@Override
|
||||
public <T extends Notify> void save(T notify) {
|
||||
notifyRepository.add(notify);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Notify> getNew() {
|
||||
final List<Notify> notifies = notifyRepository.getAll();
|
||||
notifyRepository.deleteAll(notifies);
|
||||
return notifies;
|
||||
}
|
||||
|
||||
}
|
@ -11,11 +11,11 @@ import org.sadtech.basic.filter.criteria.CriteriaQuery;
|
||||
import org.sadtech.bot.vcs.core.domain.IdAndStatusPr;
|
||||
import org.sadtech.bot.vcs.core.domain.PullRequestStatus;
|
||||
import org.sadtech.bot.vcs.core.domain.ReviewerStatus;
|
||||
import org.sadtech.bot.vcs.core.domain.change.pullrequest.ConflictPrChange;
|
||||
import org.sadtech.bot.vcs.core.domain.change.pullrequest.NewPrChange;
|
||||
import org.sadtech.bot.vcs.core.domain.change.pullrequest.ReviewersPrChange;
|
||||
import org.sadtech.bot.vcs.core.domain.change.pullrequest.StatusPrChange;
|
||||
import org.sadtech.bot.vcs.core.domain.change.pullrequest.UpdatePrChange;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.pullrequest.ConflictPrNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.pullrequest.NewPrNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.pullrequest.ReviewersPrNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.pullrequest.StatusPrNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.pullrequest.UpdatePrNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.entity.PullRequest;
|
||||
import org.sadtech.bot.vcs.core.domain.entity.PullRequestMini;
|
||||
import org.sadtech.bot.vcs.core.domain.entity.PullRequest_;
|
||||
@ -24,7 +24,7 @@ import org.sadtech.bot.vcs.core.domain.filter.PullRequestFilter;
|
||||
import org.sadtech.bot.vcs.core.domain.util.ReviewerChange;
|
||||
import org.sadtech.bot.vcs.core.exception.UpdateException;
|
||||
import org.sadtech.bot.vcs.core.repository.PullRequestsRepository;
|
||||
import org.sadtech.bot.vcs.core.service.ChangeService;
|
||||
import org.sadtech.bot.vcs.core.service.NotifyService;
|
||||
import org.sadtech.bot.vcs.core.service.PersonService;
|
||||
import org.sadtech.bot.vcs.core.service.PullRequestsService;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
@ -41,18 +41,18 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRequest, Long> implements PullRequestsService {
|
||||
|
||||
private final ChangeService changeService;
|
||||
private final NotifyService notifyService;
|
||||
private final PullRequestsRepository pullRequestsRepository;
|
||||
private final PersonService personService;
|
||||
private final FilterService<PullRequest, PullRequestFilter> filterService;
|
||||
|
||||
protected PullRequestsServiceImpl(
|
||||
PullRequestsRepository pullRequestsRepository,
|
||||
ChangeService changeService,
|
||||
NotifyService notifyService,
|
||||
PersonService personService, @Qualifier("pullRequestFilterService") FilterService<PullRequest, PullRequestFilter> pullRequestsFilterService
|
||||
) {
|
||||
super(pullRequestsRepository);
|
||||
this.changeService = changeService;
|
||||
this.notifyService = notifyService;
|
||||
this.pullRequestsRepository = pullRequestsRepository;
|
||||
this.personService = personService;
|
||||
this.filterService = pullRequestsFilterService;
|
||||
@ -64,8 +64,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
|
||||
final PullRequest newPullRequest = pullRequestsRepository.save(pullRequest);
|
||||
|
||||
changeService.save(
|
||||
NewPrChange.builder()
|
||||
notifyService.save(
|
||||
NewPrNotify.builder()
|
||||
.author(newPullRequest.getAuthorLogin())
|
||||
.description(newPullRequest.getDescription())
|
||||
.title(newPullRequest.getTitle())
|
||||
@ -98,8 +98,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
|
||||
final PullRequest newPullRequest = pullRequestsRepository.save(oldPullRequest);
|
||||
if (!pullRequest.getBitbucketVersion().equals(newPullRequest.getBitbucketVersion())) {
|
||||
changeService.save(
|
||||
UpdatePrChange.builder()
|
||||
notifyService.save(
|
||||
UpdatePrNotify.builder()
|
||||
.author(oldPullRequest.getAuthorLogin())
|
||||
.name(newPullRequest.getTitle())
|
||||
.telegramIds(getReviewerTelegrams(newPullRequest.getReviewers()))
|
||||
@ -113,8 +113,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
|
||||
private void updateConflict(PullRequest oldPullRequest, PullRequest pullRequest) {
|
||||
if (!oldPullRequest.isConflict() && pullRequest.isConflict()) {
|
||||
changeService.save(
|
||||
ConflictPrChange.builder()
|
||||
notifyService.save(
|
||||
ConflictPrNotify.builder()
|
||||
.name(pullRequest.getTitle())
|
||||
.url(pullRequest.getUrl())
|
||||
.telegramIds(
|
||||
@ -130,8 +130,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
final PullRequestStatus oldStatus = oldPullRequest.getStatus();
|
||||
final PullRequestStatus newStatus = newPullRequest.getStatus();
|
||||
if (!oldStatus.equals(newStatus)) {
|
||||
changeService.save(
|
||||
StatusPrChange.builder()
|
||||
notifyService.save(
|
||||
StatusPrNotify.builder()
|
||||
.name(newPullRequest.getTitle())
|
||||
.url(oldPullRequest.getUrl())
|
||||
.newStatus(newStatus)
|
||||
@ -179,8 +179,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
||||
oldPullRequest.getReviewers()
|
||||
.removeIf(reviewer -> oldIds.contains(reviewer.getPersonLogin()));
|
||||
if (!reviewerChanges.isEmpty()) {
|
||||
changeService.save(
|
||||
ReviewersPrChange.builder()
|
||||
notifyService.save(
|
||||
ReviewersPrNotify.builder()
|
||||
.title(newPullRequest.getTitle())
|
||||
.url(newPullRequest.getUrl())
|
||||
.telegramIds(
|
||||
|
@ -5,16 +5,16 @@ import org.sadtech.basic.core.service.AbstractSimpleManagerService;
|
||||
import org.sadtech.basic.core.util.Assert;
|
||||
import org.sadtech.bot.vcs.core.domain.Answer;
|
||||
import org.sadtech.bot.vcs.core.domain.TaskStatus;
|
||||
import org.sadtech.bot.vcs.core.domain.change.comment.AnswerCommentChange;
|
||||
import org.sadtech.bot.vcs.core.domain.change.comment.CommentChange;
|
||||
import org.sadtech.bot.vcs.core.domain.change.task.TaskCloseChange;
|
||||
import org.sadtech.bot.vcs.core.domain.change.task.TaskNewChange;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.comment.AnswerCommentNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.comment.CommentNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.task.TaskCloseNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.notify.task.TaskNewNotify;
|
||||
import org.sadtech.bot.vcs.core.domain.entity.Comment;
|
||||
import org.sadtech.bot.vcs.core.domain.entity.PullRequest;
|
||||
import org.sadtech.bot.vcs.core.domain.entity.Task;
|
||||
import org.sadtech.bot.vcs.core.exception.NotFoundException;
|
||||
import org.sadtech.bot.vcs.core.repository.TaskRepository;
|
||||
import org.sadtech.bot.vcs.core.service.ChangeService;
|
||||
import org.sadtech.bot.vcs.core.service.NotifyService;
|
||||
import org.sadtech.bot.vcs.core.service.CommentService;
|
||||
import org.sadtech.bot.vcs.core.service.PersonService;
|
||||
import org.sadtech.bot.vcs.core.service.PullRequestsService;
|
||||
@ -39,7 +39,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
||||
private final TaskRepository taskRepository;
|
||||
|
||||
private final PullRequestsService pullRequestsService;
|
||||
private final ChangeService changeService;
|
||||
private final NotifyService notifyService;
|
||||
private final PersonService personService;
|
||||
private final CommentService commentService;
|
||||
|
||||
@ -48,7 +48,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
||||
public TaskServiceImpl(
|
||||
TaskRepository taskRepository,
|
||||
PullRequestsService pullRequestsService,
|
||||
ChangeService changeService,
|
||||
NotifyService notifyService,
|
||||
PersonService personService,
|
||||
CommentService commentService,
|
||||
ConversionService conversionService
|
||||
@ -56,7 +56,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
||||
super(taskRepository);
|
||||
this.taskRepository = taskRepository;
|
||||
this.pullRequestsService = pullRequestsService;
|
||||
this.changeService = changeService;
|
||||
this.notifyService = notifyService;
|
||||
this.personService = personService;
|
||||
this.commentService = commentService;
|
||||
this.conversionService = conversionService;
|
||||
@ -93,8 +93,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
||||
if (!oldStatus.equals(newStatus)) {
|
||||
switch (newStatus) {
|
||||
case OPEN:
|
||||
changeService.save(
|
||||
TaskNewChange.builder()
|
||||
notifyService.save(
|
||||
TaskNewNotify.builder()
|
||||
.messageTask(task.getDescription())
|
||||
.authorName(oldTask.getAuthor())
|
||||
.url(oldTask.getUrl())
|
||||
@ -105,8 +105,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
||||
);
|
||||
break;
|
||||
case RESOLVED:
|
||||
changeService.save(
|
||||
TaskCloseChange.builder()
|
||||
notifyService.save(
|
||||
TaskCloseNotify.builder()
|
||||
.messageTask(oldTask.getDescription())
|
||||
.authorName(oldTask.getAuthor())
|
||||
.url(oldTask.getUrl())
|
||||
@ -133,8 +133,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
||||
.collect(Collectors.toList());
|
||||
oldTask.getAnswers().clear();
|
||||
oldTask.setAnswers(existsNewAnswersIds);
|
||||
changeService.save(
|
||||
AnswerCommentChange.builder()
|
||||
notifyService.save(
|
||||
AnswerCommentNotify.builder()
|
||||
.telegramIds(
|
||||
personService.getAllTelegramIdByLogin(Collections.singleton(oldTask.getAuthor()))
|
||||
)
|
||||
@ -178,8 +178,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
||||
final PullRequest pullRequest = pullRequestsService.getById(task.getPullRequestId())
|
||||
.orElseThrow(() -> new NotFoundException("ПР не найден"));
|
||||
|
||||
changeService.save(
|
||||
TaskNewChange.builder()
|
||||
notifyService.save(
|
||||
TaskNewNotify.builder()
|
||||
.authorName(task.getAuthor())
|
||||
.messageTask(task.getDescription())
|
||||
.url(task.getUrl())
|
||||
@ -200,8 +200,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
||||
recipientsLogins.add(login);
|
||||
}
|
||||
final Set<Long> recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins);
|
||||
changeService.save(
|
||||
CommentChange.builder()
|
||||
notifyService.save(
|
||||
CommentNotify.builder()
|
||||
.authorName(task.getAuthor())
|
||||
.url(task.getUrl())
|
||||
.telegramIds(recipientsIds)
|
||||
|
Loading…
Reference in New Issue
Block a user