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/10/14 17:59:44 UTC

[incubator-ponymail-foal] branch master updated: Support old shortened IDs from pony 0.10

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


The following commit(s) were added to refs/heads/master by this push:
     new 5bef983  Support old shortened IDs from pony 0.10
5bef983 is described below

commit 5bef983dc95caa68c7d26168f08b0892faeb37b3
Author: Daniel Gruno <hu...@apache.org>
AuthorDate: Thu Oct 14 19:56:38 2021 +0200

    Support old shortened IDs from pony 0.10
---
 server/plugins/messages.py | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/server/plugins/messages.py b/server/plugins/messages.py
index 700e861..88e3558 100644
--- a/server/plugins/messages.py
+++ b/server/plugins/messages.py
@@ -39,6 +39,7 @@ import plugins.database
 
 PYPONY_RE_PREFIX = re.compile(r"^([a-zA-Z]+:\s*)+")
 DATABASE_NOT_CONNECTED = "Database not connected!"
+OLD_SHORTENED_ID_LENGTH = 18
 
 mbox_cache_privacy: typing.Dict[str, bool] = {}
 
@@ -197,6 +198,10 @@ async def get_email(
             doc = await session.database.get(index=doctype, id=permalink)
         # Email not found through primary ID, look for other permalinks?
         except plugins.database.DBError:
+            # If using old shortened hex IDs, regexp for them instead of a direct match
+            if len(permalink) == OLD_SHORTENED_ID_LENGTH and re.match(r"^[a-f0-9]+$", permalink):
+                permalink += ".+"
+                aggtype = "regexp"
             res = await session.database.search(
                 index=doctype,
                 size=1,