Skip to content

Commit 805f46d

Browse files
committed
allow defining which SIM card to use to send a message. use the default SIM card if it's not explicitly defined.
1 parent 36ff818 commit 805f46d

17 files changed

Lines changed: 86 additions & 0 deletions

api/pkg/entities/message.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,17 @@ const (
6060
MessageEventNameFailed = MessageEventName("FAILED")
6161
)
6262

63+
type SIM string
64+
65+
const (
66+
// ISMS_1 use the SIM card in slot 1 to send the message
67+
ISMS_1 = SIM("ISMS")
68+
// ISMS_2 use the SIM card in slot 2 to send the message
69+
ISMS_2 = SIM("ISMS2")
70+
// DEFAULT use the SIM card configured as default communication card to send the message
71+
ISMS_DEFAULT = SIM("DEFAULT")
72+
)
73+
6374
// Message represents a message sent between 2 phone numbers
6475
type Message struct {
6576
ID uuid.UUID `json:"id" gorm:"primaryKey;type:uuid;" example:"32343a19-da5e-4b1b-a767-3298a73703cb"`
@@ -69,6 +80,11 @@ type Message struct {
6980
Content string `json:"content" example:"This is a sample text message"`
7081
Type MessageType `json:"type" example:"mobile-terminated"`
7182
Status MessageStatus `json:"status" gorm:"index:idx_messages_status" example:"pending"`
83+
// SIM is the type of event
84+
// * ISMS: use the SIM card in slot 1
85+
// * ISMS2: use the SIM card in slot 2
86+
// * DEFAULT: used the default communication SIM card
87+
SIM SIM `json:"sim" example:"DEFAULT"`
7288

7389
// SendDuration is the number of nanoseconds from when the request was received until when the mobile phone send the message
7490
SendDuration *int64 `json:"send_time" example:"133414"`

api/pkg/events/message_api_sent_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ type MessageAPISentPayload struct {
2020
Contact string `json:"contact"`
2121
RequestReceivedAt time.Time `json:"request_received_at"`
2222
Content string `json:"content"`
23+
SIM entities.SIM `json:"sim"`
2324
}

api/pkg/events/message_notification_scheduled_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ type MessageNotificationScheduledPayload struct {
1717
Owner string `json:"owner"`
1818
Contact string `json:"contact"`
1919
Content string `json:"content"`
20+
SIM entities.SIM `json:"sim"`
2021
UserID entities.UserID `json:"user_id"`
2122
PhoneID uuid.UUID `json:"phone_id"`
2223
ScheduledAt time.Time `json:"scheduled_at"`

api/pkg/events/message_phone_delivered_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ type MessagePhoneDeliveredPayload struct {
1919
UserID entities.UserID `json:"user_id"`
2020
Timestamp time.Time `json:"timestamp"`
2121
Content string `json:"content"`
22+
SIM entities.SIM `json:"sim"`
2223
}

api/pkg/events/message_phone_received_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ type MessagePhoneReceivedPayload struct {
1919
Contact string `json:"contact"`
2020
Timestamp time.Time `json:"timestamp"`
2121
Content string `json:"content"`
22+
SIM entities.SIM `json:"sim"`
2223
}

api/pkg/events/message_phone_sending_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ type MessagePhoneSendingPayload struct {
1818
Owner string `json:"owner"`
1919
Contact string `json:"contact"`
2020
Content string `json:"content"`
21+
SIM entities.SIM `json:"sim"`
2122
}

api/pkg/events/message_phone_sent_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ type MessagePhoneSentPayload struct {
1919
Contact string `json:"contact"`
2020
Timestamp time.Time `json:"timestamp"`
2121
Content string `json:"content"`
22+
SIM entities.SIM `json:"sim"`
2223
}

api/pkg/events/message_send_expired_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ type MessageSendExpiredPayload struct {
1919
UserID entities.UserID `json:"user_id"`
2020
Timestamp time.Time `json:"timestamp"`
2121
Content string `json:"content"`
22+
SIM entities.SIM `json:"sim"`
2223
}

api/pkg/events/message_send_failed_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ type MessageSendFailedPayload struct {
1919
Contact string `json:"contact"`
2020
Timestamp time.Time `json:"timestamp"`
2121
Content string `json:"content"`
22+
SIM entities.SIM `json:"sim"`
2223
}

api/pkg/events/message_send_retry_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ type MessageSendRetryPayload struct {
1919
UserID entities.UserID `json:"user_id"`
2020
Timestamp time.Time `json:"timestamp"`
2121
Content string `json:"content"`
22+
SIM entities.SIM `json:"sim"`
2223
}

0 commit comments

Comments
 (0)