iredmail / iRedAdmin

iRedMail Admin Panel (Open Source Edition)
https://www.iredmail.org/admin_panel.html
GNU General Public License v2.0
77 stars 28 forks source link

iredadmin pro maillist error. Error: TypeError("'<' not supported between instances of 'dict' and 'dict'",) #8

Closed shinvdu closed 3 years ago

shinvdu commented 3 years ago

file: RedAdmin-Pro-LDAP-4.8/libs/ldaplib/maillist.py line: 637

change profiles.sort() to
profiles.sort(key=lambda x: x['uid'], reverse=False)

something wrong with python3 with array sort. I get this issue by upgrade to RedAdmin-Pro-LDAP-4.8 with old iredadmin version data.

hope this can help anyone get into this issue.

iredmail commented 3 years ago

This issue was reported on Feb 14 and fixed later that day. Please use this full patch instead:

diff --git a/libs/ldaplib/maillist.py b/libs/ldaplib/maillist.py
index 2f9f9654..d8d2f443 100644
--- a/libs/ldaplib/maillist.py
+++ b/libs/ldaplib/maillist.py
@@ -632,7 +632,7 @@ def get_moderators(mail, conn=None):
             _ldif = iredutils.bytes2str(_ldif)
             profiles.append(_ldif)

-        profiles.sort()
+        profiles.sort(key=lambda x: x["mail"][0], reverse=False)

         d['profile_of_internal_moderators'] = profiles
diff --git a/controllers/ldap/api_user.py b/controllers/ldap/api_user.py
index 3f6996bd..d8c5c621 100644
--- a/controllers/ldap/api_user.py
+++ b/controllers/ldap/api_user.py
@@ -527,7 +527,7 @@ class APIUsers:
                 for (_dn, _ldif) in qr[1]:
                     profiles += [_ldif]

-                profiles.sort()
+                profiles.sort(key=lambda x: x["mail"][0], reverse=False)
                 return api_render((True, profiles))
         else:
             return api_render(qr)
diff --git a/controllers/ldap/api_alias.py b/controllers/ldap/api_alias.py
index 68294fa0..18db160d 100644
--- a/controllers/ldap/api_alias.py
+++ b/controllers/ldap/api_alias.py
@@ -45,7 +45,7 @@ class APIAliases:
                 for (_dn, _ldif) in qr[1]:
                     profiles += [_ldif]

-                profiles.sort()
+                profiles.sort(key=lambda x: x["mail"][0], reverse=False)
                 return api_render((True, profiles))
         else:
             return api_render(qr)
diff --git a/controllers/ldap/api_ml.py b/controllers/ldap/api_ml.py
index 85310c1f..c07cbb62 100644
--- a/controllers/ldap/api_ml.py
+++ b/controllers/ldap/api_ml.py
@@ -40,7 +40,7 @@ class APIMLS:
                 for (_dn, _ldif) in qr[1]:
                     profiles += [_ldif]

-                profiles.sort()
+                profiles.sort(key=lambda x: x["mail"][0], reverse=False)
                 return api_render((True, profiles))
         else:
             return api_render(qr)
shinvdu commented 3 years ago

got it, thanks.