88use Fabiang \Xmpp \Protocol \Message ;
99use Fabiang \Xmpp \Protocol \Presence ;
1010use Kanboard \Core \Base ;
11- use Kanboard \Notification \NotificationInterface ;
11+ use Kanboard \Core \ Notification \NotificationInterface ;
1212
1313/**
1414 * Jabber Notification
@@ -29,10 +29,10 @@ class Jabber extends Base implements NotificationInterface
2929 public function notifyUser (array $ user , $ event_name , array $ event_data )
3030 {
3131 try {
32- $ jid = $ this ->userMetadata ->get ($ user ['id ' ], 'jabber_jid ' );
32+ $ jid = $ this ->userMetadataModel ->get ($ user ['id ' ], 'jabber_jid ' );
3333
3434 if (! empty ($ jid )) {
35- $ project = $ this ->project ->getById ($ event_data ['task ' ]['project_id ' ]);
35+ $ project = $ this ->projectModel ->getById ($ event_data ['task ' ]['project_id ' ]);
3636 $ client = $ this ->getClient ();
3737
3838 $ message = new Message ;
@@ -59,13 +59,13 @@ public function notifyUser(array $user, $event_name, array $event_data)
5959 public function notifyProject (array $ project , $ event_name , array $ event_data )
6060 {
6161 try {
62- $ room = $ this ->projectMetadata ->get ($ project ['id ' ], 'jabber_room ' );
62+ $ room = $ this ->projectMetadataModel ->get ($ project ['id ' ], 'jabber_room ' );
6363
6464 if (! empty ($ room )) {
6565 $ client = $ this ->getClient ();
6666
6767 $ channel = new Presence ;
68- $ channel ->setTo ($ room )->setNickName ($ this ->config ->get ('jabber_nickname ' ));
68+ $ channel ->setTo ($ room )->setNickname ($ this ->configModel ->get ('jabber_nickname ' ));
6969 $ client ->send ($ channel );
7070
7171 $ message = new Message ;
@@ -90,10 +90,10 @@ public function notifyProject(array $project, $event_name, array $event_data)
9090 */
9191 public function getClient ()
9292 {
93- $ options = new Options ($ this ->config ->get ('jabber_server ' ));
94- $ options ->setUsername ($ this ->config ->get ('jabber_username ' ));
95- $ options ->setPassword ($ this ->config ->get ('jabber_password ' ));
96- $ options ->setTo ($ this ->config ->get ('jabber_domain ' ));
93+ $ options = new Options ($ this ->configModel ->get ('jabber_server ' ));
94+ $ options ->setUsername ($ this ->configModel ->get ('jabber_username ' ));
95+ $ options ->setPassword ($ this ->configModel ->get ('jabber_password ' ));
96+ $ options ->setTo ($ this ->configModel ->get ('jabber_domain ' ));
9797 $ options ->setLogger ($ this ->logger );
9898
9999 return new Client ($ options );
@@ -106,22 +106,23 @@ public function getClient()
106106 * @param array $project
107107 * @param string $event_name
108108 * @param array $event_data
109+ * @return string
109110 */
110111 public function getMessage (array $ project , $ event_name , array $ event_data )
111112 {
112113 if ($ this ->userSession ->isLogged ()) {
113114 $ author = $ this ->helper ->user ->getFullname ();
114- $ title = $ this ->notification ->getTitleWithAuthor ($ author , $ event_name , $ event_data );
115+ $ title = $ this ->notificationModel ->getTitleWithAuthor ($ author , $ event_name , $ event_data );
115116 } else {
116- $ title = $ this ->notification ->getTitleWithoutAuthor ($ event_name , $ event_data );
117+ $ title = $ this ->notificationModel ->getTitleWithoutAuthor ($ event_name , $ event_data );
117118 }
118119
119120 $ payload = '[ ' .$ project ['name ' ].'] ' ;
120121 $ payload .= $ title ;
121122 $ payload .= ' ' .$ event_data ['task ' ]['title ' ];
122123
123- if ($ this ->config ->get ('application_url ' ) !== '' ) {
124- $ payload .= ' ' .$ this ->helper ->url ->to ('task ' , 'show ' , array ('task_id ' => $ event_data ['task ' ]['id ' ], 'project_id ' => $ project ['id ' ]), '' , true );
124+ if ($ this ->configModel ->get ('application_url ' ) !== '' ) {
125+ $ payload .= ' ' .$ this ->helper ->url ->to ('TaskViewController ' , 'show ' , array ('task_id ' => $ event_data ['task ' ]['id ' ], 'project_id ' => $ project ['id ' ]), '' , true );
125126 }
126127
127128 return $ payload ;
0 commit comments