ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject [1/7] incubator-ponymail git commit: Use the right document type for asssessment
Date Sun, 10 Jul 2016 11:09:17 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master 3efed647f -> 272c74833


Use the right document type for asssessment

mbox_source does not equate mbox docs in terms of
tags allocated, so let's use mbox first and then switch
to source once tags have been processed.


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

Branch: refs/heads/master
Commit: 03fc55df427f3d6e33a004dd013671de2a792002
Parents: 3efed64
Author: humbedooh <humbedooh@apache.org>
Authored: Mon Jun 13 11:14:39 2016 +0200
Committer: humbedooh <humbedooh@apache.org>
Committed: Mon Jun 13 11:14:39 2016 +0200

----------------------------------------------------------------------
 site/api/source.lua | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/03fc55df/site/api/source.lua
----------------------------------------------------------------------
diff --git a/site/api/source.lua b/site/api/source.lua
index c7b2b60..45305e4 100644
--- a/site/api/source.lua
+++ b/site/api/source.lua
@@ -26,16 +26,16 @@ function handle(r)
     r.content_type = "text/plain"
     local get = r:parseargs()
     local eid = (get.id or r.path_info):gsub("\"", ""):gsub("/", "")
-    local doc = elastic.get("mbox_source", eid or "hmm")
+    local doc = elastic.get("mbox", eid or "hmm")
     
     -- Try searching by mid if not found, for backward compat
     if not doc or not doc.subject then
-        local docs = elastic.find("message-id:\"" .. r:escape(eid) .. "\"", 1, "mbox_source")
+        local docs = elastic.find("message-id:\"" .. r:escape(eid) .. "\"", 1, "mbox")
         if #docs == 1 then
             doc = docs[1]
         end
     end
-    if doc and doc.source then
+    if doc then
         local canAccess = false
         if doc.private then
             local account = user.get(r)
@@ -56,7 +56,12 @@ function handle(r)
         end
         if canAccess then
             doc.tid = doc.request_id
-            r:puts(doc.source)
+            local doc_raw = elastic.get('mbox_source', doc.request_id)
+            if doc_raw then
+                r:puts(doc_raw.source)
+            else
+                r:puts("No such email")
+            end
         else
             r:puts("You do not have access to view this email, sorry.")
         end


Mime
View raw message