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