Большой рефакторинг
This commit is contained in:
parent
ee5cfd5ba4
commit
32a5bf19e1
@ -25,7 +25,7 @@ public enum AppLocale {
|
||||
return Arrays.stream(values())
|
||||
.filter(appLocale -> appLocale.getLabel().equals(label))
|
||||
.findFirst()
|
||||
.orElseThrow(() -> new NotFoundException("Ошибка, локализация не найдена. Попробуйте снова."));
|
||||
.orElseThrow(NotFoundException.supplier("Ошибка, локализация не найдена. Попробуйте снова."));
|
||||
}
|
||||
|
||||
public Locale getValue() {
|
||||
|
@ -5,23 +5,18 @@ import lombok.Builder;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(of = "id")
|
||||
public class MessageSend {
|
||||
|
||||
private Long id;
|
||||
|
||||
@NonNull
|
||||
private Long telegramId;
|
||||
|
||||
@NonNull
|
||||
private String message;
|
||||
|
||||
}
|
||||
|
@ -1,13 +1,15 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* // TODO: 15.01.2021 Добавить описание.
|
||||
*
|
||||
* @author upagge 15.01.2021
|
||||
*/
|
||||
@Data
|
||||
@Getter
|
||||
@Setter
|
||||
public class PersonInformation {
|
||||
|
||||
private String username;
|
||||
|
@ -1,26 +0,0 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* // TODO: 01.10.2020 Добавить описание.
|
||||
*
|
||||
* @author upagge 01.10.2020
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum PointType {
|
||||
|
||||
CREATE_PULL_REQUEST(10),
|
||||
DECLINE_PULL_REQUEST(-CREATE_PULL_REQUEST.getPoints()),
|
||||
COMMENT_ADD(1),
|
||||
COMMENT_DELETE(-COMMENT_ADD.getPoints()),
|
||||
TASK_CREATE(2),
|
||||
TASK_DELETE(-TASK_CREATE.getPoints()),
|
||||
TASK_RECIPIENT(-1),
|
||||
TASK_DELETE_RECIPIENT(1);
|
||||
|
||||
private final Integer points;
|
||||
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain.entity;
|
||||
|
||||
import dev.struchkov.haiti.context.domain.BasicEntity;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Id;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* // TODO: 20.09.2020 Добавить описание.
|
||||
*
|
||||
* @author upagge 20.09.2020
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
//@Entity
|
||||
//@Table(name = "setting_notify")
|
||||
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
|
||||
public class NotifySetting implements BasicEntity<String> {
|
||||
|
||||
@Id
|
||||
@Column(name = "login")
|
||||
@EqualsAndHashCode.Include
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* Дата, после которой пользователю будут поступать уведомления.
|
||||
*/
|
||||
@Column(name = "start_receiving")
|
||||
private LocalDateTime startReceiving;
|
||||
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain.entity;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.domain.PipelineStatus;
|
||||
import dev.struchkov.haiti.context.domain.BasicEntity;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import dev.struchkov.bot.gitlab.context.domain.PipelineStatus;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
|
@ -4,12 +4,10 @@ import dev.struchkov.bot.gitlab.context.domain.entity.MergeRequest;
|
||||
import dev.struchkov.bot.gitlab.context.service.AppSettingService;
|
||||
import dev.struchkov.bot.gitlab.context.utils.MessageUtils;
|
||||
import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||
import dev.struchkov.bot.gitlab.context.utils.UpdateDataComparator;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* // TODO: 20.09.2020 Добавить описание.
|
||||
@ -17,9 +15,9 @@ import java.util.stream.Collectors;
|
||||
* @author upagge 20.09.2020
|
||||
*/
|
||||
@Getter
|
||||
public class GoodMorningNotify extends Notify {
|
||||
//TODO [28.01.2022]: Решить доработать и оставить или удалить.
|
||||
public class GoodMorningNotify implements Notify {
|
||||
|
||||
private static final UpdateDataComparator COMPARATOR = new UpdateDataComparator();
|
||||
private static final Integer PR_COUNT = 4;
|
||||
|
||||
private final List<MergeRequest> mergeRequestsReviews;
|
||||
@ -31,7 +29,9 @@ public class GoodMorningNotify extends Notify {
|
||||
protected GoodMorningNotify(
|
||||
List<MergeRequest> mergeRequestsReviews,
|
||||
List<MergeRequest> mergeRequestsNeedWork,
|
||||
String personName, String version) {
|
||||
String personName,
|
||||
String version
|
||||
) {
|
||||
this.mergeRequestsReviews = mergeRequestsReviews;
|
||||
this.mergeRequestsNeedWork = mergeRequestsNeedWork;
|
||||
this.personName = personName;
|
||||
@ -40,13 +40,13 @@ public class GoodMorningNotify extends Notify {
|
||||
|
||||
@Override
|
||||
public String generateMessage(AppSettingService settingService) {
|
||||
StringBuilder message = new StringBuilder().append(Smile.SUN).append(" *Доброе утро, ").append(personName).append("* ").append(Smile.SUN).append(Smile.TWO_BR);
|
||||
final StringBuilder message = new StringBuilder().append(Smile.SUN).append(" *Доброе утро, ").append(personName).append("* ").append(Smile.SUN).append(Smile.TWO_BR);
|
||||
if (!mergeRequestsReviews.isEmpty()) {
|
||||
message.append("Необходимо проверить ").append(mergeRequestsReviews.size()).append(" ПР:").append(Smile.BR);
|
||||
MessageUtils.pullRequestForReview(
|
||||
mergeRequestsReviews.stream()
|
||||
.limit(3)
|
||||
.collect(Collectors.toList())
|
||||
.toList()
|
||||
).ifPresent(message::append);
|
||||
} else {
|
||||
message.append("Поздравляю, у тебя ни одного ПР на проверку!");
|
||||
@ -54,7 +54,7 @@ public class GoodMorningNotify extends Notify {
|
||||
MessageUtils.pullRequestForNeedWork(
|
||||
mergeRequestsNeedWork.stream()
|
||||
.limit(3)
|
||||
.collect(Collectors.toList())
|
||||
.toList()
|
||||
).ifPresent(
|
||||
messageNeedWork -> message.append(Smile.TWO_BR)
|
||||
.append(Smile.DANGEROUS).append(" Требуется доработать ").append(mergeRequestsNeedWork.size()).append(" ПР:").append(Smile.BR)
|
||||
|
@ -2,14 +2,17 @@ package dev.struchkov.bot.gitlab.context.domain.notify;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.service.AppSettingService;
|
||||
import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||
import dev.struchkov.haiti.utils.Strings;
|
||||
import lombok.Builder;
|
||||
|
||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||
|
||||
/**
|
||||
* // TODO: 15.01.2021 Добавить описание.
|
||||
*
|
||||
* @author upagge 15.01.2021
|
||||
*/
|
||||
public class NewProjectNotify extends Notify {
|
||||
public class NewProjectNotify implements Notify {
|
||||
|
||||
private final String projectName;
|
||||
private final String projectUrl;
|
||||
@ -29,7 +32,7 @@ public class NewProjectNotify extends Notify {
|
||||
return settingService.getMessage(
|
||||
"notify.project.new",
|
||||
Smile.FUN.getValue(), Smile.HR.getValue(), projectName, projectUrl,
|
||||
(projectDescription != null && !"".equals(projectDescription)) ? escapeMarkdown(projectDescription) + Smile.HR : "",
|
||||
(projectDescription != null && !"".equals(projectDescription)) ? escapeMarkdown(projectDescription) + Smile.HR : Strings.EMPTY,
|
||||
Smile.AUTHOR.getValue(), authorName
|
||||
);
|
||||
}
|
||||
|
@ -1,34 +1,9 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain.notify;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.service.AppSettingService;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
public interface Notify {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class Notify {
|
||||
|
||||
protected static final Set<Character> FORBIDDEN_SYMBOLS = Stream.of(
|
||||
'\\', '+', '`', '[', ']', '\"', '~', '*', '#', '=', '_', '>', '<'
|
||||
).collect(Collectors.toSet());
|
||||
|
||||
public abstract String generateMessage(AppSettingService appSettingService);
|
||||
|
||||
public static String escapeMarkdown(@NonNull String s) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
char c = s.charAt(i);
|
||||
if (FORBIDDEN_SYMBOLS.contains(c)) {
|
||||
sb.append('\\');
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
String generateMessage(AppSettingService appSettingService);
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import lombok.Getter;
|
||||
* @author upagge 20.09.2020
|
||||
*/
|
||||
@Getter
|
||||
public class SimpleTextNotify extends Notify {
|
||||
public class SimpleTextNotify implements Notify {
|
||||
|
||||
private final String message;
|
||||
|
||||
|
@ -1,18 +1,22 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain.notify.comment;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.domain.Answer;
|
||||
import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import dev.struchkov.bot.gitlab.context.domain.notify.Notify;
|
||||
import dev.struchkov.bot.gitlab.context.service.AppSettingService;
|
||||
import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||
import dev.struchkov.haiti.utils.Strings;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.struchkov.haiti.utils.Strings.TWO_NEW_LINE;
|
||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||
|
||||
@Getter
|
||||
public class AnswerCommentNotify extends Notify {
|
||||
public class AnswerCommentNotify implements Notify {
|
||||
|
||||
private final String youMessage;
|
||||
private final String url;
|
||||
@ -33,7 +37,7 @@ public class AnswerCommentNotify extends Notify {
|
||||
public String generateMessage(AppSettingService settingService) {
|
||||
final String answerText = answers.stream()
|
||||
.map(answer -> answer.getAuthorName() + ": " + answer.getMessage().substring(0, Math.min(answer.getMessage().length(), 500)))
|
||||
.collect(Collectors.joining("\n\n"));
|
||||
.collect(Collectors.joining(TWO_NEW_LINE));
|
||||
return MessageFormat.format(
|
||||
"{0} *Новые ответы* на [комментарий]({1}){2}" +
|
||||
"{3}{2}" +
|
||||
@ -41,7 +45,7 @@ public class AnswerCommentNotify extends Notify {
|
||||
Smile.COMMENT,
|
||||
url,
|
||||
Smile.HR,
|
||||
escapeMarkdown(youMessage.substring(0, Math.min(youMessage.length(), 180))),
|
||||
escapeMarkdown(Strings.cutoff(youMessage, 180)),
|
||||
escapeMarkdown(answerText)
|
||||
);
|
||||
}
|
||||
|
@ -6,8 +6,10 @@ import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||
|
||||
@Getter
|
||||
public class CommentNotify extends Notify {
|
||||
public class CommentNotify implements Notify {
|
||||
|
||||
private final String authorName;
|
||||
private final String message;
|
||||
|
@ -1,18 +1,20 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain.notify.pipeline;
|
||||
|
||||
import lombok.Builder;
|
||||
import dev.struchkov.bot.gitlab.context.domain.notify.Notify;
|
||||
import dev.struchkov.bot.gitlab.context.service.AppSettingService;
|
||||
import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||
import lombok.Builder;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||
|
||||
/**
|
||||
* // TODO: 17.01.2021 Добавить описание.
|
||||
*
|
||||
* @author upagge 17.01.2021
|
||||
*/
|
||||
public class PipelineNotify extends Notify {
|
||||
public class PipelineNotify implements Notify {
|
||||
|
||||
private final Long pipelineId;
|
||||
private final String projectName;
|
||||
@ -22,7 +24,14 @@ public class PipelineNotify extends Notify {
|
||||
private String oldStatus = "n/a";
|
||||
|
||||
@Builder
|
||||
public PipelineNotify(Long pipelineId, String projectName, String refName, String oldStatus, String newStatus, String webUrl) {
|
||||
public PipelineNotify(
|
||||
Long pipelineId,
|
||||
String projectName,
|
||||
String refName,
|
||||
String oldStatus,
|
||||
String newStatus,
|
||||
String webUrl
|
||||
) {
|
||||
this.pipelineId = pipelineId;
|
||||
this.projectName = projectName;
|
||||
this.refName = refName;
|
||||
|
@ -11,6 +11,7 @@ import dev.struchkov.bot.gitlab.context.service.AppSettingService;
|
||||
* @author upagge 11.10.2020
|
||||
*/
|
||||
@Getter
|
||||
//TODO [28.01.2022]: Решить доработать и оставить или удалить
|
||||
public class ForgottenSmartPrNotify extends PrNotify {
|
||||
|
||||
@Builder
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain.notify.pullrequest;
|
||||
|
||||
import dev.struchkov.haiti.utils.Strings;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import dev.struchkov.bot.gitlab.context.service.AppSettingService;
|
||||
@ -8,6 +9,8 @@ import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||
|
||||
@Getter
|
||||
public class NewPrNotify extends PrNotify {
|
||||
|
||||
@ -52,7 +55,7 @@ public class NewPrNotify extends PrNotify {
|
||||
title,
|
||||
url,
|
||||
labelText,
|
||||
(description != null && !"".equals(description)) ? escapeMarkdown(description) + Smile.HR : "",
|
||||
(description != null && !"".equals(description)) ? escapeMarkdown(description) + Smile.HR : Strings.EMPTY,
|
||||
Smile.AUTHOR.getValue(),
|
||||
author,
|
||||
Smile.TREE.getValue(),
|
||||
|
@ -1,10 +1,10 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain.notify.pullrequest;
|
||||
|
||||
import lombok.Getter;
|
||||
import dev.struchkov.bot.gitlab.context.domain.notify.Notify;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public abstract class PrNotify extends Notify {
|
||||
public abstract class PrNotify implements Notify {
|
||||
|
||||
protected final String projectName;
|
||||
protected final String title;
|
||||
|
@ -4,6 +4,8 @@ import dev.struchkov.bot.gitlab.context.service.AppSettingService;
|
||||
import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||
import lombok.Builder;
|
||||
|
||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||
|
||||
/**
|
||||
* // TODO: 10.09.2020 Добавить описание.
|
||||
*
|
||||
|
@ -5,6 +5,8 @@ import dev.struchkov.bot.gitlab.context.utils.Smile;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
|
||||
import static dev.struchkov.haiti.utils.Strings.escapeMarkdown;
|
||||
|
||||
/**
|
||||
* // TODO: 10.09.2020 Добавить описание.
|
||||
*
|
||||
|
@ -1,12 +1,10 @@
|
||||
package dev.struchkov.bot.gitlab.context.domain.notify.task;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.domain.notify.Notify;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public abstract class TaskNotify extends Notify {
|
||||
public abstract class TaskNotify implements Notify {
|
||||
|
||||
protected final String authorName;
|
||||
protected final String url;
|
||||
|
@ -2,13 +2,13 @@ package dev.struchkov.bot.gitlab.context.exception;
|
||||
|
||||
import dev.struchkov.haiti.context.exception.BasicException;
|
||||
|
||||
abstract class BitbucketBotException extends BasicException {
|
||||
abstract class GitlabBotException extends BasicException {
|
||||
|
||||
public BitbucketBotException(String message) {
|
||||
public GitlabBotException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public BitbucketBotException(String message, Throwable throwable) {
|
||||
public GitlabBotException(String message, Throwable throwable) {
|
||||
super(message, throwable);
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
package dev.struchkov.bot.gitlab.context.exception;
|
||||
|
||||
public class RegException extends BitbucketBotException {
|
||||
|
||||
public RegException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
package dev.struchkov.bot.gitlab.context.exception;
|
||||
|
||||
public class UpdateException extends BitbucketBotException {
|
||||
|
||||
public UpdateException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +1,20 @@
|
||||
package dev.struchkov.bot.gitlab.context.repository;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.domain.IdAndStatusPr;
|
||||
import dev.struchkov.bot.gitlab.context.domain.MergeRequestState;
|
||||
import dev.struchkov.bot.gitlab.context.domain.entity.MergeRequest;
|
||||
import dev.struchkov.haiti.context.repository.SimpleManagerRepository;
|
||||
import dev.struchkov.haiti.filter.FilterOperation;
|
||||
import lombok.NonNull;
|
||||
import dev.struchkov.bot.gitlab.context.domain.IdAndStatusPr;
|
||||
import dev.struchkov.bot.gitlab.context.domain.MergeRequestState;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public interface MergeRequestRepository extends SimpleManagerRepository<MergeRequest, Long>, FilterOperation<MergeRequest> {
|
||||
|
||||
Set<IdAndStatusPr> findAllIdByStateIn(Set<MergeRequestState> states);
|
||||
Set<IdAndStatusPr> findAllIdByStateIn(@NonNull Set<MergeRequestState> states);
|
||||
|
||||
//TODO [28.01.2022]: Решить, нужно ли оставить
|
||||
List<MergeRequest> findAllByAssignee(@NonNull Long userId);
|
||||
|
||||
}
|
||||
|
@ -1,13 +0,0 @@
|
||||
package dev.struchkov.bot.gitlab.context.repository;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.domain.entity.NotifySetting;
|
||||
import dev.struchkov.haiti.context.repository.SimpleManagerRepository;
|
||||
|
||||
/**
|
||||
* // TODO: 20.09.2020 Добавить описание.
|
||||
*
|
||||
* @author upagge 20.09.2020
|
||||
*/
|
||||
public interface NotifySettingRepository extends SimpleManagerRepository<NotifySetting, String> {
|
||||
|
||||
}
|
@ -18,4 +18,5 @@ import java.util.Set;
|
||||
public interface PipelineRepository extends SimpleManagerRepository<Pipeline, Long>, FilterOperation<Pipeline> {
|
||||
|
||||
Sheet<Pipeline> findAllByStatuses(@NonNull Set<PipelineStatus> statuses, @NonNull Pagination pagination);
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ public interface NoteService extends SimpleManagerService<Note, Long> {
|
||||
|
||||
List<Note> getAllPersonTask(@NonNull Long userId, boolean resolved);
|
||||
|
||||
//TODO [28.01.2022]: Решить нужно ли оставлять
|
||||
Sheet<Note> getAllByResolved(boolean resolved, @NonNull Pagination pagination);
|
||||
|
||||
}
|
||||
|
@ -17,13 +17,10 @@ import java.util.stream.Collectors;
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public final class MessageUtils {
|
||||
|
||||
private static final UpdateDataComparator COMPARATOR = new UpdateDataComparator();
|
||||
|
||||
public static Optional<String> pullRequestForReview(@NonNull List<MergeRequest> mergeRequestsReviews) {
|
||||
if (!mergeRequestsReviews.isEmpty()) {
|
||||
return Optional.of(
|
||||
mergeRequestsReviews.stream()
|
||||
.sorted(COMPARATOR)
|
||||
.map(MessageUtils::generateStringItemPullRequestReview)
|
||||
.collect(Collectors.joining("\n"))
|
||||
);
|
||||
@ -51,7 +48,6 @@ public final class MessageUtils {
|
||||
link(mergeRequest.getTitle(), mergeRequest.getWebUrl());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private static String link(String name, String url) {
|
||||
return "[" + name + "](" + url + ")";
|
||||
}
|
||||
|
@ -30,8 +30,6 @@ public enum Smile {
|
||||
TOP_ONE("\uD83C\uDF1F\uD83C\uDF1F\uD83C\uDF1F"),
|
||||
TOP_TWO("\uD83D\uDE0E"),
|
||||
TOP_THREE("\uD83E\uDD49"),
|
||||
KAKASHKA("\uD83D\uDCA9"),
|
||||
LUPA("\uD83D\uDD0D"),
|
||||
DANGEROUS("⚠️"),
|
||||
COMMENT("\uD83D\uDCAC"),
|
||||
ARROW("➜"),
|
||||
|
@ -1,15 +0,0 @@
|
||||
package dev.struchkov.bot.gitlab.context.utils;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.domain.entity.MergeRequest;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class UpdateDataComparator implements Comparator<MergeRequest> {
|
||||
|
||||
@Override
|
||||
public int compare(MergeRequest mergeRequest, MergeRequest t1) {
|
||||
// return mergeRequest.getUpdateDate().compareTo(t1.getUpdateDate());
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
@ -27,8 +27,9 @@ public class DiscussionJsonConverter implements Converter<DiscussionJson, Discus
|
||||
source.getNotes().stream()
|
||||
.filter(noteJson -> !noteJson.isSystem())
|
||||
.map(noteJsonConvert::convert)
|
||||
.collect(Collectors.toList())
|
||||
.toList()
|
||||
);
|
||||
return discussion;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -44,17 +44,13 @@ public class MergeRequestJsonConverter implements Converter<MergeRequestJson, Me
|
||||
}
|
||||
|
||||
private MergeRequestState convertState(MergeRequestStateJson state) {
|
||||
switch (state) {
|
||||
case CLOSED:
|
||||
return MergeRequestState.CLOSED;
|
||||
case LOCKED:
|
||||
return MergeRequestState.LOCKED;
|
||||
case MERGED:
|
||||
return MergeRequestState.MERGED;
|
||||
case OPENED:
|
||||
return MergeRequestState.OPENED;
|
||||
}
|
||||
throw new ConvertException("Статус ПР не найден");
|
||||
return switch (state) {
|
||||
case CLOSED -> MergeRequestState.CLOSED;
|
||||
case LOCKED -> MergeRequestState.LOCKED;
|
||||
case MERGED -> MergeRequestState.MERGED;
|
||||
case OPENED -> MergeRequestState.OPENED;
|
||||
default -> throw new ConvertException("Статус ПР не найден");
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -45,30 +45,19 @@ public class PipelineJsonConverter implements Converter<PipelineJson, Pipeline>
|
||||
}
|
||||
|
||||
private PipelineStatus convertStatus(PipelineStatusJson status) {
|
||||
switch (status) {
|
||||
case SKIPPED:
|
||||
return SKIPPED;
|
||||
case CANCELED:
|
||||
return CANCELED;
|
||||
case SUCCESS:
|
||||
return SUCCESS;
|
||||
case MANUAL:
|
||||
return MANUAL;
|
||||
case CREATED:
|
||||
return CREATED;
|
||||
case PENDING:
|
||||
return PENDING;
|
||||
case RUNNING:
|
||||
return RUNNING;
|
||||
case PREPARING:
|
||||
return PREPARING;
|
||||
case SCHEDULED:
|
||||
return SCHEDULED;
|
||||
case WAITING_FOR_RESOURCE:
|
||||
return WAITING_FOR_RESOURCE;
|
||||
default:
|
||||
return FAILED;
|
||||
}
|
||||
return switch (status) {
|
||||
case SKIPPED -> SKIPPED;
|
||||
case CANCELED -> CANCELED;
|
||||
case SUCCESS -> SUCCESS;
|
||||
case MANUAL -> MANUAL;
|
||||
case CREATED -> CREATED;
|
||||
case PENDING -> PENDING;
|
||||
case RUNNING -> RUNNING;
|
||||
case PREPARING -> PREPARING;
|
||||
case SCHEDULED -> SCHEDULED;
|
||||
case WAITING_FOR_RESOURCE -> WAITING_FOR_RESOURCE;
|
||||
default -> FAILED;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* // TODO: 16.01.2021 Добавить описание.
|
||||
@ -23,7 +24,7 @@ import java.util.Locale;
|
||||
public class AppSettingServiceImpl implements AppSettingService {
|
||||
|
||||
private static final Long KEY = 1L;
|
||||
private static final NotFoundException EXCEPTION = new NotFoundException("Ошибка, невозможно найти настройки приложения, проверьте базу данных.");
|
||||
public static final Supplier<NotFoundException> NOT_FOUND_SETTINGS = NotFoundException.supplier("Ошибка, невозможно найти настройки приложения, проверьте базу данных.");
|
||||
private final AppSettingRepository appSettingRepository;
|
||||
|
||||
private final MessageSource messageSource;
|
||||
@ -31,13 +32,13 @@ public class AppSettingServiceImpl implements AppSettingService {
|
||||
@Override
|
||||
public boolean isFirstStart() {
|
||||
return appSettingRepository.findById(KEY)
|
||||
.orElseThrow(() -> EXCEPTION)
|
||||
.orElseThrow(NOT_FOUND_SETTINGS)
|
||||
.isFirstStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableFirstStart() {
|
||||
final AppSetting appSetting = appSettingRepository.findById(KEY).orElseThrow(() -> EXCEPTION);
|
||||
final AppSetting appSetting = appSettingRepository.findById(KEY).orElseThrow(NOT_FOUND_SETTINGS);
|
||||
appSetting.setFirstStart(false);
|
||||
appSettingRepository.save(appSetting);
|
||||
}
|
||||
@ -45,12 +46,11 @@ public class AppSettingServiceImpl implements AppSettingService {
|
||||
@Override
|
||||
public String getMessage(@NonNull String label) {
|
||||
final Locale value = appSettingRepository.findById(KEY)
|
||||
.orElseThrow(() -> EXCEPTION)
|
||||
.orElseThrow(NOT_FOUND_SETTINGS)
|
||||
.getAppLocale().getValue();
|
||||
final String message = messageSource.getMessage(
|
||||
return messageSource.getMessage(
|
||||
label, null, value
|
||||
);
|
||||
return message;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -60,14 +60,14 @@ public class AppSettingServiceImpl implements AppSettingService {
|
||||
label,
|
||||
paramsArray,
|
||||
appSettingRepository.findById(KEY)
|
||||
.orElseThrow(() -> EXCEPTION)
|
||||
.orElseThrow(NOT_FOUND_SETTINGS)
|
||||
.getAppLocale().getValue()
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocale(@NonNull AppLocale appLocale) {
|
||||
final AppSetting appSetting = appSettingRepository.findById(KEY).orElseThrow(() -> EXCEPTION);
|
||||
final AppSetting appSetting = appSettingRepository.findById(KEY).orElseThrow(NOT_FOUND_SETTINGS);
|
||||
appSetting.setAppLocale(appLocale);
|
||||
appSettingRepository.save(appSetting);
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public class CleanServiceImpl implements CleanService {
|
||||
|
||||
private static final int COUNT = 1000;
|
||||
private static final MergeRequestFilter CLEAN_FILTER = MergeRequestFilter.builder()
|
||||
.states(Stream.of(MERGED, CLOSED).collect(Collectors.toSet()))
|
||||
.states(Set.of(MERGED, CLOSED))
|
||||
.build();
|
||||
|
||||
private final MergeRequestsService mergeRequestsService;
|
||||
@ -45,7 +45,7 @@ public class CleanServiceImpl implements CleanService {
|
||||
while (mergeRequestSheet.hasContent()) {
|
||||
final Set<Long> ids = mergeRequestSheet.getContent().stream()
|
||||
.map(MergeRequest::getId)
|
||||
.collect(Collectors.toSet());
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
mergeRequestsService.deleteAllById(ids);
|
||||
|
||||
@ -62,7 +62,7 @@ public class CleanServiceImpl implements CleanService {
|
||||
while (sheet.hasContent()) {
|
||||
final Set<Long> ids = sheet.getContent().stream()
|
||||
.map(Pipeline::getId)
|
||||
.collect(Collectors.toSet());
|
||||
.collect(Collectors.toUnmodifiableSet());
|
||||
|
||||
pipelineService.deleteAllById(ids);
|
||||
|
||||
|
@ -97,7 +97,7 @@ public class DiscussionServiceImpl extends AbstractSimpleManagerService<Discussi
|
||||
@Override
|
||||
public Discussion update(@NonNull Discussion discussion) {
|
||||
final Discussion oldDiscussion = discussionRepository.findById(discussion.getId())
|
||||
.orElseThrow(() -> new NotFoundException("Дискуссия не найдена"));
|
||||
.orElseThrow(NotFoundException.supplier("Дискуссия не найдена"));
|
||||
final Map<Long, Note> noteMap = oldDiscussion
|
||||
.getNotes().stream()
|
||||
.collect(Collectors.toMap(Note::getId, note -> note));
|
||||
@ -148,7 +148,7 @@ public class DiscussionServiceImpl extends AbstractSimpleManagerService<Discussi
|
||||
final List<Discussion> discussions = getAllByMergeRequestId(mergeRequest.getId())
|
||||
.stream()
|
||||
.filter(discussion -> Objects.nonNull(discussion.getResponsible()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
final long allYouTasks = discussions.stream()
|
||||
.filter(discussion -> personInformation.getId().equals(discussion.getFirstNote().getAuthor().getId()))
|
||||
.count();
|
||||
@ -178,7 +178,7 @@ public class DiscussionServiceImpl extends AbstractSimpleManagerService<Discussi
|
||||
@Override
|
||||
public void answer(@NonNull String discussionId, @NonNull String text) {
|
||||
final Discussion discussion = discussionRepository.findById(discussionId)
|
||||
.orElseThrow(() -> new NotFoundException("Дисскусия " + discussionId + " не найдена"));
|
||||
.orElseThrow(NotFoundException.supplier("Дисскусия {0} не найдена", discussionId));
|
||||
final MergeRequest mergeRequest = discussion.getMergeRequest();
|
||||
final Long projectId = mergeRequest.getProjectId();
|
||||
|
||||
|
@ -30,7 +30,6 @@ import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<MergeRequest, Long> implements MergeRequestsService {
|
||||
@ -82,7 +81,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<Merge
|
||||
if (!personInformation.getId().equals(newMergeRequest.getAuthor().getId())) {
|
||||
|
||||
final String projectName = projectService.getById(newMergeRequest.getProjectId())
|
||||
.orElseThrow(() -> new NotFoundException("Проект не найден"))
|
||||
.orElseThrow(NotFoundException.supplier("Проект не найден"))
|
||||
.getName();
|
||||
if (!newMergeRequest.isConflict()) {
|
||||
notifyService.send(
|
||||
@ -110,7 +109,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<Merge
|
||||
personService.create(mergeRequest.getAuthor());
|
||||
|
||||
final MergeRequest oldMergeRequest = mergeRequestRepository.findById(mergeRequest.getId())
|
||||
.orElseThrow(() -> new NotFoundException("МержРеквест не найден"));
|
||||
.orElseThrow(NotFoundException.supplier("МержРеквест не найден"));
|
||||
|
||||
if (mergeRequest.getNotification() == null) {
|
||||
mergeRequest.setNotification(oldMergeRequest.getNotification());
|
||||
@ -118,7 +117,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<Merge
|
||||
|
||||
if (!oldMergeRequest.getUpdatedDate().equals(mergeRequest.getUpdatedDate()) || oldMergeRequest.isConflict() != mergeRequest.isConflict()) {
|
||||
final Project project = projectService.getById(mergeRequest.getProjectId())
|
||||
.orElseThrow(() -> new NotFoundException("Проект не найден"));
|
||||
.orElseThrow(NotFoundException.supplier("Проект не найден"));
|
||||
|
||||
if (Boolean.TRUE.equals(oldMergeRequest.getNotification())) {
|
||||
notifyStatus(oldMergeRequest, mergeRequest, project);
|
||||
@ -140,7 +139,7 @@ public class MergeRequestsServiceImpl extends AbstractSimpleManagerService<Merge
|
||||
final List<Discussion> discussions = discussionService.getAllByMergeRequestId(oldMergeRequest.getId())
|
||||
.stream()
|
||||
.filter(discussion -> Objects.nonNull(discussion.getResponsible()))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
final long allTask = discussions.size();
|
||||
final long resolvedTask = discussions.stream()
|
||||
.filter(Discussion::getResolved)
|
||||
|
@ -19,8 +19,6 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.CANCELED;
|
||||
import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.FAILED;
|
||||
@ -35,21 +33,25 @@ import static dev.struchkov.bot.gitlab.context.domain.PipelineStatus.SUCCESS;
|
||||
@Service
|
||||
public class PipelineServiceImpl extends AbstractSimpleManagerService<Pipeline, Long> implements PipelineService {
|
||||
|
||||
private static final Set<PipelineStatus> notificationStatus = Stream.of(
|
||||
FAILED, SUCCESS, CANCELED, SKIPPED
|
||||
).collect(Collectors.toSet());
|
||||
private static final Set<PipelineStatus> notificationStatus = Set.of(FAILED, SUCCESS, CANCELED, SKIPPED);
|
||||
|
||||
private final NotifyService notifyService;
|
||||
private final PipelineRepository repository;
|
||||
private final PipelineRepository pipelineRepository;
|
||||
private final PersonService personService;
|
||||
private final PipelineFilterService pipelineFilterService;
|
||||
|
||||
private final PersonInformation personInformation;
|
||||
|
||||
public PipelineServiceImpl(NotifyService notifyService, PipelineRepository repository, PersonService personService, PipelineFilterService pipelineFilterService, PersonInformation personInformation) {
|
||||
super(repository);
|
||||
public PipelineServiceImpl(
|
||||
NotifyService notifyService,
|
||||
PipelineRepository pipelineRepository,
|
||||
PersonService personService,
|
||||
PipelineFilterService pipelineFilterService,
|
||||
PersonInformation personInformation
|
||||
) {
|
||||
super(pipelineRepository);
|
||||
this.notifyService = notifyService;
|
||||
this.repository = repository;
|
||||
this.pipelineRepository = pipelineRepository;
|
||||
this.personService = personService;
|
||||
this.pipelineFilterService = pipelineFilterService;
|
||||
this.personInformation = personInformation;
|
||||
@ -58,7 +60,7 @@ public class PipelineServiceImpl extends AbstractSimpleManagerService<Pipeline,
|
||||
@Override
|
||||
public Pipeline create(@NonNull Pipeline pipeline) {
|
||||
personService.create(pipeline.getPerson());
|
||||
final Pipeline newPipeline = repository.save(pipeline);
|
||||
final Pipeline newPipeline = pipelineRepository.save(pipeline);
|
||||
|
||||
if (
|
||||
notificationStatus.contains(pipeline.getStatus())
|
||||
@ -81,8 +83,8 @@ public class PipelineServiceImpl extends AbstractSimpleManagerService<Pipeline,
|
||||
|
||||
@Override
|
||||
public Pipeline update(@NonNull Pipeline pipeline) {
|
||||
final Pipeline oldPipeline = repository.findById(pipeline.getId())
|
||||
.orElseThrow(() -> new NotFoundException("Pipeline не найден"));
|
||||
final Pipeline oldPipeline = pipelineRepository.findById(pipeline.getId())
|
||||
.orElseThrow(NotFoundException.supplier("Pipeline не найден"));
|
||||
|
||||
if (!oldPipeline.getUpdated().equals(pipeline.getUpdated())) {
|
||||
pipeline.setProject(oldPipeline.getProject());
|
||||
@ -103,7 +105,7 @@ public class PipelineServiceImpl extends AbstractSimpleManagerService<Pipeline,
|
||||
.build()
|
||||
);
|
||||
|
||||
return repository.save(pipeline);
|
||||
return pipelineRepository.save(pipeline);
|
||||
}
|
||||
|
||||
}
|
||||
@ -113,7 +115,7 @@ public class PipelineServiceImpl extends AbstractSimpleManagerService<Pipeline,
|
||||
|
||||
@Override
|
||||
public Sheet<Pipeline> getAllByStatuses(@NonNull Set<PipelineStatus> statuses, @NonNull Pagination pagination) {
|
||||
return repository.findAllByStatuses(statuses, pagination);
|
||||
return pipelineRepository.findAllByStatuses(statuses, pagination);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -135,4 +137,5 @@ public class PipelineServiceImpl extends AbstractSimpleManagerService<Pipeline,
|
||||
public long count(@NonNull PipelineFilter filter) {
|
||||
return pipelineFilterService.count(filter);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -46,7 +46,7 @@ public class ProjectServiceImpl extends AbstractSimpleManagerService<Project, Lo
|
||||
|
||||
if (!newProject.getCreatorId().equals(personInformation.getId())) {
|
||||
final String authorName = personService.getById(newProject.getCreatorId())
|
||||
.orElseThrow(() -> new NotFoundException("Пользователь не найден"))
|
||||
.orElseThrow(NotFoundException.supplier("Пользователь не найден"))
|
||||
.getName();
|
||||
notifyService.send(
|
||||
NewProjectNotify.builder()
|
||||
|
@ -93,7 +93,7 @@ public class DiscussionParser {
|
||||
return discussion;
|
||||
})
|
||||
.filter(discussion -> discussion.getNotes() != null && !discussion.getNotes().isEmpty())
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
discussionService.createAll(newDiscussions);
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@ import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static dev.struchkov.haiti.utils.network.HttpParse.ACCEPT;
|
||||
|
||||
@ -35,9 +34,9 @@ import static dev.struchkov.haiti.utils.network.HttpParse.ACCEPT;
|
||||
public class MergeRequestParser {
|
||||
|
||||
public static final Integer COUNT = 100;
|
||||
private static final Set<MergeRequestState> OLD_STATUSES = Stream.of(
|
||||
private static final Set<MergeRequestState> OLD_STATUSES = Set.of(
|
||||
MergeRequestState.MERGED, MergeRequestState.OPENED, MergeRequestState.CLOSED
|
||||
).collect(Collectors.toSet());
|
||||
);
|
||||
|
||||
private final GitlabProperty gitlabProperty;
|
||||
private final MergeRequestsService mergeRequestsService;
|
||||
@ -58,7 +57,7 @@ public class MergeRequestParser {
|
||||
parsingCommits(newMergeRequest);
|
||||
return newMergeRequest;
|
||||
})
|
||||
.orElseThrow(() -> new NotFoundException("МержРеквест не найден, возможно удален"));
|
||||
.orElseThrow(NotFoundException.supplier("МержРеквест не найден, возможно удален"));
|
||||
mergeRequestsService.update(mergeRequest);
|
||||
}
|
||||
|
||||
@ -98,7 +97,7 @@ public class MergeRequestParser {
|
||||
parsingCommits(mergeRequest);
|
||||
return mergeRequest;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
mergeRequestsService.createAll(newMergeRequests);
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ import static dev.struchkov.haiti.utils.network.HttpParse.ACCEPT;
|
||||
public class PipelineParser {
|
||||
|
||||
public static final Integer COUNT = 100;
|
||||
private static final Set<PipelineStatus> oldStatus = Stream.of(
|
||||
private static final Set<PipelineStatus> oldStatus = Set.of(
|
||||
CREATED, WAITING_FOR_RESOURCE, PREPARING, PENDING, RUNNING, MANUAL
|
||||
).collect(Collectors.toSet());
|
||||
);
|
||||
private final PipelineService pipelineService;
|
||||
private final ProjectService projectService;
|
||||
private final GitlabProperty gitlabProperty;
|
||||
|
@ -70,7 +70,7 @@ public class ProjectParser {
|
||||
final List<Project> newProjects = projectJsons.stream()
|
||||
.filter(json -> existsContainer.getIdNoFound().contains(json.getId()))
|
||||
.map(json -> conversionService.convert(json, Project.class))
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
if (!newProjects.isEmpty()) {
|
||||
projectService.createAll(newProjects);
|
||||
@ -97,7 +97,7 @@ public class ProjectParser {
|
||||
.header(StringUtils.H_PRIVATE_TOKEN, personProperty.getToken())
|
||||
.execute(PersonJson.class)
|
||||
.map(json -> conversionService.convert(json, Person.class)).orElseThrow(() -> new ConvertException("Ошибка преобразования нового пользователя"))
|
||||
).collect(Collectors.toList());
|
||||
).toList();
|
||||
|
||||
personService.createAll(newPersons);
|
||||
|
||||
|
@ -1,19 +0,0 @@
|
||||
package dev.struchkov.bot.gitlab.core.utils;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Адаптированная реализация Pair из пакета javafx.util. Реализация необходима, так как в некоторых сборках JDK этот
|
||||
* пакет может отсутствовать.
|
||||
*
|
||||
* @author mstruchkov 21.06.2019
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class Pair<K, V> {
|
||||
|
||||
private K key;
|
||||
private V value;
|
||||
|
||||
}
|
@ -13,11 +13,4 @@ public class StringUtils {
|
||||
|
||||
public static final String H_PRIVATE_TOKEN = "PRIVATE-TOKEN";
|
||||
|
||||
public static String cutOff(String string, int length) {
|
||||
if (string != null) {
|
||||
return string.length() > length ? string.substring(0, length) + "..." : string;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class MergeRequestRepositoryImpl extends FilterManagerRepository<MergeReq
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<IdAndStatusPr> findAllIdByStateIn(Set<MergeRequestState> statuses) {
|
||||
public Set<IdAndStatusPr> findAllIdByStateIn(@NonNull Set<MergeRequestState> statuses) {
|
||||
return repositoryJpa.findAllIdByStateIn(statuses);
|
||||
}
|
||||
|
||||
|
@ -1,23 +0,0 @@
|
||||
package dev.struchkov.bot.gitlab.data.impl;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.domain.entity.NotifySetting;
|
||||
import dev.struchkov.bot.gitlab.context.repository.NotifySettingRepository;
|
||||
import dev.struchkov.bot.gitlab.data.jpa.NotifySettingJpaRepository;
|
||||
import dev.struchkov.haiti.database.repository.manager.AbstractSimpleManagerRepository;
|
||||
|
||||
/**
|
||||
* // TODO: 20.09.2020 Добавить описание.
|
||||
*
|
||||
* @author upagge 20.09.2020
|
||||
*/
|
||||
//@Repository
|
||||
public class NotifySettingRepositoryImpl extends AbstractSimpleManagerRepository<NotifySetting, String> implements NotifySettingRepository {
|
||||
|
||||
private final NotifySettingJpaRepository jpaRepository;
|
||||
|
||||
public NotifySettingRepositoryImpl(NotifySettingJpaRepository jpaRepository) {
|
||||
super(jpaRepository);
|
||||
this.jpaRepository = jpaRepository;
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
package dev.struchkov.bot.gitlab.data.jpa;
|
||||
|
||||
import dev.struchkov.bot.gitlab.context.domain.entity.NotifySetting;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.repository.NoRepositoryBean;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* // TODO: 20.09.2020 Добавить описание.
|
||||
*
|
||||
* @author upagge 20.09.2020
|
||||
*/
|
||||
|
||||
@NoRepositoryBean
|
||||
public interface NotifySettingJpaRepository extends JpaRepository<NotifySetting, String> {
|
||||
|
||||
boolean findByLoginAndStartReceivingAfter(String login, LocalDateTime date);
|
||||
|
||||
// @Query("SELECT n.login FROM NotifySetting n WHERE n.login IN :logins AND n.startReceiving < :date")
|
||||
Set<String> findAllByLoginInAndStartReceivingAfter(@Param("logins") Set<String> logins, @Param("date") LocalDateTime date);
|
||||
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
FROM openjdk:17.0.2-jdk-slim-buster
|
||||
MAINTAINER uPagge <me@upagge.ru>
|
||||
RUN addgroup gitlabbot --disabled-password && \
|
||||
RUN apt upgrade && addgroup gitlabbot --disabled-password && \
|
||||
adduser gitlabbot --ingroup gitlabbot && \
|
||||
mkdir -p /bot && \
|
||||
chown -R gitlabbot:gitlabbot /bot
|
||||
|
@ -61,7 +61,7 @@ public class AppConfig {
|
||||
.header(ACCEPT)
|
||||
.header(StringUtils.H_PRIVATE_TOKEN, personProperty.getToken())
|
||||
.execute(PersonInformation.class)
|
||||
.orElseThrow(() -> new NotFoundException("Пользователь не найден"));
|
||||
.orElseThrow(NotFoundException.supplier("Пользователь не найден"));
|
||||
personInformation.setTelegramId(personProperty.getTelegramId());
|
||||
return personInformation;
|
||||
}
|
||||
|
2
pom.xml
2
pom.xml
@ -52,7 +52,7 @@
|
||||
<gitlab.telegram.version>3.1.0</gitlab.telegram.version>
|
||||
<gitlab.core.version>3.1.0</gitlab.core.version>
|
||||
|
||||
<haiti.ver>0.0.4</haiti.ver>
|
||||
<haiti.ver>0.0.5</haiti.ver>
|
||||
<godfather.telegram.core.version>0.0.2</godfather.telegram.core.version>
|
||||
|
||||
<javax.persistance.version>2.2</javax.persistance.version>
|
||||
|
@ -1,9 +1,7 @@
|
||||
package dev.struchkov.bot.gitlab.telegram.service;
|
||||
|
||||
import dev.struchkov.bot.gitlab.core.config.properties.GitlabProperty;
|
||||
import dev.struchkov.bot.gitlab.core.utils.StringUtils;
|
||||
import dev.struchkov.godfather.telegram.service.SendPreProcessing;
|
||||
import dev.struchkov.haiti.utils.Strings;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -20,7 +18,7 @@ public class ReplaceUrlLocalhost implements SendPreProcessing {
|
||||
|
||||
@Override
|
||||
public String pretreatment(String s) {
|
||||
if (property.getReplaceUrl() !=null && !"${GITLAB_REPLACE_URL}".equals(property.getReplaceUrl())) {
|
||||
if (property.getReplaceUrl() != null && !"${GITLAB_REPLACE_URL}".equals(property.getReplaceUrl())) {
|
||||
return s.replace(property.getReplaceUrl(), property.getBaseUrl());
|
||||
}
|
||||
return s;
|
||||
|
@ -102,7 +102,7 @@ public class MenuConfig {
|
||||
) {
|
||||
return AnswerText.builder()
|
||||
.boxAnswer(message -> {
|
||||
final List<String> urlList = Arrays.stream(message.getText().split("/")).collect(Collectors.toList());
|
||||
final List<String> urlList = Arrays.stream(message.getText().split("/")).toList();
|
||||
int lastElement = urlList.size() - 1;
|
||||
final String projectUrl = MessageFormat.format(gitlabProperty.getUrlMergeRequestAdd(), urlList.get(lastElement - 1), urlList.get(lastElement));
|
||||
projectParser.parseByUrl(projectUrl);
|
||||
|
Loading…
Reference in New Issue
Block a user