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: useless conditional when fetching id parameter
Date Tue, 24 Jan 2017 17:43:22 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master ebb268e12 -> 02b982697


useless conditional when fetching id parameter

This fixes #353

Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/02b98269
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/02b98269
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/02b98269

Branch: refs/heads/master
Commit: 02b98269706b51a8904dbda914147b6b8b2a4ffd
Parents: ebb268e
Author: Sebb <sebb@apache.org>
Authored: Tue Jan 24 17:43:10 2017 +0000
Committer: Sebb <sebb@apache.org>
Committed: Tue Jan 24 17:43:10 2017 +0000

----------------------------------------------------------------------
 CHANGELOG.md        | 1 +
 site/api/email.lua  | 6 +++++-
 site/api/source.lua | 6 +++++-
 site/api/thread.lua | 6 +++++-
 4 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/02b98269/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9031a07..e8d0d16 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -133,6 +133,7 @@
 - stats.lua first/last dates don't always agree with visible mails (#350)
 - Use constant for max list count instead of 500000 (#352)
 - Tighten wildcard searches to only search in the same domain level (#348)
+- useless conditional when fetching id parameter (#353)
 
 
 ## CHANGES in 0.9b:

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/02b98269/site/api/email.lua
----------------------------------------------------------------------
diff --git a/site/api/email.lua b/site/api/email.lua
index 733cffb..8bd0888 100644
--- a/site/api/email.lua
+++ b/site/api/email.lua
@@ -28,8 +28,12 @@ local utils = require 'lib/utils'
 function handle(r)
     cross.contentType(r, "application/json")
     local get = r:parseargs()
+    -- get the parameter (if any) and tidy it up
     local eid = (get.id or ""):gsub("\"", "")
-    local doc = elastic.get("mbox", eid or "hmm", true)
+    -- If it is the empty string then set it to "1" so ES doesn't barf
+    -- N.B. ?id is treated as ?id=1
+    if #eid == 0 then eid = "1" end
+    local doc = elastic.get("mbox", eid, true)
     
     -- Try searching by original source mid if not found, for backward compat
     if not doc or not doc.mid then

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/02b98269/site/api/source.lua
----------------------------------------------------------------------
diff --git a/site/api/source.lua b/site/api/source.lua
index 128b713..178a6e8 100644
--- a/site/api/source.lua
+++ b/site/api/source.lua
@@ -26,8 +26,12 @@ local utils = require 'lib/utils'
 function handle(r)
     cross.contentType(r, "text/plain")
     local get = r:parseargs()
+    -- get the parameter (if any) and tidy it up
     local eid = (get.id or r.path_info):gsub("\"", ""):gsub("/", "")
-    local doc = elastic.get("mbox", eid or "hmm", true)
+    -- If it is the empty string then set it to "1" so ES doesn't barf
+    -- N.B. ?id is treated as ?id=1
+    if #eid == 0 then eid = "1" end
+    local doc = elastic.get("mbox", eid, true)
     
     -- Try searching by mid if not found, for backward compat
     if not doc or not doc.mid then

http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/02b98269/site/api/thread.lua
----------------------------------------------------------------------
diff --git a/site/api/thread.lua b/site/api/thread.lua
index 9c2f737..4065c65 100644
--- a/site/api/thread.lua
+++ b/site/api/thread.lua
@@ -72,8 +72,12 @@ function handle(r)
     cross.contentType(r, "application/json")
     local now = r:clock()
     local get = r:parseargs()
+    -- get the parameter (if any) and tidy it up
     local eid = (get.id or ""):gsub("\"", "")
-    local doc = elastic.get("mbox", eid or "hmm", true)
+    -- If it is the empty string then set it to "1" so ES doesn't barf
+    -- N.B. ?id is treated as ?id=1
+    if #eid == 0 then eid = "1" end
+    local doc = elastic.get("mbox", eid, true)
     emls_thrd = {}
     -- Try searching by mid if not found, for backward compat
     if not doc or not doc.mid then


Mime
View raw message