Skip to content

Commit

Permalink
refactor: remove phonebook CTA link in SMS and email (#2207)
Browse files Browse the repository at this point in the history
* refactor: remove phonebook service

* refactor(email.class.ts): log campaignId instead of deleting

* chore: add comment to explain campaignId being unused
  • Loading branch information
KishenKumarrrrr committed Aug 28, 2023
1 parent bb1f307 commit 4e77dec
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 161 deletions.
25 changes: 8 additions & 17 deletions worker/src/core/loaders/message-worker/email.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import MailClient from '@shared/clients/mail-client.class'
import { TemplateClient, XSS_EMAIL_OPTION } from '@shared/templating'
import { ThemeClient } from '@shared/theme'
import { EmailResultRow, Message } from './interface'
import { PhonebookService } from '@core/services/phonebook.service'

const templateClient = new TemplateClient({ xssOptions: XSS_EMAIL_OPTION })
const logger = loggerWithLabel(module)
Expand Down Expand Up @@ -81,29 +80,21 @@ class Email {
campaignId: number
): Promise<Message[]> {
const showMastheadDomain = config.get('showMastheadDomain')
// This function was refactored to no longer use campaignId in a meaningful way.
// I've left it as a param to avoid cascading changes upstream.
logger.info({
message: 'Get email message',
workerId: this.workerId,
campaignId,
action: 'getMessages',
})
const result = await this.connection.query<EmailResultRow>(
'SELECT get_messages_to_send_email_with_agency(:job_id, :rate) AS message;',
{
replacements: { job_id: jobId, rate },
type: QueryTypes.SELECT,
}
)
const phonebookFeatureFlag = config.get('phonebook.enabled')
if (phonebookFeatureFlag && result.length > 0) {
try {
const managedListId = await this.fetchManagedListIdOfCampaign(
campaignId
)
return await PhonebookService.appendLinkForEmail(result, managedListId)
} catch (error) {
logger.error({
message: 'Unable to append links',
error,
workerId: this.workerId,
})
// If phonebook is down, we still want to continue sending the messages
}
}
return map(result, (row) => {
const { senderEmail } = row.message
const showMasthead = senderEmail.endsWith(showMastheadDomain)
Expand Down
15 changes: 0 additions & 15 deletions worker/src/core/loaders/message-worker/sms.class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { PhoneNumberService } from '@shared/utils/phone-number.service'
import { TemplateClient, XSS_SMS_OPTION } from '@shared/templating'
import TwilioClient from '@sms/services/twilio-client.class'
import SnsSmsClient from '@sms/services/sns-sms-client.class'
import { PhonebookService } from '@core/services/phonebook.service'

const templateClient = new TemplateClient({ xssOptions: XSS_SMS_OPTION })
const logger = loggerWithLabel(module)
Expand Down Expand Up @@ -69,20 +68,6 @@ class SMS {
}
)
const result = map(dbResults, 'get_messages_to_send_sms')

const phonebookFeatureFlag = config.get('phonebook.enabled')
if (phonebookFeatureFlag && result.length > 0) {
try {
return await PhonebookService.appendLinkForSms(result)
} catch (error) {
logger.error({
message: 'Unable to append links',
error,
workerId: this.workerId,
})
// If phonebook is down, we still want to continue sending the messages
}
}
return result
}

Expand Down
129 changes: 0 additions & 129 deletions worker/src/core/services/phonebook.service.ts

This file was deleted.

0 comments on commit 4e77dec

Please sign in to comment.