Skip to content

Commit

Permalink
Fix token to send WA messages
Browse files Browse the repository at this point in the history
  • Loading branch information
norkans7 committed Apr 29, 2022
1 parent bd84397 commit aab4afa
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
43 changes: 23 additions & 20 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ type Config struct {
LogLevel string `help:"the logging level courier should use"`
Version string `help:"the version that will be used in request and response headers"`

WhatsappAdminSystemUserToken string `help:"the token of the admin system user for WhatsApp"`

// IncludeChannels is the list of channels to enable, empty means include all
IncludeChannels []string

Expand All @@ -40,26 +42,27 @@ type Config struct {
// NewConfig returns a new default configuration object
func NewConfig() *Config {
return &Config{
Backend: "rapidpro",
Domain: "localhost",
Address: "",
Port: 8080,
DB: "postgres://temba:temba@localhost/temba?sslmode=disable",
Redis: "redis://localhost:6379/15",
SpoolDir: "/var/spool/courier",
S3Endpoint: "https://s3.amazonaws.com",
S3Region: "us-east-1",
S3MediaBucket: "courier-media",
S3MediaPrefix: "/media/",
S3DisableSSL: false,
S3ForcePathStyle: false,
AWSAccessKeyID: "",
AWSSecretAccessKey: "",
FacebookApplicationSecret: "missing_facebook_app_secret",
FacebookWebhookSecret: "missing_facebook_webhook_secret",
MaxWorkers: 32,
LogLevel: "error",
Version: "Dev",
Backend: "rapidpro",
Domain: "localhost",
Address: "",
Port: 8080,
DB: "postgres://temba:temba@localhost/temba?sslmode=disable",
Redis: "redis://localhost:6379/15",
SpoolDir: "/var/spool/courier",
S3Endpoint: "https://s3.amazonaws.com",
S3Region: "us-east-1",
S3MediaBucket: "courier-media",
S3MediaPrefix: "/media/",
S3DisableSSL: false,
S3ForcePathStyle: false,
AWSAccessKeyID: "",
AWSSecretAccessKey: "",
FacebookApplicationSecret: "missing_facebook_app_secret",
FacebookWebhookSecret: "missing_facebook_webhook_secret",
WhatsappAdminSystemUserToken: "missing_whatsapp_admin_system_user_token",
MaxWorkers: 32,
LogLevel: "error",
Version: "Dev",
}
}

Expand Down
5 changes: 1 addition & 4 deletions handlers/facebookapp/facebookapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,7 @@ type wacMTResponse struct {

func (h *handler) sendCloudAPIWhatsappMsg(ctx context.Context, msg courier.Msg) (courier.MsgStatus, error) {
// can't do anything without an access token
accessToken := msg.Channel().StringConfigForKey(courier.ConfigAuthToken, "")
if accessToken == "" {
return nil, fmt.Errorf("missing access token")
}
accessToken := h.Server().Config().WhatsappAdminSystemUserToken

base, _ := url.Parse(graphURL)
path, _ := url.Parse(fmt.Sprintf("/%s/messages", msg.Channel().Address()))
Expand Down

0 comments on commit aab4afa

Please sign in to comment.