Skip to content
Snippets Groups Projects
Unverified Commit 614bc36a authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Fix setting add

parent 5eb09e75
No related branches found
No related tags found
No related merge requests found
......@@ -92,9 +92,16 @@ RocketChat.settings.add = (_id, value, options = {}) ->
updateOperations.$unset = { section: 1 }
query.section = { $exists: false }
if not RocketChat.models.Settings.findOne(query)?
existantSetting = RocketChat.models.Settings.findOne(query)
if existantSetting?
if not existantSetting.editor? and updateOperations.$setOnInsert.editor?
updateOperations.$set.editor = updateOperations.$setOnInsert.editor
delete updateOperations.$setOnInsert.editor
else
updateOperations.$set.ts = new Date
return RocketChat.models.Settings.upsert { _id: _id }, updateOperations
return RocketChat.models.Settings.upsert { _id: _id }, updateOperations
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment