[Notice] Announcing the End of Demo Server [Read me]

Added notification event after the pulll-request's commits are changed
@aca8b347faea9d25b44d979c261dddd218d11889
--- app/actors/PullRequestActor.java
+++ app/actors/PullRequestActor.java
... | ... | @@ -25,6 +25,8 @@ |
25 | 25 |
import models.enumeration.EventType; |
26 | 26 |
import models.enumeration.State; |
27 | 27 |
|
28 |
+import java.util.List; |
|
29 |
+ |
|
28 | 30 |
public abstract class PullRequestActor extends UntypedActor { |
29 | 31 |
|
30 | 32 |
protected void processPullRequestMerging(PullRequestEventMessage message, PullRequest pullRequest) { |
... | ... | @@ -36,6 +38,7 @@ |
36 | 38 |
|
37 | 39 |
if (mergeResult.hasDiffCommits()) { |
38 | 40 |
mergeResult.saveCommits(); |
41 |
+ NotificationEvent.afterPullRequestCommitChanged(message.getSender(), pullRequest); |
|
39 | 42 |
if (!mergeResult.getNewCommits().isEmpty()) { |
40 | 43 |
PullRequestEvent.addCommitEvents(message.getSender(), pullRequest, |
41 | 44 |
mergeResult.getNewCommits(), |
--- app/models/NotificationEvent.java
+++ app/models/NotificationEvent.java
... | ... | @@ -463,6 +463,32 @@ |
463 | 463 |
return notiEvent; |
464 | 464 |
} |
465 | 465 |
|
466 |
+ public static NotificationEvent afterPullRequestCommitChanged(User sender, PullRequest pullRequest) { |
|
467 |
+ NotificationEvent notiEvent = createFrom(sender, pullRequest); |
|
468 |
+ notiEvent.title = formatReplyTitle(pullRequest); |
|
469 |
+ notiEvent.receivers = getReceivers(sender, pullRequest); |
|
470 |
+ notiEvent.eventType = PULL_REQUEST_COMMIT_CHANGED; |
|
471 |
+ notiEvent.oldValue = null; |
|
472 |
+ notiEvent.newValue = newPullRequestCommitChangedMessage(pullRequest); |
|
473 |
+ NotificationEvent.add(notiEvent); |
|
474 |
+ return notiEvent; |
|
475 |
+ } |
|
476 |
+ |
|
477 |
+ private static String newPullRequestCommitChangedMessage(PullRequest pullRequest) { |
|
478 |
+ List<PullRequestCommit> commits = PullRequestCommit.find.where().eq("pullRequest", pullRequest).orderBy().desc("authorDate").findList(); |
|
479 |
+ StringBuilder builder = new StringBuilder(); |
|
480 |
+ builder.append("### "); |
|
481 |
+ builder.append(Messages.get("notification.pullrequest.current.commits")); |
|
482 |
+ builder.append("\n"); |
|
483 |
+ for (PullRequestCommit commit : commits) { |
|
484 |
+ builder.append(commit.getCommitShortId()); |
|
485 |
+ builder.append(" "); |
|
486 |
+ builder.append(commit.getCommitShortMessage()); |
|
487 |
+ builder.append("\n"); |
|
488 |
+ } |
|
489 |
+ return builder.toString(); |
|
490 |
+ } |
|
491 |
+ |
|
466 | 492 |
/** |
467 | 493 |
* @see {@link actors.PullRequestActor#processPullRequestMerging(models.PullRequestEventMessage, models.PullRequest)} |
468 | 494 |
*/ |
... | ... | @@ -1071,5 +1097,4 @@ |
1071 | 1097 |
|
1072 | 1098 |
return find.setRawSql(RawSqlBuilder.parse(sql).create()).findList().size(); |
1073 | 1099 |
} |
1074 |
- |
|
1075 | 1100 |
} |
--- app/models/PullRequestCommit.java
+++ app/models/PullRequestCommit.java
... | ... | @@ -23,6 +23,7 @@ |
23 | 23 |
import java.util.Date; |
24 | 24 |
import java.util.List; |
25 | 25 |
|
26 |
+import javax.annotation.Nonnull; |
|
26 | 27 |
import javax.persistence.Entity; |
27 | 28 |
import javax.persistence.EnumType; |
28 | 29 |
import javax.persistence.Enumerated; |
... | ... | @@ -30,6 +31,7 @@ |
30 | 31 |
import javax.persistence.ManyToOne; |
31 | 32 |
import javax.persistence.Transient; |
32 | 33 |
|
34 |
+import org.apache.commons.lang3.StringUtils; |
|
33 | 35 |
import play.db.ebean.Model; |
34 | 36 |
import playRepository.GitCommit; |
35 | 37 |
import utils.JodaDateUtil; |
... | ... | @@ -69,6 +71,23 @@ |
69 | 71 |
return commitMessage; |
70 | 72 |
} |
71 | 73 |
|
74 |
+ public @Nonnull String getCommitShortMessage() { |
|
75 |
+ if (StringUtils.isEmpty(commitMessage)) { |
|
76 |
+ return ""; |
|
77 |
+ } |
|
78 |
+ |
|
79 |
+ if (!commitMessage.contains("\n")) { |
|
80 |
+ return commitMessage; |
|
81 |
+ } |
|
82 |
+ |
|
83 |
+ String[] segments = commitMessage.split("\n"); |
|
84 |
+ if (segments.length > 0) { |
|
85 |
+ return segments[0]; |
|
86 |
+ } |
|
87 |
+ |
|
88 |
+ return ""; |
|
89 |
+ } |
|
90 |
+ |
|
72 | 91 |
public String getCommitId() { |
73 | 92 |
return commitId; |
74 | 93 |
} |
--- conf/messages
+++ conf/messages
... | ... | @@ -370,6 +370,7 @@ |
370 | 370 |
notification.organization.type.member.enroll = Requests for joining group |
371 | 371 |
notification.pullrequest.closed = Pull Request closed |
372 | 372 |
notification.pullrequest.conflicts = Pull Request conflicts |
373 |
+notification.pullrequest.current.commits = Current Pull Request Commits |
|
373 | 374 |
notification.pullrequest.merged = Pull Request merged |
374 | 375 |
notification.pullrequest.reopened = Pull Request has been reopened |
375 | 376 |
notification.pullrequest.reviewed = {0} completed a review on pull request. |
--- conf/messages.ko
+++ conf/messages.ko
... | ... | @@ -370,6 +370,7 @@ |
370 | 370 |
notification.organization.type.member.enroll = 멤버 등록 요청 |
371 | 371 |
notification.pullrequest.closed = 코드 주고받기 닫힘(closed) |
372 | 372 |
notification.pullrequest.conflicts = 충돌이 발생 |
373 |
+notification.pullrequest.current.commits = 현재 커밋 목록 |
|
373 | 374 |
notification.pullrequest.merged = 보낸 코드가 반영됨(merged) |
374 | 375 |
notification.pullrequest.reopened = 코드 주고받기 다시 열림 |
375 | 376 |
notification.pullrequest.reviewed = {0} 님이 리뷰를 완료했습니다. |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?