From c534d03224320df95df7eec0fb81a2ddf2d18fc9 Mon Sep 17 00:00:00 2001 From: Christopher Vollick <0@psycoti.ca> Date: Mon, 6 Feb 2023 17:08:18 -0500 Subject: [PATCH] Put Chatwoot Link in Admin Info (and link to new JID) We made a change with the "direct_targets" that made it so support no longer talks to phone numbers, but customer_blah@sgx.example.com So, we no longer need to link to the phone number version of the jid, but we now have this new one. And while we're at it we also have a ticketing system that's based on that same JID, so I'll make a link to that too. --- config-schema.dhall | 1 + config.dhall.sample | 4 +++- forms/admin_info.rb | 20 ++++++++++++-------- lib/customer_info.rb | 11 +++++++++-- test/test_helper.rb | 3 ++- 5 files changed, 27 insertions(+), 12 deletions(-) diff --git a/config-schema.dhall b/config-schema.dhall index 2096ed4eb012d7f349c7b0e8972cdbf6380e8fda..002c8195da9da23c894e89c0dc992e25e41b1276 100644 --- a/config-schema.dhall +++ b/config-schema.dhall @@ -46,6 +46,7 @@ , sip : { app : Text, realm : Text } , sip_host : Text , snikket_hosting_api : Text +, support_link : forall (customer_jid : Text) -> Text , upstream_domain : Text , web : < Inet : { interface : Text, port : Natural } | Unix : Text > , web_register : { from : Text, to : Text } diff --git a/config.dhall.sample b/config.dhall.sample index dd53b870dc021f3adc3de7cf2fb01204d432a057..33e1d2c9327b7a837a81ffd0d3b9d292aa04f2d9 100644 --- a/config.dhall.sample +++ b/config.dhall.sample @@ -86,5 +86,7 @@ in upstream_domain = "example.net", approved_domains = toMap { `example.com` = Some "customer_id" }, keepgo = Some { api_key = "", access_token = "" }, - simpleswap_api_key = "" + simpleswap_api_key = "", + support_link = \(customer_jid: Text) -> + "http://localhost:3002/app/accounts/2/contacts/custom_attributes/jid/${customer_jid}" } diff --git a/forms/admin_info.rb b/forms/admin_info.rb index a7cb70cdb328d598a2a1324fee855e870e0cfebd..9b31c1ed3c9d684481d5f02b0e5d9c1f7657d774 100644 --- a/forms/admin_info.rb +++ b/forms/admin_info.rb @@ -63,11 +63,15 @@ field( value: @admin_info.api.to_s ) -if @admin_info.info.tel - field( - var: "link", - label: "Link", - type: "jid-single", - value: "#{@admin_info.info.tel}@#{CONFIG[:upstream_domain]}" - ) -end +field( + var: "link", + label: "Link", + type: "jid-single", + value: @admin_info.backend_jid +) + +field( + var: "support_link", + label: "Support Link", + value: @admin_info.support_link +) diff --git a/lib/customer_info.rb b/lib/customer_info.rb index a9acde2ab870013fee3e8aeb322d8d8ecff00c4d..b5628072ea91daab77e1e63ed2f9058fa2b0cbdd 100644 --- a/lib/customer_info.rb +++ b/lib/customer_info.rb @@ -112,12 +112,14 @@ class AdminInfo api API call_info String trust_level String + backend_jid String end def self.for( customer, trust_level_repo: TrustLevelRepo.new, - call_attempt_repo: CallAttemptRepo.new + call_attempt_repo: CallAttemptRepo.new, + backend_repo: TrivialBackendSgxRepo.new ) PromiseHash.all( jid: customer.jid, @@ -126,7 +128,8 @@ class AdminInfo info: CustomerInfo.for(customer), api: API.for(customer), call_info: call_info(customer, call_attempt_repo), - trust_level: trust_level_repo.find(customer).then(&:to_s) + trust_level: trust_level_repo.find(customer).then(&:to_s), + backend_jid: backend_repo.get(customer.customer_id).from_jid.to_s ).then(&method(:new)) end @@ -162,4 +165,8 @@ class AdminInfo info.tel.gsub(/\A\+1/, "") ].join("/") end + + def support_link + CONFIG[:support_link].call(backend_jid) + end end diff --git a/test/test_helper.rb b/test/test_helper.rb index 260589f381e28ad473332702a11847273ed379ee..f68171e4ccf09afab54898a287b94e0a172c6a98 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -114,7 +114,8 @@ CONFIG = { bandwidth_peer: "test_peer", keepgo: { api_key: "keepgokey", access_token: "keepgotoken" }, adr: "A Mailing Address", - interac: "interac@example.com" + interac: "interac@example.com", + support_link: ->(*) { "https://support.com" } }.freeze def panic(e)