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 wrap: on
line diff
--- a/s4-blog.sh	Tue Dec 08 12:24:19 2020 +0900
+++ b/s4-blog.sh	Wed Dec 09 11:34:37 2020 +0900
@@ -66,38 +66,46 @@
   ## 2017-0210 Respond to the direct reply mark such as: >#1234
   replymark=`echo "$3"|nkf -w -Z0|grep '^ *>#'`
   authgecos=`gecos $2`
-  if [ -z "$4" -a -n "$replymark"  ]; then
-    # If the action is new subscription($4="") and has ">#123" marks...
-    ids=`echo "$replymark"|sed 's/[^#0-9]*#\([0-9]*\)[^#0-9]*/\1 /g'`
-    ids=`echo $ids|tr -dc '[0-9 ]'|tr ' ' ','`
-    # -> 123,345,347
-    unames=`query "SELECT distinct author FROM article \
+  ## 2020-1209 If the first line begins with '## ', use it as Subject
+  firstline=`echo "$3"|head -1|nkf -w -Z0`
+  if [ -z "$4" ]; then
+    if [ -n "$replymark"  ]; then
+      # If the action is new subscription($4="") and has ">#123" marks...
+      ids=`echo "$replymark"|sed 's/[^#0-9]*#\([0-9]*\)[^#0-9]*/\1 /g'`
+      ids=`echo $ids|tr -dc '[0-9 ]'|tr ' ' ','`
+      # -> 123,345,347
+      unames=`query "SELECT distinct author FROM article \
 	WHERE rowid in ($ids)\
 	AND blogid=(SELECT id FROM blog WHERE rowid=$blogid);"`
-    if [ -n "$unames" ]; then
-      e4g=$(if $_isgroup; then
-	      email4group "$blogowner" $unames
-	    else
-	      for u in $unames; do
-		collectemail $u
-	      done
-	    fi)
-      emails=$emails" $e4g"
-      for e in $unames; do
-	g=`gecos $e`
-	whom=$whom"${whom:+,}${g:-$e}さん"
-      done
-      action="${whom}への返信"
+      if [ -n "$unames" ]; then
+	e4g=$(if $_isgroup; then
+		email4group "$blogowner" $unames
+	      else
+		for u in $unames; do
+		  collectemail $u
+		done
+	      fi)
+	emails=$emails" $e4g"
+	for e in $unames; do
+	  g=`gecos $e`
+	  whom=$whom"${whom:+,}${g:-$e}さん"
+	done
+	action="${whom}への返信"
+      fi
+    elif echo "$firstline" | grep -q "^## "; then
+      subject=${firstline#\#\# }
     fi
   else
+    # This else block is not symmetry, check later(2020-1209)
     [ x"$2" = x"$blogowner" ] && return # If author=blogowner, unnecessary
   fi
   test -z "$emails" && return
+  sj=${subject:-${action}通知}
   err notify: user=$user Admins=`getgroupadmins "$blogowner"` Mode=$mode Emails="[$emails]"
   quotedowner=`echo $blogowner | nkf -jM | tr -d '\n"'`
   MAIL_FROM=$noreply_from \
   SMAIL_TO="\"$quotedowner\" readers <$noreply>" \
-	  smail "$emails" "${action}通知 $urlbase"<<EOF
+	  smail "$emails" "$sj $urlbase"<<EOF
 [$blogtitle]板に${action}がありました。
 ※※※このメイルには返信できません(返信は次のURLへ)※※※
 場所: $blogurl (返信先)
@@ -566,7 +574,10 @@
   touchhelp="${touchpanel:+<p class=\"help\">$help</p>}"
   filehelp="《添付の注意》
 $file_accept_help"
-  ntmode="通知モード=$blog_notify${blog_team:+ (team=$blog_team)}"
+  ntmode="通知モード=$blog_notify${blog_team:+ (team=$blog_team)}
+記事の1行目を「## 」(半角シャープシャープ空白=大見出し)
+にするとそれがSubject(件名)になります。
+If the first line begins with &quot;## &quot;, sent it as Subject of email."
   textform=$(cat<<-EOF
 <div class="fold">
 <input type="checkbox" id="cmt" checked><label

yatex.org