|
|
@@ -120,9 +120,11 @@ class BoltService {
|
|
|
}
|
|
|
});
|
|
|
|
|
|
- this.bolt.view('createPage', async({ ack, view }) => {
|
|
|
+ this.bolt.view('createPage', async({
|
|
|
+ ack, view, body, client,
|
|
|
+ }) => {
|
|
|
await ack();
|
|
|
- await this.createPageInGrowi(view);
|
|
|
+ await this.createPageInGrowi(view, body);
|
|
|
});
|
|
|
|
|
|
this.bolt.action('button_click', async({ body, ack, say }) => {
|
|
|
@@ -272,26 +274,31 @@ class BoltService {
|
|
|
}
|
|
|
|
|
|
// Submit action in create Modal
|
|
|
- async createPageInGrowi(view) {
|
|
|
+ async createPageInGrowi(view, body) {
|
|
|
const User = this.crowi.model('User');
|
|
|
const Page = this.crowi.model('Page');
|
|
|
const pathUtils = require('growi-commons').pathUtils;
|
|
|
|
|
|
+ const contentsBody = view.state.values.contents.contents_input.value;
|
|
|
+
|
|
|
try {
|
|
|
// search "slackUser" to create page in slack
|
|
|
const slackUser = await User.findUserByUsername('slackUser');
|
|
|
|
|
|
let path = view.state.values.path.path_input.value;
|
|
|
- const body = view.state.values.contents.contents_input.value;
|
|
|
-
|
|
|
// sanitize path
|
|
|
path = this.crowi.xss.process(path);
|
|
|
path = pathUtils.normalizePath(path);
|
|
|
|
|
|
const user = slackUser._id;
|
|
|
- await Page.create(path, body, user, {});
|
|
|
+ await Page.create(path, contentsBody, user, {});
|
|
|
}
|
|
|
catch (err) {
|
|
|
+ this.client.chat.postMessage({
|
|
|
+ channel: body.user.id,
|
|
|
+ blocks: [
|
|
|
+ this.generateMarkdownSectionBlock(`Cannot create new page to existed path\n *Contents* :memo:\n ${contentsBody}`)],
|
|
|
+ });
|
|
|
logger.error('Failed to create page in GROWI.');
|
|
|
throw err;
|
|
|
}
|