Skip to content

Commit

Permalink
Add SMS
Browse files Browse the repository at this point in the history
  • Loading branch information
Clue88 committed Nov 19, 2024
1 parent bd2bd26 commit b6ce58e
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 b6ce58e

Please sign in to comment.