diff --git a/libs/gql-schema/messaging-service.ts b/libs/gql-schema/messaging-service.ts index 049c93a8f..494492b74 100644 --- a/libs/gql-schema/messaging-service.ts +++ b/libs/gql-schema/messaging-service.ts @@ -9,7 +9,6 @@ export const schema = ` messagingServiceSid: String! serviceType: MessagingServiceType! updatedAt: String! - tcrBrandRegistrationLink: String name: String active: Boolean! isDefault: Boolean diff --git a/libs/gql-schema/notice.ts b/libs/gql-schema/notice.ts index 7c1c8c1ac..426eb8fe6 100644 --- a/libs/gql-schema/notice.ts +++ b/libs/gql-schema/notice.ts @@ -1,35 +1,4 @@ export const schema = ` - interface Register10DlcNotice { - id: ID! - tcrRegistrationUrl: String - } - - type Register10DlcBrandNotice implements Register10DlcNotice { - id: ID! - tcrRegistrationUrl: String - } - - type Register10DlcCampaignNotice implements Register10DlcNotice { - id: ID! - tcrRegistrationUrl: String - } - - type Pending10DlcCampaignNotice { - id: ID! - } - - interface PricingNotice { - id: ID! - } - - type Pricing10DlcNotice implements PricingNotice { - id: ID! - } - - type PricingTollFreeNotice implements PricingNotice { - id: ID! - } - type TitleContentNotice { id: ID! title: String! @@ -38,7 +7,7 @@ export const schema = ` markdownContent: String! } - union Notice = Register10DlcBrandNotice | Register10DlcCampaignNotice | Pending10DlcCampaignNotice | Pricing10DlcNotice | PricingTollFreeNotice | TitleContentNotice + union Notice = TitleContentNotice type NoticeEdge { cursor: Cursor! diff --git a/libs/spoke-codegen/src/graphql/notifications.graphql b/libs/spoke-codegen/src/graphql/notifications.graphql index 049b764f5..d2842969a 100644 --- a/libs/spoke-codegen/src/graphql/notifications.graphql +++ b/libs/spoke-codegen/src/graphql/notifications.graphql @@ -12,23 +12,6 @@ query getOrganizationNotifications($organizationId: String!) { avatarColor markdownContent } - ... on Register10DlcBrandNotice { - id - tcrRegistrationUrl - } - ... on Register10DlcCampaignNotice { - id - tcrRegistrationUrl - } - ... on Pending10DlcCampaignNotice { - id - } - ... on Pricing10DlcNotice { - id - } - ... on PricingTollFreeNotice { - id - } } } } diff --git a/src/api/notice.ts b/src/api/notice.ts index 20f0f3e66..03275fb4c 100644 --- a/src/api/notice.ts +++ b/src/api/notice.ts @@ -1,60 +1,10 @@ -import type { - Notice, - Pending10DlcCampaignNotice, - Pricing10DlcNotice, - PricingTollFreeNotice, - Register10DlcBrandNotice, - Register10DlcCampaignNotice, - TitleContentNotice -} from "@spoke/spoke-codegen"; +import type { Notice, TitleContentNotice } from "@spoke/spoke-codegen"; import type { GraphQLType } from "graphql"; +// eslint-disable-next-line import/prefer-default-export export function isTitleContentNotice(obj: Notice): obj is TitleContentNotice { return ( (obj as TitleContentNotice & GraphQLType).__typename === "TitleContentNotice" ); } - -export function isRegister10DlcBrandNotice( - obj: Notice -): obj is Register10DlcBrandNotice { - return ( - (obj as Register10DlcBrandNotice & GraphQLType).__typename === - "Register10DlcBrandNotice" - ); -} - -export function isRegister10DlcCampaignNotice( - obj: Notice -): obj is Register10DlcCampaignNotice { - return ( - (obj as Register10DlcCampaignNotice & GraphQLType).__typename === - "Register10DlcCampaignNotice" - ); -} - -export function isPending10DlcCampaignNotice( - obj: Notice -): obj is Pending10DlcCampaignNotice { - return ( - (obj as Pending10DlcCampaignNotice & GraphQLType).__typename === - "Pending10DlcCampaignNotice" - ); -} - -export function isPricing10DlcNotice(obj: Notice): obj is Pricing10DlcNotice { - return ( - (obj as Pricing10DlcNotice & GraphQLType).__typename === - "Pricing10DlcNotice" - ); -} - -export function isPricingTollFreeNotice( - obj: Notice -): obj is PricingTollFreeNotice { - return ( - (obj as PricingTollFreeNotice & GraphQLType).__typename === - "PricingTollFreeNotice" - ); -} diff --git a/src/components/NoticeText/BrandRegistration10DlcNoticeText.tsx b/src/components/NoticeText/BrandRegistration10DlcNoticeText.tsx deleted file mode 100644 index efc1587e7..000000000 --- a/src/components/NoticeText/BrandRegistration10DlcNoticeText.tsx +++ /dev/null @@ -1,27 +0,0 @@ -import React from "react"; - -import KnowledgeBase10DlcNoticeText from "./KnowledgeBaseText"; - -const BrandRegistration10DlcNoticeText: React.FC = () => ( - <> -

- For the best messaging experience and lowest sending costs, please - complete our 10DLC registration form. -

-

- You are currently on our{" "} - - Quick Start pricing plan - - . You may send messages without registering for 10DLC at an increased - price per message segment. -

- - -); - -export default BrandRegistration10DlcNoticeText; diff --git a/src/components/NoticeText/CampaignRegistration10DlcNoticeText.tsx b/src/components/NoticeText/CampaignRegistration10DlcNoticeText.tsx deleted file mode 100644 index a99915a3d..000000000 --- a/src/components/NoticeText/CampaignRegistration10DlcNoticeText.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import React from "react"; - -import KnowledgeBase10DlcNoticeText from "./KnowledgeBaseText"; - -const CampaignRegistration10DlcNoticeText: React.FC = () => ( - <> -

- - You have started but not yet completed your 10DLC registration form. - -

-

- You must complete registration in order to gain access to our{" "} - - Standard pricing plan - - . Please complete the second section of our 10DLC form to finalize your - registration. -

-

- You are currently on our{" "} - - Quick Start pricing plan - - . You may send messages without registering for 10DLC at an increased - price per message segment. -

- - -); - -export default CampaignRegistration10DlcNoticeText; diff --git a/src/components/NoticeText/KnowledgeBaseText.tsx b/src/components/NoticeText/KnowledgeBaseText.tsx deleted file mode 100644 index f950be3a0..000000000 --- a/src/components/NoticeText/KnowledgeBaseText.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from "react"; - -const KnowledgeBase10DlcNoticeText: React.FC = () => ( -

- To learn more about 10DLC and our pricing plans{" "} - - 10DLC knowledge base article - - . -

-); - -export default KnowledgeBase10DlcNoticeText; diff --git a/src/components/NoticeText/Pending10DlcCampaignNoticeText.tsx b/src/components/NoticeText/Pending10DlcCampaignNoticeText.tsx deleted file mode 100644 index dd6fc1387..000000000 --- a/src/components/NoticeText/Pending10DlcCampaignNoticeText.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from "react"; - -const Pending10DlcCampaignNoticeText: React.FC = () => ( -

- Your 10DLC campaign has been submitted for external vetting. Please allow up - to one week for this process to be completed. -

- If your campaign remains in this status for longer than a week, please reach - out to us at{" "} - support@spokerewired.com for - assistance. -

-); - -export default Pending10DlcCampaignNoticeText; diff --git a/src/components/NoticeText/Pricing10DlcNoticeText.tsx b/src/components/NoticeText/Pricing10DlcNoticeText.tsx deleted file mode 100644 index 8293d132e..000000000 --- a/src/components/NoticeText/Pricing10DlcNoticeText.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from "react"; - -const Pricing10DlcNoticeText: React.FC = () => ( - <> -

Your organization is fully registered for 10DLC!

-

- You are currently on our{" "} - - Standard pricing plan - - , which provides our lowest costs and improved deliverability. -

- -); - -export default Pricing10DlcNoticeText; diff --git a/src/components/NoticeText/PricingTollFreeNoticeText.tsx b/src/components/NoticeText/PricingTollFreeNoticeText.tsx deleted file mode 100644 index 7a86db107..000000000 --- a/src/components/NoticeText/PricingTollFreeNoticeText.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import React from "react"; - -const PricingTollFreeNoticeText: React.FC = () => ( - <> -

Your organization is fully registered for Toll Free sending!

-

- You are currently on our{" "} - - Toll Free pricing plan - - , which provides our best deliverability and sending throughput. -

- -); - -export default PricingTollFreeNoticeText; diff --git a/src/config.js b/src/config.js index 30ee5113a..fe2895e6e 100644 --- a/src/config.js +++ b/src/config.js @@ -115,10 +115,6 @@ const validators = { default: false, isClient: true }), - ENABLE_REWIRED_SHUTDOWN_NOTICE: bool({ - desc: "Show the Rewired shutdown notice", - default: true - }), DISABLE_ASSIGNMENT_CASCADE: bool({ desc: "Whether to just assign from 1 campaign rather than gathering from multiple to fulfill a request", @@ -449,12 +445,6 @@ const validators = { "A comma separated list of contact fields to not ship to the client. Can include 'external_id, cell, and lastName'", default: "" }), - SHOW_10DLC_REGISTRATION_NOTICES: bool({ - desc: - "Whether the 10DLC Registration Notices are displayed to Admins and Owners", - default: true, - isClient: true - }), JOBS_SAME_PROCESS: bool({ desc: "Whether jobs should be executed in the same process in which they are created (vs. processing asyncronously via worker processes).", diff --git a/src/containers/AdminDashboard/components/NotificationCard.tsx b/src/containers/AdminDashboard/components/NotificationCard.tsx index 13a874424..5a3394e74 100644 --- a/src/containers/AdminDashboard/components/NotificationCard.tsx +++ b/src/containers/AdminDashboard/components/NotificationCard.tsx @@ -4,17 +4,7 @@ import Divider from "@material-ui/core/Divider"; import { useGetOrganizationNotificationsQuery } from "@spoke/spoke-codegen"; import React from "react"; -import { - isPending10DlcCampaignNotice, - isPricing10DlcNotice, - isPricingTollFreeNotice, - isRegister10DlcBrandNotice, - isRegister10DlcCampaignNotice, - isTitleContentNotice -} from "../../../api/notice"; -import Pending10DlcCampaignNoticeCard from "./Pending10DlcCampaignNoticeCard"; -import PricingNoticeCard from "./PricingNoticeCard"; -import Register10DlcNoticeCard from "./Register10DlcNoticeCard"; +import { isTitleContentNotice } from "../../../api/notice"; import TitleContentNoticeCard from "./TitleContentNoticeCard"; interface NotificationCardProps { @@ -52,20 +42,6 @@ export const NotificationCard: React.FC = ({ /> ); } - if (window.SHOW_10DLC_REGISTRATION_NOTICES) { - if ( - isRegister10DlcBrandNotice(node) || - isRegister10DlcCampaignNotice(node) - ) { - return ; - } - if (isPending10DlcCampaignNotice(node)) { - return ; - } - if (isPricing10DlcNotice(node) || isPricingTollFreeNotice(node)) { - return ; - } - } return null; })} {data?.notices.pageInfo.totalCount > 0 && } diff --git a/src/containers/AdminDashboard/components/Pending10DlcCampaignNoticeCard.tsx b/src/containers/AdminDashboard/components/Pending10DlcCampaignNoticeCard.tsx deleted file mode 100644 index 0e50df161..000000000 --- a/src/containers/AdminDashboard/components/Pending10DlcCampaignNoticeCard.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import Card from "@material-ui/core/Card"; -import CardContent from "@material-ui/core/CardContent"; -import CardHeader from "@material-ui/core/CardHeader"; -import Announcement from "@material-ui/icons/Announcement"; -import React from "react"; - -import Pending10DlcCampaignNoticeText from "../../../components/NoticeText/Pending10DlcCampaignNoticeText"; - -const Pending10DlcCampaignNoticeCard: React.FC = () => { - return ( - - } - /> - - - - - ); -}; - -export default Pending10DlcCampaignNoticeCard; diff --git a/src/containers/AdminDashboard/components/PricingNoticeCard.tsx b/src/containers/AdminDashboard/components/PricingNoticeCard.tsx deleted file mode 100644 index a191fecff..000000000 --- a/src/containers/AdminDashboard/components/PricingNoticeCard.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import Card from "@material-ui/core/Card"; -import CardContent from "@material-ui/core/CardContent"; -import CardHeader from "@material-ui/core/CardHeader"; -import AssignmentTurnedIn from "@material-ui/icons/AssignmentTurnedIn"; -import type { PricingNotice } from "@spoke/spoke-codegen"; -import React from "react"; - -import { isPricing10DlcNotice } from "../../../api/notice"; -import Pricing10DlcNoticeText from "../../../components/NoticeText/Pricing10DlcNoticeText"; -import PricingTollFreeNoticeText from "../../../components/NoticeText/PricingTollFreeNoticeText"; - -type PricingNoticeCardProps = PricingNotice; - -const PricingNoticeCard: React.FC = (props) => { - const is10DlcNotice = isPricing10DlcNotice(props); - - return ( - - } - /> - - {is10DlcNotice ? ( - - ) : ( - - )} - - - ); -}; - -export default PricingNoticeCard; diff --git a/src/containers/AdminDashboard/components/Register10DlcNoticeCard.tsx b/src/containers/AdminDashboard/components/Register10DlcNoticeCard.tsx deleted file mode 100644 index c3e2c9901..000000000 --- a/src/containers/AdminDashboard/components/Register10DlcNoticeCard.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import Button from "@material-ui/core/Button"; -import Card from "@material-ui/core/Card"; -import CardActions from "@material-ui/core/CardActions"; -import CardContent from "@material-ui/core/CardContent"; -import CardHeader from "@material-ui/core/CardHeader"; -import OpenInNew from "@material-ui/icons/OpenInNew"; -import Warning from "@material-ui/icons/Warning"; -import type { Register10DlcNotice } from "@spoke/spoke-codegen"; -import React from "react"; - -import { isRegister10DlcBrandNotice } from "../../../api/notice"; -import BrandRegistration10DlcNoticeText from "../../../components/NoticeText/BrandRegistration10DlcNoticeText"; -import CampaignRegistration10DlcNoticeText from "../../../components/NoticeText/CampaignRegistration10DlcNoticeText"; - -type Register10DlcNoticeCardProps = Register10DlcNotice; - -const Register10DlcNoticeCard: React.FC = ( - props -) => { - const isBrandNotice = isRegister10DlcBrandNotice(props); - return ( - - } - /> - - {isBrandNotice ? ( - - ) : ( - - )} - - {props.tcrRegistrationUrl === null && ( -

- Please contact your Spoke organization owner to resolve this! -

- )} -
- {props.tcrRegistrationUrl && ( - - - - )} -
- ); -}; - -export default Register10DlcNoticeCard; diff --git a/src/containers/Settings/components/Review10DlcInfo.tsx b/src/containers/Settings/components/Review10DlcInfo.tsx deleted file mode 100644 index daed0efab..000000000 --- a/src/containers/Settings/components/Review10DlcInfo.tsx +++ /dev/null @@ -1,77 +0,0 @@ -import Button from "@material-ui/core/Button"; -import Card from "@material-ui/core/Card"; -import CardActions from "@material-ui/core/CardActions"; -import CardContent from "@material-ui/core/CardContent"; -import CardHeader from "@material-ui/core/CardHeader"; -import OpenInNew from "@material-ui/icons/OpenInNew"; -import React from "react"; -import { compose } from "recompose"; - -import BrandRegistration10DlcNoticeText from "../../../components/NoticeText/BrandRegistration10DlcNoticeText"; -import type { QueryMap } from "../../../network/types"; -import { loadData } from "../../hoc/with-operations"; -import type { OrganizationMessagingServicesType } from "./queries"; -import { GET_MESSAGING_SERVICES } from "./queries"; - -interface HocProps { - data: OrganizationMessagingServicesType; -} - -export interface OuterProps { - organizationId: string; - style?: React.CSSProperties; -} - -interface InnerProps extends OuterProps, HocProps {} - -const Review10DlcInfo: React.FC = (props) => { - const { - data: { - organization: { - messagingServices: { edges } - } - }, - style - } = props; - - const link = - edges.length === 1 - ? edges[0].node.tcrBrandRegistrationLink ?? undefined - : undefined; - - return ( - - - - - - - - - - ); -}; - -const queries: QueryMap = { - data: { - query: GET_MESSAGING_SERVICES, - options: ({ organizationId }) => ({ - variables: { organizationId } - }) - } -}; - -export default compose(loadData({ queries }))( - Review10DlcInfo -); diff --git a/src/containers/Settings/components/queries.ts b/src/containers/Settings/components/queries.ts index f83ef6486..290114c6d 100644 --- a/src/containers/Settings/components/queries.ts +++ b/src/containers/Settings/components/queries.ts @@ -40,7 +40,6 @@ export const GET_MESSAGING_SERVICES = gql` node { id serviceType - tcrBrandRegistrationLink } } } diff --git a/src/global.d.ts b/src/global.d.ts index 560f0a41a..587010a21 100644 --- a/src/global.d.ts +++ b/src/global.d.ts @@ -15,7 +15,6 @@ interface Window { NODE_ENV: string; BASE_URL: string; ENABLE_TROLLBOT: boolean; - SHOW_10DLC_REGISTRATION_NOTICES: boolean; AuthService: any; } diff --git a/src/schema.graphql b/src/schema.graphql index a11696ae1..618933d05 100644 --- a/src/schema.graphql +++ b/src/schema.graphql @@ -842,7 +842,6 @@ type MessagingService { messagingServiceSid: String! serviceType: MessagingServiceType! updatedAt: String! - tcrBrandRegistrationLink: String name: String active: Boolean! isDefault: Boolean @@ -860,37 +859,6 @@ type MessagingServicePage { -interface Register10DlcNotice { - id: ID! - tcrRegistrationUrl: String -} - -type Register10DlcBrandNotice implements Register10DlcNotice { - id: ID! - tcrRegistrationUrl: String -} - -type Register10DlcCampaignNotice implements Register10DlcNotice { - id: ID! - tcrRegistrationUrl: String -} - -type Pending10DlcCampaignNotice { - id: ID! -} - -interface PricingNotice { - id: ID! -} - -type Pricing10DlcNotice implements PricingNotice { - id: ID! -} - -type PricingTollFreeNotice implements PricingNotice { - id: ID! -} - type TitleContentNotice { id: ID! title: String! @@ -899,7 +867,7 @@ type TitleContentNotice { markdownContent: String! } -union Notice = Register10DlcBrandNotice | Register10DlcCampaignNotice | Pending10DlcCampaignNotice | Pricing10DlcNotice | PricingTollFreeNotice | TitleContentNotice +union Notice = TitleContentNotice type NoticeEdge { cursor: Cursor! diff --git a/src/server/api/messaging-service.ts b/src/server/api/messaging-service.ts index 05dffced9..623967650 100644 --- a/src/server/api/messaging-service.ts +++ b/src/server/api/messaging-service.ts @@ -16,11 +16,7 @@ export const resolvers = { serviceType: (service: MessagingServiceRecord) => service.service_type === MessagingServiceType.AssembleNumbers ? GraphQLMessagingServiceType.ASSEMBLE_NUMBERS - : GraphQLMessagingServiceType.TWILIO, - tcrBrandRegistrationLink: (service: MessagingServiceRecord) => - service.service_type === MessagingServiceType.AssembleNumbers - ? `https://portal.spokerewired.com/10dlc-registration/${service.messaging_service_sid}` - : null + : GraphQLMessagingServiceType.TWILIO } }; diff --git a/src/server/api/notice.ts b/src/server/api/notice.ts index 41877fe76..78e236f6b 100644 --- a/src/server/api/notice.ts +++ b/src/server/api/notice.ts @@ -1,37 +1,13 @@ /* eslint-disable import/prefer-default-export */ import type { Notice } from "@spoke/spoke-codegen"; -import { - isPending10DlcCampaignNotice, - isPricing10DlcNotice, - isPricingTollFreeNotice, - isRegister10DlcBrandNotice, - isRegister10DlcCampaignNotice, - isTitleContentNotice -} from "../../api/notice"; +import { isTitleContentNotice } from "../../api/notice"; // explicitly setting typename export const resolvers = { Notice: { __resolveType(obj: Notice) { - if (isTitleContentNotice(obj)) { - return "TitleContentNotice"; - } - if (isRegister10DlcBrandNotice(obj)) { - return "Register10DlcBrandNotice"; - } - if (isRegister10DlcCampaignNotice(obj)) { - return "Register10DlcCampaignNotice"; - } - if (isPending10DlcCampaignNotice(obj)) { - return "Pending10DlcCampaignNotice"; - } - if (isPricing10DlcNotice(obj)) { - return "Pricing10DlcNotice"; - } - if (isPricingTollFreeNotice(obj)) { - return "PricingTollFreeNotice"; - } + if (isTitleContentNotice(obj)) return "TitleContentNotice"; return null; } } diff --git a/src/server/lib/notices/index.ts b/src/server/lib/notices/index.ts index 44a70e7a7..a278606b3 100644 --- a/src/server/lib/notices/index.ts +++ b/src/server/lib/notices/index.ts @@ -1,24 +1,14 @@ import type { Notice } from "@spoke/spoke-codegen"; -import { config } from "../../../config"; -import { get10DlcBrandNotices } from "./register-10dlc-brand"; -import SpokeRewiredShutdownNotice from "./spoke-rewired-shutdown"; import type { OrgLevelNotificationGetter } from "./types"; export const getInstanceNotifications = (_userId: string): Notice[] => { - return [ - ...(config.ENABLE_REWIRED_SHUTDOWN_NOTICE - ? [SpokeRewiredShutdownNotice] - : []) - ]; + return []; }; export const getOrgLevelNotifications: OrgLevelNotificationGetter = async ( - userId, - organizationId + _userId, + _organizationId ) => { - const notices: Notice[] = await Promise.all([ - get10DlcBrandNotices(userId, organizationId) - ]).then((noticeSets) => noticeSets.flat()); - return notices; + return []; }; diff --git a/src/server/lib/notices/register-10dlc-brand.ts b/src/server/lib/notices/register-10dlc-brand.ts deleted file mode 100644 index 177ddc3cd..000000000 --- a/src/server/lib/notices/register-10dlc-brand.ts +++ /dev/null @@ -1,200 +0,0 @@ -import request from "superagent"; - -import { r } from "../../models"; -import type { OrgLevelNotificationGetter } from "./types"; - -const PORTAL_API_URL = "https://portal-api.spokerewired.com/graphql"; - -const fetchBillingAccountQuery = ` - query GetBillingAccountBySwitchboardProfileId($switchboardProfileId: UUID!) { - billingAccount: billingAccountBySwitchboardProfileId( - switchboardProfileId: $switchboardProfileId - ) { - id - __typename - } - } -`; - -const fetchBrandQuery = ` - query AnonGetTcr10DlcBrandByBillingAccountId($billingAccountId: UUID!) { - brand: brandByBillingAccountId(billingAccountId: $billingAccountId) { - id - state - campaigns: tcr10DlcCampaignsByBrandId { - nodes { - id - state - __typename - } - } - __typename - } - } -`; - -const fetchProfileQuery = ` - query GetSwitchboardProfile($profileId: UUID!) { - profile: switchboardProfileByProfileId(profileId: $profileId) { - id - channel - } - } -`; - -export const get10DlcBrandNotices: OrgLevelNotificationGetter = async ( - userId, - organizationId -) => { - const profilesQuery = r - .knex("messaging_service") - .join( - "user_organization", - "user_organization.organization_id", - "messaging_service.organization_id" - ) - .select(["messaging_service_sid", r.knex.raw("array_agg(role) as roles")]) - .groupBy("messaging_service_sid") - .where({ - service_type: "assemble-numbers", - user_id: userId, - active: true - }) - .whereIn("role", ["OWNER", "ADMIN", "SUPERVOLUNTEER"]) - .where({ - "user_organization.organization_id": organizationId - }); - - const profiles: { - messaging_service_sid: string; - roles: string[]; - }[] = await profilesQuery; - - const ownedProfiles = profiles.filter(({ roles }) => roles.includes("OWNER")); - - let profilesWithChannels: any[] = []; - try { - profilesWithChannels = await Promise.all( - profiles.map(async ({ messaging_service_sid }) => { - const payload = { - operationName: "GetSwitchboardProfile", - query: fetchProfileQuery, - variables: { - profileId: messaging_service_sid - } - }; - - const profileResponse = await request - .post(PORTAL_API_URL) - .timeout(1000) - .send(payload); - - return profileResponse.body.data?.profile; - }) - ); - } catch { - // Error fetching from Portal (it may not be reachable) - return []; - } - - // if a registered profile exists, show the notice for their lowest cost pricing plan - - const profile10Dlc = profilesWithChannels.find((p) => p.channel === "_10DLC"); - if (profile10Dlc !== undefined) { - return [ - { - __typename: "Pricing10DlcNotice", - id: profile10Dlc.id - } - ]; - } - - const profileTollFree = profilesWithChannels.find( - (p) => p.channel === "TOLL_FREE" - ); - if (profileTollFree !== undefined) - return [ - { - __typename: "PricingTollFreeNotice", - id: profileTollFree.id - } - ]; - - const messagingServiceSid = - ownedProfiles.length > 0 - ? ownedProfiles[0].messaging_service_sid - : profiles[0].messaging_service_sid; - - let brand: { campaigns: { nodes: { state: string }[] } } | undefined; - - for (const profile of profiles) { - const payload = { - operationName: "GetBillingAccountBySwitchboardProfileId", - query: fetchBillingAccountQuery, - variables: { - switchboardProfileId: profile.messaging_service_sid - } - }; - - const billingAccountResponse = await request - .post(PORTAL_API_URL) - .send(payload); - - if (billingAccountResponse.body?.data?.billingAccount?.id) { - const brandPayload = { - operationName: "AnonGetTcr10DlcBrandByBillingAccountId", - query: fetchBrandQuery, - variables: { - billingAccountId: billingAccountResponse.body.data.billingAccount.id - } - }; - - const brandResponse = await request - .post(PORTAL_API_URL) - .send(brandPayload); - - const brandData = brandResponse.body.data?.brand; - if (brandData) brand = brandData; - } - } - - if (brand === undefined) - // they haven't registered a brand yet - return [ - { - __typename: "Register10DlcBrandNotice", - id: messagingServiceSid, - tcrRegistrationUrl: - ownedProfiles.length > 0 - ? `https://portal.spokerewired.com/10dlc-registration/${messagingServiceSid}` - : null - } - ]; - - const campaigns = brand?.campaigns?.nodes; - if ( - campaigns === undefined || - !campaigns.some(({ state }: { state: string }) => state === "REGISTERED") - ) - // they haven't registered a campaign yet - return [ - { - __typename: "Register10DlcCampaignNotice", - id: messagingServiceSid, - tcrRegistrationUrl: - ownedProfiles.length > 0 - ? `https://portal.spokerewired.com/10dlc-registration/${messagingServiceSid}` - : null - } - ]; - - // they registered a campaign and a 10DLC profile isn't added to spoke yet - return [ - { - __typename: "Pending10DlcCampaignNotice", - id: messagingServiceSid - } - ]; -}; - -export default get10DlcBrandNotices; diff --git a/src/server/lib/notices/spoke-rewired-shutdown.ts b/src/server/lib/notices/spoke-rewired-shutdown.ts deleted file mode 100644 index 6e401dd4b..000000000 --- a/src/server/lib/notices/spoke-rewired-shutdown.ts +++ /dev/null @@ -1,16 +0,0 @@ -import type { TitleContentNotice } from "@spoke/spoke-codegen"; - -const shutdownNoticeContent = `Politics Rewired is winding down operations. Text messages will no longer be deliverable after **November 15, 2023** and your instance will no longer be available after **November 22, 2023**. Please find more details in our transition document here: [politicsrewired.com](https://www.politicsrewired.com) - -Thank you for choosing us for your texting outreach, and we wish you the best of luck with all of your future organizing work ❤️`; - -export const SpokeRewiredShutdownNotice: TitleContentNotice = { - __typename: "TitleContentNotice", - id: "shutdown-notice", - title: "Spoke Rewired Shutdown", - avatarIcon: "announcement", - avatarColor: "error", - markdownContent: shutdownNoticeContent -}; - -export default SpokeRewiredShutdownNotice;