Search in sources :

Example 1 with PacketInfo

use of i2p.bote.email.EmailMetadata.PacketInfo in project i2p.i2p-bote by i2p.

the class DeliveryChecker method checkDelivery.

/**
 * Checks the DHT for all undelivered packets belonging to a given email.
 * @param email
 * @throws InterruptedException
 */
private void checkDelivery(Email email) throws InterruptedException {
    EmailMetadata metadata = email.getMetadata();
    Collection<PacketInfo> packets = metadata.getUndeliveredPacketKeys();
    synchronized (sentFolder) {
        boolean updateMetadata = false;
        for (PacketInfo packet : packets) {
            UniqueId delAuth = dht.findDeleteAuthorizationKey(packet.dhtKey, packet.delVerificationHash);
            if (delAuth != null) {
                metadata.setPacketDelivered(packet.dhtKey, true);
                updateMetadata = true;
                log.debug("Delivery of email packet with DHT key " + packet.dhtKey + " confirmed.");
            }
        }
        if (updateMetadata)
            try {
                sentFolder.saveMetadata(email);
            } catch (Exception e) {
                log.error("Can't save email metadata.", e);
            }
    }
}
Also used : UniqueId(i2p.bote.UniqueId) PacketInfo(i2p.bote.email.EmailMetadata.PacketInfo) EmailMetadata(i2p.bote.email.EmailMetadata) PasswordException(i2p.bote.fileencryption.PasswordException)

Aggregations

UniqueId (i2p.bote.UniqueId)1 EmailMetadata (i2p.bote.email.EmailMetadata)1 PacketInfo (i2p.bote.email.EmailMetadata.PacketInfo)1 PasswordException (i2p.bote.fileencryption.PasswordException)1