about summary refs log tree commit homepage
path: root/lib/PublicInbox/Inbox.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2016-06-20 00:57:17 +0000
committerEric Wong <e@80x24.org>2016-06-20 00:57:39 +0000
commit0c8f677e55941c5c65b263294692899c549ce533 (patch)
tree17a806c0af928bcdc52932c5b13b2abcc744534f /lib/PublicInbox/Inbox.pm
parent4b313dc74bc9bb84a542b7ec920cdb92879e7523 (diff)
downloadpublic-inbox-0c8f677e55941c5c65b263294692899c549ce533.tar.gz
Inboxes are normally created by Config, but having the
population logic in Inbox should make it easier to mock
for testing.
Diffstat (limited to 'lib/PublicInbox/Inbox.pm')
-rw-r--r--lib/PublicInbox/Inbox.pm3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/PublicInbox/Inbox.pm b/lib/PublicInbox/Inbox.pm
index faab03ce..3f1b7334 100644
--- a/lib/PublicInbox/Inbox.pm
+++ b/lib/PublicInbox/Inbox.pm
@@ -11,6 +11,9 @@ use PublicInbox::MID qw(mid2path);
 
 sub new {
         my ($class, $opts) = @_;
+        my $v = $opts->{address} ||= 'public-inbox@example.com';
+        my $p = $opts->{-primary_address} = ref($v) eq 'ARRAY' ? $v->[0] : $v;
+        $opts->{domain} = ($p =~ /\@(\S+)\z/) ? $1 : 'localhost';
         bless $opts, $class;
 }