Skip to content

Commit

Permalink
Add optional requestID comment
Browse files Browse the repository at this point in the history
  • Loading branch information
AchoArnold committed Jul 17, 2023
1 parent c2b21ed commit abc0c64
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 23 deletions.
3 changes: 3 additions & 0 deletions android/app/src/main/java/com/httpsms/LoginActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class LoginActivity : AppCompatActivity() {
override fun onResume() {
super.onResume()
setPhoneNumber()
disableSim2()
}

private fun registerListeners() {
Expand All @@ -56,6 +57,7 @@ class LoginActivity : AppCompatActivity() {
sim2Layout.visibility = LinearLayout.VISIBLE
return
}
Timber.d("single sim detected")
val sim2Layout = findViewById<LinearLayout>(R.id.loginPhoneNumberLayoutSIM2)
sim2Layout.visibility = View.GONE
}
Expand Down Expand Up @@ -108,6 +110,7 @@ class LoginActivity : AppCompatActivity() {
var permissions = arrayOf(
Manifest.permission.SEND_SMS,
Manifest.permission.RECEIVE_SMS,
Manifest.permission.READ_PHONE_STATE,
Manifest.permission.READ_SMS,
)

Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/java/com/httpsms/SmsManagerService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.os.Build
import android.telephony.SmsManager
import android.telephony.SubscriptionManager
import androidx.core.app.ActivityCompat
import timber.log.Timber


class SmsManagerService {
Expand All @@ -27,6 +28,7 @@ class SmsManagerService {
fun isDualSIM(context: Context) : Boolean {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED
) {
Timber.w("cannot check if dual sim, no permission")
return false
}
val localSubscriptionManager: SubscriptionManager = if (Build.VERSION.SDK_INT < 31) {
Expand Down
17 changes: 9 additions & 8 deletions api/pkg/events/message_send_expired_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ const EventTypeMessageSendExpired = "message.send.expired"

// MessageSendExpiredPayload is the payload of the EventTypeMessageSendExpired event
type MessageSendExpiredPayload struct {
MessageID uuid.UUID `json:"message_id"`
Owner string `json:"owner"`
RequestID *string `json:"request_id"`
Contact string `json:"contact"`
UserID entities.UserID `json:"user_id"`
Timestamp time.Time `json:"timestamp"`
Content string `json:"content"`
SIM entities.SIM `json:"sim"`
MessageID uuid.UUID `json:"message_id"`
Owner string `json:"owner"`
SendAttemptCount uint `json:"send_attempt_count"`
RequestID *string `json:"request_id"`
Contact string `json:"contact"`
UserID entities.UserID `json:"user_id"`
Timestamp time.Time `json:"timestamp"`
Content string `json:"content"`
SIM entities.SIM `json:"sim"`
}
10 changes: 6 additions & 4 deletions api/pkg/requests/message_bulk_send_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
// MessageBulkSend is the payload for sending bulk SMS messages
type MessageBulkSend struct {
request
From string `json:"from" example:"+18005550199"`
To []string `json:"to" example:"+18005550100,+18005550100"`
RequestID string `json:"request_id" example:"153554b5-ae44-44a0-8f4f-7bbac5657ad4" validate:"optional"`
Content string `json:"content" example:"This is a sample text message"`
From string `json:"from" example:"+18005550199"`
To []string `json:"to" example:"+18005550100,+18005550100"`
Content string `json:"content" example:"This is a sample text message"`

// RequestID is an optional parameter used to track a request from the client's perspective
RequestID string `json:"request_id" example:"153554b5-ae44-44a0-8f4f-7bbac5657ad4" validate:"optional"`
}

// Sanitize sets defaults to MessageReceive
Expand Down
8 changes: 5 additions & 3 deletions api/pkg/requests/message_send_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import (
// MessageSend is the payload for sending and SMS message
type MessageSend struct {
request
From string `json:"from" example:"+18005550199"`
To string `json:"to" example:"+18005550100"`
From string `json:"from" example:"+18005550199"`
To string `json:"to" example:"+18005550100"`
Content string `json:"content" example:"This is a sample text message"`

// RequestID is an optional parameter used to track a request from the client's perspective
RequestID string `json:"request_id" example:"153554b5-ae44-44a0-8f4f-7bbac5657ad4" validate:"optional"`
Content string `json:"content" example:"This is a sample text message"`
}

// Sanitize sets defaults to MessageReceive
Expand Down
17 changes: 9 additions & 8 deletions api/pkg/services/message_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -668,14 +668,15 @@ func (service *MessageService) CheckExpired(ctx context.Context, params MessageC
}

event, err := service.createMessageSendExpiredEvent(params.Source, events.MessageSendExpiredPayload{
MessageID: message.ID,
Owner: message.Owner,
Contact: message.Contact,
RequestID: message.RequestID,
UserID: message.UserID,
Timestamp: time.Now().UTC(),
Content: message.Content,
SIM: message.SIM,
MessageID: message.ID,
Owner: message.Owner,
Contact: message.Contact,
RequestID: message.RequestID,
SendAttemptCount: message.SendAttemptCount,
UserID: message.UserID,
Timestamp: time.Now().UTC(),
Content: message.Content,
SIM: message.SIM,
})
if err != nil {
msg := fmt.Sprintf("cannot create event [%s] for message with id [%s]", events.EventTypeMessageSendExpired, params.MessageID)
Expand Down

0 comments on commit abc0c64

Please sign in to comment.