Keep a published rule when some invitation emails already went out, and only set Reply-To when the inviter address is a mailbox.
This commit is contained in:
1 parent
3c984e00c5
commit
ab6a0c807d
7 files changed
+161
-10
No files matched your search
@@ -8,6 +8,28 @@ import {
|
||||
|
||||
export const RULE_STAKEHOLDER_INVITE_LOGO_PATH = getAssetPath(ASSETS.LOGO_MARK);
|
||||
|
||||
/** Letter name when neither the inviter nor the rule owner has an email. */
|
||||
export const RULE_STAKEHOLDER_INVITER_FALLBACK = "Someone from this community";
|
||||
|
||||
const MAILBOX_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
||||
|
||||
/** Reply-To only when the inviter value is a mailbox. */
|
||||
export function stakeholderInviteReplyTo(
|
||||
inviterEmail: string,
|
||||
): string | undefined {
|
||||
const mailbox = inviterEmail.trim().toLowerCase();
|
||||
if (!MAILBOX_PATTERN.test(mailbox)) return undefined;
|
||||
return mailbox;
|
||||
}
|
||||
|
||||
/** Email addresses stay lowercase; any other label is kept for the letter. */
|
||||
export function stakeholderInviteInviterLabel(inviterEmail: string): string {
|
||||
const replyTo = stakeholderInviteReplyTo(inviterEmail);
|
||||
if (replyTo) return replyTo;
|
||||
const trimmed = inviterEmail.trim();
|
||||
return trimmed.length > 0 ? trimmed : RULE_STAKEHOLDER_INVITER_FALLBACK;
|
||||
}
|
||||
|
||||
const PREVIEW_TEXT =
|
||||
"It covers how they talk, who belongs, how they decide and what happens when they disagree.";
|
||||
|
||||
@@ -44,7 +66,7 @@ export function buildRuleStakeholderInviteMail(
|
||||
input: RuleStakeholderInviteMailInput,
|
||||
): RuleStakeholderInviteMailContent {
|
||||
const communityName = input.communityName.trim() || "A community";
|
||||
const inviterEmail = input.inviterEmail.trim().toLowerCase();
|
||||
const inviterEmail = stakeholderInviteInviterLabel(input.inviterEmail);
|
||||
const origin = input.origin.replace(/\/$/, "");
|
||||
const verifyUrl = input.verifyUrl;
|
||||
const copyUrl = ruleStakeholderInviteCopyUrl(verifyUrl);
|
||||
|
||||
Reference in new issue
Block a user