|
@@ -117,14 +117,14 @@ module.exports = function(crowi) {
|
|
|
const message = {
|
|
const message = {
|
|
|
channel: '#' + channel,
|
|
channel: '#' + channel,
|
|
|
username: Config.appTitle(config),
|
|
username: Config.appTitle(config),
|
|
|
- text: getSlackMessageText(page.path, user, updateType),
|
|
|
|
|
|
|
+ text: getSlackMessageTextForPage(page.path, user, updateType),
|
|
|
attachments: [attachment],
|
|
attachments: [attachment],
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
return message;
|
|
return message;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const prepareSlackMessageForComment = function(comment, user, channel, updateType) {
|
|
|
|
|
|
|
+ const prepareSlackMessageForComment = function(comment, user, channel) {
|
|
|
const url = config.crowi['app:url'] || '';
|
|
const url = config.crowi['app:url'] || '';
|
|
|
const body = prepareAttachmentTextForComment(comment, user);
|
|
const body = prepareAttachmentTextForComment(comment, user);
|
|
|
|
|
|
|
@@ -143,14 +143,14 @@ module.exports = function(crowi) {
|
|
|
const message = {
|
|
const message = {
|
|
|
channel: '#' + channel,
|
|
channel: '#' + channel,
|
|
|
username: Config.appTitle(config),
|
|
username: Config.appTitle(config),
|
|
|
- text: getSlackMessageText(comment.page.path, user, updateType),
|
|
|
|
|
|
|
+ text: getSlackMessageTextForComment('what do i do with path', user),
|
|
|
attachments: [attachment],
|
|
attachments: [attachment],
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
return message;
|
|
return message;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const getSlackMessageText = function(path, user, updateType) {
|
|
|
|
|
|
|
+ const getSlackMessageTextForPage = function(path, user, updateType) {
|
|
|
let text;
|
|
let text;
|
|
|
const url = config.crowi['app:url'] || '';
|
|
const url = config.crowi['app:url'] || '';
|
|
|
|
|
|
|
@@ -158,9 +158,6 @@ module.exports = function(crowi) {
|
|
|
if (updateType == 'create') {
|
|
if (updateType == 'create') {
|
|
|
text = `:white_check_mark: ${user.username} created a new page! ${pageUrl}`;
|
|
text = `:white_check_mark: ${user.username} created a new page! ${pageUrl}`;
|
|
|
}
|
|
}
|
|
|
- else if (updateType == 'comment') {
|
|
|
|
|
- text = `:speech_balloon: ${user.username} commented on ${pageUrl}`;
|
|
|
|
|
- }
|
|
|
|
|
else {
|
|
else {
|
|
|
text = `:up: ${user.username} updated ${pageUrl}`;
|
|
text = `:up: ${user.username} updated ${pageUrl}`;
|
|
|
}
|
|
}
|
|
@@ -168,20 +165,28 @@ module.exports = function(crowi) {
|
|
|
return text;
|
|
return text;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ const getSlackMessageTextForComment = function(path, user) {
|
|
|
|
|
+ const url = config.crowi['app:url'] || '';
|
|
|
|
|
+ const pageUrl = `<${url}${path}|${path}>`;
|
|
|
|
|
+ const text = `:speech_balloon: ${user.username} commented on ${pageUrl}`;
|
|
|
|
|
+
|
|
|
|
|
+ return text;
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
// slack.post = function (channel, message, opts) {
|
|
// slack.post = function (channel, message, opts) {
|
|
|
slack.postPage = (page, user, channel, updateType, previousRevision) => {
|
|
slack.postPage = (page, user, channel, updateType, previousRevision) => {
|
|
|
const messageObj = prepareSlackMessageForPage(page, user, channel, updateType, previousRevision);
|
|
const messageObj = prepareSlackMessageForPage(page, user, channel, updateType, previousRevision);
|
|
|
|
|
|
|
|
- return promisifiedSlackSend(messageObj);
|
|
|
|
|
|
|
+ return promisifiedSlackPost(messageObj);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- slack.postComment = (comment, user, channel, updateType) => {
|
|
|
|
|
- const messageObj = prepareSlackMessageForComment(comment, user, channel, updateType);
|
|
|
|
|
|
|
+ slack.postComment = (comment, user, channel) => {
|
|
|
|
|
+ const messageObj = prepareSlackMessageForComment(comment, user, channel);
|
|
|
|
|
|
|
|
- return promisifiedSlackSend(messageObj);
|
|
|
|
|
|
|
+ return promisifiedSlackPost(messageObj);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- const promisifiedSlackSend = (messageObj) => {
|
|
|
|
|
|
|
+ const promisifiedSlackPost = (messageObj) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
// define callback function for Promise
|
|
// define callback function for Promise
|
|
|
const callback = function(err, res) {
|
|
const callback = function(err, res) {
|