Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Handle events for messages with multiple segments

Acho Arnold344c10f227f4
diff --git a/android/app/src/main/java/com/httpsms/Receiver.kt b/android/app/src/main/java/com/httpsms/Receiver.kt
index 0fb7fbf2..34d44a31 100644
--- a/android/app/src/main/java/com/httpsms/Receiver.kt
+++ b/android/app/src/main/java/com/httpsms/Receiver.kt
@@ -20,6 +20,12 @@ object Receiver {
Timber.w("cannot handle message with id [$messageId] because the user is not active")
return false
}
+
+ if(messageId.contains(".")) {
+ Timber.d("message id [${messageId}] is for multipart segment [${messageId.split(".")[1]}]")
+ return false
+ }
+
return true
}
}
diff --git a/api/cmd/experiments/main.go b/api/cmd/experiments/main.go
index 8872381f..b1c1fe29 100644
--- a/api/cmd/experiments/main.go
+++ b/api/cmd/experiments/main.go
@@ -23,10 +23,11 @@ func main() {
func loadTest() {
wg := sync.WaitGroup{}
- for i := 0; i < 2; i++ {
+ for i := 0; i < 1; i++ {
wg.Add(1)
go func(count int) {
- sendSMS(count)
+ sendSMS(fmt.Sprintf("[%d] In the quiet of the night, the stars above whisper secrets of the universe. We, mere stardust, seek meaning in their cosmic dance, yearning to unlock the mysteries of existence that stretch far beyond our earthly bounds.", count))
+ sendSMS(fmt.Sprintf("[%d] Hello, World", count))
wg.Done()
}(i)
@@ -34,11 +35,11 @@ func loadTest() {
wg.Wait()
}
-func sendSMS(count int) {
+func sendSMS(content string) {
var response string
err := requests.URL(os.Getenv("BASIC_URL")).
BodyJSON(map[string]any{
- "content": fmt.Sprintf("Hello, World [%d]", count),
+ "content": content,
"from": os.Getenv("BASIC_FROM"),
"to": os.Getenv("BASIC_TO"),
}).