|
|
@@ -255,6 +255,7 @@ module.exports = function(crowi, app) {
|
|
|
tree: [],
|
|
|
pageRelatedGroup: null,
|
|
|
template: null,
|
|
|
+ slack: '',
|
|
|
};
|
|
|
|
|
|
var pageTeamplate = 'customlayout-selector/page';
|
|
|
@@ -291,18 +292,10 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
|
})
|
|
|
.then(() => {
|
|
|
- if (page.extended.slack) {
|
|
|
- renderVars.slack = page.extended.slack;
|
|
|
- return;
|
|
|
- }
|
|
|
- else {
|
|
|
- return UpdatePost.findSettingsByPath(page.path)
|
|
|
- .then(function(data) {
|
|
|
- renderVars.slack = data.map(e => e.channel).join(', ');
|
|
|
- }).catch(function(err) {
|
|
|
- debug('Error occured in getting slack channels', err);
|
|
|
+ return getSlackChannels(page)
|
|
|
+ .then((channels) => {
|
|
|
+ renderVars.slack = channels;
|
|
|
});
|
|
|
- }
|
|
|
})
|
|
|
.then(function() {
|
|
|
var userPage = isUserPage(page.path);
|
|
|
@@ -382,6 +375,30 @@ module.exports = function(crowi, app) {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
+ const getSlackChannels = async page => {
|
|
|
+ if (page.extended.slack) {
|
|
|
+ return page.extended.slack;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ const data = await UpdatePost.findSettingsByPath(page.path);
|
|
|
+ const channels = data.map(e => e.channel).join(', ');
|
|
|
+ return channels;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ // const getSlackChannels = page => {
|
|
|
+ // if (page.extended.slack) {
|
|
|
+ // return page.extended.slack;
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // return UpdatePost.findSettingsByPath(page.path)
|
|
|
+ // .then((data) => {
|
|
|
+ // const channels = data.map(e => e.channel).join(', ');
|
|
|
+ // return channels;
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // };
|
|
|
+
|
|
|
const replacePlaceholders = (template, req) => {
|
|
|
const definitions = {
|
|
|
pagepath: getPathFromRequest(req),
|
|
|
@@ -508,18 +525,10 @@ module.exports = function(crowi, app) {
|
|
|
}
|
|
|
})
|
|
|
.then(() => {
|
|
|
- if (pageData.extended.slack) {
|
|
|
- renderVars.slack = pageData.extended.slack;
|
|
|
- return;
|
|
|
- }
|
|
|
- else {
|
|
|
- return UpdatePost.findSettingsByPath(pageData.path)
|
|
|
- .then(function(data) {
|
|
|
- renderVars.slack = data.map(e => e.channel).join(', ');
|
|
|
- }).catch(function(err) {
|
|
|
- debug('Error occured in getting slack channels', err);
|
|
|
+ return getSlackChannels(pageData)
|
|
|
+ .then((channels) => {
|
|
|
+ renderVars.slack = channels;
|
|
|
});
|
|
|
- }
|
|
|
})
|
|
|
.then(function() {
|
|
|
if (userPage) {
|