@@ -272,14 +272,12 @@ func (c *Core) InsertSubscriber(sub models.Subscriber, listIDs []int, listUUIDs
272
272
pq .Array (listUUIDs ),
273
273
subStatus ); err != nil {
274
274
if pqErr , ok := err .(* pq.Error ); ok && pqErr .Constraint == "subscribers_email_key" {
275
- return models.Subscriber {}, false , echo .NewHTTPError (http .StatusConflict ,
276
- c .i18n .T ("subscribers.emailExists" ))
275
+ return models.Subscriber {}, false , echo .NewHTTPError (http .StatusConflict , c .i18n .T ("subscribers.emailExists" ))
277
276
} else {
278
277
// return sub.Subscriber, errSubscriberExists
279
278
c .log .Printf ("error inserting subscriber: %v" , err )
280
279
return models.Subscriber {}, false , echo .NewHTTPError (http .StatusInternalServerError ,
281
- c .i18n .Ts ("globals.messages.errorCreating" ,
282
- "name" , "{globals.terms.subscriber}" , "error" , pqErrMsg (err )))
280
+ c .i18n .Ts ("globals.messages.errorCreating" , "name" , "{globals.terms.subscriber}" , "error" , pqErrMsg (err )))
283
281
}
284
282
}
285
283
@@ -337,7 +335,7 @@ func (c *Core) UpdateSubscriber(id int, sub models.Subscriber) (models.Subscribe
337
335
// UpdateSubscriberWithLists updates a subscriber's properties.
338
336
// If deleteLists is set to true, all existing subscriptions are deleted and only
339
337
// the ones provided are added or retained.
340
- func (c * Core ) UpdateSubscriberWithLists (id int , sub models.Subscriber , listIDs []int , listUUIDs []string , preconfirm , deleteLists bool ) (models.Subscriber , error ) {
338
+ func (c * Core ) UpdateSubscriberWithLists (id int , sub models.Subscriber , listIDs []int , listUUIDs []string , preconfirm , deleteLists bool ) (models.Subscriber , bool , error ) {
341
339
subStatus := models .SubscriptionStatusUnconfirmed
342
340
if preconfirm {
343
341
subStatus = models .SubscriptionStatusConfirmed
@@ -347,7 +345,7 @@ func (c *Core) UpdateSubscriberWithLists(id int, sub models.Subscriber, listIDs
347
345
attribs := []byte ("{}" )
348
346
if len (sub .Attribs ) > 0 {
349
347
if b , err := json .Marshal (sub .Attribs ); err != nil {
350
- return models.Subscriber {}, echo .NewHTTPError (http .StatusInternalServerError ,
348
+ return models.Subscriber {}, false , echo .NewHTTPError (http .StatusInternalServerError ,
351
349
c .i18n .Ts ("globals.messages.errorUpdating" ,
352
350
"name" , "{globals.terms.subscriber}" , "error" , err .Error ()))
353
351
} else {
@@ -366,21 +364,23 @@ func (c *Core) UpdateSubscriberWithLists(id int, sub models.Subscriber, listIDs
366
364
deleteLists )
367
365
if err != nil {
368
366
c .log .Printf ("error updating subscriber: %v" , err )
369
- return models.Subscriber {}, echo .NewHTTPError (http .StatusInternalServerError ,
367
+ return models.Subscriber {}, false , echo .NewHTTPError (http .StatusInternalServerError ,
370
368
c .i18n .Ts ("globals.messages.errorUpdating" , "name" , "{globals.terms.subscriber}" , "error" , pqErrMsg (err )))
371
369
}
372
370
373
371
out , err := c .GetSubscriber (sub .ID , "" , sub .Email )
374
372
if err != nil {
375
- return models.Subscriber {}, err
373
+ return models.Subscriber {}, false , err
376
374
}
377
375
376
+ hasOptin := false
378
377
if ! preconfirm && c .constants .SendOptinConfirmation {
379
378
// Send a confirmation e-mail (if there are any double opt-in lists).
380
- c .h .SendOptinConfirmation (out , listIDs )
379
+ num , _ := c .h .SendOptinConfirmation (out , listIDs )
380
+ hasOptin = num > 0
381
381
}
382
382
383
- return out , nil
383
+ return out , hasOptin , nil
384
384
}
385
385
386
386
// BlocklistSubscribers blocklists the given list of subscribers.
0 commit comments