summaryrefslogtreecommitdiff
path: root/lib/feed2imap/config.rb
diff options
context:
space:
mode:
authorLucas Nussbaum <lucas@lucas-nussbaum.net>2009-12-26 01:51:37 +0100
committerLucas Nussbaum <lucas@lucas-nussbaum.net>2009-12-26 01:51:37 +0100
commitdb52aeb97fcc73e3b9a3a2a6e2e9eb63fd4cb0f8 (patch)
tree7839546f11f95a37bd3016d1e2ad38c8f3d6e727 /lib/feed2imap/config.rb
parentec808b0f4bfd213b7b81996d8c46c1d98bbafa7c (diff)
downloadfeed2imap-db52aeb97fcc73e3b9a3a2a6e2e9eb63fd4cb0f8.tar.gz
feed2imap-db52aeb97fcc73e3b9a3a2a6e2e9eb63fd4cb0f8.tar.bz2
feed2imap-db52aeb97fcc73e3b9a3a2a6e2e9eb63fd4cb0f8.zip
Avoid using "acme.com"
Patch from Guido Berhoerster <guido@berhoerster.name>: Hello, here is a small patch that avoids using the valid(!) domain "acme.com" for generating message ids and email addresses. It adds a new global configuration option "default-email" which will be used in case a feed does provide one, currently feed2imap resorts to "feed2imap@acme.com". If this configuration option is not given it will basically default to <logname>@<hostname> as returned by Etc.getlogin and Socket.gethostname. Yours,
Diffstat (limited to 'lib/feed2imap/config.rb')
-rw-r--r--lib/feed2imap/config.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/feed2imap/config.rb b/lib/feed2imap/config.rb
index 5f6f448..a9c796c 100644
--- a/lib/feed2imap/config.rb
+++ b/lib/feed2imap/config.rb
@@ -21,13 +21,19 @@ require 'yaml'
require 'uri'
require 'feed2imap/imap'
require 'feed2imap/maildir'
+require 'etc'
+require 'socket'
# Default cache file
DEFCACHE = ENV['HOME'] + '/.feed2imap.cache'
+# Hostname and login name of the current user
+HOSTNAME = Socket.gethostname
+LOGNAME = Etc.getlogin
+
# Feed2imap configuration
class F2IConfig
- attr_reader :imap_accounts, :cache, :feeds, :dumpdir, :updateddebug, :max_failures, :include_images
+ attr_reader :imap_accounts, :cache, :feeds, :dumpdir, :updateddebug, :max_failures, :include_images, :default_email, :hostname
# Load the configuration from the IO stream
# TODO should do some sanity check on the data read.
@@ -40,6 +46,8 @@ class F2IConfig
@max_failures = (@conf['max-failures'] || 10).to_i
@updateddebug = (@conf['debug-updated'] and @conf['debug-updated'] != 'false')
@include_images = (@conf['include-images'] and @conf['include-images'] != 'false')
+ @default_email = (@conf['default-email'] || "#{LOGNAME}@#{HOSTNAME}")
+ @hostname = HOSTNAME # FIXME: should this be configurable as well?
@imap_accounts = ImapAccounts::new
maildir_account = MaildirAccount::new
@conf['feeds'].each do |f|