You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ponymail.apache.org by hu...@apache.org on 2021/03/29 13:10:45 UTC

[incubator-ponymail-foal] 08/19: add audit trail when indexing email

This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit a9607d164a4f8cea08f701f2a641872df9e33a23
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Mon Mar 29 10:27:20 2021 +0200

    add audit trail when indexing email
---
 tools/archiver.py | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/tools/archiver.py b/tools/archiver.py
index eab73fa..a940d2f 100755
--- a/tools/archiver.py
+++ b/tools/archiver.py
@@ -568,6 +568,21 @@ class Archiver(object):  # N.B. Also used by import-mbox.py
                     "source": mbox_source(raw_message),
                 },
             )
+
+            # Write to audit log
+            elastic.index(
+                index=elastic.db_auditlog,
+                body={
+                    "date": time.strftime("%Y/%m/%d %H:%M:%S", time.gmtime(time.time())),
+                    "action": "index",
+                    "remote": "internal",
+                    "author": "archiver.py",
+                    "target": ojson["mid"],
+                    "lid": lid,
+                    "log": f"Indexed email {ojson['message-id']} for {lid} as {ojson['mid']}",
+                }
+            )
+
         # If we have a dump dir and ES failed, push to dump dir instead as a JSON object
         # We'll leave it to another process to pick up the slack.
         except Exception as err: