@@ -53,57 +53,55 @@ class IssueHook extends gitbucket.core.plugin.IssueHook
5353 with IssuesService {
5454
5555 override def created (issue : Issue , r : RepositoryInfo )(implicit context : Context ): Unit = {
56- Notifier ().toNotify(
57- subject( issue, r),
58- message(issue.content getOrElse " " , r)(content => s """
59- | $content <br/>
60- |--<br/>
61- |<a href=" ${ s " ${context.baseUrl} / ${r.owner} / ${r.name} /issues/ ${issue.issueId} " } ">View it on GitBucket</a>
62- """ .stripMargin)
63- )(recipients(issue))
56+ val markdown =
57+ s """ | ${ issue.content getOrElse " " }
58+ |
59+ |----
60+ |[View it on GitBucket]( ${ s " ${context.baseUrl} / ${r.owner} / ${r.name} /issues/ ${issue.issueId} " } )
61+ | """ .stripMargin
62+
63+ Notifier ().toNotify(subject(issue, r), markdown, Some (toHtml(markdown, r)) )(recipients(issue))
6464 }
6565
6666 override def addedComment (commentId : Int , content : String , issue : Issue , r : RepositoryInfo )(implicit context : Context ): Unit = {
67- Notifier ().toNotify(
68- subject(issue, r),
69- message(content, r)(content => s """
70- | $content <br/>
71- |--<br/>
72- |<a href=" ${ s " ${context.baseUrl} / ${r.owner} / ${r.name} /issues/ ${issue.issueId} #comment- $commentId " } ">View it on GitBucket</a>
73- """ .stripMargin)
74- )(recipients(issue))
67+ val markdown =
68+ s """ | ${content}
69+ |
70+ |----
71+ |[View it on GitBucket]( ${ s " ${context.baseUrl} / ${r.owner} / ${r.name} /issues/ ${issue.issueId} #comment- $commentId " } )
72+ | """ .stripMargin
73+
74+ Notifier ().toNotify(subject(issue, r), markdown, Some (toHtml(markdown, r)) )(recipients(issue))
7575 }
7676
7777 override def closed (issue : Issue , r : RepositoryInfo )(implicit context : Context ): Unit = {
78- Notifier ().toNotify(
79- subject(issue, r),
80- message(" close" , r)(content => s """
81- | $content <a href=" ${s " ${context.baseUrl}/ ${r.owner}/ ${r.name}/issues/ ${issue.issueId}" }"># ${issue.issueId}</a>
82- """ .stripMargin)
83- )(recipients(issue))
78+ val markdown =
79+ s """ |close #[ ${issue.issueId}]( ${s " ${context.baseUrl}/ ${r.owner}/ ${r.name}/issues/ ${issue.issueId}" })
80+ | """ .stripMargin
81+
82+ Notifier ().toNotify(subject(issue, r), markdown, Some (toHtml(markdown, r)))(recipients(issue))
8483 }
8584
8685 override def reopened (issue : Issue , r : RepositoryInfo )(implicit context : Context ): Unit = {
87- Notifier ().toNotify(
88- subject(issue, r),
89- message(" reopen" , r)(content => s """
90- | $content <a href=" ${s " ${context.baseUrl}/ ${r.owner}/ ${r.name}/issues/ ${issue.issueId}" }"># ${issue.issueId}</a>
91- """ .stripMargin)
92- )(recipients(issue))
86+ val markdown =
87+ s """ |reopen #[ ${issue.issueId}]( ${s " ${context.baseUrl}/ ${r.owner}/ ${r.name}/issues/ ${issue.issueId}" })
88+ | """ .stripMargin
89+
90+ Notifier ().toNotify(subject(issue, r), markdown, Some (toHtml(markdown, r)))(recipients(issue))
9391 }
9492
9593
9694 protected def subject (issue : Issue , r : RepositoryInfo ): String = s " [ ${r.owner}/ ${r.name}] ${issue.title} (# ${issue.issueId}) "
9795
98- protected def message ( content : String , r : RepositoryInfo )( msg : String => String )(implicit context : Context ): String =
99- msg( Markdown .toHtml(
100- markdown = content ,
96+ protected def toHtml ( markdown : String , r : RepositoryInfo )(implicit context : Context ): String =
97+ Markdown .toHtml(
98+ markdown = markdown ,
10199 repository = r,
102100 enableWikiLink = false ,
103101 enableRefsLink = true ,
104102 enableAnchor = false ,
105103 enableLineBreaks = false
106- ))
104+ )
107105
108106 protected val recipients : Issue => Account => Session => Seq [String ] = {
109107 issue => loginAccount => implicit session =>
@@ -122,35 +120,34 @@ class IssueHook extends gitbucket.core.plugin.IssueHook
122120class PullRequestHook extends IssueHook with gitbucket.core.plugin.PullRequestHook {
123121
124122 override def created (issue : Issue , r : RepositoryInfo )(implicit context : Context ): Unit = {
125- val url = s " ${context.baseUrl} / ${r.owner} / ${r.name} /pull/ ${issue.issueId} "
126- Notifier ().toNotify(
127- subject(issue, r),
128- message(issue.content getOrElse " " , r)(content => s """
129- | $content <hr/>
130- |View, comment on, or merge it at:<br/>
131- |<a href=" $url "> $url </a>
132- """ .stripMargin)
133- )(recipients(issue))
123+ val markdown =
124+ s """ | ${issue.content getOrElse " " }
125+ |
126+ |----
127+ |View, comment on, or merge it at:
128+ | ${context.baseUrl} / ${r.owner} / ${r.name} /pull/ ${issue.issueId}
129+ | """ .stripMargin
130+
131+ Notifier ().toNotify(subject(issue, r), markdown, Some (toHtml(markdown, r)) )(recipients(issue))
134132 }
135133
136134 override def addedComment (commentId : Int , content : String , issue : Issue , r : RepositoryInfo )(implicit context : Context ): Unit = {
137- Notifier ().toNotify(
138- subject(issue, r),
139- message(content, r)(content => s """
140- | $content <br/>
141- |--<br/>
142- |<a href=" ${ s " ${context.baseUrl} / ${r.owner} / ${r.name} /pull/ ${issue.issueId} #comment- $commentId " } ">View it on GitBucket</a>
143- """ .stripMargin)
144- )(recipients(issue))
135+ val markdown =
136+ s """ | $content
137+ |
138+ |----
139+ |[View it on GitBucket]( ${ s " ${context.baseUrl} / ${r.owner} / ${r.name} /pull/ ${issue.issueId} #comment- $commentId " } )
140+ | """ .stripMargin
141+
142+ Notifier ().toNotify(subject(issue, r), markdown, Some (toHtml(markdown, r)) )(recipients(issue))
145143 }
146144
147145 override def merged (issue : Issue , r : RepositoryInfo )(implicit context : Context ): Unit = {
148- Notifier ().toNotify(
149- subject(issue, r),
150- message(" merge" , r)(content => s """
151- | $content <a href=" ${s " ${context.baseUrl}/ ${r.owner}/ ${r.name}/pull/ ${issue.issueId}" }"># ${issue.issueId}</a>
152- """ .stripMargin)
153- )(recipients(issue))
146+ val markdown =
147+ s """ |merge #[ ${issue.issueId}]( ${s " ${context.baseUrl}/ ${r.owner}/ ${r.name}/pull/ ${issue.issueId}" })
148+ | """ .stripMargin
149+
150+ Notifier ().toNotify(subject(issue, r), markdown, Some (toHtml(markdown, r)))(recipients(issue))
154151 }
155152
156153}
0 commit comments