Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id D1DFE200BB7 for ; Wed, 9 Nov 2016 23:31:43 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id D070B160AEB; Wed, 9 Nov 2016 22:31:43 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 23D5F160AFA for ; Wed, 9 Nov 2016 23:31:42 +0100 (CET) Received: (qmail 47050 invoked by uid 500); 9 Nov 2016 22:31:42 -0000 Mailing-List: contact commits-help@ponymail.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@ponymail.incubator.apache.org Delivered-To: mailing list commits@ponymail.incubator.apache.org Received: (qmail 47041 invoked by uid 99); 9 Nov 2016 22:31:42 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Nov 2016 22:31:42 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id BFF2918819F for ; Wed, 9 Nov 2016 22:31:41 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -6.219 X-Spam-Level: X-Spam-Status: No, score=-6.219 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-2.999] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id JmIvOG0Nj2hQ for ; Wed, 9 Nov 2016 22:31:39 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with SMTP id 14AF05F30E for ; Wed, 9 Nov 2016 22:31:37 +0000 (UTC) Received: (qmail 46933 invoked by uid 99); 9 Nov 2016 22:31:37 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Nov 2016 22:31:37 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 33377E0999; Wed, 9 Nov 2016 22:31:37 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sebb@apache.org To: commits@ponymail.incubator.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: incubator-ponymail git commit: elastic.lua index function should not auto-generate ids Date: Wed, 9 Nov 2016 22:31:37 +0000 (UTC) archived-at: Wed, 09 Nov 2016 22:31:44 -0000 Repository: incubator-ponymail Updated Branches: refs/heads/master e23c5360b -> c0bb4ebcd elastic.lua index function should not auto-generate ids This fixes #222 Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/c0bb4ebc Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/c0bb4ebc Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/c0bb4ebc Branch: refs/heads/master Commit: c0bb4ebcd8d883bb18b531b0232c1555f37f6b72 Parents: e23c536 Author: Sebb Authored: Wed Nov 9 22:31:20 2016 +0000 Committer: Sebb Committed: Wed Nov 9 22:31:20 2016 +0000 ---------------------------------------------------------------------- site/api/lib/elastic.lua | 4 ++-- site/api/lib/user.lua | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/c0bb4ebc/site/api/lib/elastic.lua ---------------------------------------------------------------------- diff --git a/site/api/lib/elastic.lua b/site/api/lib/elastic.lua index 342e57d..8f1feca 100644 --- a/site/api/lib/elastic.lua +++ b/site/api/lib/elastic.lua @@ -170,9 +170,9 @@ function update(doctype, id, query, consistency) end -- Put a new document somewhere -function index(r, id, ty, body, consistency) +function index(id, ty, body, consistency) if not id then - id = r:sha1(ty .. (math.random(1,99999999)*os.time()) .. ':' .. r:clock()) + error("id parameter must be provided", 3) end local url = config.es_url .. ty .. "/" .. id if consistency then http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/c0bb4ebc/site/api/lib/user.lua ---------------------------------------------------------------------- diff --git a/site/api/lib/user.lua b/site/api/lib/user.lua index decd446..065e835 100644 --- a/site/api/lib/user.lua +++ b/site/api/lib/user.lua @@ -62,7 +62,7 @@ function updateUser(r, cid, data) prefs = oaccount.preferences favs = oaccount.favorites end - elastic.index(r, r:sha1(cid), 'account', JSON.encode{ + elastic.index(r:sha1(cid), 'account', JSON.encode{ credentials = { uid = data.uid, email = data.email, @@ -92,7 +92,7 @@ function logoutUser(r, usr) if usr and usr.cid then local js = elastic.get('account', r:sha1(usr.cid)) js.internal.cookie = 'nil' - elastic.index(r, r:sha1(usr.cid), 'account', JSON.encode(js)) + elastic.index(r:sha1(usr.cid), 'account', JSON.encode(js)) end r:setcookie{ key = "ponymail", @@ -110,7 +110,7 @@ function savePreferences(r, usr, alts) if alts then js.credentials.altemail = usr.credentials.altemail end - elastic.index(r, r:sha1(usr.cid), 'account', JSON.encode(js)) + elastic.index(r:sha1(usr.cid), 'account', JSON.encode(js)) end end @@ -119,7 +119,7 @@ function saveFavorites(r, usr) if usr and usr.cid then local js = elastic.get('account', r:sha1(usr.cid)) js.favorites = usr.favorites - elastic.index(r, r:sha1(usr.cid), 'account', JSON.encode(js)) + elastic.index(r:sha1(usr.cid), 'account', JSON.encode(js)) end end