Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ db-upgrade:
goose up

db-upgrade-raw:
go run ./cmd/$(project_name)/main.go db-upgrade
go run ./cmd/$(project_name)/main.go db:migrate

run:
go run cmd/$(project_name)/main.go
Expand Down
7 changes: 4 additions & 3 deletions api/requests.http
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@baseUrl=http://localhost:3000
@cloudUrl=https://sms.capcom.me
@credentials={{$dotenv CLOUD__CREDENTIALS}}
@mobileToken={{$dotenv MOBILE__TOKEN}}
@phone={{$dotenv PHONE}}

###
Expand All @@ -13,7 +14,7 @@ Content-Type: application/json
}

###
POST {{cloudUrl}}/api/3rdparty/v1/message HTTP/1.1
POST {{baseUrl}}/api/3rdparty/v1/message HTTP/1.1
Content-Type: application/json
Authorization: Basic {{credentials}}

Expand All @@ -32,11 +33,11 @@ Authorization: Basic {{credentials}}

###
GET {{baseUrl}}/api/mobile/v1/message HTTP/1.1
Authorization: Bearer KuvE4LBXzvy8QO2ZXDDMP
Authorization: Bearer {{mobileToken}}

###
PATCH {{baseUrl}}/api/mobile/v1/message HTTP/1.1
Authorization: Bearer KuvE4LBXzvy8QO2ZXDDMP
Authorization: Bearer {{mobileToken}}
Content-Type: application/json

[
Expand Down
6 changes: 6 additions & 0 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,12 @@
"79990001234"
]
},
"simNumber": {
"description": "Номер сим-карты",
"type": "integer",
"maximum": 3,
"example": 1
},
"ttl": {
"description": "Время жизни сообщения в секундах",
"type": "integer",
Expand Down
5 changes: 5 additions & 0 deletions api/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ definitions:
maxItems: 100
minItems: 1
type: array
simNumber:
description: Номер сим-карты
example: 1
maximum: 3
type: integer
ttl:
description: Время жизни сообщения в секундах
example: 86400
Expand Down
10 changes: 10 additions & 0 deletions db/migrations/20231116233831_sim_number.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- +goose Up
-- +goose StatementBegin
ALTER TABLE `messages`
ADD `sim_number` tinyint(1) unsigned;
-- +goose StatementEnd
---
-- +goose Down
-- +goose StatementBegin
ALTER TABLE `messages` DROP `sim_number`;
-- +goose StatementEnd
1 change: 1 addition & 0 deletions internal/sms-gateway/models/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type Message struct {
Message string `gorm:"not null;type:tinytext"`
State MessageState `gorm:"not null;type:enum('Pending','Sent','Processed','Delivered','Failed');default:Pending;index:idx_messages_device_state"`
ValidUntil *time.Time `gorm:"type:datetime"`
SimNumber *uint8 `gorm:"type:tinyint(1) unsigned"`

Device Device `gorm:"foreignKey:DeviceID;constraint:OnDelete:CASCADE"`
Recipients []MessageRecipient `gorm:"foreignKey:MessageID;constraint:OnDelete:CASCADE"`
Expand Down
2 changes: 2 additions & 0 deletions internal/sms-gateway/services/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func (s *MessagesService) SelectPending(deviceID string) ([]smsgateway.Message,
Message: v.Message,
TTL: ttl,
PhoneNumbers: s.recipientsToDomain(v.Recipients),
SimNumber: v.SimNumber,
}
}

Expand Down Expand Up @@ -128,6 +129,7 @@ func (s *MessagesService) Enqeue(device models.Device, message smsgateway.Messag
ExtID: message.ID,
Message: message.Message,
ValidUntil: validUntil,
SimNumber: message.SimNumber,
Recipients: s.recipientsToModel(message.PhoneNumbers),
}
if msg.ExtID == "" {
Expand Down
1 change: 1 addition & 0 deletions pkg/smsgateway/domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type Message struct {
ID string `json:"id,omitempty" validate:"omitempty,max=36" example:"PyDmBQZZXYmyxMwED8Fzy"` // Идентификатор
Message string `json:"message" validate:"required,max=256" example:"Hello World!"` // Текст сообщения
TTL *uint64 `json:"ttl,omitempty" validate:"omitempty,min=5" example:"86400"` // Время жизни сообщения в секундах
SimNumber *uint8 `json:"simNumber,omitempty" validate:"omitempty,max=3" example:"1"` // Номер сим-карты
PhoneNumbers []string `json:"phoneNumbers" validate:"required,min=1,max=100,dive,required,min=10" example:"79990001234"` // Получатели
}

Expand Down
2 changes: 2 additions & 0 deletions web/mkdocs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Android SMS Gateway turns your Android smartphone into an SMS gateway. It's a li

## Features

- **No registration required:** No registration or email is required to create an account.
- **Send SMS programmatically:** Use our API to send messages directly from your own applications or services.
- **Supports Android 5.0 and above:** The application is compatible with Android 5.0 and later versions.
- **Message status tracking:** Monitor the status of your sent messages in real-time.
- **Starts at boot:** The application starts running as soon as your device boots up.
- **Prevents sleep mode:** Your device won't go to sleep while the application is running, ensuring continuous service.
- **Supports multiple SIM cards:** The application supports multiple SIM cards.

## Ideal For

Expand Down
7 changes: 7 additions & 0 deletions web/mkdocs/docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ You can install app to your device from prebuilt APK or by building from sources

You need an Android device with Android 5.0 (Lollipop) or above for using the application.

### Permissions

To use the application, you need to grant the following permissions:

- **SEND_SMS**: This permission is required to send SMS messages.
- **READ_PHONE_STATE**: This permission is required to select the SIM card. Optional, if you don't want to select the SIM card.

## Installation from APK

1. Navigate to the [Releases](https://github.com/capcom6/android-sms-gateway/releases) page.
Expand Down
5 changes: 5 additions & 0 deletions web/mkdocs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
mkdocs==1.5.3
mkdocs-material==9.4.8
mkdocs-material-extensions==1.3
mkdocs-minify-plugin==0.7.1
mkdocs-render-swagger-plugin==0.1.1