Skip to content

Commit

Permalink
Merge pull request #691 from pennlabs/alert-2.0-sms
Browse files Browse the repository at this point in the history
Add SMS
  • Loading branch information
esinx authored Nov 19, 2024
2 parents f01a2b9 + b6ce58e commit 2951e1d
Show file tree
Hide file tree
Showing 4 changed files with 727 additions and 6 deletions.
1 change: 1 addition & 0 deletions services/alert/webhook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
},
"dependencies": {
"@aws-sdk/client-sesv2": "^3.672.0",
"@aws-sdk/client-sns": "^3.693.0",
"dotenv": "^16.4.5",
"drizzle-orm": "^0.36.0",
"pg": "^8.13.1",
Expand Down
20 changes: 20 additions & 0 deletions services/alert/webhook/src/core/sms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { SNSClient, PublishCommand } from "@aws-sdk/client-sns"

const client = new SNSClient({region: "us-east-1"})

export const sendCourseAlertSMS = async (args: {
section_id: string
recipient: string[]
}) => {
const { section_id, recipient } = args
const commandPromises = recipient.map((phoneNumber) =>
client.send(
new PublishCommand({
Message: `PennCourseAlert: ${section_id} is now open!`,
PhoneNumber: phoneNumber,
})
)
)
const results = await Promise.allSettled(commandPromises)
return results.filter((result, _) => result.status !== "fulfilled")
}
6 changes: 0 additions & 6 deletions services/alert/webhook/src/test.ts

This file was deleted.

Loading

0 comments on commit 2951e1d

Please sign in to comment.