|
|
@ -4,6 +4,9 @@ use warnings; |
|
|
|
use Hush::RPC; |
|
|
|
use Try::Tiny; |
|
|
|
use File::Spec::Functions; |
|
|
|
use Carp qw/longmess/; |
|
|
|
|
|
|
|
sub barf { die longmess(@_) } |
|
|
|
|
|
|
|
our $VERSION = 20171031; |
|
|
|
|
|
|
@ -68,13 +71,37 @@ sub new { |
|
|
|
} |
|
|
|
|
|
|
|
sub new_list { |
|
|
|
my ($self,$name) = @_; |
|
|
|
my $lists = $self->{lists}; |
|
|
|
my ($self,$name) = @_; |
|
|
|
my $lists = $self->{lists}; |
|
|
|
# a list is simply a list of addresses, which can be looked up by name, and maybe some other metadata |
|
|
|
$lists->{$name} = { recipients => {} }; |
|
|
|
|
|
|
|
my $list_dir = catdir($HUSHLIST_CONFIG_DIR,$name); |
|
|
|
if (!-e $list_dir) { |
|
|
|
# create the config dir for the list for the first time |
|
|
|
mkdir $list_dir; |
|
|
|
if ($!) { |
|
|
|
barf "Could not create directory $list_dir !"; |
|
|
|
} |
|
|
|
} |
|
|
|
my $list_specific_conf = catfile($HUSHLIST_CONFIG_DIR,$name,'list.conf'); |
|
|
|
my $time = time; |
|
|
|
|
|
|
|
open my $fh, '>', $list_specific_conf or barf "Could not open $list_specific_conf for writing"; |
|
|
|
print $fh "# hushlist $name config\n"; |
|
|
|
print $fh "generated=$time\n"; |
|
|
|
print $fh "generated_by=Hush::List $Hush::List::VERSION\n"; |
|
|
|
close $fh; |
|
|
|
|
|
|
|
# We consider members.txt the oracle, so users can simply maintain a list |
|
|
|
# of zaddrs into a file, if they want. We sync/serialize to list.json |
|
|
|
# each time we run |
|
|
|
# hust list contacts? |
|
|
|
|
|
|
|
# TODO: still in flux |
|
|
|
# ~/.hush/list/LIST_NAME/ |
|
|
|
# ~/.hush/list/LIST_NAME/list.conf - list-specific config items |
|
|
|
# ~/.hush/list/LIST_NAME/members.txt - list member zaddrs, one per line |
|
|
|
# ~/.hush/list/LIST_NAME/list.json - list data, in JSON |
|
|
|
# ~/.hush/list/LIST_NAME/list.png - user-specified image for list |
|
|
|
return $self; |
|
|
|