s4

changeset 878:85a20c87bf97

Use the "## "heading in the first as Subject of notification email.
author HIROSE Yuuji <yuuji@gentei.org>
date Wed, 09 Dec 2020 11:34:37 +0900
parents 0905a624c720
children 188ad98d443f
files s4-blog.sh
diffstat 1 files changed, 33 insertions(+), 22 deletions(-) [+]
line diff
     1.1 --- a/s4-blog.sh	Tue Dec 08 12:24:19 2020 +0900
     1.2 +++ b/s4-blog.sh	Wed Dec 09 11:34:37 2020 +0900
     1.3 @@ -66,38 +66,46 @@
     1.4    ## 2017-0210 Respond to the direct reply mark such as: >#1234
     1.5    replymark=`echo "$3"|nkf -w -Z0|grep '^ *>#'`
     1.6    authgecos=`gecos $2`
     1.7 -  if [ -z "$4" -a -n "$replymark"  ]; then
     1.8 -    # If the action is new subscription($4="") and has ">#123" marks...
     1.9 -    ids=`echo "$replymark"|sed 's/[^#0-9]*#\([0-9]*\)[^#0-9]*/\1 /g'`
    1.10 -    ids=`echo $ids|tr -dc '[0-9 ]'|tr ' ' ','`
    1.11 -    # -> 123,345,347
    1.12 -    unames=`query "SELECT distinct author FROM article \
    1.13 +  ## 2020-1209 If the first line begins with '## ', use it as Subject
    1.14 +  firstline=`echo "$3"|head -1|nkf -w -Z0`
    1.15 +  if [ -z "$4" ]; then
    1.16 +    if [ -n "$replymark"  ]; then
    1.17 +      # If the action is new subscription($4="") and has ">#123" marks...
    1.18 +      ids=`echo "$replymark"|sed 's/[^#0-9]*#\([0-9]*\)[^#0-9]*/\1 /g'`
    1.19 +      ids=`echo $ids|tr -dc '[0-9 ]'|tr ' ' ','`
    1.20 +      # -> 123,345,347
    1.21 +      unames=`query "SELECT distinct author FROM article \
    1.22  	WHERE rowid in ($ids)\
    1.23  	AND blogid=(SELECT id FROM blog WHERE rowid=$blogid);"`
    1.24 -    if [ -n "$unames" ]; then
    1.25 -      e4g=$(if $_isgroup; then
    1.26 -	      email4group "$blogowner" $unames
    1.27 -	    else
    1.28 -	      for u in $unames; do
    1.29 -		collectemail $u
    1.30 -	      done
    1.31 -	    fi)
    1.32 -      emails=$emails" $e4g"
    1.33 -      for e in $unames; do
    1.34 -	g=`gecos $e`
    1.35 -	whom=$whom"${whom:+,}${g:-$e}さん"
    1.36 -      done
    1.37 -      action="${whom}への返信"
    1.38 +      if [ -n "$unames" ]; then
    1.39 +	e4g=$(if $_isgroup; then
    1.40 +		email4group "$blogowner" $unames
    1.41 +	      else
    1.42 +		for u in $unames; do
    1.43 +		  collectemail $u
    1.44 +		done
    1.45 +	      fi)
    1.46 +	emails=$emails" $e4g"
    1.47 +	for e in $unames; do
    1.48 +	  g=`gecos $e`
    1.49 +	  whom=$whom"${whom:+,}${g:-$e}さん"
    1.50 +	done
    1.51 +	action="${whom}への返信"
    1.52 +      fi
    1.53 +    elif echo "$firstline" | grep -q "^## "; then
    1.54 +      subject=${firstline#\#\# }
    1.55      fi
    1.56    else
    1.57 +    # This else block is not symmetry, check later(2020-1209)
    1.58      [ x"$2" = x"$blogowner" ] && return # If author=blogowner, unnecessary
    1.59    fi
    1.60    test -z "$emails" && return
    1.61 +  sj=${subject:-${action}通知}
    1.62    err notify: user=$user Admins=`getgroupadmins "$blogowner"` Mode=$mode Emails="[$emails]"
    1.63    quotedowner=`echo $blogowner | nkf -jM | tr -d '\n"'`
    1.64    MAIL_FROM=$noreply_from \
    1.65    SMAIL_TO="\"$quotedowner\" readers <$noreply>" \
    1.66 -	  smail "$emails" "${action}通知 $urlbase"<<EOF
    1.67 +	  smail "$emails" "$sj $urlbase"<<EOF
    1.68  [$blogtitle]板に${action}がありました。
    1.69  ※※※このメイルには返信できません(返信は次のURLへ)※※※
    1.70  場所: $blogurl (返信先)
    1.71 @@ -566,7 +574,10 @@
    1.72    touchhelp="${touchpanel:+<p class=\"help\">$help</p>}"
    1.73    filehelp="《添付の注意》
    1.74  $file_accept_help"
    1.75 -  ntmode="通知モード=$blog_notify${blog_team:+ (team=$blog_team)}"
    1.76 +  ntmode="通知モード=$blog_notify${blog_team:+ (team=$blog_team)}
    1.77 +記事の1行目を「## 」(半角シャープシャープ空白=大見出し)
    1.78 +にするとそれがSubject(件名)になります。
    1.79 +If the first line begins with &quot;## &quot;, sent it as Subject of email."
    1.80    textform=$(cat<<-EOF
    1.81  <div class="fold">
    1.82  <input type="checkbox" id="cmt" checked><label