Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C-4453] Fix notification email image and layout #8647

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,6 @@ export const BodyStyles = () => {
}
}

@media (max-width: 720px) {
#bodyCell {
text-align: center;
}
}

@media (max-width: 720px) {
.templateContainer {
display: table !important;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Knex } from 'knex'
import { mapNotifications } from '../../processNotifications/mappers/mapNotifications'
import { BaseNotification } from '../../processNotifications/mappers/base'
import { EmailFrequency } from '../../processNotifications/mappers/userNotificationSettings'
import { getContentNode } from '../../utils/env'

type RenderEmailProps = {
userId: number
Expand Down Expand Up @@ -86,16 +87,12 @@ const DEFAULT_TRACK_COVER_ART_URL = ''
const DEFAULT_PLAYLIST_IMAGE_IRL = ''

const getUserProfileUrl = (user: UserResource) => {
if (!user.creator_node_endpoint) {
return null
}
const contentNodes = user.creator_node_endpoint.split(',')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

big yikes. nice. can you check if user has .cover_photo and .profile_picture ? if they are coming from our api they should just full content-node urls

Copy link
Contributor Author

@isaacsolo isaacsolo May 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't think we have those, it's coming straight from the discovery DB

const userRows: UserResource[] = await dnDb
.select(
'users.user_id',
'users.handle',
'users.name',
'users.profile_picture_sizes',
'users.profile_picture',
'users.creator_node_endpoint'
)
.from('users')
.whereIn('user_id', Array.from(ids.users))
.andWhere('is_current', true)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah word, yup this good then :)

const primaryEndpoint = contentNodes[0]
let profilePictureUrl = DEFAULT_PROFILE_IMG
const contentNode = getContentNode()
if (user.profile_picture_sizes) {
profilePictureUrl = `${primaryEndpoint}/ipfs/${user.profile_picture_sizes}/1000x1000.jpg`
profilePictureUrl = `${contentNode}/content/${user.profile_picture_sizes}/1000x1000.jpg`
} else if (user.profile_picture) {
profilePictureUrl = `${primaryEndpoint}/ipfs/${user.profile_picture}`
profilePictureUrl = `${contentNode}/content/${user.profile_picture}`
}
return profilePictureUrl
}
Expand Down Expand Up @@ -252,7 +249,7 @@ const getNotificationProps = async (
for (const notification of mappedNotifications) {
const resourcesToFetch = notification.getResourcesForEmail()
Object.entries(resourcesToFetch).forEach(([key, value]) => {
; (value as Set<number>).forEach(
;(value as Set<number>).forEach(
idsToFetch[key as keyof ResourceIds].add,
idsToFetch[key as keyof ResourceIds]
)
Expand All @@ -266,7 +263,7 @@ const getNotificationProps = async (
for (const notification of acc[n]) {
const resourcesToFetch = notification.getResourcesForEmail()
Object.entries(resourcesToFetch).forEach(([key, value]) => {
; (value as Set<number>).forEach(
;(value as Set<number>).forEach(
idsToFetch[key as keyof ResourceIds].add,
idsToFetch[key as keyof ResourceIds]
)
Expand Down Expand Up @@ -310,12 +307,15 @@ const getEmailSubject = (
// they receive the email.
const formattedDayAgo = now.format('MMMM Do YYYY')
const shortWeekAgoFormat = weekAgo.format('MMMM Do')
const liveSubjectFormat = `${notificationCount} unread notification${notificationCount > 1 ? 's' : ''
}`
const weeklySubjectFormat = `${notificationCount} unread notification${notificationCount > 1 ? 's' : ''
} from ${shortWeekAgoFormat} - ${formattedDayAgo}`
const dailySubjectFormat = `${notificationCount} unread notification${notificationCount > 1 ? 's' : ''
} from ${formattedDayAgo}`
const liveSubjectFormat = `${notificationCount} unread notification${
notificationCount > 1 ? 's' : ''
}`
const weeklySubjectFormat = `${notificationCount} unread notification${
notificationCount > 1 ? 's' : ''
} from ${shortWeekAgoFormat} - ${formattedDayAgo}`
const dailySubjectFormat = `${notificationCount} unread notification${
notificationCount > 1 ? 's' : ''
} from ${formattedDayAgo}`

let subject
if (frequency === 'live') {
Expand Down