Changeset e010ee0


Ignore:
Timestamp:
Sep 14, 2009, 10:34:19 PM (15 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
26f9e2e
Parents:
385dd69
Message:
Perform more sanity checking on config before creating handles.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/BarnOwl/Module/Twitter.pm

    r385dd69 re010ee0  
    9595
    9696$raw_cfg = [$raw_cfg] unless UNIVERSAL::isa $raw_cfg, "ARRAY";
     97
     98# Perform some sanity checking on the configuration.
     99{
     100    my %nicks;
     101    my $default = 0;
     102
     103    for my $cfg (@$raw_cfg) {
     104        if(! exists $cfg->{user}) {
     105            fail("Account has no username set.");
     106        }
     107        my $user = $cfg->{user};
     108        if(! exists $cfg->{password}) {
     109            fail("Account $user has no username set.");
     110        }
     111        if(@$raw_cfg > 1&&
     112           !exists($cfg->{account_nickname}) ) {
     113            fail("Account $user has no account_nickname set.");
     114        }
     115        if($cfg->{account_nickname}) {
     116            if($nicks{$cfg->{account_nickname}}++) {
     117                fail("Nickname " . $cfg->{account_nickname} . " specified more than once.");
     118            }
     119        }
     120        if($cfg->{default} || $cfg->{default_sender}) {
     121            if($default++) {
     122                fail("Multiple accounts marked as 'default'.");
     123            }
     124        }
     125    }
     126}
    97127
    98128for my $cfg (@$raw_cfg) {
Note: See TracChangeset for help on using the changeset viewer.