Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added mailchimp subscriber for sandbox #228

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ type Configuration struct {
GITHUB_CLIENT_ID string
GITHUB_CLIENT_SECRET string
SANDBOX_REDIRECT_URI string
POISON_MSGS_RETENTION_IN_HOURS int
POISON_MSGS_RETENTION_IN_HOURS int
MAILCHIMP_KEY string
MAILCHIMP_LIST_ID string
}

func GetConfig() Configuration {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ require (
github.com/google/gofuzz v1.1.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect
github.com/hanzoai/gochimp3 v0.0.0-20210305004051-da66ea724147 // indirect
github.com/imdario/mergo v0.3.5 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hanzoai/gochimp3 v0.0.0-20210305004051-da66ea724147 h1:gfRXBgmkTMt7yuwW/ugBjbd+c0eoP++0otxdAePhY2U=
github.com/hanzoai/gochimp3 v0.0.0-20210305004051-da66ea724147/go.mod h1:zJr4NZygb2gyqkQpZ2Yf/UzbOhIhVfLCj8ST925KPrI=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
Expand Down
21 changes: 21 additions & 0 deletions handlers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/dgrijalva/jwt-go"
"github.com/gin-gonic/gin"
"github.com/hanzoai/gochimp3"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/primitive"
"go.mongodb.org/mongo-driver/mongo"
Expand Down Expand Up @@ -148,6 +149,26 @@ func (sbh SandboxHandler) Login(c *gin.Context) {
AvatarId: 1,
ProfilePic: profilePic,
}

mailchimpClient := gochimp3.New(configuration.MAILCHIMP_KEY)

mailchimpListID := configuration.MAILCHIMP_LIST_ID

mailchimpList, err := mailchimpClient.GetList(mailchimpListID, nil)
if err != nil {
logger.Error("Login(Sandbox) error: " + err.Error())
}

mailchimpReq := &gochimp3.MemberRequest{
EmailAddress: email,
Status: "subscribed",
Tags: []string{"Sandbox"},
}

if _, err := mailchimpList.CreateMember(mailchimpReq); err != nil {
logger.Error("Login(Sandbox) error: " + err.Error())
}

_, err = sandboxUsersCollection.InsertOne(context.TODO(), user)
if err != nil {
logger.Error("Login(Sandbox) error: " + err.Error())
Expand Down