shithub: rc

ref: c1a707427fbbb5129e467516fc671e976ee3e398
dir: /nml/

View raw version
#!/bin/rc
# Mailing list script called from /mail/box/$list/pipeto.
# 2023-05-13T19:01:43-04:00
rfork en
fn fixheader{
	{
		sed 1q $D/rawunix
		cat $D/rawheader
		echo 'List-ID: <'$LIST.$DOMAIN'>'
		echo 'List-Help: <http://lists.9front.org>'
		echo X-Glyph: ➈
		echo -n 'X-Bullshit: '
		bullshit
		echo
	} >>$TMP.header >>[2]$TMP.errors
}
fn fixmsg{ cat $TMP.header $D/rawbody >$TMP.med >>[2]$TMP.errors }
fn index{ awk -v fileid'='$2^: '{print fileid $0}' >>/mail/box/$1/index >>[2]$TMP.errors }
fn blingdex{ <$TMP.med index $LIST `{sed -n 19p $D/info} >>[2]$TMP.errors }
fn try{ <$TMP.med /bin/upas/ml -p -r $REPLY /mail/box/$LIST/address-list $LIST >>[2]$TMP.errors }
fn die{ {echo 'ACHTUNG! This list does not accept HTML messages. See: https://useplaintext.email'; echo $status; echo; echo errors:; cat $TMP.errors; echo; echo message:; cat $TMP.raw} | mail -s $LIST^@^$DOMAIN^' '^FAILED $*; cleanup; exit }
fn cleanup{ rm -f $TMP $TMP.* }
@{
	rfork en	
	{<$TMP.raw sed '/^$/,$ s/^From / From /'; echo} >$TMP
	/bin/upas/fs -f $TMP
	D=/mail/fs/mbox/1	
#	if(~ `{file $D/body} *HTML* && ! ~ `{cat $D/from} *code.9front.org sl@stanleylieber.com)	# sorry, but fuck you
#		die `{cat $D/from}
	fixheader && fixmsg && try 
	cleanup
	exit
} >/dev/null >[2=1] &