ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject incubator-ponymail git commit: elastic.lua index function should not auto-generate ids
Date Wed, 09 Nov 2016 22:31:37 GMT
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 <sebb@apache.org>
Authored: Wed Nov 9 22:31:20 2016 +0000
Committer: Sebb <sebb@apache.org>
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
 


Mime
View raw message