You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by se...@apache.org on 2016/12/18 02:03:06 UTC
incubator-ponymail git commit: Move extractCanonEmail to utils
Repository: incubator-ponymail
Updated Branches:
refs/heads/master b78032b5c -> ff97e6726
Move extractCanonEmail to utils
Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/ff97e672
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/ff97e672
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/ff97e672
Branch: refs/heads/master
Commit: ff97e6726e748520f40dca84630a9a542c739f93
Parents: b78032b
Author: Sebb <se...@apache.org>
Authored: Sun Dec 18 02:02:54 2016 +0000
Committer: Sebb <se...@apache.org>
Committed: Sun Dec 18 02:02:54 2016 +0000
----------------------------------------------------------------------
CHANGELOG.md | 1 +
site/api/email.lua | 9 +--------
site/api/lib/utils.lua | 12 ++++++++++++
site/api/stats.lua | 13 +------------
4 files changed, 15 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ff97e672/CHANGELOG.md
----------------------------------------------------------------------
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ecf2502..daef88f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -85,6 +85,7 @@
- alts.js does not check for errors when calling preferences.lua (#304)
- An unauthorised private mail should be treated like a non-existent mail (#295)
- Move common anonymizing code to utils (#308)
+- Move extractCanonEmail to utils
## CHANGES in 0.9b:
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ff97e672/site/api/email.lua
----------------------------------------------------------------------
diff --git a/site/api/email.lua b/site/api/email.lua
index 1139f3c..1b4677c 100644
--- a/site/api/email.lua
+++ b/site/api/email.lua
@@ -83,14 +83,7 @@ function handle(r)
end
-- Or do we just want the email itself?
else
- doc.from = doc.from or "unknown"
- local eml = doc.from:match("<(.-)>") or doc.from:match("%S+@%S+") or nil
- if eml == nil and doc.from:match(".- at .- %(") then
- eml = doc.from:match("(.- at .-) %("):gsub(" at ", "@")
- doc.from = eml
- elseif eml == nil then
- eml = "unknown"
- end
+ local eml = utils.extractCanonEmail(doc.from or "unknown")
if not account then -- anonymize email address if not logged in
doc = utils.anonymizeHdrs(doc, true)
end
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ff97e672/site/api/lib/utils.lua
----------------------------------------------------------------------
diff --git a/site/api/lib/utils.lua b/site/api/lib/utils.lua
index 13e77c0..6d168bb 100644
--- a/site/api/lib/utils.lua
+++ b/site/api/lib/utils.lua
@@ -82,10 +82,22 @@ local function anonymizeHdrs(doc, from_raw)
return doc
end
+-- extract canonical email address from from field
+local function extractCanonEmail(from)
+ local eml = from:match("<(.-)>") or from:match("%S+@%S+") or nil
+ if eml == nil and from:match(".- at .- %(") then
+ eml = from:match("(.- at .-) %("):gsub(" at ", "@")
+ elseif eml == nil then
+ eml = "unknown"
+ end
+ return eml
+end
+
return {
anonymizeHdrs = anonymizeHdrs,
anonymizeBody = anonymizeBody,
anonymizeEmail = anonymizeEmail,
+ extractCanonEmail = extractCanonEmail,
findParent = findParent
}
http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/ff97e672/site/api/stats.lua
----------------------------------------------------------------------
diff --git a/site/api/stats.lua b/site/api/stats.lua
index ea524c6..cfed0ac 100644
--- a/site/api/stats.lua
+++ b/site/api/stats.lua
@@ -72,17 +72,6 @@ local function extractCanonName(from)
return name:gsub("\"", ""):gsub("%s+$", "")
end
--- extract canonical email address from from field
-local function extractCanonEmail(from)
- local eml = from:match("<(.-)>") or from:match("%S+@%S+") or nil
- if eml == nil and from:match(".- at .- %(") then
- eml = from:match("(.- at .-) %("):gsub(" at ", "@")
- elseif eml == nil then
- eml = "unknown"
- end
- return eml
-end
-
function handle(r)
cross.contentType(r, "application/json")
local t = {}
@@ -399,7 +388,7 @@ function handle(r)
tnow = r:clock()
for x,y in pairs (doc.aggregations.from.buckets) do
- local eml = extractCanonEmail(y.key)
+ local eml = utils.extractCanonEmail(y.key)
local gravatar = r:md5(eml:lower())
local name = extractCanonName(y.key)
table.insert(top10, {