diff --git a/packages/api-v4/.changeset/pr-10991-added-1727125536609.md b/packages/api-v4/.changeset/pr-10991-added-1727125536609.md new file mode 100644 index 00000000000..85aa3e7a23f --- /dev/null +++ b/packages/api-v4/.changeset/pr-10991-added-1727125536609.md @@ -0,0 +1,5 @@ +--- +"@linode/api-v4": Added +--- + +'SMTP Enabled' account & Linode capabilities ([#10991](https://github.com/linode/manager/pull/10991)) diff --git a/packages/api-v4/src/account/types.ts b/packages/api-v4/src/account/types.ts index 39211183930..1ba20f8260b 100644 --- a/packages/api-v4/src/account/types.ts +++ b/packages/api-v4/src/account/types.ts @@ -78,6 +78,7 @@ export type AccountCapability = | 'Object Storage Endpoint Types' | 'Object Storage' | 'Placement Group' + | 'SMTP Enabled' | 'Support Ticket Severity' | 'Vlans' | 'VPCs'; diff --git a/packages/api-v4/src/linodes/types.ts b/packages/api-v4/src/linodes/types.ts index aa74b71ac70..5a194836115 100644 --- a/packages/api-v4/src/linodes/types.ts +++ b/packages/api-v4/src/linodes/types.ts @@ -54,7 +54,7 @@ export interface LinodeBackups { last_successful: string | null; } -export type LinodeCapabilities = 'Block Storage Encryption'; +export type LinodeCapabilities = 'Block Storage Encryption' | 'SMTP Enabled'; export type Window = | 'Scheduling' diff --git a/packages/manager/.changeset/pr-10991-changed-1727125505081.md b/packages/manager/.changeset/pr-10991-changed-1727125505081.md new file mode 100644 index 00000000000..acce1f1ed60 --- /dev/null +++ b/packages/manager/.changeset/pr-10991-changed-1727125505081.md @@ -0,0 +1,5 @@ +--- +"@linode/manager": Changed +--- + +Hide SMTP warning for Linodes and accounts that have SMTP enabled ([#10991](https://github.com/linode/manager/pull/10991)) diff --git a/packages/manager/cypress/e2e/core/helpAndSupport/open-support-ticket.spec.ts b/packages/manager/cypress/e2e/core/helpAndSupport/open-support-ticket.spec.ts index 5644f5deea4..ec286a59281 100644 --- a/packages/manager/cypress/e2e/core/helpAndSupport/open-support-ticket.spec.ts +++ b/packages/manager/cypress/e2e/core/helpAndSupport/open-support-ticket.spec.ts @@ -42,7 +42,6 @@ import { import { createTestLinode } from 'support/util/linodes'; import { cleanUp } from 'support/util/cleanup'; import { authenticate } from 'support/api/authentication'; -import { MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED } from 'src/constants'; import { mockCreateLinodeAccountLimitError, mockGetLinodes, @@ -227,7 +226,6 @@ describe('open support tickets', () => { first_name: 'Jane', last_name: 'Doe', company: 'Acme Co.', - active_since: MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED, }); const mockFormFields = { diff --git a/packages/manager/src/constants.ts b/packages/manager/src/constants.ts index 99c1ee53599..b400343c46f 100644 --- a/packages/manager/src/constants.ts +++ b/packages/manager/src/constants.ts @@ -233,11 +233,6 @@ export const PAYMENT_HARD_MAX = 50_000; export const DB_ROOT_USERNAME = 'linroot'; -// "In an effort to fight spam, Linode restricts outbound connections on ports 25, 465, and 587 on all Linodes for new accounts created after November 5th, 2019." -// https://www.linode.com/docs/email/best-practices/running-a-mail-server/ -export const MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED = - '2022-11-30T00:00:00.000Z'; // Date of release for Manager v1.81.0. - // The date Linode switching to Akamai (for purposes of billing) export const AKAMAI_DATE = '2022-12-15 00:00:00'; diff --git a/packages/manager/src/features/Linodes/LinodesDetail/LinodesDetailNavigation.tsx b/packages/manager/src/features/Linodes/LinodesDetail/LinodesDetailNavigation.tsx index 0fff44b46ce..dccfa5c7e00 100644 --- a/packages/manager/src/features/Linodes/LinodesDetail/LinodesDetailNavigation.tsx +++ b/packages/manager/src/features/Linodes/LinodesDetail/LinodesDetailNavigation.tsx @@ -117,7 +117,10 @@ const LinodesDetailNavigation = () => { tabs[getIndex()]?.title ?? 'Detail View' }`} /> - + {({ text }) => text !== null ? ( ( {props.text} @@ -20,28 +18,10 @@ const props: SMTPRestrictionTextProps = { children: defaultChildren, }; -describe('accountCreatedAfterRestrictions', () => { - it('defaults to true with bad/no input', () => { - expect(accountCreatedAfterRestrictions()).toBe(true); - expect(accountCreatedAfterRestrictions('not a date!')).toBe(true); - }); - - it('only returns true when the account was created after the magic date', () => { - expect(accountCreatedAfterRestrictions('2022-11-27 00:00:00Z')).toBe(false); - expect(accountCreatedAfterRestrictions('2022-11-29 23:59:59Z')).toBe(false); - expect( - accountCreatedAfterRestrictions( - MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED - ) - ).toBe(true); - expect(accountCreatedAfterRestrictions('2022-11-30 00:00:01Z')).toBe(true); - }); -}); - describe('SMTPRestrictionText component', () => { - it('should render when user account is created on or after the magic date', async () => { + it('should not render for an account with the "SMTP Enabled" capability', async () => { const account = accountFactory.build({ - active_since: MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED, + capabilities: ['SMTP Enabled'], }); server.use( @@ -50,22 +30,24 @@ describe('SMTPRestrictionText component', () => { }) ); - const { findByText } = renderWithTheme( + const { queryByText } = renderWithTheme( ); - await findByText('SMTP ports may be restricted on this Linode.', { - exact: false, - }); + await waitFor(() => + expect( + queryByText('SMTP ports may be restricted on this Linode.', { + exact: false, + }) + ).toBeNull() + ); }); - it('should not render when user account is created before the magic date', async () => { - const account = accountFactory.build({ - active_since: '2022-11-27 00:00:00Z', - }); + it('should not render for a Linode with the "SMTP Enabled" capability', async () => { + const account = accountFactory.build(); server.use( http.get('*/account', () => { @@ -75,6 +57,7 @@ describe('SMTPRestrictionText component', () => { const { queryByText } = renderWithTheme( @@ -90,9 +73,7 @@ describe('SMTPRestrictionText component', () => { }); it('should default to not including a link to open a support ticket', () => { - const account = accountFactory.build({ - active_since: MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED, - }); + const account = accountFactory.build(); server.use( http.get('*/account', () => { @@ -108,9 +89,7 @@ describe('SMTPRestrictionText component', () => { }); it('should include a link to open a support ticket when the prop is provided', () => { - const account = accountFactory.build({ - active_since: MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED, - }); + const account = accountFactory.build(); server.use( http.get('*/account', () => { diff --git a/packages/manager/src/features/Linodes/SMTPRestrictionText.tsx b/packages/manager/src/features/Linodes/SMTPRestrictionText.tsx index 968aec807a3..23ff57d2be9 100644 --- a/packages/manager/src/features/Linodes/SMTPRestrictionText.tsx +++ b/packages/manager/src/features/Linodes/SMTPRestrictionText.tsx @@ -3,12 +3,14 @@ import * as React from 'react'; import { Link } from 'src/components/Link'; import { SupportLink } from 'src/components/SupportLink'; import { Typography } from 'src/components/Typography'; -import { MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED } from 'src/constants'; import { useAccount } from 'src/queries/account/account'; import { sendLinodeCreateDocsEvent } from 'src/utilities/analytics/customEventAnalytics'; +import type { Linode } from '@linode/api-v4'; + export interface SMTPRestrictionTextProps { children: (props: { text: React.ReactNode }) => React.ReactNode; + linode?: Linode; supportLink?: { id: number; label: string; @@ -16,14 +18,17 @@ export interface SMTPRestrictionTextProps { } export const SMTPRestrictionText = (props: SMTPRestrictionTextProps) => { - const { supportLink } = props; + const { linode, supportLink } = props; const { data: account } = useAccount(); + const displayRestrictionText = + linode === undefined + ? !account?.capabilities.includes('SMTP Enabled') + : !linode.capabilities?.includes('SMTP Enabled'); + // If there account was created before restrictions were put into place, // there's no need to display anything. - const text = !accountCreatedAfterRestrictions( - account?.active_since - ) ? null : ( + const text = displayRestrictionText ? ( SMTP ports may be restricted on this Linode. Need to send email? Review our{' '} @@ -46,26 +51,7 @@ export const SMTPRestrictionText = (props: SMTPRestrictionTextProps) => { )} . - ); - - // eslint-disable-next-line - return <>{props.children({ text })}; -}; - -export const accountCreatedAfterRestrictions = (_accountCreated?: string) => { - // Default to `true` for bad input. - if (!_accountCreated) { - return true; - } - - const restrictionsImplemented = new Date( - MAGIC_DATE_THAT_EMAIL_RESTRICTIONS_WERE_IMPLEMENTED - ).getTime(); - const accountCreated = new Date(_accountCreated).getTime(); - - if (isNaN(accountCreated)) { - return true; - } + ) : null; - return accountCreated >= restrictionsImplemented; + return props.children({ text }); };