shithub: rc-nntpd

ref: 53c3169386da4cffee65e3dfe94723c299e98d05
dir: /handlers/get-article-by-uuid/

View raw version
#!/bin/rc

. log.rc

group_name=$1
article_uuid=$2

if (~ $group_name '' || ~ $article_uuid '')
	exit 500

group_path=`{echo -n $group_name | sed 's/\./\//'}
group_path=$news/$group_path

for (article_path in `{walk -f $group_path}) {
	article_found=`{cat $article_path | \
					gunzip | \
					grep -i 'message-id: ' | \
					grep $article_uuid }
	if (! ~ $article_found '') {
		article_id=`{basename $article_path}
		echo $article_id
		exit
	}
}

exit 430