ssoma-mda: Use the email subject as the commit message
[ssoma-mda.git] / ssoma-mda
1 #!/usr/bin/perl -w
2 # Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors
3 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
4 # This is the command-line mail delivery agent for servers.
5 # Try to keep this small as it may be invoked frequently for each message
6 # delivered.
7 my $usage = "ssoma-mda [-1] /path/to/git/repo < /path/to/rfc2822_message";
8 use strict;
9 use warnings;
10 use Ssoma::MDA;
11 use Ssoma::Git;
12 use Email::Simple;
13 my $once = $ARGV[0] eq "-1";
14 my $repo = pop @ARGV or die "Usage: $usage\n";
15 my $git = Ssoma::Git->new($repo);
16 my $mda = Ssoma::MDA->new($git);
17 my $simple;
18 {
19         local $/;
20         $simple = Email::Simple->new(<STDIN>);
21 }
22 $mda->deliver($simple, $once);