Add screenshot uploads to feedback modal, Webex bot DM on issue close
- Feedback modal now supports up to 3 image attachments (PNG/JPG/GIF/WebP, 5MB each) with thumbnail previews. Images are uploaded to GitLab project uploads and embedded as markdown in the issue description. - New webhook endpoint (POST /api/webhooks/gitlab) receives issue close events, parses the submitter from the description, looks up their email, and sends a Webex DM via the Patches O'Houlihan bot. - New helper: backend/helpers/webexBot.js (fire-and-forget DM sender). - Requires WEBEX_BOT_TOKEN and GITLAB_WEBHOOK_SECRET in backend/.env.
This commit is contained in:
64
backend/helpers/webexBot.js
Normal file
64
backend/helpers/webexBot.js
Normal file
@@ -0,0 +1,64 @@
|
||||
// Webex Bot DM Helper
|
||||
// Fire-and-forget pattern — logs success/failure but never throws.
|
||||
// Used to notify users when their feedback issues are resolved.
|
||||
|
||||
const https = require('https');
|
||||
|
||||
const WEBEX_API_URL = 'https://webexapis.com/v1/messages';
|
||||
const WEBEX_BOT_TOKEN = process.env.WEBEX_BOT_TOKEN || '';
|
||||
|
||||
/**
|
||||
* Send a direct message to a user via Webex Teams bot.
|
||||
* @param {string} email - Recipient's email address
|
||||
* @param {string} markdownMessage - Message body (Webex markdown supported)
|
||||
*/
|
||||
function sendDirectMessage(email, markdownMessage) {
|
||||
if (!WEBEX_BOT_TOKEN) {
|
||||
console.warn('[WebexBot] WEBEX_BOT_TOKEN not configured — skipping DM');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!email || !markdownMessage) {
|
||||
console.warn('[WebexBot] Missing email or message — skipping DM');
|
||||
return;
|
||||
}
|
||||
|
||||
const postData = JSON.stringify({
|
||||
toPersonEmail: email,
|
||||
markdown: markdownMessage,
|
||||
});
|
||||
|
||||
const parsed = new URL(WEBEX_API_URL);
|
||||
|
||||
const reqOpts = {
|
||||
method: 'POST',
|
||||
hostname: parsed.hostname,
|
||||
path: parsed.pathname,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${WEBEX_BOT_TOKEN}`,
|
||||
'Content-Length': Buffer.byteLength(postData),
|
||||
},
|
||||
};
|
||||
|
||||
const req = https.request(reqOpts, (res) => {
|
||||
let data = '';
|
||||
res.on('data', chunk => { data += chunk; });
|
||||
res.on('end', () => {
|
||||
if (res.statusCode >= 200 && res.statusCode < 300) {
|
||||
console.log(`[WebexBot] DM sent to ${email} (${res.statusCode})`);
|
||||
} else {
|
||||
console.error(`[WebexBot] Failed to DM ${email} — ${res.statusCode}: ${data}`);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', (err) => {
|
||||
console.error(`[WebexBot] Request error sending DM to ${email}:`, err.message);
|
||||
});
|
||||
|
||||
req.write(postData);
|
||||
req.end();
|
||||
}
|
||||
|
||||
module.exports = { sendDirectMessage };
|
||||
Reference in New Issue
Block a user