Skip to content

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

Add missed call event

Acho Arnolda89c51ea24b1
diff --git a/android/app/src/main/java/com/httpsms/HttpSmsApiService.kt b/android/app/src/main/java/com/httpsms/HttpSmsApiService.kt
index 73274d54..97a2c819 100644
--- a/android/app/src/main/java/com/httpsms/HttpSmsApiService.kt
+++ b/android/app/src/main/java/com/httpsms/HttpSmsApiService.kt
@@ -91,7 +91,7 @@ class HttpSmsApiService(private val apiKey: String, private val baseURL: URI) {
if (!response.isSuccessful) {
Timber.e("error response [${response.body?.string()}] with code [${response.code}] while receiving message [${body}]")
response.close()
- return false
+ return response.code == 422 || response.code == 401
}
val message = ResponseMessage.fromJson(response.body!!.string())
diff --git a/api/docs/docs.go b/api/docs/docs.go
index c4ed24b2..6665cb2c 100644
--- a/api/docs/docs.go
+++ b/api/docs/docs.go
@@ -923,7 +923,7 @@ const docTemplate = `{
"type": "string",
"default": "32343a19-da5e-4b1b-a767-3298a73703ca",
"description": "ID of the message thread",
- "name": "messageID",
+ "name": "messageThreadID",
"in": "path",
"required": true
}
@@ -1125,6 +1125,75 @@ const docTemplate = `{
}
}
},
+ "/messages/calls/missed": {
+ "post": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "This endpoint is called by the httpSMS android app to register a missed call event on the mobile phone.",
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "Messages"
+ ],
+ "summary": "Register a missed call event on the mobile phone",
+ "parameters": [
+ {
+ "description": "Payload of the missed call event.",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/requests.MessageCallMissed"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/responses.MessageResponse"
+ }
+ },
+ "400": {
+ "description": "Bad Request",
+ "schema": {
+ "$ref": "#/definitions/responses.BadRequest"
+ }
+ },
+ "401": {
+ "description": "Unauthorized",
+ "schema": {
+ "$ref": "#/definitions/responses.Unauthorized"
+ }
+ },
+ "404": {
+ "description": "Not Found",
+ "schema": {
+ "$ref": "#/definitions/responses.NotFound"
+ }
+ },
+ "422": {
+ "description": "Unprocessable Entity",
+ "schema": {
+ "$ref": "#/definitions/responses.UnprocessableEntity"
+ }
+ },
+ "500": {
+ "description": "Internal Server Error",
+ "schema": {
+ "$ref": "#/definitions/responses.InternalServerError"
+ }
+ }
+ }
+ }
+ },
"/messages/outstanding": {
"get": {
"security": [
@@ -2340,6 +2409,7 @@ const docTemplate = `{
"content",
"created_at",
"delivered_at",
+ "encrypted",
"expired_at",
"failed_at",
"failure_reason",
@@ -2383,6 +2453,10 @@ const docTemplate = `{
"type": "string",
"example": "2022-06-05T14:26:09.527976+03:00"
},
+ "encrypted": {
+ "type": "boolean",
+ "example": false
+ },
"expired_at": {
"type": "string",
"example": "2022-06-05T14:26:09.527976+03:00"
@@ -2551,6 +2625,7 @@ const docTemplate = `{
"max_send_attempts",
"message_expiration_seconds",
"messages_per_minute",
+ "missed_call_auto_reply",
"phone_number",
"sim",
"updated_at",
@@ -2582,6 +2657,10 @@ const docTemplate = `{
"type": "integer",
"example": 1
},
+ "missed_call_auto_reply": {
+ "type": "string",
+ "example": "This phone cannot receive calls. Please send an SMS instead."
+ },
"phone_number": {
"type": "string",
"example": "+18005550199"
@@ -2621,8 +2700,10 @@ const docTemplate = `{
"pro-lifetime",
"20k-monthly",
"100k-monthly",
+ "50k-monthly",
"20k-yearly",
- "100k-yearly"
+ "100k-yearly",
+ "50k-yearly"
],
"x-enum-varnames": [
"SubscriptionNameFree",
@@ -2633,8 +2714,10 @@ const docTemplate = `{
"SubscriptionNameProLifetime",
"SubscriptionName20KMonthly",
"SubscriptionName100KMonthly",
+ "SubscriptionName50KMonthly",
"SubscriptionName20KYearly",
- "SubscriptionName100KYearly"
+ "SubscriptionName100KYearly",
+ "SubscriptionName50KYearly"
]
},
"entities.User": {
@@ -2663,7 +2746,7 @@ const docTemplate = `{
},
"api_key": {
"type": "string",
- "example": "xyz"
+ "example": "x-api-key"
},
"created_at": {
"type": "string",
@@ -2838,6 +2921,7 @@ const docTemplate = `{
"type": "object",
"required": [
"content",
+ "encrypted",
"from",
"to"
],
@@ -2846,6 +2930,11 @@ const docTemplate = `{
"type": "string",
"example": "This is a sample text message"
},
+ "encrypted": {
+ "description": "Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app",
+ "type": "boolean",
+ "example": false
+ },
"from": {
"type": "string",
"example": "+18005550199"
@@ -2867,6 +2956,33 @@ const docTemplate = `{
}
}
},
+ "requests.MessageCallMissed": {
+ "type": "object",
+ "required": [
+ "from",
+ "sim",
+ "timestamp",
+ "to"
+ ],
+ "properties": {
+ "from": {
+ "type": "string",
+ "example": "+18005550199"
+ },
+ "sim": {
+ "type": "string",
+ "example": "SIM1"
+ },
+ "timestamp": {
+ "type": "string",
+ "example": "2022-06-05T14:26:09.527976+03:00"
+ },
+ "to": {
+ "type": "string",
+ "example": "+18005550100"
+ }
+ }
+ },
"requests.MessageEvent": {
"type": "object",
"required": [
@@ -2895,6 +3011,7 @@ const docTemplate = `{
"type": "object",
"required": [
"content",
+ "encrypted",
"from",
"sim",
"timestamp",
@@ -2905,6 +3022,11 @@ const docTemplate = `{
"type": "string",
"example": "This is a sample text message received on a phone"
},
+ "encrypted": {
+ "description": "Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app",
+ "type": "boolean",
+ "example": false
+ },
"from": {
"type": "string",
"example": "+18005550199"
@@ -2933,6 +3055,7 @@ const docTemplate = `{
"type": "object",
"required": [
"content",
+ "encrypted",
"from",
"to"
],
@@ -2941,6 +3064,11 @@ const docTemplate = `{
"type": "string",
"example": "This is a sample text message"
},
+ "encrypted": {
+ "description": "Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app",
+ "type": "boolean",
+ "example": false
+ },
"from": {
"type": "string",
"example": "+18005550199"
@@ -2980,6 +3108,7 @@ const docTemplate = `{
"max_send_attempts",
"message_expiration_seconds",
"messages_per_minute",
+ "missed_call_auto_reply",
"phone_number",
"sim"
],
@@ -3002,6 +3131,10 @@ const docTemplate = `{
"type": "integer",
"example": 1
},
+ "missed_call_auto_reply": {
+ "type": "string",
+ "example": "e.g This phone cannot receive calls. Please send an SMS instead."
+ },
"phone_number": {
"type": "string",
"example": "+18005550199"
@@ -3591,7 +3724,7 @@ var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "api.httpsms.com",
BasePath: "/v1",
- Schemes: []string{"https"},
+ Schemes: []string{"http", "https"},
Title: "HTTP SMS API",
Description: "API to send SMS messages using android [SmsManager](https://developer.android.com/reference/android/telephony/SmsManager) via HTTP",
InfoInstanceName: "swagger",
diff --git a/api/docs/swagger.json b/api/docs/swagger.json
index 255c69ed..a7fff945 100644
--- a/api/docs/swagger.json
+++ b/api/docs/swagger.json
@@ -1,5 +1,5 @@
{
- "schemes": ["https"],
+ "schemes": ["http", "https"],
"swagger": "2.0",
"info": {
"description": "API to send SMS messages using android [SmsManager](https://developer.android.com/reference/android/telephony/SmsManager) via HTTP",
@@ -827,7 +827,7 @@
"type": "string",
"default": "32343a19-da5e-4b1b-a767-3298a73703ca",
"description": "ID of the message thread",
- "name": "messageID",
+ "name": "messageThreadID",
"in": "path",
"required": true
}
@@ -1017,6 +1017,69 @@
}
}
},
+ "/messages/calls/missed": {
+ "post": {
+ "security": [
+ {
+ "ApiKeyAuth": []
+ }
+ ],
+ "description": "This endpoint is called by the httpSMS android app to register a missed call event on the mobile phone.",
+ "consumes": ["application/json"],
+ "produces": ["application/json"],
+ "tags": ["Messages"],
+ "summary": "Register a missed call event on the mobile phone",
+ "parameters": [
+ {
+ "description": "Payload of the missed call event.",
+ "name": "payload",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/requests.MessageCallMissed"
+ }
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "OK",
+ "schema": {
+ "$ref": "#/definitions/responses.MessageResponse"
+ }
+ },
+ "400": {
+ "description": "Bad Request",
+ "schema": {
+ "$ref": "#/definitions/responses.BadRequest"
+ }
+ },
+ "401": {
+ "description": "Unauthorized",
+ "schema": {
+ "$ref": "#/definitions/responses.Unauthorized"
+ }
+ },
+ "404": {
+ "description": "Not Found",
+ "schema": {
+ "$ref": "#/definitions/responses.NotFound"
+ }
+ },
+ "422": {
+ "description": "Unprocessable Entity",
+ "schema": {
+ "$ref": "#/definitions/responses.UnprocessableEntity"
+ }
+ },
+ "500": {
+ "description": "Internal Server Error",
+ "schema": {
+ "$ref": "#/definitions/responses.InternalServerError"
+ }
+ }
+ }
+ }
+ },
"/messages/outstanding": {
"get": {
"security": [
@@ -2134,6 +2197,7 @@
"content",
"created_at",
"delivered_at",
+ "encrypted",
"expired_at",
"failed_at",
"failure_reason",
@@ -2177,6 +2241,10 @@
"type": "string",
"example": "2022-06-05T14:26:09.527976+03:00"
},
+ "encrypted": {
+ "type": "boolean",
+ "example": false
+ },
"expired_at": {
"type": "string",
"example": "2022-06-05T14:26:09.527976+03:00"
@@ -2345,6 +2413,7 @@
"max_send_attempts",
"message_expiration_seconds",
"messages_per_minute",
+ "missed_call_auto_reply",
"phone_number",
"sim",
"updated_at",
@@ -2376,6 +2445,10 @@
"type": "integer",
"example": 1
},
+ "missed_call_auto_reply": {
+ "type": "string",
+ "example": "This phone cannot receive calls. Please send an SMS instead."
+ },
"phone_number": {
"type": "string",
"example": "+18005550199"
@@ -2409,8 +2482,10 @@
"pro-lifetime",
"20k-monthly",
"100k-monthly",
+ "50k-monthly",
"20k-yearly",
- "100k-yearly"
+ "100k-yearly",
+ "50k-yearly"
],
"x-enum-varnames": [
"SubscriptionNameFree",
@@ -2421,8 +2496,10 @@
"SubscriptionNameProLifetime",
"SubscriptionName20KMonthly",
"SubscriptionName100KMonthly",
+ "SubscriptionName50KMonthly",
"SubscriptionName20KYearly",
- "SubscriptionName100KYearly"
+ "SubscriptionName100KYearly",
+ "SubscriptionName50KYearly"
]
},
"entities.User": {
@@ -2451,7 +2528,7 @@
},
"api_key": {
"type": "string",
- "example": "xyz"
+ "example": "x-api-key"
},
"created_at": {
"type": "string",
@@ -2608,12 +2685,17 @@
},
"requests.MessageBulkSend": {
"type": "object",
- "required": ["content", "from", "to"],
+ "required": ["content", "encrypted", "from", "to"],
"properties": {
"content": {
"type": "string",
"example": "This is a sample text message"
},
+ "encrypted": {
+ "description": "Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app",
+ "type": "boolean",
+ "example": false
+ },
"from": {
"type": "string",
"example": "+18005550199"
@@ -2632,6 +2714,28 @@
}
}
},
+ "requests.MessageCallMissed": {
+ "type": "object",
+ "required": ["from", "sim", "timestamp", "to"],
+ "properties": {
+ "from": {
+ "type": "string",
+ "example": "+18005550199"
+ },
+ "sim": {
+ "type": "string",
+ "example": "SIM1"
+ },
+ "timestamp": {
+ "type": "string",
+ "example": "2022-06-05T14:26:09.527976+03:00"
+ },
+ "to": {
+ "type": "string",
+ "example": "+18005550100"
+ }
+ }
+ },
"requests.MessageEvent": {
"type": "object",
"required": ["event_name", "reason", "timestamp"],
@@ -2654,12 +2758,17 @@
},
"requests.MessageReceive": {
"type": "object",
- "required": ["content", "from", "sim", "timestamp", "to"],
+ "required": ["content", "encrypted", "from", "sim", "timestamp", "to"],
"properties": {
"content": {
"type": "string",
"example": "This is a sample text message received on a phone"
},
+ "encrypted": {
+ "description": "Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app",
+ "type": "boolean",
+ "example": false
+ },
"from": {
"type": "string",
"example": "+18005550199"
@@ -2686,12 +2795,17 @@
},
"requests.MessageSend": {
"type": "object",
- "required": ["content", "from", "to"],
+ "required": ["content", "encrypted", "from", "to"],
"properties": {
"content": {
"type": "string",
"example": "This is a sample text message"
},
+ "encrypted": {
+ "description": "Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app",
+ "type": "boolean",
+ "example": false
+ },
"from": {
"type": "string",
"example": "+18005550199"
@@ -2729,6 +2843,7 @@
"max_send_attempts",
"message_expiration_seconds",
"messages_per_minute",
+ "missed_call_auto_reply",
"phone_number",
"sim"
],
@@ -2751,6 +2866,10 @@
"type": "integer",
"example": 1
},
+ "missed_call_auto_reply": {
+ "type": "string",
+ "example": "e.g This phone cannot receive calls. Please send an SMS instead."
+ },
"phone_number": {
"type": "string",
"example": "+18005550199"
diff --git a/api/docs/swagger.yaml b/api/docs/swagger.yaml
index eecb08f1..564e8c22 100644
--- a/api/docs/swagger.yaml
+++ b/api/docs/swagger.yaml
@@ -117,6 +117,9 @@ definitions:
delivered_at:
example: "2022-06-05T14:26:09.527976+03:00"
type: string
+ encrypted:
+ example: false
+ type: boolean
expired_at:
example: "2022-06-05T14:26:09.527976+03:00"
type: string
@@ -195,6 +198,7 @@ definitions:
- content
- created_at
- delivered_at
+ - encrypted
- expired_at
- failed_at
- failure_reason
@@ -294,6 +298,9 @@ definitions:
messages_per_minute:
example: 1
type: integer
+ missed_call_auto_reply:
+ example: This phone cannot receive calls. Please send an SMS instead.
+ type: string
phone_number:
example: "+18005550199"
type: string
@@ -312,6 +319,7 @@ definitions:
- max_send_attempts
- message_expiration_seconds
- messages_per_minute
+ - missed_call_auto_reply
- phone_number
- sim
- updated_at
@@ -335,8 +343,10 @@ definitions:
- pro-lifetime
- 20k-monthly
- 100k-monthly
+ - 50k-monthly
- 20k-yearly
- 100k-yearly
+ - 50k-yearly
type: string
x-enum-varnames:
- SubscriptionNameFree
@@ -347,15 +357,17 @@ definitions:
- SubscriptionNameProLifetime
- SubscriptionName20KMonthly
- SubscriptionName100KMonthly
+ - SubscriptionName50KMonthly
- SubscriptionName20KYearly
- SubscriptionName100KYearly
+ - SubscriptionName50KYearly
entities.User:
properties:
active_phone_id:
example: 32343a19-da5e-4b1b-a767-3298a73703cb
type: string
api_key:
- example: xyz
+ example: x-api-key
type: string
created_at:
example: "2022-06-05T14:26:02.302718+03:00"
@@ -498,6 +510,12 @@ definitions:
content:
example: This is a sample text message
type: string
+ encrypted:
+ description:
+ Encrypted is used to determine if the content is end-to-end encrypted.
+ Make sure to set the encryption key on the httpSMS mobile app
+ example: false
+ type: boolean
from:
example: "+18005550199"
type: string
@@ -516,9 +534,30 @@ definitions:
type: array
required:
- content
+ - encrypted
- from
- to
type: object
+ requests.MessageCallMissed:
+ properties:
+ from:
+ example: "+18005550199"
+ type: string
+ sim:
+ example: SIM1
+ type: string
+ timestamp:
+ example: "2022-06-05T14:26:09.527976+03:00"
+ type: string
+ to:
+ example: "+18005550100"
+ type: string
+ required:
+ - from
+ - sim
+ - timestamp
+ - to
+ type: object
requests.MessageEvent:
properties:
event_name:
@@ -548,6 +587,12 @@ definitions:
content:
example: This is a sample text message received on a phone
type: string
+ encrypted:
+ description:
+ Encrypted is used to determine if the content is end-to-end encrypted.
+ Make sure to set the encryption key on the httpSMS mobile app
+ example: false
+ type: boolean
from:
example: "+18005550199"
type: string
@@ -567,6 +612,7 @@ definitions:
type: string
required:
- content
+ - encrypted
- from
- sim
- timestamp
@@ -577,6 +623,12 @@ definitions:
content:
example: This is a sample text message
type: string
+ encrypted:
+ description:
+ Encrypted is used to determine if the content is end-to-end encrypted.
+ Make sure to set the encryption key on the httpSMS mobile app
+ example: false
+ type: boolean
from:
example: "+18005550199"
type: string
@@ -597,6 +649,7 @@ definitions:
type: string
required:
- content
+ - encrypted
- from
- to
type: object
@@ -628,6 +681,9 @@ definitions:
messages_per_minute:
example: 1
type: integer
+ missed_call_auto_reply:
+ example: e.g This phone cannot receive calls. Please send an SMS instead.
+ type: string
phone_number:
example: "+18005550199"
type: string
@@ -642,6 +698,7 @@ definitions:
- max_send_attempts
- message_expiration_seconds
- messages_per_minute
+ - missed_call_auto_reply
- phone_number
- sim
type: object
@@ -1606,7 +1663,7 @@ paths:
- default: 32343a19-da5e-4b1b-a767-3298a73703ca
description: ID of the message thread
in: path
- name: messageID
+ name: messageThreadID
required: true
type: string
produces:
@@ -1889,6 +1946,52 @@ paths:
summary: Send bulk SMS messages
tags:
- Messages
+ /messages/calls/missed:
+ post:
+ consumes:
+ - application/json
+ description:
+ This endpoint is called by the httpSMS android app to register
+ a missed call event on the mobile phone.
+ parameters:
+ - description: Payload of the missed call event.
+ in: body
+ name: payload
+ required: true
+ schema:
+ $ref: "#/definitions/requests.MessageCallMissed"
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: OK
+ schema:
+ $ref: "#/definitions/responses.MessageResponse"
+ "400":
+ description: Bad Request
+ schema:
+ $ref: "#/definitions/responses.BadRequest"
+ "401":
+ description: Unauthorized
+ schema:
+ $ref: "#/definitions/responses.Unauthorized"
+ "404":
+ description: Not Found
+ schema:
+ $ref: "#/definitions/responses.NotFound"
+ "422":
+ description: Unprocessable Entity
+ schema:
+ $ref: "#/definitions/responses.UnprocessableEntity"
+ "500":
+ description: Internal Server Error
+ schema:
+ $ref: "#/definitions/responses.InternalServerError"
+ security:
+ - ApiKeyAuth: []
+ summary: Register a missed call event on the mobile phone
+ tags:
+ - Messages
/messages/outstanding:
get:
consumes:
@@ -2491,6 +2594,7 @@ paths:
tags:
- Webhooks
schemes:
+ - http
- https
securityDefinitions:
ApiKeyAuth:
diff --git a/api/pkg/requests/message_call_missed_request.go b/api/pkg/requests/message_call_missed_request.go
index 7640182c..bc9e832f 100644
--- a/api/pkg/requests/message_call_missed_request.go
+++ b/api/pkg/requests/message_call_missed_request.go
@@ -30,7 +30,7 @@ func (input *MessageCallMissed) Sanitize() MessageCallMissed {
// ToCallMissedParams converts MessageCallMissed to services.MessageSendParams
func (input *MessageCallMissed) ToCallMissedParams(userID entities.UserID, source string) *services.MissedCallParams {
- to, _ := phonenumbers.Parse(input.From, phonenumbers.UNKNOWN_REGION)
+ to, _ := phonenumbers.Parse(input.To, phonenumbers.UNKNOWN_REGION)
return &services.MissedCallParams{
Source: source,
Owner: to,
diff --git a/api/pkg/requests/phone_update_request.go b/api/pkg/requests/phone_update_request.go
index f2d33f28..5b9d0fac 100644
--- a/api/pkg/requests/phone_update_request.go
+++ b/api/pkg/requests/phone_update_request.go
@@ -24,7 +24,7 @@ type PhoneUpsert struct {
FcmToken string `json:"fcm_token" example:"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzd....."`
- MissedCallAutoReply *string `json:"missed_call_auto_reply" example:"e.g This phone cannot receive calls. Please send an SMS instead."`
+ MissedCallAutoReply *string `json:"missed_call_auto_reply" example:"e.g. This phone cannot receive calls. Please send an SMS instead."`
// SIM is the SIM slot of the phone in case the phone has more than 1 SIM slot
SIM string `json:"sim" example:"SIM1"`
@@ -73,6 +73,7 @@ func (input *PhoneUpsert) ToUpsertParams(user entities.AuthUser, source string)
Source: source,
PhoneNumber: phone,
MessagesPerMinute: messagesPerMinute,
+ MissedCallAutoReply: input.MissedCallAutoReply,
MessageExpirationDuration: timeout,
MaxSendAttempts: maxSendAttempts,
FcmToken: fcmToken,
diff --git a/api/pkg/requests/user_update_request.go b/api/pkg/requests/user_update_request.go
index 678c7824..d6848f47 100644
--- a/api/pkg/requests/user_update_request.go
+++ b/api/pkg/requests/user_update_request.go
@@ -29,8 +29,15 @@ func (input *UserUpdate) ToUpdateParams() services.UserUpdateParams {
if err != nil {
location = time.UTC
}
+
+ var activePhoneID *uuid.UUID
+ if input.ActivePhoneID != "" {
+ val := uuid.MustParse(input.ActivePhoneID)
+ activePhoneID = &val
+ }
+
return services.UserUpdateParams{
- ActivePhoneID: uuid.MustParse(input.ActivePhoneID),
+ ActivePhoneID: activePhoneID,
Timezone: location,
}
}
diff --git a/api/pkg/services/message_service.go b/api/pkg/services/message_service.go
index 20f02182..d28f3124 100644
--- a/api/pkg/services/message_service.go
+++ b/api/pkg/services/message_service.go
@@ -742,8 +742,8 @@ func (service *MessageService) HandleMessageExpired(ctx context.Context, params
return service.tracer.WrapErrorSpan(span, stacktrace.Propagate(err, msg))
}
- if !message.IsSending() && !message.IsScheduled() {
- msg := fmt.Sprintf("message has wrong status [%s]. expected [%s, %s, %s]", message.Status, entities.MessageStatusSending, entities.MessageStatusScheduled)
+ if !message.IsSending() && !message.IsScheduled() && !message.IsPending() {
+ msg := fmt.Sprintf("message has wrong status [%s]. expected [%s, %s, %s]", message.Status, entities.MessageStatusSending, entities.MessageStatusScheduled, entities.MessageStatusPending)
return service.tracer.WrapErrorSpan(span, stacktrace.NewError(msg))
}
diff --git a/api/pkg/services/user_service.go b/api/pkg/services/user_service.go
index bf16a7ee..6154c5b3 100644
--- a/api/pkg/services/user_service.go
+++ b/api/pkg/services/user_service.go
@@ -86,7 +86,7 @@ func (service *UserService) GetByID(ctx context.Context, userID entities.UserID)
// UserUpdateParams are parameters for updating an entities.User
type UserUpdateParams struct {
Timezone *time.Location
- ActivePhoneID uuid.UUID
+ ActivePhoneID *uuid.UUID
}
// Update an entities.User
@@ -107,7 +107,7 @@ func (service *UserService) Update(ctx context.Context, authUser entities.AuthUs
}
user.Timezone = params.Timezone.String()
- user.ActivePhoneID = &params.ActivePhoneID
+ user.ActivePhoneID = params.ActivePhoneID
if err = service.repository.Update(ctx, user); err != nil {
msg := fmt.Sprintf("cannot save user with id [%s]", user.ID)
diff --git a/api/pkg/validators/user_handler_validator.go b/api/pkg/validators/user_handler_validator.go
index 1b90cdbc..553a1cd8 100644
--- a/api/pkg/validators/user_handler_validator.go
+++ b/api/pkg/validators/user_handler_validator.go
@@ -34,7 +34,6 @@ func (validator *UserHandlerValidator) ValidateUpdate(_ context.Context, request
Data: &request,
Rules: govalidator.MapData{
"active_phone_id": []string{
- "required",
"uuid",
},
},
diff --git a/web/models/api.ts b/web/models/api.ts
index 87db8a0e..6b92cc54 100644
--- a/web/models/api.ts
+++ b/web/models/api.ts
@@ -73,6 +73,8 @@ export interface EntitiesMessage {
created_at: string
/** @example "2022-06-05T14:26:09.527976+03:00" */
delivered_at: string
+ /** @example false */
+ encrypted: boolean
/** @example "2022-06-05T14:26:09.527976+03:00" */
expired_at: string
/** @example "2022-06-05T14:26:09.527976+03:00" */
@@ -169,6 +171,8 @@ export interface EntitiesPhone {
message_expiration_seconds: number
/** @example 1 */
messages_per_minute: number
+ /** @example "This phone cannot receive calls. Please send an SMS instead." */
+ missed_call_auto_reply: string
/** @example "+18005550199" */
phone_number: string
sim: EntitiesSIM
@@ -192,14 +196,16 @@ export enum EntitiesSubscriptionName {
SubscriptionNameProLifetime = 'pro-lifetime',
SubscriptionName20KMonthly = '20k-monthly',
SubscriptionName100KMonthly = '100k-monthly',
+ SubscriptionName50KMonthly = '50k-monthly',
SubscriptionName20KYearly = '20k-yearly',
SubscriptionName100KYearly = '100k-yearly',
+ SubscriptionName50KYearly = '50k-yearly',
}
export interface EntitiesUser {
/** @example "32343a19-da5e-4b1b-a767-3298a73703cb" */
active_phone_id: string
- /** @example "xyz" */
+ /** @example "x-api-key" */
api_key: string
/** @example "2022-06-05T14:26:02.302718+03:00" */
created_at: string
@@ -268,6 +274,11 @@ export interface RequestsHeartbeatStore {
export interface RequestsMessageBulkSend {
/** @example "This is a sample text message" */
content: string
+ /**
+ * Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app
+ * @example false
+ */
+ encrypted: boolean
/** @example "+18005550199" */
from: string
/**
@@ -279,6 +290,17 @@ export interface RequestsMessageBulkSend {
to: string[]
}
+export interface RequestsMessageCallMissed {
+ /** @example "+18005550199" */
+ from: string
+ /** @example "SIM1" */
+ sim: string
+ /** @example "2022-06-05T14:26:09.527976+03:00" */
+ timestamp: string
+ /** @example "+18005550100" */
+ to: string
+}
+
export interface RequestsMessageEvent {
/**
* EventName is the type of event
@@ -300,6 +322,11 @@ export interface RequestsMessageEvent {
export interface RequestsMessageReceive {
/** @example "This is a sample text message received on a phone" */
content: string
+ /**
+ * Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app
+ * @example false
+ */
+ encrypted: boolean
/** @example "+18005550199" */
from: string
/**
@@ -319,6 +346,11 @@ export interface RequestsMessageReceive {
export interface RequestsMessageSend {
/** @example "This is a sample text message" */
content: string
+ /**
+ * Encrypted is used to determine if the content is end-to-end encrypted. Make sure to set the encryption key on the httpSMS mobile app
+ * @example false
+ */
+ encrypted: boolean
/** @example "+18005550199" */
from: string
/**
@@ -355,6 +387,8 @@ export interface RequestsPhoneUpsert {
message_expiration_seconds: number
/** @example 1 */
messages_per_minute: number
+ /** @example "e.g. This phone cannot receive calls. Please send an SMS instead." */
+ missed_call_auto_reply: string
/** @example "+18005550199" */
phone_number: string
/**
diff --git a/web/pages/index.vue b/web/pages/index.vue
index 4879be6f..e62d15ac 100644
--- a/web/pages/index.vue
+++ b/web/pages/index.vue
@@ -51,8 +51,8 @@
</v-btn>
</div>
<p class="text-body-2 mt-2">
- ⚡Trusted by <b>3,081+</b> happy users who have sent or received
- more than <b>651,009+</b> messages.
+ ⚡Trusted by <b>3,587+</b> happy users who have sent or received
+ more than <b>816,171+</b> messages.
</p>
<div
class="mt-4"
@@ -795,6 +795,19 @@ Console.WriteLine(await response.Content.ReadAsStringAsync());
</p>
</v-expansion-panel-content>
</v-expansion-panel>
+ <v-expansion-panel>
+ <v-expansion-panel-header class="text-h6">
+ Can I change the sender of the SMS message
+ </v-expansion-panel-header>
+ <v-expansion-panel-content>
+ <p class="mt-8">
+ No you cannot. When you send an SMS message using the httpSMS
+ app it uses your SIM card to send the message so the recipient
+ will see your phone number as the sender of the SMS. You
+ cannot use your brand name as the sender ID.
+ </p>
+ </v-expansion-panel-content>
+ </v-expansion-panel>
</v-expansion-panels>
</v-col>
</v-row>
diff --git a/web/pages/login.vue b/web/pages/login.vue
index 8107291c..d973eec2 100644
--- a/web/pages/login.vue
+++ b/web/pages/login.vue
@@ -14,9 +14,9 @@
<span class="text-h3">Welcome</span>
</div>
<p class="subtitle-1 text-center text--secondary mt-1 mb-4">
- Join <b>3,081+</b> happy users who have sent or
+ Join <b>3,587+</b> happy users who have sent or
<br />
- received more than <b>651,009+</b> SMS messages
+ received more than <b>816,171+</b> SMS messages
</p>
<v-card max-width="360" class="mx-auto">
<v-card-text class="px-0">
diff --git a/web/pages/settings/index.vue b/web/pages/settings/index.vue
index d6603014..fbab6794 100644
--- a/web/pages/settings/index.vue
+++ b/web/pages/settings/index.vue
@@ -47,7 +47,7 @@
style="max-width: 250px"
label="Timezone"
:items="timezones"
- @change="updateUser"
+ @change="updateTimezone"
></v-autocomplete>
</div>
<h5 class="text-h4 mb-3 mt-3">API Key</h5>
@@ -345,7 +345,7 @@
</v-row>
</v-container>
</div>
- <v-dialog v-model="showPhoneEdit" max-width="600px">
+ <v-dialog v-model="showPhoneEdit" max-width="700px">
<v-card>
<v-card-title>Edit Phone</v-card-title>
<v-card-text v-if="activePhone" class="mt-6">
@@ -409,6 +409,17 @@
label="Max Send Attempts"
>
</v-text-field>
+ <v-textarea
+ v-model="activePhone.missed_call_auto_reply"
+ outlined
+ dense
+ label="Missed Call AutoReply"
+ persistent-placeholder
+ persistent-hint
+ placeholder="We are currently closed at the moment, please send us a text message from 09:00 to 17:00"
+ hint="Here you can configure an automated SMS message which is sent to the caller when this phone has a missed call"
+ >
+ </v-textarea>
</v-col>
</v-row>
</v-container>
@@ -709,6 +720,7 @@ export default Vue.extend({
id: null,
name: '',
server_id: '',
+ missed_call_auto_reply: '',
incoming_channel_id: '',
},
updatingEmailNotifications: false,
@@ -732,6 +744,7 @@ export default Vue.extend({
'message.phone.delivered',
'message.send.failed',
'message.send.expired',
+ 'message.call.missed',
'phone.heartbeat.offline',
'phone.heartbeat.online',
],
@@ -852,6 +865,7 @@ export default Vue.extend({
name: '',
server_id: '',
incoming_channel_id: '',
+ missed_call_auto_reply: '',
}
this.showDiscordEdit = true
this.resetErrors()
@@ -969,13 +983,10 @@ export default Vue.extend({
})
},
- updateUser(timezone) {
+ updateTimezone(timezone) {
this.resetErrors()
this.$store
- .dispatch('updateUser', {
- owner: this.$store.getters.getOwner,
- timezone,
- })
+ .dispatch('updateTimezone', timezone)
.then(() => {
this.$store.dispatch('addNotification', {
message: 'Timezone updated successfully',
diff --git a/web/pages/threads/_id/index.vue b/web/pages/threads/_id/index.vue
index 6d618afd..b7b643b0 100644
--- a/web/pages/threads/_id/index.vue
+++ b/web/pages/threads/_id/index.vue
@@ -103,11 +103,14 @@
>
<v-spacer v-if="isMT(message)"></v-spacer>
<v-avatar
- v-if="!isMT(message)"
+ v-if="isMo(message)"
:color="$store.getters.getThread.color"
>
<v-icon>{{ mdiAccount }}</v-icon>
</v-avatar>
+ <v-avatar v-if="isMissedCall(message)" color="#1e1e1e">
+ <v-icon large color="red">{{ mdiCallMissed }}</v-icon>
+ </v-avatar>
<v-menu v-if="isMT(message)" offset-y>
<template #activator="{ on }">
<v-btn icon text class="mt-2" v-on="on">
@@ -151,8 +154,14 @@
<v-card-text
class="text--primary text-break"
style="white-space: pre-line"
- >{{ message.content }}</v-card-text
>
+ <span v-if="!isMissedCall(message)">{{
+ message.content
+ }}</span>
+ <span v-else class="text--secondary"
+ >Missed phone call</span
+ >
+ </v-card-text>
</v-card>
<div class="d-flex">
<p class="ml-2 text--secondary caption mr-2">
@@ -304,6 +313,7 @@ import {
mdiArrowLeft,
mdiCheckAll,
mdiDelete,
+ mdiCallMissed,
mdiCheck,
mdiAlert,
mdiPackageUp,
@@ -329,6 +339,7 @@ export default Vue.extend({
mdiDotsVertical,
mdiArrowLeft,
mdiCheckAll,
+ mdiCallMissed,
mdiCheck,
mdiAlert,
mdiDelete,
@@ -436,6 +447,14 @@ export default Vue.extend({
return message.type === 'mobile-terminated'
},
+ isMo(message: Message): boolean {
+ return message.type === 'mobile-originated'
+ },
+
+ isMissedCall(message: Message): boolean {
+ return message.type === 'call/missed'
+ },
+
scrollToElement() {
const el: Element = this.$refs.messageBody as Element
if (el) {
diff --git a/web/store/index.ts b/web/store/index.ts
index b5f8523b..b8a52247 100644
--- a/web/store/index.ts
+++ b/web/store/index.ts
@@ -365,6 +365,7 @@ export const actions = {
message_expiration_seconds: parseInt(
phone.message_expiration_seconds.toString(),
),
+ missed_call_auto_reply: phone.missed_call_auto_reply,
max_send_attempts: parseInt(phone.max_send_attempts.toString()),
messages_per_minute: parseInt(phone.messages_per_minute.toString()),
})
@@ -639,6 +640,24 @@ export const actions = {
context.commit('setUser', response.data.data)
},
+ updateTimezone(
+ context: ActionContext<State, State>,
+ payload: string,
+ ): Promise<EntitiesUser> {
+ return new Promise<EntitiesUser>((resolve, reject) => {
+ axios
+ .put<ResponsesUserResponse>(`/v1/users/me`, {
+ timezone: payload ?? context.getters.getUser.timezone,
+ })
+ .then((response: AxiosResponse<ResponsesUserResponse>) => {
+ resolve(response.data.data)
+ })
+ .catch((error: AxiosError) => {
+ reject(getErrorMessages(error))
+ })
+ })
+ },
+
async updateThread(
context: ActionContext<State, State>,
payload: { threadId: string; isArchived: boolean },