Skip to content

Commit

Permalink
feat(Support): add captured URL to new ticket notif
Browse files Browse the repository at this point in the history
  • Loading branch information
jakeaturner committed Aug 21, 2024
1 parent ec8afff commit 14bc4ad
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
6 changes: 4 additions & 2 deletions server/api/mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -787,8 +787,9 @@ const sendSupportTicketCreateConfirmation = (recipientAddress, ticketID, params)
* @param {string} ticketAuthor - the ticket's author
* @param {string} ticketCategory - the ticket's category
* @param {string} ticketPriority - the ticket's priority
* @param {string | undefined} capturedURL - the URL of the page where the ticket was created or provided by the user
*/
const sendSupportTicketCreateInternalNotification = (recipientAddresses, ticketID, ticketTitle, ticketBody, ticketAuthor, ticketCategory, ticketPriority) => {
const sendSupportTicketCreateInternalNotification = (recipientAddresses, ticketID, ticketTitle, ticketBody, ticketAuthor, ticketCategory, ticketPriority, capturedURL) => {
return mailgun.messages.create(process.env.MAILGUN_DOMAIN, {
from: 'LibreTexts Support <[email protected]>',
to: recipientAddresses,
Expand All @@ -800,8 +801,9 @@ const sendSupportTicketCreateInternalNotification = (recipientAddresses, ticketI
<p><strong>Author:</strong> ${ticketAuthor}</p>
<p><strong>Category:</strong> ${ticketCategory}</p>
<p><strong>Priority:</strong> ${ticketPriority}</p>
${capturedURL ? `<p><strong>Related URL:</strong> ${capturedURL}</p>` : ''}
<br />
<p><strong>Body:</strong> ${ticketBody}</p>
<p><strong>Description:</strong> ${ticketBody}</p>
<br />
<p>You can view the ticket at <a href="https://commons.libretexts.org/support/ticket/${ticketID}" target="_blank" rel="noopener noreferrer">https://commons.libretexts.org/support/ticket/${ticketID}</a>.</p>
<p>Sincerely,</p>
Expand Down
13 changes: 7 additions & 6 deletions server/api/support.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,9 @@ async function getOpenInProgressTickets(
.populate("assignedUsers")
.populate("user")
.exec()) as (SupportTicketInterface & {
assignedUsers?: UserInterface[];
user?: UserInterface;
})[];
assignedUsers?: UserInterface[];
user?: UserInterface;
})[];

// We have to sort the tickets in memory because we can only alphabetically sort by priority in query
if (req.query.sort === "priority") {
Expand Down Expand Up @@ -628,7 +628,8 @@ async function createTicket(
ticket.description,
authorString,
capitalizeFirstLetter(ticket.category),
capitalizeFirstLetter(ticket.priority)
capitalizeFirstLetter(ticket.priority),
ticket.capturedURL ?? undefined
);

if (teamToNotify.length > 0) emailPromises.push(teamPromise);
Expand Down Expand Up @@ -1325,8 +1326,8 @@ const _getTicketAuthorString = (
const ticketAuthor = foundUser
? `${foundUser.firstName} ${foundUser.lastName}`
: guest
? `${guest.firstName} ${guest.lastName}`
: "Unknown";
? `${guest.firstName} ${guest.lastName}`
: "Unknown";
const authorString = `${ticketAuthor} (${emailToNotify})`;
return authorString;
};
Expand Down

0 comments on commit 14bc4ad

Please sign in to comment.