On 11/2/21 9:30 AM, bob B wrote:
So just want to make sure I have the latest information after searching this list and googling or have I missed something? It appears there is no way in mailman3 to delete archives. There has been discussion on implementing this, but it has not been developed? is that correct?
I'm not sure when it first appeared, but current Hyperkitty has Delete Archive button on the list overview page, but it is only available to Django superusers, not to list owners.
I saw references to:
from hyperkitty.models import MailingList ml = MailingList.objects.get(name="test2@freeculture.org") ml.delete()
But how do I run this? I believe it is run in mailman-core (I am in a docker environment but that should not matter). I can get into the mailman shell, but that command does not work
It is run in a Django management shell, not mailman shell.
************** Question 2
What about pruning archives? I use to run a script for mailman2 to prune archives of messages older than X days for a list, Is that possible in mailman3
There are a few ways to do this. You can export the archive for a list as an mbox and edit the mbox to delete the messages you want to prune. Then delete the archive for this list and finally run hyperkitty_import to import the pruned mbox.
Alternatively, in a django management shell, you could try something like
import datetime
from hyperkitty.models import Email
for msg in Email.objects.filter(mailinglist_id=X):
if msg.date < datetime.datetime(Y, M, D,
tzinfo=datetime.timezone.utc):
msg.delete()
where X is the id of the mailing list you want to prune, or if you wanted to do all lists, just use Email.objects.all() instead of filtering on mailinglist_id.
And, Y, M and D are integer Year, Month and Day for the cutoff.
Note that something like
from hyperkitty.models import MailingList
for ml in MailingList.objects.all():
print('{}: {}'.format(ml.name, ml.id))
will print all the list names and their ids.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan