summaryrefslogtreecommitdiffstats
path: root/hyperkitty/lib/archiver.py
diff options
context:
space:
mode:
Diffstat (limited to 'hyperkitty/lib/archiver.py')
-rw-r--r--hyperkitty/lib/archiver.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/hyperkitty/lib/archiver.py b/hyperkitty/lib/archiver.py
new file mode 100644
index 0000000..d0af7a2
--- /dev/null
+++ b/hyperkitty/lib/archiver.py
@@ -0,0 +1,53 @@
+# -*- coding: utf-8 -*-
+"""
+Class implementation of Mailman's IArchiver interface
+"""
+
+
+from mailman.interfaces.archiver import IArchiver
+from django.core.urlresolvers import reverse
+from hyperkitty.lib import ThreadSafeStorePool
+
+
+class Archiver(object):
+
+ implements(IArchiver)
+
+ name = "hyperkitty"
+
+ def __init__(self):
+ self.store = None
+
+ def list_url(self, mlist):
+ """Return the url to the top of the list's archive.
+
+ :param mlist: The IMailingList object.
+ :returns: The url string.
+ """
+ return reverse('archives', mlist_fqdn=mlist)
+
+ def permalink(self, mlist, msg):
+ """Return the url to the message in the archive.
+
+ This url points directly to the message in the archive. This method
+ only calculates the url, it does not actually archive the message.
+
+ :param mlist: The IMailingList object.
+ :param msg: The message object.
+ :returns: The url string or None if the message's archive url cannot
+ be calculated.
+ """
+ return reverse('message_index', mlist_fqdn=mlist, hashid=msg.message_id_hash)
+
+ def archive_message(self, mlist, msg):
+ """Send the message to the archiver.
+
+ :param mlist: The IMailingList object.
+ :param msg: The message object.
+ :returns: The url string or None if the message's archive url cannot
+ be calculated.
+ """
+ if self.store is None:
+ self.store = ThreadSafeStorePool().get()
+ msg.message_id_hash = self.store.add_to_list(mlist.list_name, msg)
+ # Update karma