Exemplo n.º 1
0
    def test_imap_folder_path(self):
        p1 = imap_folder_path("imap://[email protected]@kolab.example.org/Calendar;UID=3")
        self.assertEqual(p1, "user/john.doe/[email protected]")

        p2 = imap_folder_path("imap://[email protected]@kolab.example.org/INBOX;UIDVALIDITY=1411487702")
        self.assertEqual(p2, "user/[email protected]")

        # test shared folders (but how are they referred in the uri?)
        p3 = imap_folder_path("imap://kolab.example.org/Shared%20Folders/shared/Project-X%40example.org;UIDVALIDITY=1412093781/;UID=2")
        self.assertEqual(p3, "shared/[email protected]")
Exemplo n.º 2
0
    def get_imap_folder_acl(self, notification):
        notification = json.loads(notification)
        log.debug("GETACL for %r" % (notification), level=9)

        # split the uri parameter into useful parts
        uri = parse_imap_uri(notification['uri'])
        folder_path = imap_folder_path(uri)

        # get folder acls using pykolab's imap module
        acls = {}
        try:
            self.imap.connect()
            acls = self.imap.list_acls(folder_path)
            self.imap.disconnect()
        except Exception, e:
            log.warning("Failed to get ACLs for %r: %r", folder_path, e)
Exemplo n.º 3
0
    def get_imap_folder_metadata(self, notification):
        notification = json.loads(notification)
        log.debug("GETMETADATA for %r" % (notification), level=9)

        # split the uri parameter into useful parts
        uri = parse_imap_uri(notification['uri'])
        folder_path = imap_folder_path(uri)

        # get metadata using pykolab's imap module
        metadata = {}
        try:
            self.imap.connect()
            metadata = self.imap.get_metadata(folder_path)[folder_path]
            self.imap.disconnect()
        except Exception, e:
            log.warning("Failed to get metadata for %r: %r", folder_path, e)