Browse Source

Decide on how to store list data on local FS

master
Jonathan "Duke" Leto 7 years ago
parent
commit
3f2c441710
  1. 15
      bin/hushlist
  2. 11
      lib/Hush/List.pm

15
bin/hushlist

@ -4,8 +4,10 @@ use warnings;
use Try::Tiny;
use lib 'lib';
use Hush::List;
use Data::Dumper;
my $command = shift || help();
# we only need one
my $list = Hush::List->new;
my $COMMANDS = {
@ -14,13 +16,26 @@ my $COMMANDS = {
"remove" => \&remove,
"send" => \&send,
};
run();
sub help {
print "It would be nice to give some help\n";
}
sub new {
my $name = shift || '';
die "Invalid hushlist name '$name' !" unless $name;
$list->new_list($name);
print "hushlist '$name' created, enjoy your private comms :)\n";
}
sub run {
print "Running command $command\n";
my $cmd = $COMMANDS->{$command};
if ($cmd) {
$cmd->(@ARGV);
} else {
help();
}

11
lib/Hush/List.pm

@ -72,6 +72,11 @@ sub new_list {
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 => {} };
# ~/.hush/list/LIST_NAME/
# ~/.hush/list/LIST_NAME/list.conf - list-specific config items
# ~/.hush/list/LIST_NAME/list.json - list data, in JSON
# ~/.hush/list/LIST_NAME/list.png - user-specified image for list
return $self;
}
@ -117,8 +122,10 @@ sub send_message {
die "Max recipients of $MAX_RECIPIENTS exceeded" if (@$recipients > $MAX_RECIPIENTS);
# prevent an easily searchable single xtn amount
my $amount = 1e-4 + (1e-5*rand());
# TODO: can we make amount=0 and have fee-only xtns?
# amount is hidden, so it does not identify list messages via metadata
my $amount = 1e-4;
my $fee = 1e-6;
# this could blow up for a bajillion reasons...
try {

Loading…
Cancel
Save