Split direct sources/direct targets

Stephen Paul Weber created

Thus allowing multiple JIDs to be treated as "direct inputs" for a given number,
such as cronjobs sending notifications from support.

Change summary

config-schema.dhall | 1 +
config.dhall.sample | 3 +++
sgx_jmp.rb          | 6 ++++++
3 files changed, 10 insertions(+)

Detailed changes

config-schema.dhall 🔗

@@ -15,6 +15,7 @@
 , component : { jid : Text, secret : Text }
 , credit_card_url : forall (jid : Text) -> forall (customer_id : Text) -> Text
 , creds : { account : Text, password : Text, username : Text }
+, direct_sources : List { mapKey : Text, mapValue : Text }
 , direct_targets : List { mapKey : Text, mapValue : Text }
 , electrum : { rpc_password : Text, rpc_uri : Text, rpc_username : Text }
 , electrum_notify_url :

config.dhall.sample 🔗

@@ -87,6 +87,9 @@ in
 	direct_targets = toMap {
 		`+15551234567` = "support@example.com"
 	},
+	direct_sources = toMap {
+		`support@example.com` = "+15551234567"
+	},
 	keep_area_codes = ["555"],
 	keep_area_codes_in = { account = "", site_id = "", sip_peer_id = "" },
 	snikket_hosting_api = "",

sgx_jmp.rb 🔗

@@ -367,7 +367,13 @@ CONFIG[:direct_targets].each do |(tel, jid)|
 			BLATHER << m
 		}
 	end
+end
 
+CONFIG[:direct_sources].each do |(jid, tel)|
+	customer_repo = CustomerRepo.new(
+		sgx_repo: TrivialBackendSgxRepo.new(jid: jid),
+		set_user: Sentry.method(:set_user)
+	)
 	message to: /\Acustomer_/, from: /\A#{Regexp.escape(jid)}\/?/ do |m|
 		customer_repo.find(m.to.node.delete_prefix("customer_")).then { |customer|
 			m.from = "#{tel}@sgx-jmp" # stanza_to will fix domain