mirror of
https://github.com/knadh/listmonk.git
synced 2025-11-01 11:36:19 +08:00
Suppress optin e-mail send errors on subscriber insert/edit APIs.
This commit is contained in:
parent
fcbebc272b
commit
81d05e4dd6
4 changed files with 10 additions and 10 deletions
|
|
@ -740,7 +740,7 @@ func (a *App) processSubForm(c echo.Context) (bool, error) {
|
|||
Name: req.Name,
|
||||
Email: req.Email,
|
||||
Status: models.SubscriberStatusEnabled,
|
||||
}, nil, listUUIDs, false)
|
||||
}, nil, listUUIDs, false, true)
|
||||
if err == nil {
|
||||
return hasOptin, nil
|
||||
}
|
||||
|
|
@ -757,7 +757,7 @@ func (a *App) processSubForm(c echo.Context) (bool, error) {
|
|||
}
|
||||
|
||||
// Update the subscriber's subscriptions in the DB.
|
||||
_, hasOptin, err := a.core.UpdateSubscriberWithLists(sub.ID, sub, nil, listUUIDs, false, false)
|
||||
_, hasOptin, err := a.core.UpdateSubscriberWithLists(sub.ID, sub, nil, listUUIDs, false, false, true)
|
||||
if err == nil {
|
||||
return hasOptin, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,7 +217,7 @@ func (a *App) CreateSubscriber(c echo.Context) error {
|
|||
listIDs := user.FilterListsByPerm(auth.PermTypeManage, req.Lists)
|
||||
|
||||
// Insert the subscriber into the DB.
|
||||
sub, _, err := a.core.InsertSubscriber(req.Subscriber, listIDs, nil, req.PreconfirmSubs)
|
||||
sub, _, err := a.core.InsertSubscriber(req.Subscriber, listIDs, nil, req.PreconfirmSubs, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -256,7 +256,7 @@ func (a *App) UpdateSubscriber(c echo.Context) error {
|
|||
|
||||
// Update the subscriber in the DB.
|
||||
id := getID(c)
|
||||
out, _, err := a.core.UpdateSubscriberWithLists(id, req.Subscriber, listIDs, nil, req.PreconfirmSubs, true)
|
||||
out, _, err := a.core.UpdateSubscriberWithLists(id, req.Subscriber, listIDs, nil, req.PreconfirmSubs, true, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ describe('Login ', () => {
|
|||
cy.get('tbody tr').should('have.length', 2);
|
||||
cy.get('tbody tr:nth-child(1) [data-cy=btn-edit]').should('exist');
|
||||
cy.get('tbody tr:nth-child(1) [data-cy=btn-delete]').should('exist');
|
||||
cy.get('tbody tr:nth-child(2) [data-cy=btn-edit]').should('not.exist');
|
||||
cy.get('tbody tr:nth-child(2) [data-cy=btn-delete]').should('not.exist');
|
||||
cy.get('tbody tr:nth-child(2) [data-cy=btn-edit]').should('exist');
|
||||
cy.get('tbody tr:nth-child(2) [data-cy=btn-delete]').should('exist');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ func (c *Core) ExportSubscribers(searchStr, query string, subIDs, listIDs []int,
|
|||
// InsertSubscriber inserts a subscriber and returns the ID. The first bool indicates if
|
||||
// it was a new subscriber, and the second bool indicates if the subscriber was sent an optin confirmation.
|
||||
// bool = optinSent?
|
||||
func (c *Core) InsertSubscriber(sub models.Subscriber, listIDs []int, listUUIDs []string, preconfirm bool) (models.Subscriber, bool, error) {
|
||||
func (c *Core) InsertSubscriber(sub models.Subscriber, listIDs []int, listUUIDs []string, preconfirm, assertOptin bool) (models.Subscriber, bool, error) {
|
||||
uu, err := uuid.NewV4()
|
||||
if err != nil {
|
||||
c.log.Printf("error generating UUID: %v", err)
|
||||
|
|
@ -325,7 +325,7 @@ func (c *Core) InsertSubscriber(sub models.Subscriber, listIDs []int, listUUIDs
|
|||
if !preconfirm && c.consts.SendOptinConfirmation {
|
||||
// Send a confirmation e-mail (if there are any double opt-in lists).
|
||||
num, err := c.h.SendOptinConfirmation(out, listIDs)
|
||||
if err != nil {
|
||||
if assertOptin && err != nil {
|
||||
return out, hasOptin, err
|
||||
}
|
||||
|
||||
|
|
@ -372,7 +372,7 @@ func (c *Core) UpdateSubscriber(id int, sub models.Subscriber) (models.Subscribe
|
|||
// UpdateSubscriberWithLists updates a subscriber's properties.
|
||||
// If deleteLists is set to true, all existing subscriptions are deleted and only
|
||||
// the ones provided are added or retained.
|
||||
func (c *Core) UpdateSubscriberWithLists(id int, sub models.Subscriber, listIDs []int, listUUIDs []string, preconfirm, deleteLists bool) (models.Subscriber, bool, error) {
|
||||
func (c *Core) UpdateSubscriberWithLists(id int, sub models.Subscriber, listIDs []int, listUUIDs []string, preconfirm, deleteLists, assertOptin bool) (models.Subscriber, bool, error) {
|
||||
subStatus := models.SubscriptionStatusUnconfirmed
|
||||
if preconfirm {
|
||||
subStatus = models.SubscriptionStatusConfirmed
|
||||
|
|
@ -414,7 +414,7 @@ func (c *Core) UpdateSubscriberWithLists(id int, sub models.Subscriber, listIDs
|
|||
if !preconfirm && c.consts.SendOptinConfirmation {
|
||||
// Send a confirmation e-mail (if there are any double opt-in lists).
|
||||
num, err := c.h.SendOptinConfirmation(out, listIDs)
|
||||
if err != nil {
|
||||
if assertOptin && err != nil {
|
||||
return out, hasOptin, err
|
||||
}
|
||||
hasOptin = num > 0
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue