diff --git a/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/purchase.ts b/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/purchase.ts index 807cc9a402e..bb7b9a693cb 100644 --- a/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/purchase.ts +++ b/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/purchase.ts @@ -1,18 +1,21 @@ -import { capitalize } from 'lodash' - export const email = ({ purchaserName, - contentType, + purchaserProfileImage, + purchaserHandle, + purchaserLink, contentTitle, contentLink, contentImage, artistName, price, payExtra, - total + total, + vendor }: { purchaserName: string - contentType: string + purchaserHandle: string + purchaserProfileImage: string + purchaserLink: string contentTitle: string contentLink: string contentImage: string @@ -20,706 +23,965 @@ export const email = ({ price: string payExtra: string total: string + vendor: string }) => { + const copyrightYear = new Date().getFullYear().toString() + return ` - - - - - - - - - - - - - -
- - -
-
- -
- -
- -
-
- - - -
-
-
- - - -
-
- -
-
- -
-
 
-
- - - -
-
-
- - -
- - -
- - -
- -
-
- Thanks For Your Purchase! -
-
 
-
- Thank You for Your Support -
-
- -
-
- - -
-
-
- - -
-
-
- - -
-
-
- - -
-
-
- Hello ${purchaserName}, -
-
 
-
- Congratulations! You're now the proud owner of a new ${contentType} on Audius.

This isn't just a purchase. It's a show of support to an artist you love, and it goes a long way. You can now enjoy your newly purchased ${contentType} anytime from your Audius Library!
-
-
-
-
-
-
-
-
-
-
- -
- - -
-
-
- - -
-
- - -
-
- Transaction Summary -
-
-
-
-
-
- - -
-
- - - -
-
- - - -
-
-
- Premium ${capitalize( - contentType - )} -
-
-
- -
-
-
- - - -
-
-
- $${price} -
-
-
- -
-
-
-
-
- ${ - payExtra !== '0.00' - ? `
- - -
-
- - - -
-
- - - -
-
-
- Pay Extra -
-
-
- -
-
-
- - - -
-
-
- $${payExtra} -
-
-
- -
-
-
-
-
` - : '' - } -
- - -
-
- - - -
-
- - - -
-
-
- Total -
-
-
- -
-
-
- - - -
-
-
- - -
-
-
- $${total} -
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
- -
-
 
-
- - - -
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
-
-
-
-
-
- - -
-
-
- © 2024 Audius, Inc. All Rights Reserved. -
-
-
-
-
-
- -
-
-
- -
-
-
- - + + + + + + + + + + Thank you for your purchase! + + + + + + + + + + + + + +
+ + + + + +
+ + + +
‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ 
+ + + + + +
+
+ + + ` } diff --git a/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/sale.ts b/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/sale.ts index c5a4afced23..c3af4b7e2df 100644 --- a/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/sale.ts +++ b/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/sale.ts @@ -1,5 +1,3 @@ -import { capitalize } from 'lodash' - export const email = ({ purchaserName, purchaserLink, @@ -8,6 +6,9 @@ export const email = ({ contentLink, contentImage, artistName, + artistHandle, + artistImage, + artistLink, price, payExtra, total @@ -16,714 +17,940 @@ export const email = ({ purchaserLink: string contentType: string contentTitle: string + artistHandle: string + artistImage: string contentLink: string contentImage: string artistName: string + artistLink: string price: string payExtra: string total: string }) => { + const copyrightYear = new Date().getFullYear().toString() + return ` - - - - - - - - - - - - - -
- - -
-
- -
- -
- -
-
- - - -
-
-
- - - -
-
- -
-
- -
-
 
-
- - - -
-
-
- - -
- - -
- - -
- -
-
- Congratulations! -
-
 
-
- Your ${capitalize( - contentType - )} Has Been Purchased -
-
- -
-
- - -
-
-
- - -
-
-
- - -
-
-
- - -
-
-
- Hello ${artistName}, -
-
 
-
- Congratulations! ${purchaserName} just bought your ${contentType} on Audius! -
-
-
-
-
-
-
-
-
-
- -
- - -
-
-
- - -
-
- - -
-
- Transaction Summary -
-
-
-
-
-
- - -
-
- - - -
-
- - - -
-
-
- Premium ${capitalize( - contentType - )} -
-
-
- -
-
-
- - - -
-
-
- $${price} -
-
-
- -
-
-
-
-
- ${ - payExtra !== '0.00' - ? `
- - -
-
- - - -
-
- - - -
-
-
- Pay Extra -
-
-
- -
-
-
- - - -
-
-
- $${payExtra} -
-
-
- -
-
-
-
-
` - : '' - } -
- - -
-
- - - -
-
- - - -
-
-
- Total -
-
-
- -
-
-
- - - -
-
-
- - -
-
-
- $${total} -
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
- -
-
 
-
- - - -
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
-
-
-
-
-
- - -
-
-
- © 2024 Audius, Inc. All Rights Reserved. -
-
-
-
-
-
- -
-
-
- -
-
-
- - + + + + + + + + + + Congrats! You’ve made a sale on Audius! + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+
+ + ` } diff --git a/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/transfer.ts b/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/transfer.ts index 7aaeb16bd32..fc6e374579f 100644 --- a/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/transfer.ts +++ b/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/transfer.ts @@ -1,483 +1,733 @@ export const email = ({ name, + handle, + profilePicture, + profileLink, amount, wallet, signature }: { name: string + handle: string + profilePicture: string + profileLink: string amount: string wallet: string signature: string }) => { + const copyrightYear = new Date().getFullYear().toString() + return ` - - - - - - - - - - - - - -
- - -
-
- -
- -
- -
-
- - - -
-
-
- - - -
-
- -
-
- -
-
 
-
- - - -
-
-
- - -
- - -
- - -
- -
-
- Transfer Confirmation! -
-
 
-
- Your Transfer Has Been Started -
-
- -
-
- - -
-
-
- - -
-
-
- - -
-
-
- Hello ${name}, -
-
 
-
- We have successfully processed your Solana USD (USDC) transfer request. -
-
-
-
-
-
-
-
- - -
-
-
- - -
-
-
- Transfer Details -
-
 
-
- Transfer Amount: ${amount} USDC
Transfer To: ${wallet}
-
-
 
- - - - -
-
- View on Solana Explorer -
-
- -
-
-
-
-
-
 
-
- -
-
-
-
-
-
- -
-
 
-
- - - -
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
-
-
-
-
-
- - -
-
-
- © 2024 Audius, Inc. All Rights Reserved. -
-
-
-
-
-
- -
-
-
- -
-
-
- - + + + + + + + + + + Your USDC Transfer is Complete! + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+
+ + ` } diff --git a/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/withdrawal.ts b/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/withdrawal.ts index d6ccddc538a..109debb2839 100644 --- a/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/withdrawal.ts +++ b/packages/discovery-provider/plugins/notifications/src/email/notifications/preRendered/withdrawal.ts @@ -1,461 +1,720 @@ -export const email = ({ name, amount }: { name: string; amount: string }) => { +export const email = ({ + name, + handle, + profilePicture, + profileLink, + amount +}: { + name: string + handle: string + profilePicture: string + profileLink: string + amount: string +}) => { + const copyrightYear = new Date().getFullYear().toString() return ` - - - - - - - - - - - - - -
- - -
-
- -
- -
- -
-
- - - -
-
-
- - - -
-
- -
-
- -
-
 
-
- - - -
-
-
- - -
- - -
- - -
- -
-
- Transfer Confirmation! -
-
 
-
- Your Transfer Has Been Started -
-
- -
-
- - -
-
-
- - -
-
-
- - -
-
-
- Hello ${name}, -
-
 
-
- We have successfully processed your Solana USD (USDC) transfer request. -
-
-
-
-
-
-
-
- - -
-
-
- - -
-
-
- Transfer Details -
-
 
-
- Transfer Amount: ${amount} USDC
-
-
 
-
-
-
-
 
-
- -
-
-
-
-
-
- -
-
 
-
- - - -
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
-
-
-
-
-
- - -
-
- - -
-
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
- -
- - -
-
- - -
- -
-
-
-
-
-
-
-
-
- - -
-
-
- © 2024 Audius, Inc. All Rights Reserved. -
-
-
-
-
-
- -
-
-
- -
-
-
- - -` + + + + + + + + + + Your USDC Transfer is Complete! + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+
+ + + ` } diff --git a/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcPurchaseBuyer.ts b/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcPurchaseBuyer.ts index e2d4605af59..b468b7c09c9 100644 --- a/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcPurchaseBuyer.ts +++ b/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcPurchaseBuyer.ts @@ -19,7 +19,12 @@ import { disableDeviceArns } from '../../utils/disableArnEndpoint' import { capitalize } from 'lodash' import { sendBrowserNotification } from '../../web' import { EntityType } from '../../email/notifications/types' -import { formatUSDCWeiToUSDString } from '../../utils/format' +import { + formatContentUrl, + formatImageUrl, + formatProfileUrl, + formatUSDCWeiToUSDString +} from '../../utils/format' import { email } from '../../email/notifications/preRendered/purchase' import { logger } from '../../logger' import { getContentNode, getHostname } from '../../utils/env' @@ -35,6 +40,7 @@ export class USDCPurchaseBuyer extends BaseNotification { contentType: string extraAmount: string totalAmount: string + vendor: string constructor( dnDB: Knex, @@ -42,6 +48,7 @@ export class USDCPurchaseBuyer extends BaseNotification { notification: USDCPurchaseBuyerRow ) { super(dnDB, identityDB, notification) + logger.info(`asdf constructor`) this.amount = formatUSDCWeiToUSDString( this.notification.data.amount.toString() ) @@ -57,6 +64,7 @@ export class USDCPurchaseBuyer extends BaseNotification { this.notificationReceiverUserId = this.notification.data.buyer_user_id this.contentId = this.notification.data.content_id this.contentType = this.notification.data.content_type + this.vendor = this.notification.data.vendor } async processNotification({ @@ -111,6 +119,9 @@ export class USDCPurchaseBuyer extends BaseNotification { const sellerUsername = users[this.sellerUserId]?.name const sellerHandle = users[this.sellerUserId]?.handle const purchaserUsername = users[this.notificationReceiverUserId]?.name + const purchaserProfilePictureSizes = + users[this.notificationReceiverUserId]?.profile_picture_sizes + const purchaserHandle = users[this.notificationReceiverUserId]?.handle const title = 'Purchase Successful' const body = `You just purchased ${purchasedContentName} from ${capitalize( @@ -185,21 +196,27 @@ export class USDCPurchaseBuyer extends BaseNotification { identityDb: this.identityDB }) } - + logger.info(`asdf this ${this}`) await sendTransactionalEmail({ email: userNotificationSettings.getUserEmail( this.notificationReceiverUserId ), html: email({ purchaserName: purchaserUsername, + purchaserProfileImage: formatImageUrl( + purchaserProfilePictureSizes, + 150 + ), + purchaserHandle, + purchaserLink: formatProfileUrl(purchaserHandle), artistName: sellerUsername, - contentType: this.contentType, contentTitle: purchasedContentName, - contentLink: `${getHostname()}/${sellerHandle}/${slug}`, - contentImage: `${getContentNode()}/content/${cover_art_sizes}/480x480.jpg`, + contentLink: formatContentUrl(sellerHandle, slug), + contentImage: formatImageUrl(cover_art_sizes, 480), price: this.amount, payExtra: this.extraAmount, - total: this.totalAmount + total: this.totalAmount, + vendor: this.vendor }), subject: 'Thank You For Your Support' }) diff --git a/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcPurchaseSeller.ts b/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcPurchaseSeller.ts index 9adb9e86d40..2326cbb9296 100644 --- a/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcPurchaseSeller.ts +++ b/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcPurchaseSeller.ts @@ -19,10 +19,14 @@ import { disableDeviceArns } from '../../utils/disableArnEndpoint' import { capitalize } from 'lodash' import { sendBrowserNotification } from '../../web' import { EntityType } from '../../email/notifications/types' -import { formatUSDCWeiToUSDString } from '../../utils/format' +import { + formatContentUrl, + formatImageUrl, + formatProfileUrl, + formatUSDCWeiToUSDString +} from '../../utils/format' import { email } from '../../email/notifications/preRendered/sale' import { logger } from '../../logger' -import { getContentNode, getHostname } from '../../utils/env' type USDCPurchaseSellerRow = Omit & { data: USDCPurchaseSellerNotification @@ -124,6 +128,8 @@ export class USDCPurchaseSeller extends BaseNotification const buyerHandle = users[this.buyerUserId]?.handle const sellerUsername = users[this.notificationReceiverUserId]?.name const sellerHandle = users[this.notificationReceiverUserId]?.handle + const sellerProfilePictureSizes = + users[this.notificationReceiverUserId]?.profile_picture_sizes const price = this.totalAmount await sendBrowserNotification( @@ -206,12 +212,15 @@ export class USDCPurchaseSeller extends BaseNotification ), html: email({ purchaserName: buyerUsername, - purchaserLink: `${getHostname()}/${buyerHandle}`, + purchaserLink: formatProfileUrl(buyerHandle), artistName: sellerUsername, + artistHandle: sellerHandle, contentType: this.contentType, contentTitle: purchasedContentName, - contentLink: `${getHostname()}/${sellerHandle}/${slug}`, - contentImage: `${getContentNode()}/content/${cover_art_sizes}/480x480.jpg`, + contentLink: formatContentUrl(sellerHandle, slug), + contentImage: formatImageUrl(cover_art_sizes, 480), + artistImage: formatImageUrl(sellerProfilePictureSizes, 150), + artistLink: formatProfileUrl(sellerHandle), price: this.amount, payExtra: this.extraAmount, total: this.totalAmount diff --git a/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcTransfer.ts b/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcTransfer.ts index b2b602667da..68339828258 100644 --- a/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcTransfer.ts +++ b/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcTransfer.ts @@ -6,7 +6,11 @@ import { logger } from '../../logger' import { sendTransactionalEmail } from '../../email/notifications/sendEmail' import { buildUserNotificationSettings } from './userNotificationSettings' import { email } from '../../email/notifications/preRendered/transfer' -import { formatUSDCWeiToUSDString } from '../../utils/format' +import { + formatImageUrl, + formatProfileUrl, + formatUSDCWeiToUSDString +} from '../../utils/format' type USDCTransferRow = Omit & { data: USDCTransferNotification @@ -50,6 +54,9 @@ export class USDCTransfer extends BaseNotification { email: userNotificationSettings.getUserEmail(user.user_id), html: email({ name: user.name, + handle: user.handle, + profilePicture: formatImageUrl(user.profile_picture_sizes, 150), + profileLink: formatProfileUrl(user.handle), amount: this.amount, wallet: this.receiverAccount, signature: this.signature diff --git a/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcWithdrawal.ts b/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcWithdrawal.ts index 92757be60dc..1bff915975f 100644 --- a/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcWithdrawal.ts +++ b/packages/discovery-provider/plugins/notifications/src/processNotifications/mappers/usdcWithdrawal.ts @@ -6,7 +6,11 @@ import { logger } from './../../logger' import { sendTransactionalEmail } from '../../email/notifications/sendEmail' import { buildUserNotificationSettings } from './userNotificationSettings' import { email } from '../../email/notifications/preRendered/withdrawal' -import { formatUSDCWeiToUSDString } from '../../utils/format' +import { + formatImageUrl, + formatProfileUrl, + formatUSDCWeiToUSDString +} from '../../utils/format' type USDCWithdrawalRow = Omit & { data: USDCWithdrawalNotification @@ -50,6 +54,9 @@ export class USDCWithdrawal extends BaseNotification { email: userNotificationSettings.getUserEmail(user.user_id), html: email({ name: user.name, + handle: user.handle, + profilePicture: formatImageUrl(user.profile_picture_sizes, 150), + profileLink: formatProfileUrl(user.handle), amount: this.amount }), subject: 'Your Withdrawal Has Been Started' diff --git a/packages/discovery-provider/plugins/notifications/src/types/notifications.ts b/packages/discovery-provider/plugins/notifications/src/types/notifications.ts index 1b52bfa5a22..a4eb357995b 100644 --- a/packages/discovery-provider/plugins/notifications/src/types/notifications.ts +++ b/packages/discovery-provider/plugins/notifications/src/types/notifications.ts @@ -256,6 +256,7 @@ export type USDCPurchaseBuyerNotification = { amount: number extra_amount: number content_id: number + vendor: string } export type USDCPurchaseSellerNotification = { diff --git a/packages/discovery-provider/plugins/notifications/src/utils/format.ts b/packages/discovery-provider/plugins/notifications/src/utils/format.ts index cb99dc8186d..bd14bd50c39 100644 --- a/packages/discovery-provider/plugins/notifications/src/utils/format.ts +++ b/packages/discovery-provider/plugins/notifications/src/utils/format.ts @@ -1,4 +1,5 @@ import BN from 'bn.js' +import { getContentNode, getHostname } from './env' export const formatNumberCommas = (num) => { const parts = num.toString().split('.') @@ -76,3 +77,15 @@ export const getNumberSuffix = (num) => { else if (num === 3) return 'rd' return 'th' } + +export const formatImageUrl = (profilePictureSizes: string, size: number) => { + return `${getContentNode()}/content/${profilePictureSizes}/${size}x${size}.jpg` +} + +export const formatProfileUrl = (handle: string) => { + return `${getHostname()}/${handle}` +} + +export const formatContentUrl = (handle: string, slug: string) => { + return `${getHostname()}/${handle}/${slug}` +}