create-heresay 0.2.42 โ 0.2.43
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-heresay",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.43",
|
|
4
4
|
"description": "Set up your own Heresay: in-app feedback that every report gets a hearing. Creates a Firebase project in your Google account and deploys the dashboard, API and SDK to it.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
package/release/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.2.
|
|
1
|
+
0.2.43
|
|
@@ -207,7 +207,7 @@ export async function notificationSettings(p, req, deps, body) {
|
|
|
207
207
|
if (!deps.sendNotification)
|
|
208
208
|
return json(503, { error: 'Notification delivery is unavailable.' });
|
|
209
209
|
try {
|
|
210
|
-
await deps.sendNotification(provider, target, 'Heresay
|
|
210
|
+
await deps.sendNotification(provider, target, 'โ
Heresay is connected. You will get the alerts you chose in Notifications.');
|
|
211
211
|
return json(200, { ok: true });
|
|
212
212
|
}
|
|
213
213
|
catch {
|
|
@@ -216,6 +216,11 @@ export async function notificationSettings(p, req, deps, body) {
|
|
|
216
216
|
}
|
|
217
217
|
return json(404, { error: 'not found' });
|
|
218
218
|
}
|
|
219
|
+
const HEADLINE = {
|
|
220
|
+
new_report: ['๐', 'New report'], accepted: ['โ
', 'Accepted'], fixed: ['๐ ๏ธ', 'Fixed'], handoff: ['๐', 'Handed off'],
|
|
221
|
+
};
|
|
222
|
+
const TYPE = { broken: ['๐', 'Broken'], confusing: ['๐ค', 'Confusing'], improvement: ['โจ', 'Improvement'], idea: ['๐ก', 'Idea'] };
|
|
223
|
+
const esc = (t) => t.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
219
224
|
const actionsReady = (tg) => !!(tg.webhook_secret && tg.webhook_url);
|
|
220
225
|
/** Metadata only: open reports and reporter details must never flow into an integration. */
|
|
221
226
|
export async function notify(event, project, reportId, deps) {
|
|
@@ -227,16 +232,24 @@ export async function notify(event, project, reportId, deps) {
|
|
|
227
232
|
new_report: 'A new report needs your review', accepted: 'A report was accepted for a coding agent',
|
|
228
233
|
fixed: 'A report was marked fixed', handoff: 'A coding agent handed off a report',
|
|
229
234
|
};
|
|
235
|
+
const [emoji, head] = HEADLINE[event];
|
|
236
|
+
// The type is one of four fixed words, never the reporter's text.
|
|
237
|
+
const found = await deps.store.getReport(project.id, reportId).catch(() => null);
|
|
238
|
+
const type = (found && TYPE[found.type]) || null;
|
|
230
239
|
const origin = deps.selfOrigins?.[0];
|
|
231
|
-
const
|
|
232
|
-
|
|
240
|
+
const link = origin ? `${origin}/app/#/apps/${encodeURIComponent(project.id)}` : null;
|
|
241
|
+
const meta = [type ? `${type[0]} ${type[1]}` : null, reportId];
|
|
242
|
+
const text = [`${emoji} ${head} ยท ${project.name}`, `${labels[event]}.`, meta.filter(Boolean).join(' ยท ')].join('\n') + (link ? `\n${link}` : '');
|
|
243
|
+
// Telegram gets bold and a link; the app name is the team's own, escaped, and nothing from a reporter is in it.
|
|
244
|
+
const html = `${emoji} <b>${esc(head)}</b> ยท ${esc(project.name)}\n${esc(labels[event])}.\n${type ? `${type[0]} ${type[1]} ยท ` : ''}<code>${esc(reportId)}</code>`
|
|
245
|
+
+ (link ? `\n<a href="${esc(link)}">Open in Heresay โ</a>` : '');
|
|
233
246
|
await Promise.all(['telegram', 'cliq'].map(async (provider) => {
|
|
234
247
|
if (!settings[provider].enabled)
|
|
235
248
|
return;
|
|
236
249
|
try {
|
|
237
250
|
const markup = provider === 'telegram' && event === 'new_report' && actionsReady(settings.telegram)
|
|
238
251
|
? reportKeyboard(project.id, reportId) : null;
|
|
239
|
-
await deps.sendNotification(provider, settings[provider], text, markup ? { telegram_markup: markup } : undefined);
|
|
252
|
+
await deps.sendNotification(provider, settings[provider], provider === 'telegram' ? html : text, provider === 'telegram' ? { telegram_html: true, ...(markup ? { telegram_markup: markup } : {}) } : undefined);
|
|
240
253
|
deps.log('api.notification_sent', { provider, notification_event: event, project_id: project.id, report_id: reportId });
|
|
241
254
|
}
|
|
242
255
|
catch {
|
|
@@ -258,7 +271,7 @@ export function notificationSender(http = fetch) {
|
|
|
258
271
|
throw new Error('Notification token missing.');
|
|
259
272
|
if (provider === 'telegram' && 'chat_id' in destination) {
|
|
260
273
|
url = `https://api.telegram.org/bot${destination.token}/sendMessage`;
|
|
261
|
-
body = { chat_id: destination.chat_id, text, link_preview_options: { is_disabled: true }, ...(extra?.telegram_markup ? { reply_markup: extra.telegram_markup } : {}) };
|
|
274
|
+
body = { chat_id: destination.chat_id, text, ...(extra?.telegram_html ? { parse_mode: 'HTML' } : {}), link_preview_options: { is_disabled: true }, ...(extra?.telegram_markup ? { reply_markup: extra.telegram_markup } : {}) };
|
|
262
275
|
}
|
|
263
276
|
else if (provider === 'cliq' && 'endpoint' in destination && validCliqEndpoint(destination.endpoint)) {
|
|
264
277
|
const u = new URL(destination.endpoint);
|
|
@@ -36,9 +36,9 @@ export function reportKeyboard(project_id, report_id) {
|
|
|
36
36
|
if (Buffer.byteLength(data('a')) > 64)
|
|
37
37
|
return null;
|
|
38
38
|
return { inline_keyboard: [[
|
|
39
|
-
{ text: 'Accept', callback_data: data('a') },
|
|
40
|
-
{ text: 'Decline', callback_data: data('d') },
|
|
41
|
-
{ text: '
|
|
39
|
+
{ text: 'โ
Accept', callback_data: data('a') },
|
|
40
|
+
{ text: 'โ๏ธ Decline', callback_data: data('d') },
|
|
41
|
+
{ text: '๐ Full text', callback_data: data('t') },
|
|
42
42
|
]] };
|
|
43
43
|
}
|
|
44
44
|
// ---- keeping Telegram's webhook in step with the saved bot ----------------------------------
|
|
@@ -253,7 +253,7 @@ async function handleUpdate(u, members, tg, deps, triage) {
|
|
|
253
253
|
const res = await triage(project, report.id, 'accept', email, fakeReq(), deps);
|
|
254
254
|
if (res.status === 200) {
|
|
255
255
|
await answer('Accepted');
|
|
256
|
-
await finish(api, token, cb.message,
|
|
256
|
+
await finish(api, token, cb.message, `โ
Accepted by ${email}`);
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
259
|
await alreadyOrFail(res, project, report.id, answer, cb.message);
|
|
@@ -346,7 +346,7 @@ async function handleUpdate(u, members, tg, deps, triage) {
|
|
|
346
346
|
const original = { message_id: Number(pending.data.message_id), chat: msg.chat, text: String(pending.data.text ?? '') };
|
|
347
347
|
if (res.status === 200) {
|
|
348
348
|
await deps.store.deleteAuth('decline', key);
|
|
349
|
-
await finish(api, token, original,
|
|
349
|
+
await finish(api, token, original, `โ๏ธ Declined by ${email}: ${text}`);
|
|
350
350
|
await reply('Declined. The reporter will see your reason.');
|
|
351
351
|
return;
|
|
352
352
|
}
|
|
@@ -376,7 +376,9 @@ const fakeReq = (body = {}) => ({ method: 'POST', path: '', query: {}, headers:
|
|
|
376
376
|
async function finish(api, token, message, line) {
|
|
377
377
|
await api(token, 'editMessageText', {
|
|
378
378
|
chat_id: message.chat.id, message_id: message.message_id,
|
|
379
|
-
text: capText(`${(message.text ?? '').replace(/\n\n(Accepted|Declined) by [\s\S]*$/, '')}\n\n${line}`.trim()),
|
|
379
|
+
text: capText(`${(message.text ?? '').replace(/\n\n(โ
Accepted|โ๏ธ Declined|Accepted|Declined) by [\s\S]*$/, '')}\n\n${line}`.trim()),
|
|
380
|
+
// The alert's bold and link, kept: the outcome is added after them, so their positions still hold.
|
|
381
|
+
...(message.entities?.length ? { entities: message.entities } : {}),
|
|
380
382
|
link_preview_options: { is_disabled: true }, reply_markup: { inline_keyboard: [] },
|
|
381
383
|
});
|
|
382
384
|
}
|