From 16a1f899b52e69e1fc3a917daa91e21ad78dd36d Mon Sep 17 00:00:00 2001 From: Rowan Seymour Date: Thu, 14 Sep 2023 16:20:22 -0500 Subject: [PATCH] WIP --- core/models/assets.go | 5 +++++ core/models/channels.go | 33 +++++++++++++++++++-------------- go.mod | 2 +- go.sum | 4 ++-- 4 files changed, 27 insertions(+), 17 deletions(-) diff --git a/core/models/assets.go b/core/models/assets.go index b28c5d608..562186ba9 100644 --- a/core/models/assets.go +++ b/core/models/assets.go @@ -393,6 +393,7 @@ const ( RefreshTicketers = Refresh(1 << 14) RefreshTopics = Refresh(1 << 15) RefreshUsers = Refresh(1 << 16) + RefreshOptIns = Refresh(1 << 17) ) // GetOrgAssets creates or gets org assets for the passed in org @@ -631,6 +632,10 @@ func (a *OrgAssets) Locations() ([]assets.LocationHierarchy, error) { return a.locations, nil } +func (a *OrgAssets) OptIns() ([]assets.OptIn, error) { + return nil, nil // TODO +} + func (a *OrgAssets) Resthooks() ([]assets.Resthook, error) { return a.resthooks, nil } diff --git a/core/models/channels.go b/core/models/channels.go index dfa366bb8..ec9909371 100644 --- a/core/models/channels.go +++ b/core/models/channels.go @@ -42,20 +42,21 @@ const ( type Channel struct { // inner struct for privacy and so we don't collide with method names c struct { - ID ChannelID `json:"id"` - UUID assets.ChannelUUID `json:"uuid"` - OrgID OrgID `json:"org_id"` - Name string `json:"name"` - Address string `json:"address"` - ChannelType ChannelType `json:"channel_type"` - TPS int `json:"tps"` - Country null.String `json:"country"` - Schemes []string `json:"schemes"` - Roles []assets.ChannelRole `json:"roles"` - MatchPrefixes []string `json:"match_prefixes"` - AllowInternational bool `json:"allow_international"` - MachineDetection bool `json:"machine_detection"` - Config map[string]any `json:"config"` + ID ChannelID `json:"id"` + UUID assets.ChannelUUID `json:"uuid"` + OrgID OrgID `json:"org_id"` + Name string `json:"name"` + Address string `json:"address"` + ChannelType ChannelType `json:"channel_type"` + TPS int `json:"tps"` + Country null.String `json:"country"` + Schemes []string `json:"schemes"` + Roles []assets.ChannelRole `json:"roles"` + Features []assets.ChannelFeature `json:"features"` + MatchPrefixes []string `json:"match_prefixes"` + AllowInternational bool `json:"allow_international"` + MachineDetection bool `json:"machine_detection"` + Config map[string]any `json:"config"` } } @@ -89,6 +90,9 @@ func (c *Channel) Schemes() []string { return c.c.Schemes } // Roles returns the roles this channel supports func (c *Channel) Roles() []assets.ChannelRole { return c.c.Roles } +// Features returns the features this channel supports +func (c *Channel) Features() []assets.ChannelFeature { return c.c.Features } + // MatchPrefixes returns the prefixes we should also match when determining channel affinity func (c *Channel) MatchPrefixes() []string { return c.c.MatchPrefixes } @@ -210,6 +214,7 @@ SELECT ROW_TO_JSON(r) FROM (SELECT END FROM unnest(regexp_split_to_array(c.role,'')) AS r) ) as roles, + CASE WHEN channel_type IN ('FBA') THEN {'optins'}::text[] ELSE {}::text[] END, jsonb_extract_path(c.config, 'matching_prefixes') AS match_prefixes, jsonb_extract_path(c.config, 'allow_international') AS allow_international, jsonb_extract_path(c.config, 'machine_detection') AS machine_detection diff --git a/go.mod b/go.mod index 9c3ae73bf..79fca7d04 100644 --- a/go.mod +++ b/go.mod @@ -17,7 +17,7 @@ require ( github.com/lib/pq v1.10.9 github.com/nyaruka/ezconf v0.2.1 github.com/nyaruka/gocommon v1.41.2 - github.com/nyaruka/goflow v0.194.0 + github.com/nyaruka/goflow v0.195.0 github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d github.com/nyaruka/null/v3 v3.0.0 github.com/nyaruka/redisx v0.5.0 diff --git a/go.sum b/go.sum index c4dcf82de..c6ec4027e 100644 --- a/go.sum +++ b/go.sum @@ -84,8 +84,8 @@ github.com/nyaruka/ezconf v0.2.1 h1:TDXWoqjqYya1uhou1mAJZg7rgFYL98EB0Tb3+BWtUh0= github.com/nyaruka/ezconf v0.2.1/go.mod h1:ey182kYkw2MIi4XiWe1FR/mzI33WCmTWuceDYYxgnQw= github.com/nyaruka/gocommon v1.41.2 h1:eGHOJMu9VZhnHri7XzQQax/sW5SSGS2qwS1ORt6idEo= github.com/nyaruka/gocommon v1.41.2/go.mod h1:cJ2XmEX+FDOzBvE19IW+hG8EFVsSrNgCp7NrxAlP4Xg= -github.com/nyaruka/goflow v0.194.0 h1:7LV/f/IiGe5YXAASy10JhH4Jho6i1IYyp2xfyDaLjhE= -github.com/nyaruka/goflow v0.194.0/go.mod h1:ZC+XSZMA+R1HV3C7mfcrEYUb/SyF5BnjnonRBEPA8gM= +github.com/nyaruka/goflow v0.195.0 h1:AuoNa4w5qtRyrLc7dxvnMr1TW9DGkxpFiVy5vq3gSIw= +github.com/nyaruka/goflow v0.195.0/go.mod h1:ZC+XSZMA+R1HV3C7mfcrEYUb/SyF5BnjnonRBEPA8gM= github.com/nyaruka/librato v1.0.0 h1:Vznj9WCeC1yZXbBYyYp40KnbmXLbEkjKmHesV/v2SR0= github.com/nyaruka/librato v1.0.0/go.mod h1:pkRNLFhFurOz0QqBz6/DuTFhHHxAubWxs4Jx+J7yUgg= github.com/nyaruka/logrus_sentry v0.8.2-0.20190129182604-c2962b80ba7d h1:hyp9u36KIwbTCo2JAJ+TuJcJBc+UZzEig7RI/S5Dvkc=