summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLucas Nussbaum <lucas@lucas-nussbaum.net>2009-05-06 13:39:07 +0200
committerLucas Nussbaum <lucas@lucas-nussbaum.net>2009-05-06 13:39:07 +0200
commit6a3c1e29ce1da699af27603e1787a284c7395d57 (patch)
treed6dc888cb27d028d2e5eab2aac561c3a1394a8a0
parent92b406375fa95e9111653b8139d74cebe8c65b01 (diff)
downloadfeed2imap-6a3c1e29ce1da699af27603e1787a284c7395d57.tar.gz
feed2imap-6a3c1e29ce1da699af27603e1787a284c7395d57.tar.bz2
feed2imap-6a3c1e29ce1da699af27603e1787a284c7395d57.zip
Use Message-Id instead of X-CacheIndex
Diffstat (limited to '')
-rw-r--r--lib/feed2imap/feed2imap.rb9
-rw-r--r--lib/feed2imap/imap.rb4
-rw-r--r--lib/feed2imap/itemtomail.rb4
3 files changed, 10 insertions, 7 deletions
diff --git a/lib/feed2imap/feed2imap.rb b/lib/feed2imap/feed2imap.rb
index 3627ab0..fb8fb12 100644
--- a/lib/feed2imap/feed2imap.rb
+++ b/lib/feed2imap/feed2imap.rb
@@ -234,14 +234,17 @@ class Feed2Imap
@logger.info("#{f.name}: #{newitems.length} new items, #{updateditems.length} updated items.") if newitems.length > 0 or updateditems.length > 0 or @logger.level == Logger::DEBUG
begin
if !cacherebuild
+ fn = f.name.gsub(/[^0-9A-Za-z]/,'')
updateditems.each do |i|
- email = item_to_mail(i, i.cacheditem.index, true, f.name, f.include_images, f.wrapto)
+ id = "<#{fn}-#{i.cacheditem.index}@acme.com>"
+ email = item_to_mail(i, id, true, f.name, f.include_images, f.wrapto)
f.imapaccount.updatemail(f.folder, email,
- i.cacheditem.index, i.date || Time::new)
+ id, i.date || Time::new)
end
# reverse is needed to upload older items first (fixes gna#8986)
newitems.reverse.each do |i|
- email = item_to_mail(i, i.cacheditem.index, false, f.name, f.include_images, f.wrapto)
+ id = "<#{fn}-#{i.cacheditem.index}@acme.com>"
+ email = item_to_mail(i, id, false, f.name, f.include_images, f.wrapto)
f.imapaccount.putmail(f.folder, email, i.date || Time::new)
end
end
diff --git a/lib/feed2imap/imap.rb b/lib/feed2imap/imap.rb
index 63cd733..6840c11 100644
--- a/lib/feed2imap/imap.rb
+++ b/lib/feed2imap/imap.rb
@@ -102,10 +102,10 @@ class ImapAccount
end
# update a mail
- def updatemail(folder, mail, idx, date = Time::now)
+ def updatemail(folder, mail, id, date = Time::now)
create_folder_if_not_exists(folder)
@connection.select(folder)
- searchres = @connection.search(['HEADER', 'X-CacheIndex', "-#{idx}-"])
+ searchres = @connection.search(['HEADER', 'Message-Id', id])
flags = nil
if searchres.length > 0
# we get the flags from the first result and delete everything
diff --git a/lib/feed2imap/itemtomail.rb b/lib/feed2imap/itemtomail.rb
index 00ce84f..ffa6b22 100644
--- a/lib/feed2imap/itemtomail.rb
+++ b/lib/feed2imap/itemtomail.rb
@@ -47,7 +47,7 @@ class String
end
end
-def item_to_mail(item, index, updated, from = 'Feed2Imap', inline_images = false, wrapto = false)
+def item_to_mail(item, id, updated, from = 'Feed2Imap', inline_images = false, wrapto = false)
message = RMail::Message::new
if item.creator and item.creator != ''
if item.creator.include?('@')
@@ -66,7 +66,7 @@ def item_to_mail(item, index, updated, from = 'Feed2Imap', inline_images = false
message.header['Date'] = item.date.rfc2822
end
message.header['X-Feed2Imap-Version'] = F2I_VERSION if defined?(F2I_VERSION)
- message.header['X-CacheIndex'] = "-#{index}-"
+ message.header['Message-Id'] = id
message.header['X-F2IStatus'] = "Updated" if updated
# treat subject. Might need MIME encoding.
subj = item.title or (item.date and item.date.to_s) or item.link