mirror of https://github.com/gophish/gophish
Fix new records being added on completing a campaign (#2599)
There were new records with name '[Deleted]' being added when a campaign was completed. This used to happen when the resource associated with a campaign (template, page, profile) was deleted before marking the campaign as completed. The save gorm call used to upsert these values and ended up adding rogue records.pull/2631/head
parent
095a9ba20c
commit
cec2da5128
|
@ -661,7 +661,8 @@ func CompleteCampaign(id int64, uid int64) error {
|
||||||
// Mark the campaign as complete
|
// Mark the campaign as complete
|
||||||
c.CompletedDate = time.Now().UTC()
|
c.CompletedDate = time.Now().UTC()
|
||||||
c.Status = CampaignComplete
|
c.Status = CampaignComplete
|
||||||
err = db.Where("id=? and user_id=?", id, uid).Save(&c).Error
|
err = db.Model(&Campaign{}).Where("id=? and user_id=?", id, uid).
|
||||||
|
Select([]string{"completed_date", "status"}).UpdateColumns(&c).Error
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err)
|
log.Error(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue