ponymail-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From humbed...@apache.org
Subject incubator-ponymail git commit: refactor anonymization
Date Wed, 01 Jun 2016 06:43:59 GMT
Repository: incubator-ponymail
Updated Branches:
  refs/heads/master c68e32c80 -> c20eb984e


refactor anonymization


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

Branch: refs/heads/master
Commit: c20eb984eb75b4bd2c67c4e88e0ffddcee35f016
Parents: c68e32c
Author: humbedooh <humbedooh@apache.org>
Authored: Wed Jun 1 08:43:41 2016 +0200
Committer: humbedooh <humbedooh@apache.org>
Committed: Wed Jun 1 08:43:41 2016 +0200

----------------------------------------------------------------------
 site/api/thread.lua | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/c20eb984/site/api/thread.lua
----------------------------------------------------------------------
diff --git a/site/api/thread.lua b/site/api/thread.lua
index 77883be..9d474bf 100644
--- a/site/api/thread.lua
+++ b/site/api/thread.lua
@@ -27,6 +27,20 @@ local config = require 'lib/config'
 
 local emls_thrd
 
+-- anonymizer func
+function anonymize(doc)
+    if doc.from and #doc.from > 0 then
+        doc.from = doc.from:gsub("(%S+)@(%S+)", function(a,b) return a:sub(1,2) .. "..."
.. "@" .. b end)
+    end
+    if doc.cc and #doc.cc > 0 then
+        doc.cc = doc.cc:gsub("(%S+)@(%S+)", function(a,b) return a:sub(1,2) .. "..." .. "@"
.. b end)
+    end
+    if doc.to and #doc.to > 0 then
+        doc.to = doc.to:gsub("(%S+)@(%S+)", function(a,b) return a:sub(1,2) .. "..." .. "@"
.. b end)
+    end
+    return doc
+end
+
 -- func that fetches all children of an original topic email thingy
 function fetchChildren(r, pdoc, c, biglist, rights, account)
     c = (c or 0) + 1
@@ -58,7 +72,7 @@ function fetchChildren(r, pdoc, c, biglist, rights, account)
             biglist[doc['message-id']] = true
             local mykids = fetchChildren(r, doc, c, biglist, rights, account)
             if not account and config.antispam then
-                doc.from = doc.from:gsub("(%S+)@(%S+)", function(a,b) return a:sub(1,2) ..
"..." .. "@" .. b end)
+                doc = anonymize(doc)
             end
             local dc = {
                 tid = doc.mid,
@@ -152,7 +166,7 @@ function handle(r)
         end
         if canAccess and doc and doc.mid then
             if not account and config.antispam then
-                doc.from = doc.from:gsub("(%S+)@(%S+)", function(a,b) return a:sub(1,2) ..
"..." .. "@" .. b end)
+                doc = anonymize(doc)
             end
             table.insert(emls_thrd, doc)
             doc.children = fetchChildren(r, doc, 1, nil, rights, account)


Mime
View raw message