Example #1
0
    def checkRecipients(self):
        """
        Check the validity of the Recipient header values. These must all be local as there
        is no concept of server-to-server relaying.
        """

        results = []
        for recipient in self.recipients:
            # Get the calendar user object for this recipient
            recipientAddress = yield calendarUserFromCalendarUserAddress(
                recipient, self.txn)

            # If no calendar user we may have a remote recipient but we should check whether
            # the address is one that ought to be on our server and treat that as a missing
            # user. Also if server-to-server is not enabled then remote addresses are not allowed.
            if not recipientAddress.hosted():
                localUser = (
                    yield
                    addressmapping.mapper.isCalendarUserInMyDomain(recipient))
                if localUser:
                    log.error(
                        "No record for calendar user address: {r}",
                        r=recipient,
                    )
                else:
                    log.error(
                        "Unknown calendar user address: {r}",
                        r=recipient,
                    )
                results.append(InvalidCalendarUser(recipient))
            else:
                # Map recipient to their inbox and cache on calendar user object
                inbox = None
                if recipientAddress.validRecipient():
                    if isinstance(recipientAddress, LocalCalendarUser):
                        recipient_home = yield self.txn.calendarHomeWithUID(
                            recipientAddress.record.uid, create=True)
                        if recipient_home:
                            inbox = (yield
                                     recipient_home.calendarWithName("inbox"))
                    else:
                        inbox = "dummy"
                    recipientAddress.inbox = inbox

                if inbox:
                    results.append(recipientAddress)
                else:
                    log.error(
                        "No scheduling for calendar user: {r}",
                        r=recipient,
                    )
                    results.append(InvalidCalendarUser(recipient))

        self.recipients = results
Example #2
0
    def getCalendarUser(self, cuaddr):

        # Get the type
        cuaddr_type = (yield self.getCalendarUserServiceType(cuaddr))
        if cuaddr_type == DeliveryService.serviceType_caldav:
            returnValue(InvalidCalendarUser(cuaddr))
        elif cuaddr_type == DeliveryService.serviceType_ischedule:
            returnValue(RemoteCalendarUser(cuaddr))
        elif cuaddr_type == DeliveryService.serviceType_imip:
            returnValue(EmailCalendarUser(cuaddr))
        else:
            returnValue(InvalidCalendarUser(cuaddr))