-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
If a subscribed user sends an SMS starting with "report", the text after "report" will be interpreted as an address and sent out as an alert to all subscribers. This operates through the same code path as the alert form on the site. Right now, this only supports plain text addresses. We will be able to integrate it with geocoding in the future to acquire coordinates, as well as correct typos.
- Loading branch information
Showing
6 changed files
with
126 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,20 @@ | ||
package models | ||
|
||
case class Alert(address: String) | ||
import com.twilio.rest.api.v2010.account.Message | ||
import com.twilio.`type`.PhoneNumber | ||
import play.api.i18n.{Lang, MessagesApi} | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
case class Alert(address: String) { | ||
def sendAlert(subscribers: Seq[Subscriber], messagesApi: MessagesApi) = { | ||
subscribers.map { subscriber => | ||
implicit val lang: Lang = Lang.get("en").get | ||
Message | ||
.creator(new PhoneNumber(subscriber.phone), // to | ||
new PhoneNumber(sys.env("TWILIO_PHONE")), // from | ||
messagesApi("action_alert", address)) | ||
.create() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters