Skip to content

📝 Add docstrings to feature/add-messages-priority #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
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: 2 additions & 0 deletions internal/sms-gateway/handlers/converters/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"github.com/android-sms-gateway/server/internal/sms-gateway/modules/messages"
)

// MessageToDTO converts a messages.MessageOut into an smsgateway.MobileMessage by mapping corresponding fields.
// It transfers all relevant message details—including ID, Message, SimNumber, WithDeliveryReport, IsEncrypted, PhoneNumbers, TTL, ValidUntil, and Priority—and assigns the CreatedAt timestamp from the input message.
func MessageToDTO(m messages.MessageOut) smsgateway.MobileMessage {
return smsgateway.MobileMessage{
Message: smsgateway.Message{
Expand Down
2 changes: 2 additions & 0 deletions internal/sms-gateway/modules/messages/converters.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/capcom6/go-helpers/slices"
)

// messageToDomain converts a models.Message to a MessageOut domain object. It maps the input message’s fields—including the external ID, text, recipient phone numbers (converted via recipientToDomain), encryption flag, SIM number, delivery report indicator, and priority—to the corresponding fields in MessageOut. If the input specifies a ValidUntil timestamp, the function computes a non-negative TTL (time-to-live) in seconds relative to the current time and assigns it. The output also preserves the original creation timestamp.
func messageToDomain(input models.Message) MessageOut {
var ttl *uint64 = nil
if input.ValidUntil != nil {
Expand All @@ -32,6 +33,7 @@ func messageToDomain(input models.Message) MessageOut {
}
}

// RecipientToDomain extracts and returns the phone number from the given MessageRecipient.
func recipientToDomain(input models.MessageRecipient) string {
return input.PhoneNumber
}