all repos — listfix @ 062aa06276f269031a2ff98755264a043e179575

Postfix Mailing List Software; Maintained on behalf the of Agency Economy Incorporated NFP.

Transform all email arguments to lower case before handling.
Also include new function to make existing emails in the db all
lowercase.

	modified:   listfix.py
	modified:   listfix/args.py
	modified:   listfix/db.py
Brian Barto bartobrian@gmail.com
Mon, 05 Dec 2022 14:06:44 -0500
commit

062aa06276f269031a2ff98755264a043e179575

parent

c5ec9f46a1a80f486336cbb66333aa8e37baad38

3 files changed, 18 insertions(+), 2 deletions(-)

jump to
M listfix.pylistfix.py

@@ -31,6 +31,8 @@ exit()

sender_email = email_in.get_sender_email() sender_name = email_in.get_sender_name() + sender_email = sender_email.lower() + log.info(f"Email from: {sender_email}") log.info(f"Email list: {list_email}")

@@ -91,6 +93,10 @@ list_email = args.get_list_email()

recipient_email = args.get_recipient_email() db.destroy_recipient(list_email, recipient_email) print(f"Recipient ({recipient_email}) removed from list ({list_email})") + +elif (command == "lower"): + db.lower_emails() + print(f"Completed.") elif (command == "test"): test = Test()
M listfix/args.pylistfix/args.py

@@ -20,7 +20,7 @@ if (len(self.args) < 3):

raise IndexError(f"Missing argument(s) for '{self.command}' command.") if (not re_email_arg.match(self.args[2])): raise ValueError(f"Invalid argument value: {self.args[2]}") - return self.args[2] + return self.args[2].lower() def get_list_name(self): if (len(self.args) < 4):

@@ -32,7 +32,7 @@ if (len(self.args) < 4):

raise IndexError(f"Missing argument(s) for '{self.command}' command.") if (not re_email_arg.match(self.args[3])): raise ValueError(f"Invalid argument value: {self.args[3]}") - return self.args[3] + return self.args[3].lower() def get_recipient_name(self): if (len(self.args) < 5):
M listfix/db.pylistfix/db.py

@@ -66,6 +66,16 @@ if (not self.check_list_exists(list_email)):

raise ValueError(f"Email list does not exist: {list_email}") del self.json[list_email] + def lower_emails(self): + lists = self.get_lists() + for x in lists: + self.json[x.lower()] = self.json.pop(x) + lists = self.get_lists() + for x in lists: + recipients = self.get_list_recipients(x) + for y in recipients: + self.json[x]['recipients'][y.lower()] = self.json[x]['recipients'].pop(y) + def save(self): f = open(self.path, "w") json.dump(self.json, f, indent=4)