Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/types/node-22.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
flozia authored Feb 5, 2025
2 parents 25f82d9 + 5533a3c commit 5736110
Show file tree
Hide file tree
Showing 23 changed files with 301 additions and 58 deletions.
4 changes: 2 additions & 2 deletions config/nimbus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ features:
}
- channel: staging
value: {
"enabled": true,
"variant": redesign,
"enabled": false,
"variant": default,
}
- channel: production
value: {
Expand Down
12 changes: 12 additions & 0 deletions locales-pending/emails-all.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
email-footer-reason-subscriber = You’re receiving this automated email as a subscriber of { -brand-mozilla-monitor }. If you received it in error, no action is required. For more information, please visit <support-link>{ -brand-mozilla } Support</support-link>.
email-footer-reason-subscriber-one-time = You’ve received this one-time automated email because you are subscribed to { -brand-monitor-plus }. You won’t receive any further emails like this. For more information, please visit <support-link>{ -brand-mozilla } Support</support-link>.
# Variables:
# $support_link (string) - The URL the user can visit for support, e.g. "https://support.mozilla.org"
email-footer-support-content-plain = Visit our Support Center for help:
{ $support_link }
# Variables:
# $hibp_link (string) - URL to Have I Been Pwned, e.g. "https://haveibeenpwned.com".
email-footer-source-hibp-plain = Breach data provided by { -brand-HIBP }: { $hibp_link }
## Monthly overview email

email-monthly-free-subject = Your monthly { -brand-monitor } report
Expand Down Expand Up @@ -96,3 +104,7 @@ email-monthly-report-hero-free-no-breaches-heading = Great news!
email-monthly-report-hero-free-no-breaches-body = { -brand-monitor } didn’t find any data exposures to be resolved.
email-monthly-report-hero-free-no-breaches-cta = View your dashboard
email-unsubscribe-link = <link_to_unsub>Unsubscribe from this email</link_to_unsub> anytime.
# Variables:
# $unsub_link (string) - URL to the unsubscribe page, e.g. "https://monitor.mozilla.org/unsubscribe-email/...".
email-unsubscribe-link-plain = Unsubscribe from this email anytime:
{ $unsub_link }
7 changes: 7 additions & 0 deletions locales-pending/emails-plus.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ email-plus-expiration-body-part1 = Your { -brand-monitor-plus } subscription end
# Variables:
# $end_date (string) - The localised date the subscription will expire, e.g. "April 2, 1337".
email-plus-expiration-body-part2-styled = To keep your access, sign in and <renewal-link>renew your subscription</renewal-link> before <b>{ $end_date }</b>. If you need help, <support-link>contact our Support team</support-link>.
# Variables:
# $end_date (string) - The localised date the subscription will expire, e.g. "April 2, 1337".
# $renewal_link (string) - The URL the user can visit to renew their subscription, e.g. "https://monitor.mozilla.com/user/plus-expiration/"
email-plus-expiration-body-part2-plain = To keep your access, sign in and renew your subscription before { $end_date }: { $renewal_link }.
# Variables:
# $support_link (string) - The URL the user can visit to contact support, e.g. "https://support.mozilla.org/questions/new/monitor/form"
email-plus-expiration-body-part3-plain = If you need help, contact our Support team: { $support_link }.
# Variables:
# $end_date (string) - The localised date the subscription will expire, e.g. "April 2, 1337".
Expand Down
33 changes: 13 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,14 @@
"react-stately": "^3.35.0",
"react-toastify": "^11.0.2",
"server-only": "^0.0.1",
"sharp": "^0.33.5",
"uuid": "^11.0.5",
"winston": "^3.17.0"
},
"devDependencies": {
"@faker-js/faker": "^9.4.0",
"@google-cloud/bigquery": "^7.9.1",
"@playwright/test": "^1.50.0",
"@playwright/test": "^1.50.1",
"@storybook/addon-a11y": "^8.5.3",
"@storybook/addon-actions": "^8.5.3",
"@storybook/addon-essentials": "^8.5.3",
Expand Down
Binary file modified public/images/email/mozilla-logo-bw.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,37 @@ import {
deleteSubscriberChurns,
} from "../../../../../../db/tables/subscriber_churns";
import { SubscriberChurnRow } from "knex/types/tables";
import { getServerSession } from "../../../../../functions/server/getServerSession";
import { isAdmin } from "../../../../../api/utils/auth";

/**
* Helper function to perform session + admin check.
* Returns true if the current session belongs to an admin user.
*/
async function isAuthorized(): Promise<boolean> {
const session = await getServerSession();
return Boolean(session?.user?.email && isAdmin(session.user.email));
}

export async function getAllChurns() {
if (!(await isAuthorized())) {
return null;
}
return getAllSubscriberChurns();
}

export async function upsertAllChurns(
churningSubscribers: SubscriberChurnRow[],
) {
if (!(await isAuthorized())) {
return null;
}
return upsertSubscriberChurns(churningSubscribers);
}

export async function clearAllChurns() {
if (!(await isAuthorized())) {
return null;
}
return deleteSubscriberChurns();
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default async function DevPage() {

return (
<ChurnAdmin
churningSubscribers={await getAllChurns()}
churningSubscribers={(await getAllChurns()) ?? []}
churnsToEmail={await getChurnsToEmail()}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ import { isEligibleForPremium } from "../../../../../functions/universal/premium
import { MonthlyActivityFreeEmail } from "../../../../../../emails/templates/monthlyActivityFree/MonthlyActivityFreeEmail";
import { getMonthlyActivityFreeUnsubscribeLink } from "../../../../../../app/functions/cronjobs/unsubscribeLinks";
import { getScanResultsWithBroker } from "../../../../../../db/tables/onerep_scans";
import { UpcomingExpirationEmail } from "../../../../../../emails/templates/upcomingExpiration/UpcomingExpirationEmail";
import {
getUnstyledUpcomingExpirationEmail,
UpcomingExpirationEmail,
} from "../../../../../../emails/templates/upcomingExpiration/UpcomingExpirationEmail";
import { CONST_DAY_MILLISECONDS } from "../../../../../../constants";

async function getAdminSubscriber(): Promise<SubscriberRow | null> {
const session = await getServerSession();
Expand All @@ -66,6 +70,7 @@ async function send(
emailAddress: string,
subject: string,
template: ReactNode,
plaintextVersion?: string,
) {
const subscriber = await getAdminSubscriber();
if (!subscriber) {
Expand All @@ -85,6 +90,7 @@ async function send(
emailAddress,
"Test email: " + subject,
await renderEmail(template),
plaintextVersion,
);
}

Expand Down Expand Up @@ -301,8 +307,13 @@ export async function triggerPlusExpirationEmail(emailAddress: string) {
<UpcomingExpirationEmail
subscriber={sanitizeSubscriberRow(subscriber)}
// Always pretend that the user's account expires in 7 days for the test email:
expirationDate={new Date(Date.now() + 7 * 24 * 60 * 60 * 1000)}
expirationDate={new Date(Date.now() + 7 * CONST_DAY_MILLISECONDS)}
l10n={l10n}
/>,
getUnstyledUpcomingExpirationEmail({
subscriber: sanitizeSubscriberRow(subscriber),
expirationDate: new Date(Date.now() + 7 * CONST_DAY_MILLISECONDS),
l10n: l10n,
}),
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { logger } from "../../../../../functions/server/logging";
import { checkChurnCouponCode } from "../../../../../functions/server/applyCoupon";
import { applyRenewalCoupon } from "./actions";
import { getEnabledFeatureFlags } from "../../../../../../db/tables/featureFlags";
import { getChurnsToEmail } from "../../../../../../db/tables/subscriber_churns";
import { getUpcomingChurns } from "../../../../../../db/tables/subscriber_churns";

export default async function PlusExpirationPage() {
const session = await getServerSession();
Expand Down Expand Up @@ -41,7 +41,7 @@ export default async function PlusExpirationPage() {
}

const couponCheckResult = await checkChurnCouponCode(subscriber);
const subscribersToEmail = await getChurnsToEmail();
const expiringSubscriptions = await getUpcomingChurns();

return (
<View
Expand All @@ -50,9 +50,9 @@ export default async function PlusExpirationPage() {
applyCouponAction={applyRenewalCoupon}
manageSubscriptionsUrl={process.env.FXA_SUBSCRIPTIONS_URL!}
isOnExpirationList={
typeof subscribersToEmail.find(
(subscriberToEmail) =>
subscriberToEmail.userid === subscriber.fxa_uid,
typeof expiringSubscriptions.find(
(expiringSubscription) =>
expiringSubscription.userid === subscriber.fxa_uid,
) !== "undefined"
}
/>
Expand Down
9 changes: 2 additions & 7 deletions src/app/(proper_react)/images/mozilla-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5736110

Please sign in to comment.