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

🔨 Fix the notification template #234

Merged
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 4 additions & 3 deletions scripts/generate-emails.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ const mjml2html = require('mjml')
const { compile } = require('handlebars')

const ghRaw = 'https://raw.githubusercontent.com/Joystream'
const gleevLogos = `${ghRaw}/atlas-notification-assets/main/logos/gleev`
const gleevRoot = 'https://atlas-git-fork-thesan-feature-orion-notifications-joystream.vercel.app'
const emailAssets = 'https://eu-central-1.linodeobjects.com/atlas-assets/email'
const gleevLogos = `${emailAssets}/logos/gleev`
const gleevRoot = 'https://atlas-git-notifications-joystream.vercel.app'
const contexts = {
gleev: {
title: 'Hi alice,',
Expand All @@ -29,7 +30,7 @@ const contexts = {
link: `${gleevRoot}/video/1?commentId=METAPROTOCOL-OLYMPIA-3882-2`,
date: '07 Jul 2023 at 10:41',
avatar: `${ghRaw}/founding-members/main/avatars/primary-avatar/1.png`,
icon: `${ghRaw}/atlas-notification-assets/main/icons/follow.png`,
icon: `${emailAssets}/icons/follow.png`,
iconColor: '#5A58FF',
},
},
Expand Down
36 changes: 23 additions & 13 deletions src/auth-server/emails/templates/mjml/notification.html.mst.mjml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<mjml>
<mj-head>
<mj-font
name="IBM Plex Sans"
href="https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600"
/>
<mj-attributes>
<mj-all
font-family="sans"
font-family="'IBM Plex Sans', sans-serif"
font-size="12px"
line-height="16px"
color="#000000"
Expand All @@ -19,16 +23,16 @@
font-size="14px"
inner-padding="0 10px"
font-weight="600"
color="#FFFFFF"
color="#000000"
padding="0"
/>
</mj-attributes>
</mj-head>

<mj-body background-color="#DAE2EB">
<mj-body>
<!-- Header -->
<mj-section padding="24px 0 0">
<mj-column background-color="#4038FF">
<mj-column>
<mj-image
src="{{ app.logo }}"
alt="{{ app.name }}"
Expand All @@ -44,7 +48,7 @@
<!-- Greeting -->
<mj-section padding="0">
<mj-column>
<mj-text mj-class="bold" padding="0" font-size="18px" line-height="24px">
<mj-text mj-class="bold" padding="0" font-size="24px" line-height="24px">
{{ title }}
</mj-text>
<mj-text mj-class="big" padding="8px 0 24px 0">{{ subTitle }}</mj-text>
Expand All @@ -71,14 +75,20 @@

<!-- Text -->
<mj-column vertical-align="middle" width="90%">
<mj-button mj-class="link" href="{{ notification.link }}" padding="0 0 0 20px">
<mj-button
mj-class="link"
href="{{ notification.link }}"
padding="0 0 0 20px"
font-weight="500"
>
{{ notification.text }}
</mj-button>
<mj-button
mj-class="link"
href="{{ notification.link }}"
padding="4px 0 0 20px"
color="#52616B"
font-weight="500"
>
{{ notification.date }}
</mj-button>
Expand Down Expand Up @@ -106,19 +116,19 @@

<!-- Footer -->
<mj-section padding="0">
<mj-column background-color="#000000">
<mj-column background-color="#DAE2EB">
<mj-image
src="{{ app.logoAlt }}"
alt="{{ app.name }}"
width="96px"
height="88px"
padding="0px"
width="35px"
height="30px"
padding="24px 0 10px"
></mj-image>
</mj-column>
</mj-section>

<mj-section padding="0">
<mj-group background-color="#000000">
<mj-group background-color="#DAE2EB">
<mj-column>
<mj-button
mj-class="link footer-link"
Expand All @@ -138,8 +148,8 @@
</mj-section>

<mj-section padding="0 0 24px">
<mj-column background-color="#000000" padding="16px 16px 24px">
<mj-text color="#FFFFFF" align="center" padding="0">
<mj-column background-color="#DAE2EB" padding="16px 16px 24px">
<mj-text color="#343D44" align="center" padding="0">
You can
<a href="{{ app.unsubscribeLink }}" target="_blank" style="color: currentColor">
unsubscribe
Expand Down
7 changes: 4 additions & 3 deletions src/mail-scheduler/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export async function executeMailDelivery(
const resp = await sendGridSend({
from: await config.get(ConfigVariable.SendgridFromEmail, em),
to: toAccount.email,
subject: `New notification from ${appName}!`,
subject: `New notification from ${appName}`,
content,
})
const className = Object.prototype.toString.call(resp)
Expand Down Expand Up @@ -56,15 +56,16 @@ export async function createMailContent(
const name = appKey === 'viewer' ? appName : 'Studio'

const appAssetStorage = await config.get(ConfigVariable.AppAssetStorage, em)
const logosAssetsRoot = `${appAssetStorage}/logos/${appName.toLowerCase()}`
const appNameAlt = await config.get(ConfigVariable.AppNameAlt, em)

const content = notificationEmailContent({
...(await getMessage(em, notification)),
app: {
name,
nameAlt: appNameAlt,
logo: `${appAssetStorage}/header-${appKey}.png`,
logoAlt: `${appAssetStorage}/footer.png`,
logo: `${logosAssetsRoot}/header-${appKey}.png`,
logoAlt: `${logosAssetsRoot}/footer.png`,
homeLink: appRoot,
notificationLink,
unsubscribeLink,
Expand Down
9 changes: 5 additions & 4 deletions src/utils/notification/notificationAvatars.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { EntityManager } from 'typeorm'
import { Channel, MemberMetadata } from '../../model'

const PLACEHOLDER = 'https://example.com/avatar.png'
import { ConfigVariable, config } from '../config'

export const getNotificationAvatar = async (
em: EntityManager,
Expand All @@ -13,7 +12,8 @@ export const getNotificationAvatar = async (
const avatar = channel?.avatarPhoto

if (!avatar || !avatar.isAccepted || !avatar.resolvedUrls[0]) {
return PLACEHOLDER
const notificationAssetRoot = await config.get(ConfigVariable.AppAssetStorage, em)
return `${notificationAssetRoot}/placeholder/avatar.png`
}

return avatar.resolvedUrls[0]
Expand All @@ -24,7 +24,8 @@ export const getNotificationAvatar = async (

// AvatarObject is not yet supported
if (!avatar || avatar.isTypeOf === 'AvatarObject') {
return PLACEHOLDER
const notificationAssetRoot = await config.get(ConfigVariable.AppAssetStorage, em)
return `${notificationAssetRoot}/placeholder/avatar.png`
}

return avatar.avatarUri
Expand Down
4 changes: 2 additions & 2 deletions src/utils/notification/notificationIcons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ export const getNotificationIcon = async (
em: EntityManager,
icon: NotificationIconType
): Promise<string> => {
const notificationAssetRoot = await config.get(ConfigVariable.AppRootDomain, em)
return `${notificationAssetRoot}/${icon}.png`
const notificationAssetRoot = await config.get(ConfigVariable.AppAssetStorage, em)
return `${notificationAssetRoot}/icons/${icon}.png`
}
Loading