Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Support multiple from numbers for system SMS configs #1312

Merged
merged 1 commit into from
Dec 10, 2020

Conversation

sethvargo
Copy link
Member

This gives system administrators the ability to define a list of available SMS phone numbers. When the system SMS configuration is shared with a realm, the realm can choose the phone number from which they want to send messages.

Not pictured: the 6 hours I spent fighting gorm.

Fixes #1291

Release Note

Support multiple 'from' numbers for system SMS configs

@google-cla google-cla bot added the cla: yes Auto: added by CLA bot when all committers have signed a CLA. label Dec 10, 2020
value TEXT UNIQUE
)`,
`ALTER TABLE realms ADD COLUMN IF NOT EXISTS sms_from_number_id INTEGER`,
`ALTER TABLE realms ADD CONSTRAINT fk_sms_from_number FOREIGN KEY (sms_from_number_id) REFERENCES sms_from_numbers(id)`,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approximately here is where I lost 4 hours to gorm + AutoMigrate.

func (db *Database) CreateOrUpdateSMSFromNumbers(numbers []*SMSFromNumber) error {
ids := make([]uint, 0, len(numbers))

return db.db.Transaction(func(tx *gorm.DB) error {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I'm also crying a little bit here.

This gives system administrators the ability to define a list of available SMS phone numbers. When the system SMS configuration is shared with a realm, the realm can choose the phone number from which they want to send messages.
@sethvargo
Copy link
Member Author

/assign @mikehelmick
/assign @whaught

@google-oss-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sethvargo, whaught

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-robot google-oss-robot merged commit dcdbc54 into main Dec 10, 2020
@google-oss-robot google-oss-robot deleted the sethvargo/multi_sms branch December 10, 2020 16:41
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla: yes Auto: added by CLA bot when all committers have signed a CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow multiple SMS from numbers
4 participants