@@ -53,57 +53,55 @@ class IssueHook extends gitbucket.core.plugin.IssueHook
53
53
with IssuesService {
54
54
55
55
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))
64
64
}
65
65
66
66
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))
75
75
}
76
76
77
77
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))
84
83
}
85
84
86
85
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))
93
91
}
94
92
95
93
96
94
protected def subject (issue : Issue , r : RepositoryInfo ): String = s " [ ${r.owner}/ ${r.name}] ${issue.title} (# ${issue.issueId}) "
97
95
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 ,
101
99
repository = r,
102
100
enableWikiLink = false ,
103
101
enableRefsLink = true ,
104
102
enableAnchor = false ,
105
103
enableLineBreaks = false
106
- ))
104
+ )
107
105
108
106
protected val recipients : Issue => Account => Session => Seq [String ] = {
109
107
issue => loginAccount => implicit session =>
@@ -122,35 +120,34 @@ class IssueHook extends gitbucket.core.plugin.IssueHook
122
120
class PullRequestHook extends IssueHook with gitbucket.core.plugin.PullRequestHook {
123
121
124
122
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))
134
132
}
135
133
136
134
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))
145
143
}
146
144
147
145
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))
154
151
}
155
152
156
153
}
0 commit comments