Vishal 1 éve
szülő
commit
b8100b1273
1 módosított fájl, 11 hozzáadás és 11 törlés
  1. 11 11
      server/pkg/controller/mailing_lists.go

+ 11 - 11
server/pkg/controller/mailing_lists.go

@@ -13,23 +13,23 @@ import (
 	"github.com/spf13/viper"
 	"github.com/spf13/viper"
 )
 )
 
 
-// ZohoMailingListsController is used to keeping the external mailing lists in sync
+// MailingListsController is used to keeping the external mailing lists in sync
 // with customer email changes.
 // with customer email changes.
 //
 //
-// ZohoMailingListsController contains methods for keeping external mailing lists in
+// MailingListsController contains methods for keeping external mailing lists in
 // sync when new users sign up, or update their email, or delete their account.
 // sync when new users sign up, or update their email, or delete their account.
 // Currently, these mailing lists are hosted on Zoho Campaigns.
 // Currently, these mailing lists are hosted on Zoho Campaigns.
 //
 //
 // See also: Syncing emails with Zoho Campaigns
 // See also: Syncing emails with Zoho Campaigns
-type ZohoMailingListsController struct {
+type MailingListsController struct {
 	zohoAccessToken string
 	zohoAccessToken string
 	zohoListKey     string
 	zohoListKey     string
 	zohoTopicIds    string
 	zohoTopicIds    string
 	zohoCredentials zoho.Credentials
 	zohoCredentials zoho.Credentials
 }
 }
 
 
-// Return a new instance of ZohoMailingListsController
-func NewZohoMailingListsController() *ZohoMailingListsController {
+// Return a new instance of MailingListsController
+func NewMailingListsController() *MailingListsController {
 	zohoCredentials := zoho.Credentials{
 	zohoCredentials := zoho.Credentials{
 		ClientID:     viper.GetString("zoho.client-id"),
 		ClientID:     viper.GetString("zoho.client-id"),
 		ClientSecret: viper.GetString("zoho.client-secret"),
 		ClientSecret: viper.GetString("zoho.client-secret"),
@@ -58,7 +58,7 @@ func NewZohoMailingListsController() *ZohoMailingListsController {
 	// we'll use the refresh token to create an access token on demand.
 	// we'll use the refresh token to create an access token on demand.
 	zohoAccessToken := viper.GetString("zoho.access_token")
 	zohoAccessToken := viper.GetString("zoho.access_token")
 
 
-	return &ZohoMailingListsController{
+	return &MailingListsController{
 		zohoCredentials: zohoCredentials,
 		zohoCredentials: zohoCredentials,
 		zohoListKey:     zohoListKey,
 		zohoListKey:     zohoListKey,
 		zohoTopicIds:    zohoTopicIds,
 		zohoTopicIds:    zohoTopicIds,
@@ -101,7 +101,7 @@ func NewListmonkMailingListsController() *ListmonkMailingListsController {
 // that can be later updated or deleted via their API. So instead, we maintain
 // that can be later updated or deleted via their API. So instead, we maintain
 // the email addresses of our customers in a Zoho Campaign "list", and subscribe
 // the email addresses of our customers in a Zoho Campaign "list", and subscribe
 // or unsubscribe them to this list.
 // or unsubscribe them to this list.
-func (c *ZohoMailingListsController) Subscribe(email string) error {
+func (c *MailingListsController) Subscribe(email string) error {
 	if c.shouldSkipZoho() {
 	if c.shouldSkipZoho() {
 		return stacktrace.Propagate(ente.ErrNotImplemented, "")
 		return stacktrace.Propagate(ente.ErrNotImplemented, "")
 	}
 	}
@@ -121,7 +121,7 @@ func (c *ZohoMailingListsController) Subscribe(email string) error {
 // Unsubscribe the given email address to our default Zoho Campaigns list.
 // Unsubscribe the given email address to our default Zoho Campaigns list.
 //
 //
 // See: [Note: Syncing emails with Zoho Campaigns]
 // See: [Note: Syncing emails with Zoho Campaigns]
-func (c *ZohoMailingListsController) Unsubscribe(email string) error {
+func (c *MailingListsController) Unsubscribe(email string) error {
 	if c.shouldSkipZoho() {
 	if c.shouldSkipZoho() {
 		return stacktrace.Propagate(ente.ErrNotImplemented, "")
 		return stacktrace.Propagate(ente.ErrNotImplemented, "")
 	}
 	}
@@ -130,9 +130,9 @@ func (c *ZohoMailingListsController) Unsubscribe(email string) error {
 	return c.doListActionZoho("listunsubscribe", email)
 	return c.doListActionZoho("listunsubscribe", email)
 }
 }
 
 
-// shouldSkipZoho checks if the ZohoMailingListsController should be skipped
+// shouldSkipZoho checks if the MailingListsController should be skipped
 // due to missing credentials.
 // due to missing credentials.
-func (c *ZohoMailingListsController) shouldSkipZoho() bool {
+func (c *MailingListsController) shouldSkipZoho() bool {
 	if c.zohoCredentials.RefreshToken == "" {
 	if c.zohoCredentials.RefreshToken == "" {
 		log.Info("Skipping Zoho mailing list update because credentials are not configured")
 		log.Info("Skipping Zoho mailing list update because credentials are not configured")
 		return true
 		return true
@@ -142,7 +142,7 @@ func (c *ZohoMailingListsController) shouldSkipZoho() bool {
 
 
 // Both the listsubscribe and listunsubscribe Zoho Campaigns API endpoints work
 // Both the listsubscribe and listunsubscribe Zoho Campaigns API endpoints work
 // similarly, so use this function to keep the common code.
 // similarly, so use this function to keep the common code.
-func (c *ZohoMailingListsController) doListActionZoho(action string, email string) error {
+func (c *MailingListsController) doListActionZoho(action string, email string) error {
 	// Query escape the email so that any pluses get converted to %2B.
 	// Query escape the email so that any pluses get converted to %2B.
 	escapedEmail := url.QueryEscape(email)
 	escapedEmail := url.QueryEscape(email)
 	contactInfo := fmt.Sprintf("{Contact+Email: \"%s\"}", escapedEmail)
 	contactInfo := fmt.Sprintf("{Contact+Email: \"%s\"}", escapedEmail)