Use standard SetCollectionAttribute method for saving email sub settings

This commit is contained in:
Matt Baer 2023-09-25 15:29:23 -04:00
parent ac40b2f733
commit d1afa44a2e

View file

@ -977,7 +977,7 @@ func (db *datastore) UpdateCollection(app *App, c *SubmittedCollection, alias st
// Update EmailSub value // Update EmailSub value
if c.EmailSubs { if c.EmailSubs {
// TODO: ensure these work with SQLite // TODO: ensure these work with SQLite
_, err = db.Exec("INSERT INTO collectionattributes (collection_id, attribute, value) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE value = ?", collID, "email_subs", "1", "1") err = db.SetCollectionAttribute(collID, "email_subs", "1")
if err != nil { if err != nil {
log.Error("Unable to insert email_subs value: %v", err) log.Error("Unable to insert email_subs value: %v", err)
return err return err
@ -994,7 +994,7 @@ func (db *datastore) UpdateCollection(app *App, c *SubmittedCollection, alias st
skipUpdate = true skipUpdate = true
} }
if !skipUpdate { if !skipUpdate {
_, err = db.Exec("INSERT INTO collectionattributes (collection_id, attribute, value) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE value = ?", collID, collAttrLetterReplyTo, *c.LetterReply, *c.LetterReply) err = db.SetCollectionAttribute(collID, collAttrLetterReplyTo, *c.LetterReply)
if err != nil { if err != nil {
log.Error("Unable to insert %s value: %v", collAttrLetterReplyTo, err) log.Error("Unable to insert %s value: %v", collAttrLetterReplyTo, err)
return err return err