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

chore: Transactional emails to React email #2349

Merged
merged 37 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
97831a2
moved emails to react emails
Dhruwang Mar 27, 2024
a2add42
merged main
Dhruwang Mar 27, 2024
700bf36
tweaks
Dhruwang Mar 27, 2024
2d799dc
fix: weekly
Dhruwang Mar 27, 2024
d55d10a
code improvements
Dhruwang Mar 28, 2024
f968d57
Merge branch 'main' of https://github.com/Dhruwang/formbricks into re…
Dhruwang Mar 28, 2024
9ce581a
file upload response email fixes
Dhruwang Mar 28, 2024
8b1316e
fix: warnings
Dhruwang Mar 28, 2024
0584933
revreted onboarding change
Dhruwang Mar 28, 2024
397a022
fix: build errors
Dhruwang Mar 28, 2024
bd8b1e5
merged main
Dhruwang Apr 9, 2024
19be962
Merge branch 'main' of https://github.com/formbricks/formbricks into …
gupta-piyush19 Apr 10, 2024
ed710f7
fix link and forget -> forgot
gupta-piyush19 Apr 10, 2024
2301115
Merge branch 'main' of https://github.com/formbricks/formbricks into …
gupta-piyush19 Apr 10, 2024
9001e94
Merge branch 'main' of https://github.com/Dhruwang/formbricks into re…
Dhruwang Apr 11, 2024
6e8062b
fix: question responsing display and tweaks
Dhruwang Apr 11, 2024
ab053ca
Merge branch 'main' into react-email
Dhruwang Apr 11, 2024
898f794
fix: variable naming
Dhruwang Apr 11, 2024
81fd0d0
Merge branch 'react-email' of https://github.com/formbricks/formbrick…
Dhruwang Apr 11, 2024
d13b955
added email package
Dhruwang Apr 11, 2024
347a136
Merge branch 'main' of https://github.com/Dhruwang/formbricks into re…
Dhruwang Apr 12, 2024
17969ef
cleanups and structural changes
Dhruwang Apr 12, 2024
23e7c95
fix: build
Dhruwang Apr 12, 2024
9132166
Merge branch 'main' into react-email
Dhruwang Apr 17, 2024
b856ad0
Merge branch 'main' of https://github.com/Dhruwang/formbricks into re…
Dhruwang Apr 23, 2024
bad78c0
Merge branch 'react-email' of https://github.com/formbricks/formbrick…
Dhruwang Apr 23, 2024
a05fbe3
Merge branch 'main' of https://github.com/Dhruwang/formbricks into re…
Dhruwang Apr 23, 2024
27b8d04
embed email fixes
Dhruwang Apr 23, 2024
a3018b1
solve conflict
mattinannt Apr 24, 2024
3961a92
rename types for code consistency
mattinannt Apr 24, 2024
22e9b16
Merge branch 'main' of https://github.com/formbricks/formbricks into …
Dhruwang Apr 25, 2024
6c12ecc
updated pnpm-lock
Dhruwang Apr 25, 2024
6df81b5
Merge branch 'react-email' of https://github.com/formbricks/formbrick…
Dhruwang Apr 25, 2024
60b0e89
fix: pnpm-lock
Dhruwang Apr 25, 2024
39d8036
Merge branch 'main' into react-email
mattinannt Apr 25, 2024
951c2e1
Merge branch 'main' of https://github.com/Dhruwang/formbricks into re…
Dhruwang Apr 25, 2024
a051cbf
Merge branch 'react-email' of https://github.com/formbricks/formbrick…
Dhruwang Apr 25, 2024
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 @@ -2,6 +2,7 @@

import { getServerSession } from "next-auth";

import { sendInviteMemberEmail } from "@formbricks/email";
import { hasTeamAuthority } from "@formbricks/lib/auth";
import { authOptions } from "@formbricks/lib/authOptions";
import { INVITE_DISABLED } from "@formbricks/lib/constants";
Expand Down Expand Up @@ -109,8 +110,36 @@ export const createInviteTokenAction = async (inviteId: string) => {
return { inviteToken: encodeURIComponent(inviteToken) };
};

export const resendInviteAction = async (inviteId: string) => {
return await resendInvite(inviteId);
export const resendInviteAction = async (inviteId: string, teamId: string) => {
const session = await getServerSession(authOptions);

if (!session) {
throw new AuthenticationError("Not authenticated");
}

const isUserAuthorized = await hasTeamAuthority(session.user.id, teamId);

if (INVITE_DISABLED) {
throw new AuthenticationError("Invite disabled");
}

if (!isUserAuthorized) {
throw new AuthenticationError("Not authorized");
}

const { hasCreateOrUpdateMembersAccess } = await verifyUserRoleAccess(teamId, session.user.id);
if (!hasCreateOrUpdateMembersAccess) {
throw new AuthenticationError("Not authorized");
}
const invite = await getInvite(inviteId);

const updatedInvite = await resendInvite(inviteId);
await sendInviteMemberEmail(
inviteId,
updatedInvite.email,
invite?.creator.name ?? "",
updatedInvite.name ?? ""
);
};

export const inviteUserAction = async (
Expand Down Expand Up @@ -150,6 +179,10 @@ export const inviteUserAction = async (
},
});

if (invite) {
await sendInviteMemberEmail(invite.id, email, session.user.name ?? "", name ?? "", false);
}

return invite;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default function MemberActions({ team, member, invite, showDeleteButton }
try {
if (!invite) return;

await resendInviteAction(invite.id);
await resendInviteAction(invite.id, team.id);
toast.success("Invitation sent once more.");
} catch (err) {
toast.error(`Error: ${err.message}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { getEmailTemplateHtml } from "@/app/(app)/environments/[environmentId]/s
import { customAlphabet } from "nanoid";
import { getServerSession } from "next-auth";

import { sendEmbedSurveyPreviewEmail } from "@formbricks/email";
import { authOptions } from "@formbricks/lib/authOptions";
import { sendEmbedSurveyPreviewEmail } from "@formbricks/lib/emails/emails";
import { canUserAccessSurvey } from "@formbricks/lib/survey/auth";
import { getSurvey, updateSurvey } from "@formbricks/lib/survey/service";
import { formatSurveyDateFields } from "@formbricks/lib/survey/util";
Expand Down
Loading
Loading