Added no results text for Slack slash command
This commit is contained in:
@ -26,24 +26,30 @@ router.post('hooks.slack', async ctx => {
|
|||||||
limit: 5,
|
limit: 5,
|
||||||
});
|
});
|
||||||
|
|
||||||
const results = [];
|
if (documents) {
|
||||||
let number = 1;
|
const results = [];
|
||||||
for (const document of documents) {
|
let number = 1;
|
||||||
results.push(
|
for (const document of documents) {
|
||||||
`${number}. <${process.env.URL}${document.getUrl()}|${document.title}>`
|
results.push(
|
||||||
);
|
`${number}. <${process.env.URL}${document.getUrl()}|${document.title}>`
|
||||||
number += 1;
|
);
|
||||||
}
|
number += 1;
|
||||||
|
}
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
text: 'Search results:',
|
text: 'Search results:',
|
||||||
attachments: [
|
attachments: [
|
||||||
{
|
{
|
||||||
text: results.join('\n'),
|
text: results.join('\n'),
|
||||||
color: '#3AA3E3',
|
color: '#3AA3E3',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
} else {
|
||||||
|
ctx.body = {
|
||||||
|
text: 'No search results',
|
||||||
|
};
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
Reference in New Issue
Block a user