Skip to Content.
Sympa Menu

en - Re: [sympa-users] Custom mhonarc script, trouble after upgrade...

Subject: The mailing list for listmasters using Sympa

List archive

Chronological Thread  
  • From: IKEDA Soji <address@concealed>
  • To: Marco Gaiarin <address@concealed>
  • Cc: address@concealed
  • Subject: Re: [sympa-users] Custom mhonarc script, trouble after upgrade...
  • Date: Mon, 4 Mar 2019 10:24:08 +0900

Hi Marco,

On Thu, 28 Feb 2019 22:15:45 +0100
Marco Gaiarin <address@concealed> wrote:

>
> Again, i reply to myself.
>
> > Something like:
> >
> > https://sympa-community.github.io/manual/man/Sympa-Message-Plugin.3.html
> > Seems well-suited, probably a hook in pre_distribute will suffice...
> > right?
>
> I've tried to read /usr/share/sympa/lib/Sympa/Message/Plugin/FixEncoding.pm,
> the only example available, but seems rather obscure to me (but, clearly,
> i don't know perl decently...).
>
> Seems to me that:
>
> a) i need a module called
> /usr/share/sympa/lib/Sympa/Message/Plugin/Newsgate.pm
>
> b) where exist a package called:
> package Sympa::Message::Plugin::Newsgate;
>
> c) where there's a function/sub that have to be called 'pre_distribute'
>
> d) the third 'variable' passed to that function is the message, coded using
> the internal format, depicted in 'man Sympa::Message'.
>
>
> e) Ok, done that i need to translate listname into newsgroup name; i have a
> file for that, i can do simple regexp in perl, but i've not clear how to
> get the listname. Sympa::Message speaks about 'context' but really i've not
> understood what mean...

You can get it as:

sub pre_digest {
my $class = shift;
my $name = shift;
my $message = shift;

my $list = $message->{context};

my $listname = $list->{name}; # LISTNAME
my $listhost = $list->{domain}; # LISTHOST
my $listid = $list->get_id; # LISTNAME@LISTHOST

...
}

> f) eventually done that, i need to pipe message (raw message) to my gateway
> script; seems i need to use $message->dump() but really i've not understood
> how.

Try doing:

my $string = $message->as_string(original => 1);

my $pipeout;
if (open $pipeout, '|-', '/usr/local/bin/mail2news',
"NEWSGROUP=$newsgroup", "LIST=$listid", "TAG=$listname") {
print $pipeout $string;
close $pipeout;

my $status = $? >> 8;
if ($status) {
$log->syslog('err', 'mail2news exited with status %s', $status);
}
}


You might want to contribute your plugin to sympa-contribs:
https://github.com/sympa-community/sympa-contribs


Regards,

-- Soji

> Someone can help me?! Thanks. ;-)
>
> --
> Dio del cielo se mi vorrai
> in mezzo agli altri uomini mi cercherai (F. De Andre`)
>
>


--
IKEDA Soji <address@concealed>



Archive powered by MHonArc 2.6.19+.

Top of Page