Skip to content

Commit 5142e5f

Browse files
authored
fix-ENG-72 (#596)
1 parent 022a047 commit 5142e5f

File tree

4 files changed

+19
-15
lines changed

4 files changed

+19
-15
lines changed

apps/platform/trpc/routers/orgRouter/setup/profileRouter.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { eq } from '@u22n/database/orm';
44
import { orgs } from '@u22n/database/schema';
55
import { typeIdValidator } from '@u22n/utils/typeid';
66
import { TRPCError } from '@trpc/server';
7+
import { refreshOrgShortcodeCache } from '~platform/utils/orgShortcode';
78

89
export const orgProfileRouter = router({
910
getOrgProfile: orgProcedure
@@ -68,6 +69,8 @@ export const orgProfileRouter = router({
6869
})
6970
.where(eq(orgs.id, orgId));
7071

72+
await refreshOrgShortcodeCache(orgId);
73+
7174
return {
7275
success: true
7376
};

apps/platform/trpc/routers/orgRouter/users/invitesRouter.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import {
1616
orgInvitations,
1717
orgMembers,
1818
orgMemberProfiles,
19-
accounts
19+
accounts,
20+
orgs
2021
} from '@u22n/database/schema';
2122
import { typeIdGenerator, typeIdValidator } from '@u22n/utils/typeid';
2223
import { nanoIdToken, zodSchemas } from '@u22n/utils/zodSchemas';
@@ -194,11 +195,11 @@ export const invitesRouter = router({
194195
const res = await sendInviteEmail({
195196
to: notification?.notificationEmailAddress || '',
196197
invitedName: `${newOrgMember.firstName} ${newOrgMember.lastName || ''}`,
197-
invitingOrg: org.name,
198+
invitingOrgName: org.name,
198199
expiryDate: new Date(
199200
Date.now() + 7 * 24 * 60 * 60 * 1000
200201
).toDateString(),
201-
inviteUrl: `https://app.uninbox.com/join/invite/${newInviteToken}`
202+
inviteUrl: `https://${env.WEBAPP_URL}/join/invite/${newInviteToken}`
202203
});
203204

204205
if (!res) {

apps/platform/utils/mail/inviteTemplate.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
export interface InviteEmailProps {
55
to: string;
66
invitedName: string;
7-
invitingOrg: string;
7+
invitingOrgName: string;
88
inviteUrl: string;
99
expiryDate: string;
1010
}
@@ -14,13 +14,13 @@ export const inviteTemplatePlainText = ({
1414
expiryDate,
1515
inviteUrl,
1616
invitedName,
17-
invitingOrg
17+
invitingOrgName
1818
}: InviteEmailProps) =>
1919
`Hello ${invitedName},
2020
21-
You have been invited to join ${invitingOrg} on Uninbox.
21+
You have been invited to join ${invitingOrgName} on Uninbox.
2222
23-
Join ${invitingOrg} at ${inviteUrl}
23+
Join ${invitingOrgName} at ${inviteUrl}
2424
2525
If the button is not working, copy paste this link in your browser:
2626
${inviteUrl}
@@ -40,15 +40,15 @@ export const inviteTemplate = ({
4040
expiryDate,
4141
inviteUrl,
4242
invitedName,
43-
invitingOrg
43+
invitingOrgName
4444
}: InviteEmailProps) =>
4545
`<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4646
<html dir="ltr" lang="en">
4747
4848
<head>
4949
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
5050
</head>
51-
<div style="display:none;overflow:hidden;line-height:1px;opacity:0;max-height:0;max-width:0">You got an invite to join ${invitingOrg} on Uninbox<div> ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏</div>
51+
<div style="display:none;overflow:hidden;line-height:1px;opacity:0;max-height:0;max-width:0">You got an invite to join ${invitingOrgName} on Uninbox<div> ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏ ‌​‍‎‏</div>
5252
</div>
5353
5454
<body style="margin-left:auto;margin-right:auto;margin-top:auto;margin-bottom:auto;background-color:rgb(255,255,255);padding-left:0.5rem;padding-right:0.5rem;font-family:ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, &quot;Segoe UI&quot;, Roboto, &quot;Helvetica Neue&quot;, Arial, &quot;Noto Sans&quot;, sans-serif, &quot;Apple Color Emoji&quot;, &quot;Segoe UI Emoji&quot;, &quot;Segoe UI Symbol&quot;, &quot;Noto Color Emoji&quot;">
@@ -64,11 +64,11 @@ export const inviteTemplate = ({
6464
</tbody>
6565
</table>
6666
<p style="font-size:14px;line-height:12px;margin:16px 0;margin-top:2.5rem;color:rgb(0,0,0)">Hello <strong>${invitedName}</strong>,</p>
67-
<p style="font-size:14px;line-height:12px;margin:16px 0;color:rgb(0,0,0)">You have been invited to join <strong>${invitingOrg}</strong> on Uninbox.</p>
67+
<p style="font-size:14px;line-height:12px;margin:16px 0;color:rgb(0,0,0)">You have been invited to join <strong>${invitingOrgName}</strong> on Uninbox.</p>
6868
<table align="center" width="100%" border="0" cellPadding="0" cellSpacing="0" role="presentation" style="margin-bottom:32px;margin-top:32px;text-align:center">
6969
<tbody>
7070
<tr>
71-
<td><a href="${inviteUrl}" style="line-height:100%;text-decoration:none;display:inline-block;max-width:100%;border-radius:0.25rem;background-color:rgb(0,0,0);padding-left:1.25rem;padding-right:1.25rem;padding-top:0.75rem;padding-bottom:0.75rem;text-align:center;font-size:12px;font-weight:600;color:rgb(255,255,255);text-decoration-line:none;padding:12px 20px 12px 20px" target="_blank"><span><!--[if mso]><i style="letter-spacing: 20px;mso-font-width:-100%;mso-text-raise:18" hidden>&nbsp;</i><![endif]--></span><span style="max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:9px">Join <!-- -->${invitingOrg}</span><span><!--[if mso]><i style="letter-spacing: 20px;mso-font-width:-100%" hidden>&nbsp;</i><![endif]--></span></a></td>
71+
<td><a href="${inviteUrl}" style="line-height:100%;text-decoration:none;display:inline-block;max-width:100%;border-radius:0.25rem;background-color:rgb(0,0,0);padding-left:1.25rem;padding-right:1.25rem;padding-top:0.75rem;padding-bottom:0.75rem;text-align:center;font-size:12px;font-weight:600;color:rgb(255,255,255);text-decoration-line:none;padding:12px 20px 12px 20px" target="_blank"><span><!--[if mso]><i style="letter-spacing: 20px;mso-font-width:-100%;mso-text-raise:18" hidden>&nbsp;</i><![endif]--></span><span style="max-width:100%;display:inline-block;line-height:120%;mso-padding-alt:0px;mso-text-raise:9px">Join <!-- -->${invitingOrgName}</span><span><!--[if mso]><i style="letter-spacing: 20px;mso-font-width:-100%" hidden>&nbsp;</i><![endif]--></span></a></td>
7272
</tr>
7373
</tbody>
7474
</table>

apps/platform/utils/mail/transactional.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type PostalResponse =
3030
};
3131

3232
export async function sendInviteEmail({
33-
invitingOrg,
33+
invitingOrgName,
3434
to,
3535
invitedName,
3636
expiryDate,
@@ -50,19 +50,19 @@ export async function sendInviteEmail({
5050
cc: [],
5151
from: `${config.sendAsName} <${config.sendAsEmail}>`,
5252
sender: config.sendAsEmail,
53-
subject: `You have been invited to join ${invitingOrg} on Uninbox`,
53+
subject: `You have been invited to join ${invitingOrgName} on Uninbox`,
5454
plain_body: inviteTemplatePlainText({
5555
expiryDate,
5656
invitedName,
5757
inviteUrl,
58-
invitingOrg,
58+
invitingOrgName: invitingOrgName,
5959
to
6060
}),
6161
html_body: inviteTemplate({
6262
expiryDate,
6363
invitedName,
6464
inviteUrl,
65-
invitingOrg,
65+
invitingOrgName: invitingOrgName,
6666
to
6767
}),
6868
attachments: [],

0 commit comments

Comments
 (0)