Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rowanseymour committed Sep 14, 2023
1 parent 8ba6ad2 commit 16a1f89
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 17 deletions.
5 changes: 5 additions & 0 deletions core/models/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down
33 changes: 19 additions & 14 deletions core/models/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
}

Expand Down Expand Up @@ -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 }

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down

0 comments on commit 16a1f89

Please sign in to comment.