diff --git a/src/main/java/com/tsc/bitbucketbot/domain/entity/PullRequest.java b/src/main/java/com/tsc/bitbucketbot/domain/entity/PullRequest.java index 834c098..6913dac 100644 --- a/src/main/java/com/tsc/bitbucketbot/domain/entity/PullRequest.java +++ b/src/main/java/com/tsc/bitbucketbot/domain/entity/PullRequest.java @@ -59,6 +59,9 @@ public class PullRequest { @Column(name = "version") private Integer version; + @Column(name = "description") + private String description; + @ManyToOne @JoinColumn(name = "author_login") private User author; diff --git a/src/main/java/com/tsc/bitbucketbot/service/Utils.java b/src/main/java/com/tsc/bitbucketbot/service/Utils.java index 24029c9..568fc08 100644 --- a/src/main/java/com/tsc/bitbucketbot/service/Utils.java +++ b/src/main/java/com/tsc/bitbucketbot/service/Utils.java @@ -36,11 +36,9 @@ public class Utils { @NonNull public static Optional urlToJson(String urlValue, String token, Class classOfT) { StringBuilder sb = null; - URL url; URLConnection urlCon; try { - url = new URL(urlValue); - urlCon = url.openConnection(); + urlCon = new URL(urlValue).openConnection(); if (token != null) { urlCon.setRequestProperty("Authorization", "Bearer " + token); } @@ -49,7 +47,6 @@ public class Utils { && urlCon.getHeaderField("Content-Encoding").equals("gzip")) { in = new BufferedReader(new InputStreamReader(new GZIPInputStream(urlCon.getInputStream()))); } else { - in = new BufferedReader(new InputStreamReader(urlCon.getInputStream())); } String inputLine; @@ -60,7 +57,7 @@ public class Utils { } in.close(); } catch (IOException e) { - + log.error(e.getMessage()); } if (sb != null) { try { diff --git a/src/main/java/com/tsc/bitbucketbot/service/converter/PullRequestJsonConverter.java b/src/main/java/com/tsc/bitbucketbot/service/converter/PullRequestJsonConverter.java index e9e708a..50e507c 100644 --- a/src/main/java/com/tsc/bitbucketbot/service/converter/PullRequestJsonConverter.java +++ b/src/main/java/com/tsc/bitbucketbot/service/converter/PullRequestJsonConverter.java @@ -37,6 +37,7 @@ public class PullRequestJsonConverter implements Converter 180 ? description.substring(0, 180) + "..." : description; + } + return null; + } + private User convertUser(UserJson userJson) { return userService.getByLogin(userJson.getName()).orElse(userJsonConverter.convert(userJson)); } diff --git a/src/main/java/com/tsc/bitbucketbot/utils/Message.java b/src/main/java/com/tsc/bitbucketbot/utils/Message.java index 34aee5e..1176135 100644 --- a/src/main/java/com/tsc/bitbucketbot/utils/Message.java +++ b/src/main/java/com/tsc/bitbucketbot/utils/Message.java @@ -31,11 +31,14 @@ public class Message { @NonNull public static String newPullRequest(PullRequest pullRequest) { - return Smile.FUN + " *Новый Pull Request*" + Smile.BR + + String message = Smile.FUN + " *Новый Pull Request*" + Smile.BR + link(pullRequest.getName(), pullRequest.getUrl()) + - Smile.HR + - Smile.AUTHOR + ": " + pullRequest.getAuthor().getLogin() + - Smile.TWO_BR; + Smile.HR; + if (pullRequest.getDescription() != null && !"".equals(pullRequest.getDescription())) { + message += pullRequest.getDescription() + Smile.HR; + } + message += Smile.AUTHOR + ": " + pullRequest.getAuthor().getLogin() + Smile.TWO_BR; + return message; } @NonNull @@ -109,7 +112,6 @@ public class Message { .limit(PR_COUNT) .collect(Collectors.toList()); oldPr.forEach(pullRequest -> message.append(topPr(pullRequest))); - message.append(Smile.BR); } else { message.append("Ты либо самый лучший работник, либо тебе не доверяют проверку ПР ").append(Smile.MEGA_FUN).append(Smile.TWO_BR) .append("Поздравляю, у тебя ни одного ПР на проверку!").append(Smile.BR); diff --git a/src/main/resources/liquibase/change-set/v1.3.0.xml b/src/main/resources/liquibase/change-set/v1.3.0.xml index eddfc13..066e11e 100644 --- a/src/main/resources/liquibase/change-set/v1.3.0.xml +++ b/src/main/resources/liquibase/change-set/v1.3.0.xml @@ -25,4 +25,10 @@ + + + + + + \ No newline at end of file