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.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.sadtech.bot.vcs.core.scheduler.SchedulerComments;
|
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
import org.springframework.stereotype.Component;
|
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.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -9,9 +9,9 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
|
@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 LocalDateTime localDateTime = LocalDateTime.now();
|
||||||
protected final Set<Long> telegramIds;
|
protected final Set<Long> telegramIds;
|
||||||
|
|
||||||
@ -19,7 +19,7 @@ public abstract class Change {
|
|||||||
@EqualsAndHashCode.Include
|
@EqualsAndHashCode.Include
|
||||||
protected Long id;
|
protected Long id;
|
||||||
|
|
||||||
protected Change(ChangeType type, Set<Long> telegramIds) {
|
protected Notify(NotifyType type, Set<Long> telegramIds) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.telegramIds = telegramIds;
|
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,
|
STATUS_PR,
|
||||||
UPDATE_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.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.sadtech.bot.vcs.core.domain.Answer;
|
import org.sadtech.bot.vcs.core.domain.Answer;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||||
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 org.sadtech.bot.vcs.core.utils.Smile;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -15,20 +15,20 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class AnswerCommentChange extends Change {
|
public class AnswerCommentNotify extends Notify {
|
||||||
|
|
||||||
private final String youMessage;
|
private final String youMessage;
|
||||||
private final String url;
|
private final String url;
|
||||||
private final List<Answer> answers;
|
private final List<Answer> answers;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
protected AnswerCommentChange(
|
protected AnswerCommentNotify(
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String youMessage,
|
String youMessage,
|
||||||
String url,
|
String url,
|
||||||
List<Answer> answers
|
List<Answer> answers
|
||||||
) {
|
) {
|
||||||
super(ChangeType.NEW_ANSWERS_COMMENT, telegramIds);
|
super(NotifyType.NEW_ANSWERS_COMMENT, telegramIds);
|
||||||
this.youMessage = youMessage;
|
this.youMessage = youMessage;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.answers = answers;
|
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.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||||
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 org.sadtech.bot.vcs.core.utils.Smile;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -12,20 +12,20 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class CommentChange extends Change {
|
public class CommentNotify extends Notify {
|
||||||
|
|
||||||
private final String authorName;
|
private final String authorName;
|
||||||
private final String message;
|
private final String message;
|
||||||
private final String url;
|
private final String url;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
private CommentChange(
|
private CommentNotify(
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String url,
|
String url,
|
||||||
String authorName,
|
String authorName,
|
||||||
String message
|
String message
|
||||||
) {
|
) {
|
||||||
super(ChangeType.NEW_COMMENT, telegramIds);
|
super(NotifyType.NEW_COMMENT, telegramIds);
|
||||||
this.authorName = authorName;
|
this.authorName = authorName;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.url = url;
|
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.Builder;
|
||||||
import lombok.Getter;
|
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 org.sadtech.bot.vcs.core.utils.Smile;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class ConflictPrChange extends PrChange {
|
public class ConflictPrNotify extends PrNotify {
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
private ConflictPrChange(
|
private ConflictPrNotify(
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String name,
|
String name,
|
||||||
String url
|
String url
|
||||||
) {
|
) {
|
||||||
super(ChangeType.CONFLICT_PR, telegramIds, name, url);
|
super(NotifyType.CONFLICT_PR, telegramIds, name, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
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 org.sadtech.bot.vcs.core.utils.Smile;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -11,19 +11,19 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class NewPrChange extends PrChange {
|
public class NewPrNotify extends PrNotify {
|
||||||
|
|
||||||
private final String description;
|
private final String description;
|
||||||
private final String author;
|
private final String author;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
private NewPrChange(
|
private NewPrNotify(
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String title,
|
String title,
|
||||||
String url,
|
String url,
|
||||||
String description,
|
String description,
|
||||||
String author) {
|
String author) {
|
||||||
super(ChangeType.NEW_PR, telegramIds, title, url);
|
super(NotifyType.NEW_PR, telegramIds, title, url);
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.author = author;
|
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.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public abstract class PrChange extends Change {
|
public abstract class PrNotify extends Notify {
|
||||||
|
|
||||||
protected final String title;
|
protected final String title;
|
||||||
protected final String url;
|
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);
|
super(type, telegramIds);
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.url = url;
|
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.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
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.domain.util.ReviewerChange;
|
||||||
import org.sadtech.bot.vcs.core.utils.Smile;
|
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
|
@Getter
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class ReviewersPrChange extends PrChange {
|
public class ReviewersPrNotify extends PrNotify {
|
||||||
|
|
||||||
private final List<ReviewerChange> reviewerChanges;
|
private final List<ReviewerChange> reviewerChanges;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
private ReviewersPrChange(
|
private ReviewersPrNotify(
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String title,
|
String title,
|
||||||
String url,
|
String url,
|
||||||
List<ReviewerChange> reviewerChanges) {
|
List<ReviewerChange> reviewerChanges) {
|
||||||
super(ChangeType.REVIEWERS, telegramIds, title, url);
|
super(NotifyType.REVIEWERS, telegramIds, title, url);
|
||||||
this.reviewerChanges = reviewerChanges;
|
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.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.sadtech.bot.vcs.core.domain.PullRequestStatus;
|
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 org.sadtech.bot.vcs.core.utils.Smile;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -12,19 +12,19 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class StatusPrChange extends PrChange {
|
public class StatusPrNotify extends PrNotify {
|
||||||
|
|
||||||
private final PullRequestStatus oldStatus;
|
private final PullRequestStatus oldStatus;
|
||||||
private final PullRequestStatus newStatus;
|
private final PullRequestStatus newStatus;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
private StatusPrChange(
|
private StatusPrNotify(
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String name,
|
String name,
|
||||||
String url,
|
String url,
|
||||||
PullRequestStatus oldStatus,
|
PullRequestStatus oldStatus,
|
||||||
PullRequestStatus newStatus) {
|
PullRequestStatus newStatus) {
|
||||||
super(ChangeType.STATUS_PR, telegramIds, name, url);
|
super(NotifyType.STATUS_PR, telegramIds, name, url);
|
||||||
this.oldStatus = oldStatus;
|
this.oldStatus = oldStatus;
|
||||||
this.newStatus = newStatus;
|
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.Builder;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
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 org.sadtech.bot.vcs.core.utils.Smile;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -11,16 +11,16 @@ import java.util.Set;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class UpdatePrChange extends PrChange {
|
public class UpdatePrNotify extends PrNotify {
|
||||||
|
|
||||||
private final String author;
|
private final String author;
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
private UpdatePrChange(
|
private UpdatePrNotify(
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String name,
|
String name,
|
||||||
String url, String author) {
|
String url, String author) {
|
||||||
super(ChangeType.UPDATE_PR, telegramIds, name, url);
|
super(NotifyType.UPDATE_PR, telegramIds, name, url);
|
||||||
this.author = author;
|
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 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 org.sadtech.bot.vcs.core.utils.Smile;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -12,16 +12,16 @@ import java.util.Set;
|
|||||||
*
|
*
|
||||||
* @author upagge 10.09.2020
|
* @author upagge 10.09.2020
|
||||||
*/
|
*/
|
||||||
public class TaskCloseChange extends TaskChange {
|
public class TaskCloseNotify extends TaskNotify {
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
protected TaskCloseChange(
|
protected TaskCloseNotify(
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String authorName,
|
String authorName,
|
||||||
String url,
|
String url,
|
||||||
String messageTask
|
String messageTask
|
||||||
) {
|
) {
|
||||||
super(ChangeType.RESOLVED_TASK, telegramIds, authorName, url, messageTask);
|
super(NotifyType.RESOLVED_TASK, telegramIds, authorName, url, messageTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.Builder;
|
||||||
import lombok.Getter;
|
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 org.sadtech.bot.vcs.core.utils.Smile;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -14,16 +14,16 @@ import java.util.Set;
|
|||||||
* @author upagge 10.09.2020
|
* @author upagge 10.09.2020
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
public class TaskNewChange extends TaskChange {
|
public class TaskNewNotify extends TaskNotify {
|
||||||
|
|
||||||
@Builder
|
@Builder
|
||||||
protected TaskNewChange(
|
protected TaskNewNotify(
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String authorName,
|
String authorName,
|
||||||
String url,
|
String url,
|
||||||
String messageTask
|
String messageTask
|
||||||
) {
|
) {
|
||||||
super(ChangeType.NEW_TASK, telegramIds, authorName, url, messageTask);
|
super(NotifyType.NEW_TASK, telegramIds, authorName, url, messageTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.ChangeType;
|
import org.sadtech.bot.vcs.core.domain.notify.NotifyType;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public abstract class TaskChange extends Change {
|
public abstract class TaskNotify extends Notify {
|
||||||
|
|
||||||
protected final String authorName;
|
protected final String authorName;
|
||||||
protected final String url;
|
protected final String url;
|
||||||
protected final String messageTask;
|
protected final String messageTask;
|
||||||
|
|
||||||
protected TaskChange(
|
protected TaskNotify(
|
||||||
ChangeType type,
|
NotifyType type,
|
||||||
Set<Long> telegramIds,
|
Set<Long> telegramIds,
|
||||||
String authorName,
|
String authorName,
|
||||||
String url,
|
String url,
|
@ -12,8 +12,8 @@ import org.sadtech.bot.vcs.core.domain.ReviewerStatus;
|
|||||||
@Getter
|
@Getter
|
||||||
public class ReviewerChange {
|
public class ReviewerChange {
|
||||||
|
|
||||||
private String name;
|
private final String name;
|
||||||
private Type type;
|
private final Type type;
|
||||||
private ReviewerStatus status;
|
private ReviewerStatus status;
|
||||||
private ReviewerStatus oldStatus;
|
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
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SchedulerNotification {
|
public class NotificationScheduler {
|
||||||
|
|
||||||
private static final Set<String> tksLoginNotify = new HashSet<>(Arrays.asList(
|
private static final Set<String> tksLoginNotify = new HashSet<>(Arrays.asList(
|
||||||
"mstruchkov", "dganin", "emukhin", "ktorgaeva", "imescheryakov", "kkeglev"
|
"mstruchkov", "dganin", "emukhin", "ktorgaeva", "imescheryakov", "kkeglev"
|
@ -2,8 +2,8 @@ package org.sadtech.bot.vcs.core.scheduler;
|
|||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.sadtech.bot.vcs.core.domain.MessageSend;
|
import org.sadtech.bot.vcs.core.domain.MessageSend;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.Change;
|
import org.sadtech.bot.vcs.core.domain.notify.Notify;
|
||||||
import org.sadtech.bot.vcs.core.service.ChangeService;
|
import org.sadtech.bot.vcs.core.service.NotifyService;
|
||||||
import org.sadtech.bot.vcs.core.service.MessageSendService;
|
import org.sadtech.bot.vcs.core.service.MessageSendService;
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@ -19,10 +19,10 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class SchedulerChangeParsing {
|
public class NotifyParsingScheduler {
|
||||||
|
|
||||||
private final MessageSendService messageSendService;
|
private final MessageSendService messageSendService;
|
||||||
private final ChangeService changeService;
|
private final NotifyService notifyService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Проверяет наличие новых изменений. Если изменения найдены, то создает новое сообщение и отправляет
|
* Проверяет наличие новых изменений. Если изменения найдены, то создает новое сообщение и отправляет
|
||||||
@ -30,12 +30,12 @@ public class SchedulerChangeParsing {
|
|||||||
*/
|
*/
|
||||||
@Scheduled(cron = "*/15 * * * * *")
|
@Scheduled(cron = "*/15 * * * * *")
|
||||||
public void parsing() {
|
public void parsing() {
|
||||||
final List<Change> newChange = changeService.getNew().stream()
|
final List<Notify> newNotify = notifyService.getNew().stream()
|
||||||
.filter(change -> change.getTelegramIds() != null && !change.getTelegramIds().isEmpty())
|
.filter(notify -> notify.getTelegramIds() != null && !notify.getTelegramIds().isEmpty())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
for (Change change : newChange) {
|
for (Notify notify : newNotify) {
|
||||||
final String message = change.generateMessage();
|
final String message = notify.generateMessage();
|
||||||
change.getTelegramIds().forEach(
|
notify.getTelegramIds().forEach(
|
||||||
telegramId -> messageSendService.add(
|
telegramId -> messageSendService.add(
|
||||||
MessageSend.builder()
|
MessageSend.builder()
|
||||||
.telegramId(telegramId)
|
.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;
|
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;
|
import java.util.List;
|
||||||
|
|
||||||
@ -8,15 +8,15 @@ import java.util.List;
|
|||||||
* Сервис по работе с изменениями в битбакете.
|
* Сервис по работе с изменениями в битбакете.
|
||||||
*
|
*
|
||||||
* @author upagge
|
* @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 lombok.NonNull;
|
||||||
import org.sadtech.basic.core.service.AbstractSimpleManagerService;
|
import org.sadtech.basic.core.service.AbstractSimpleManagerService;
|
||||||
import org.sadtech.bot.vcs.core.domain.Answer;
|
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.notify.comment.AnswerCommentNotify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.comment.CommentChange;
|
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.Comment;
|
||||||
import org.sadtech.bot.vcs.core.domain.entity.Task;
|
import org.sadtech.bot.vcs.core.domain.entity.Task;
|
||||||
import org.sadtech.bot.vcs.core.exception.NotFoundException;
|
import org.sadtech.bot.vcs.core.exception.NotFoundException;
|
||||||
import org.sadtech.bot.vcs.core.repository.CommentRepository;
|
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.CommentService;
|
||||||
import org.sadtech.bot.vcs.core.service.PersonService;
|
import org.sadtech.bot.vcs.core.service.PersonService;
|
||||||
import org.sadtech.bot.vcs.core.service.TaskService;
|
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 CommentRepository commentRepository;
|
||||||
private final PersonService personService;
|
private final PersonService personService;
|
||||||
private final ChangeService changeService;
|
private final NotifyService notifyService;
|
||||||
private final TaskService taskService;
|
private final TaskService taskService;
|
||||||
|
|
||||||
private final ConversionService conversionService;
|
private final ConversionService conversionService;
|
||||||
@ -41,14 +41,14 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
|
|||||||
public CommentServiceImpl(
|
public CommentServiceImpl(
|
||||||
CommentRepository commentRepository,
|
CommentRepository commentRepository,
|
||||||
PersonService personService,
|
PersonService personService,
|
||||||
ChangeService changeService,
|
NotifyService notifyService,
|
||||||
@Lazy TaskService taskService,
|
@Lazy TaskService taskService,
|
||||||
ConversionService conversionService
|
ConversionService conversionService
|
||||||
) {
|
) {
|
||||||
super(commentRepository);
|
super(commentRepository);
|
||||||
this.personService = personService;
|
this.personService = personService;
|
||||||
this.commentRepository = commentRepository;
|
this.commentRepository = commentRepository;
|
||||||
this.changeService = changeService;
|
this.notifyService = notifyService;
|
||||||
this.taskService = taskService;
|
this.taskService = taskService;
|
||||||
this.conversionService = conversionService;
|
this.conversionService = conversionService;
|
||||||
}
|
}
|
||||||
@ -79,8 +79,8 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
|
|||||||
recipientsLogins.add(login);
|
recipientsLogins.add(login);
|
||||||
}
|
}
|
||||||
final Set<Long> recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins);
|
final Set<Long> recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins);
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
CommentChange.builder()
|
CommentNotify.builder()
|
||||||
.authorName(comment.getAuthor())
|
.authorName(comment.getAuthor())
|
||||||
.url(comment.getUrl())
|
.url(comment.getUrl())
|
||||||
.telegramIds(recipientsIds)
|
.telegramIds(recipientsIds)
|
||||||
@ -132,8 +132,8 @@ public class CommentServiceImpl extends AbstractSimpleManagerService<Comment, Lo
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
oldComment.getAnswers().clear();
|
oldComment.getAnswers().clear();
|
||||||
oldComment.setAnswers(existsNewAnswersIds);
|
oldComment.setAnswers(existsNewAnswersIds);
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
AnswerCommentChange.builder()
|
AnswerCommentNotify.builder()
|
||||||
.telegramIds(
|
.telegramIds(
|
||||||
personService.getAllTelegramIdByLogin(Collections.singleton(newComment.getAuthor()))
|
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.IdAndStatusPr;
|
||||||
import org.sadtech.bot.vcs.core.domain.PullRequestStatus;
|
import org.sadtech.bot.vcs.core.domain.PullRequestStatus;
|
||||||
import org.sadtech.bot.vcs.core.domain.ReviewerStatus;
|
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.notify.pullrequest.ConflictPrNotify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.pullrequest.NewPrChange;
|
import org.sadtech.bot.vcs.core.domain.notify.pullrequest.NewPrNotify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.pullrequest.ReviewersPrChange;
|
import org.sadtech.bot.vcs.core.domain.notify.pullrequest.ReviewersPrNotify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.pullrequest.StatusPrChange;
|
import org.sadtech.bot.vcs.core.domain.notify.pullrequest.StatusPrNotify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.pullrequest.UpdatePrChange;
|
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.PullRequest;
|
||||||
import org.sadtech.bot.vcs.core.domain.entity.PullRequestMini;
|
import org.sadtech.bot.vcs.core.domain.entity.PullRequestMini;
|
||||||
import org.sadtech.bot.vcs.core.domain.entity.PullRequest_;
|
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.domain.util.ReviewerChange;
|
||||||
import org.sadtech.bot.vcs.core.exception.UpdateException;
|
import org.sadtech.bot.vcs.core.exception.UpdateException;
|
||||||
import org.sadtech.bot.vcs.core.repository.PullRequestsRepository;
|
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.PersonService;
|
||||||
import org.sadtech.bot.vcs.core.service.PullRequestsService;
|
import org.sadtech.bot.vcs.core.service.PullRequestsService;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
@ -41,18 +41,18 @@ import java.util.stream.Collectors;
|
|||||||
@Service
|
@Service
|
||||||
public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRequest, Long> implements PullRequestsService {
|
public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRequest, Long> implements PullRequestsService {
|
||||||
|
|
||||||
private final ChangeService changeService;
|
private final NotifyService notifyService;
|
||||||
private final PullRequestsRepository pullRequestsRepository;
|
private final PullRequestsRepository pullRequestsRepository;
|
||||||
private final PersonService personService;
|
private final PersonService personService;
|
||||||
private final FilterService<PullRequest, PullRequestFilter> filterService;
|
private final FilterService<PullRequest, PullRequestFilter> filterService;
|
||||||
|
|
||||||
protected PullRequestsServiceImpl(
|
protected PullRequestsServiceImpl(
|
||||||
PullRequestsRepository pullRequestsRepository,
|
PullRequestsRepository pullRequestsRepository,
|
||||||
ChangeService changeService,
|
NotifyService notifyService,
|
||||||
PersonService personService, @Qualifier("pullRequestFilterService") FilterService<PullRequest, PullRequestFilter> pullRequestsFilterService
|
PersonService personService, @Qualifier("pullRequestFilterService") FilterService<PullRequest, PullRequestFilter> pullRequestsFilterService
|
||||||
) {
|
) {
|
||||||
super(pullRequestsRepository);
|
super(pullRequestsRepository);
|
||||||
this.changeService = changeService;
|
this.notifyService = notifyService;
|
||||||
this.pullRequestsRepository = pullRequestsRepository;
|
this.pullRequestsRepository = pullRequestsRepository;
|
||||||
this.personService = personService;
|
this.personService = personService;
|
||||||
this.filterService = pullRequestsFilterService;
|
this.filterService = pullRequestsFilterService;
|
||||||
@ -64,8 +64,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
|||||||
|
|
||||||
final PullRequest newPullRequest = pullRequestsRepository.save(pullRequest);
|
final PullRequest newPullRequest = pullRequestsRepository.save(pullRequest);
|
||||||
|
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
NewPrChange.builder()
|
NewPrNotify.builder()
|
||||||
.author(newPullRequest.getAuthorLogin())
|
.author(newPullRequest.getAuthorLogin())
|
||||||
.description(newPullRequest.getDescription())
|
.description(newPullRequest.getDescription())
|
||||||
.title(newPullRequest.getTitle())
|
.title(newPullRequest.getTitle())
|
||||||
@ -98,8 +98,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
|||||||
|
|
||||||
final PullRequest newPullRequest = pullRequestsRepository.save(oldPullRequest);
|
final PullRequest newPullRequest = pullRequestsRepository.save(oldPullRequest);
|
||||||
if (!pullRequest.getBitbucketVersion().equals(newPullRequest.getBitbucketVersion())) {
|
if (!pullRequest.getBitbucketVersion().equals(newPullRequest.getBitbucketVersion())) {
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
UpdatePrChange.builder()
|
UpdatePrNotify.builder()
|
||||||
.author(oldPullRequest.getAuthorLogin())
|
.author(oldPullRequest.getAuthorLogin())
|
||||||
.name(newPullRequest.getTitle())
|
.name(newPullRequest.getTitle())
|
||||||
.telegramIds(getReviewerTelegrams(newPullRequest.getReviewers()))
|
.telegramIds(getReviewerTelegrams(newPullRequest.getReviewers()))
|
||||||
@ -113,8 +113,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
|||||||
|
|
||||||
private void updateConflict(PullRequest oldPullRequest, PullRequest pullRequest) {
|
private void updateConflict(PullRequest oldPullRequest, PullRequest pullRequest) {
|
||||||
if (!oldPullRequest.isConflict() && pullRequest.isConflict()) {
|
if (!oldPullRequest.isConflict() && pullRequest.isConflict()) {
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
ConflictPrChange.builder()
|
ConflictPrNotify.builder()
|
||||||
.name(pullRequest.getTitle())
|
.name(pullRequest.getTitle())
|
||||||
.url(pullRequest.getUrl())
|
.url(pullRequest.getUrl())
|
||||||
.telegramIds(
|
.telegramIds(
|
||||||
@ -130,8 +130,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
|||||||
final PullRequestStatus oldStatus = oldPullRequest.getStatus();
|
final PullRequestStatus oldStatus = oldPullRequest.getStatus();
|
||||||
final PullRequestStatus newStatus = newPullRequest.getStatus();
|
final PullRequestStatus newStatus = newPullRequest.getStatus();
|
||||||
if (!oldStatus.equals(newStatus)) {
|
if (!oldStatus.equals(newStatus)) {
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
StatusPrChange.builder()
|
StatusPrNotify.builder()
|
||||||
.name(newPullRequest.getTitle())
|
.name(newPullRequest.getTitle())
|
||||||
.url(oldPullRequest.getUrl())
|
.url(oldPullRequest.getUrl())
|
||||||
.newStatus(newStatus)
|
.newStatus(newStatus)
|
||||||
@ -179,8 +179,8 @@ public class PullRequestsServiceImpl extends AbstractSimpleManagerService<PullRe
|
|||||||
oldPullRequest.getReviewers()
|
oldPullRequest.getReviewers()
|
||||||
.removeIf(reviewer -> oldIds.contains(reviewer.getPersonLogin()));
|
.removeIf(reviewer -> oldIds.contains(reviewer.getPersonLogin()));
|
||||||
if (!reviewerChanges.isEmpty()) {
|
if (!reviewerChanges.isEmpty()) {
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
ReviewersPrChange.builder()
|
ReviewersPrNotify.builder()
|
||||||
.title(newPullRequest.getTitle())
|
.title(newPullRequest.getTitle())
|
||||||
.url(newPullRequest.getUrl())
|
.url(newPullRequest.getUrl())
|
||||||
.telegramIds(
|
.telegramIds(
|
||||||
|
@ -5,16 +5,16 @@ import org.sadtech.basic.core.service.AbstractSimpleManagerService;
|
|||||||
import org.sadtech.basic.core.util.Assert;
|
import org.sadtech.basic.core.util.Assert;
|
||||||
import org.sadtech.bot.vcs.core.domain.Answer;
|
import org.sadtech.bot.vcs.core.domain.Answer;
|
||||||
import org.sadtech.bot.vcs.core.domain.TaskStatus;
|
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.notify.comment.AnswerCommentNotify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.comment.CommentChange;
|
import org.sadtech.bot.vcs.core.domain.notify.comment.CommentNotify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.task.TaskCloseChange;
|
import org.sadtech.bot.vcs.core.domain.notify.task.TaskCloseNotify;
|
||||||
import org.sadtech.bot.vcs.core.domain.change.task.TaskNewChange;
|
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.Comment;
|
||||||
import org.sadtech.bot.vcs.core.domain.entity.PullRequest;
|
import org.sadtech.bot.vcs.core.domain.entity.PullRequest;
|
||||||
import org.sadtech.bot.vcs.core.domain.entity.Task;
|
import org.sadtech.bot.vcs.core.domain.entity.Task;
|
||||||
import org.sadtech.bot.vcs.core.exception.NotFoundException;
|
import org.sadtech.bot.vcs.core.exception.NotFoundException;
|
||||||
import org.sadtech.bot.vcs.core.repository.TaskRepository;
|
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.CommentService;
|
||||||
import org.sadtech.bot.vcs.core.service.PersonService;
|
import org.sadtech.bot.vcs.core.service.PersonService;
|
||||||
import org.sadtech.bot.vcs.core.service.PullRequestsService;
|
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 TaskRepository taskRepository;
|
||||||
|
|
||||||
private final PullRequestsService pullRequestsService;
|
private final PullRequestsService pullRequestsService;
|
||||||
private final ChangeService changeService;
|
private final NotifyService notifyService;
|
||||||
private final PersonService personService;
|
private final PersonService personService;
|
||||||
private final CommentService commentService;
|
private final CommentService commentService;
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
|||||||
public TaskServiceImpl(
|
public TaskServiceImpl(
|
||||||
TaskRepository taskRepository,
|
TaskRepository taskRepository,
|
||||||
PullRequestsService pullRequestsService,
|
PullRequestsService pullRequestsService,
|
||||||
ChangeService changeService,
|
NotifyService notifyService,
|
||||||
PersonService personService,
|
PersonService personService,
|
||||||
CommentService commentService,
|
CommentService commentService,
|
||||||
ConversionService conversionService
|
ConversionService conversionService
|
||||||
@ -56,7 +56,7 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
|||||||
super(taskRepository);
|
super(taskRepository);
|
||||||
this.taskRepository = taskRepository;
|
this.taskRepository = taskRepository;
|
||||||
this.pullRequestsService = pullRequestsService;
|
this.pullRequestsService = pullRequestsService;
|
||||||
this.changeService = changeService;
|
this.notifyService = notifyService;
|
||||||
this.personService = personService;
|
this.personService = personService;
|
||||||
this.commentService = commentService;
|
this.commentService = commentService;
|
||||||
this.conversionService = conversionService;
|
this.conversionService = conversionService;
|
||||||
@ -93,8 +93,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
|||||||
if (!oldStatus.equals(newStatus)) {
|
if (!oldStatus.equals(newStatus)) {
|
||||||
switch (newStatus) {
|
switch (newStatus) {
|
||||||
case OPEN:
|
case OPEN:
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
TaskNewChange.builder()
|
TaskNewNotify.builder()
|
||||||
.messageTask(task.getDescription())
|
.messageTask(task.getDescription())
|
||||||
.authorName(oldTask.getAuthor())
|
.authorName(oldTask.getAuthor())
|
||||||
.url(oldTask.getUrl())
|
.url(oldTask.getUrl())
|
||||||
@ -105,8 +105,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case RESOLVED:
|
case RESOLVED:
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
TaskCloseChange.builder()
|
TaskCloseNotify.builder()
|
||||||
.messageTask(oldTask.getDescription())
|
.messageTask(oldTask.getDescription())
|
||||||
.authorName(oldTask.getAuthor())
|
.authorName(oldTask.getAuthor())
|
||||||
.url(oldTask.getUrl())
|
.url(oldTask.getUrl())
|
||||||
@ -133,8 +133,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
oldTask.getAnswers().clear();
|
oldTask.getAnswers().clear();
|
||||||
oldTask.setAnswers(existsNewAnswersIds);
|
oldTask.setAnswers(existsNewAnswersIds);
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
AnswerCommentChange.builder()
|
AnswerCommentNotify.builder()
|
||||||
.telegramIds(
|
.telegramIds(
|
||||||
personService.getAllTelegramIdByLogin(Collections.singleton(oldTask.getAuthor()))
|
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())
|
final PullRequest pullRequest = pullRequestsService.getById(task.getPullRequestId())
|
||||||
.orElseThrow(() -> new NotFoundException("ПР не найден"));
|
.orElseThrow(() -> new NotFoundException("ПР не найден"));
|
||||||
|
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
TaskNewChange.builder()
|
TaskNewNotify.builder()
|
||||||
.authorName(task.getAuthor())
|
.authorName(task.getAuthor())
|
||||||
.messageTask(task.getDescription())
|
.messageTask(task.getDescription())
|
||||||
.url(task.getUrl())
|
.url(task.getUrl())
|
||||||
@ -200,8 +200,8 @@ public class TaskServiceImpl extends AbstractSimpleManagerService<Task, Long> im
|
|||||||
recipientsLogins.add(login);
|
recipientsLogins.add(login);
|
||||||
}
|
}
|
||||||
final Set<Long> recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins);
|
final Set<Long> recipientsIds = personService.getAllTelegramIdByLogin(recipientsLogins);
|
||||||
changeService.save(
|
notifyService.save(
|
||||||
CommentChange.builder()
|
CommentNotify.builder()
|
||||||
.authorName(task.getAuthor())
|
.authorName(task.getAuthor())
|
||||||
.url(task.getUrl())
|
.url(task.getUrl())
|
||||||
.telegramIds(recipientsIds)
|
.telegramIds(recipientsIds)
|
||||||
|
Loading…
Reference in New Issue
Block a user