Просмотр исходного кода

handled error in sending notification, use crowi.slack.postComment

sou 7 лет назад
Родитель
Сommit
e272c760a9
2 измененных файлов с 5 добавлено и 2 удалено
  1. 1 2
      lib/routes/comment.js
  2. 4 0
      resource/js/components/SlackNotification.js

+ 1 - 2
lib/routes/comment.js

@@ -80,13 +80,12 @@ module.exports = function(crowi, app) {
     // slack notification
     if (slackNotificationForm.isNotification) {
       try {
-        const slackNotify = new slack(crowi);
         const user = await User.findUserByUsername(req.user.username);
         const path = page.path;
         const channels = slackNotificationForm.notifSlackChannel;
 
         channels.split(',').map(function(chan) {
-          slackNotify.postComment(createdComment, user, chan, path);
+          crowi.slack.postComment(createdComment, user, chan, path);
         });
       }
       catch (err) {

+ 4 - 0
resource/js/components/SlackNotification.js

@@ -57,11 +57,13 @@ export default class SlackNotification extends React.Component {
 
   updateState(value) {
     this.setState({notifSlackChannel: value});
+    this.props.onChannelChange(value);
   }
 
   updateStateCheckbox(event) {
     const value = event.target.checked;
     this.setState({isNotification: value});
+    this.props.onSlackOnChange(value);
   }
 
   render() {
@@ -94,4 +96,6 @@ SlackNotification.propTypes = {
   crowi: PropTypes.object.isRequired,
   pageId: PropTypes.string,
   pagePath: PropTypes.string,
+  onChannelChange: PropTypes.func.isRequired,
+  onSlackOnChange: PropTypes.func.isRequired,
 };