@@ -2,8 +2,8 @@ package gitbucket.notifications.service
22
33import gitbucket .core .controller .Context
44import gitbucket .core .model .{Account , Issue }
5- import gitbucket .core .service .RepositoryService .RepositoryInfo
6- import gitbucket .core .util .Notifier
5+ import gitbucket .core .service ._ , RepositoryService .RepositoryInfo
6+ import gitbucket .core .util .{ LDAPUtil , Notifier }
77import gitbucket .core .view .Markdown
88import gitbucket .notifications .model .Profile ._
99import profile .blockingApi ._
@@ -46,7 +46,11 @@ class RepositoryHook extends gitbucket.core.plugin.RepositoryHook {
4646
4747}
4848
49- class IssueHook extends gitbucket.core.plugin.IssueHook {
49+ class IssueHook extends gitbucket.core.plugin.IssueHook
50+ with NotificationsService
51+ with RepositoryService
52+ with AccountService
53+ with IssuesService {
5054
5155 override def created (issue : Issue , r : RepositoryInfo )(implicit context : Context ): Unit = {
5256 Notifier ().toNotify(
@@ -89,11 +93,10 @@ class IssueHook extends gitbucket.core.plugin.IssueHook {
8993 }
9094
9195
92- protected val subject : (Issue , RepositoryInfo ) => String =
93- (issue, r) => s " [ ${r.owner}/ ${r.name}] ${issue.title} (# ${issue.issueId}) "
96+ protected def subject (issue : Issue , r : RepositoryInfo ): String = s " [ ${r.owner}/ ${r.name}] ${issue.title} (# ${issue.issueId}) "
9497
95- protected val message : ( String , RepositoryInfo ) => ( String => String ) => String =
96- (content, r) => msg => msg(Markdown .toHtml(
98+ protected def message ( content : String , r : RepositoryInfo )( msg : String => String )( implicit context : Context ) : String =
99+ msg(Markdown .toHtml(
97100 markdown = content,
98101 repository = r,
99102 enableWikiLink = false ,
@@ -102,10 +105,16 @@ class IssueHook extends gitbucket.core.plugin.IssueHook {
102105 enableLineBreaks = false
103106 ))
104107
105- // TODO
106108 protected val recipients : Issue => Account => Session => Seq [String ] = {
107109 issue => loginAccount => implicit session =>
108- Seq (" " )
110+ getNotificationUsers(issue)
111+ .withFilter ( _ != loginAccount.userName ) // the operation in person is excluded
112+ .flatMap (
113+ getAccountByUserName(_)
114+ .filterNot (_.isGroupAccount)
115+ .filterNot (LDAPUtil .isDummyMailAddress)
116+ .map (_.mailAddress)
117+ )
109118 }
110119
111120}
0 commit comments