' + escH(intro) + '
' + blocks.map(b => 'InstantAdPay support. Reply on the page above, or email support@instantadpay.com and keep the ticket number in the subject.
' + escH(b.name) + ' support. ' + escH(b.footer) + '
'; } function confirmRequester(t, m) { if (!deps.mailer || !deps.mailer.hasKey()) return; - const link = linkFor(t); + const link = linkFor(t), b = brandOf(t); const text = 'Hi' + (t.name ? ' ' + t.name : '') + ',\n\nWe got your message and opened ticket ' + t.ref + '. Marty reads every one and will reply as soon as he can.\n\n' - + 'Subject: ' + t.subject + '\n\n' + m.body + '\n\nView the ticket or add more detail here (no sign-in needed):\n' + link + '\n\nInstantAdPay support'; - deps.mailer.send(t.email, '[' + t.ref + '] ' + t.subject, text, htmlMail('We got your message and opened ticket ' + t.ref + '. Marty reads every one and will reply as soon as he can.', [m.body], link, 'View your ticket'), { transactional: true }) + + 'Subject: ' + t.subject + '\n\n' + m.body + '\n\nView the ticket or add more detail here (no sign-in needed):\n' + link + '\n\n' + b.name + ' support'; + deps.mailer.send(t.email, '[' + t.ref + '] ' + t.subject, text, htmlMail('We got your message and opened ticket ' + t.ref + '. Marty reads every one and will reply as soon as he can.', [m.body], link, 'View your ticket', b), { transactional: true }) .catch(e => console.error('support confirm mail', e.message)); } function notifyRequester(t, m) { throttled('member:' + t.id, 2 * 60 * 1000, m, async items => { const cur = (await impl().getTicket(t.id)) || t; - const link = linkFor(cur); + const link = linkFor(cur), b = brandOf(cur); const bodies = items.map(i => i.body); if (deps.mailer && deps.mailer.hasKey()) { const text = 'Hi' + (cur.name ? ' ' + cur.name : '') + ',\n\nMarty replied to your support ticket ' + cur.ref + ':\n\n' + bodies.join('\n\n---\n\n') - + '\n\nRead the whole thread and reply here:\n' + link + '\n\nInstantAdPay support'; - deps.mailer.send(cur.email, '[' + cur.ref + '] ' + cur.subject, text, htmlMail('Marty replied to your support ticket ' + cur.ref + ':', bodies, link, 'Read and reply'), { transactional: true }) + + '\n\nRead the whole thread and reply here:\n' + link + (cur.platform === 'linkspin' ? '\n\nOr open Help in your LinkSpin Control Room: ' + b.help(cur.ref) : '') + '\n\n' + b.name + ' support'; + deps.mailer.send(cur.email, '[' + cur.ref + '] ' + cur.subject, text, htmlMail('Marty replied to your support ticket ' + cur.ref + ':', bodies, link, 'Read and reply', b), { transactional: true }) .catch(e => console.error('support reply mail', e.message)); } - // members also get it in their on-site inbox, as a notice: it never pops the sign-in modal + // members also get it in their on-site inbox, as a notice: it never pops the sign-in modal. InstantAdPay tickets only: + // a LinkSpin ticket is followed on LinkSpin (its Help badge), and its requester may have no real account here at all + if (cur.platform !== 'iap') return; try { const acct = deps.accounts && await deps.accounts.byEmail(cur.email); if (acct && deps.messages) await deps.messages.deliver(1, deps.adminEmail || 'house@instantadpay.com', [cur.email], 'Support replied: [' + cur.ref + '] ' + cur.subject.slice(0, 110), @@ -288,8 +302,9 @@ async function byToken(tok) { } const pubMsg = m => ({ id: m.id, author: m.author, body: m.body, attachments: m.attachments, created: m.created }); const pubTicket = t => ({ ref: t.ref, platform: t.platform, subject: t.subject, category: t.category, status: t.status, created: t.created, updated: t.updated, unread: t.memberUnread }); -async function memberList(email) { return (await impl().list({ email: lc(email), limit: 100 })).map(pubTicket); } -async function memberUnread(email) { return impl().memberUnread(lc(email)); } +// platform: only that site's tickets (each site's Help pane shows its own); omitted = all of them +async function memberList(email, platform) { return (await impl().list({ email: lc(email), platform: PLATFORMS.includes(platform) ? platform : '', limit: 100 })).map(pubTicket); } +async function memberUnread(email, platform) { return impl().memberUnread(lc(email), PLATFORMS.includes(platform) ? platform : ''); } // the requester's view of one ticket (no internal notes); opening it clears their unread flag async function memberView(t) { if (t.memberUnread) await impl().updateTicket(t.id, { memberUnread: false }); @@ -319,5 +334,5 @@ async function ingestEmail(e) { return Object.assign(r, { created: true }); } -module.exports = { init, CATEGORIES, STATUSES, PRIORITIES, PLATFORMS, SOURCES, DEFAULT_TEMPLATES, refOf, parseRef, tokenFor, linkFor, +module.exports = { init, PLATFORM_NAME, CATEGORIES, STATUSES, PRIORITIES, PLATFORMS, SOURCES, DEFAULT_TEMPLATES, refOf, parseRef, tokenFor, linkFor, create, addMessage, setFields, byRef, byToken, memberList, memberUnread, memberView, adminList, adminView, counts, ingestEmail };