diff options
author | Koren Lev <korenlev@gmail.com> | 2017-09-06 19:47:54 +0300 |
---|---|---|
committer | Koren Lev <korenlev@gmail.com> | 2017-09-06 19:47:54 +0300 |
commit | fc2702ba260b7a8705ee9f2d1f606af8dfa768da (patch) | |
tree | 1a9be5648c0148a0624de550351b5dfe75b6c5d4 /ui/imports/api/configurations/methods.js | |
parent | 7e0fce9122cc61aef397c7a4e2780fb018404513 (diff) |
ui updates
Change-Id: I2d3f87e34a74ce21bbb9e3df989b6527337b7228
Signed-off-by: Koren Lev <korenlev@gmail.com>
Diffstat (limited to 'ui/imports/api/configurations/methods.js')
-rw-r--r-- | ui/imports/api/configurations/methods.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ui/imports/api/configurations/methods.js b/ui/imports/api/configurations/methods.js new file mode 100644 index 0000000..7366e3e --- /dev/null +++ b/ui/imports/api/configurations/methods.js @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////////////// +// Copyright (c) 2017 Koren Lev (Cisco Systems), Yaron Yogev (Cisco Systems) and others / +// / +// All rights reserved. This program and the accompanying materials / +// are made available under the terms of the Apache License, Version 2.0 / +// which accompanies this distribution, and is available at / +// http://www.apache.org/licenses/LICENSE-2.0 / +///////////////////////////////////////////////////////////////////////////////////////// +import { ValidatedMethod } from 'meteor/mdg:validated-method'; +import { Configurations } from '/imports/api/configurations/configurations'; +import * as R from 'ramda'; + +export const save = new ValidatedMethod({ + name: 'configurations.save', + validate: Configurations.simpleSchema() + .pick([ + 'messages_view_backward_delta' + ]).validator({ clean: true, filter: false }), + run({ + messages_view_backward_delta + }) { + + let userId = this.userId; + let conf = Configurations.findOne({ user_id: userId }); + + if (conf) { + Configurations.update({ _id: conf._id}, { $set: { + messages_view_backward_delta: messages_view_backward_delta + }}); + } else { + let item = Configurations.schema.clean({}); + item = R.merge(item, { + user_id: userId, + messages_view_backward_delta: messages_view_backward_delta + }); + Configurations.insert(item); + } + } +}); |