aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2007-09-06 13:05:56 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2007-09-06 13:05:56 +0000
commit747e41693d7f2a808b3314cf82b3af38f98daf2d (patch)
treea023fea0ac96b2abdc2c98141d90a841544dbbf9
parentafd4995c30c273a02f81e80a972688936907853a (diff)
downloadwydawca-747e41693d7f2a808b3314cf82b3af38f98daf2d.tar.gz
wydawca-747e41693d7f2a808b3314cf82b3af38f98daf2d.tar.bz2
Redo mail notifications
git-svn-id: file:///svnroot/wydawca/trunk@316 6bb4bd81-ecc2-4fd4-a2d4-9571d19c0d33
-rw-r--r--ChangeLog16
-rwxr-xr-xbootstrap2
-rw-r--r--doc/wydawca.texi143
-rw-r--r--etc/messages.rc (renamed from src/wydawca.rc)110
-rw-r--r--etc/wydawca.rc63
-rw-r--r--src/config.c167
-rw-r--r--src/mail.c172
-rw-r--r--src/mail.h4
-rw-r--r--src/wydawca.h18
9 files changed, 491 insertions, 204 deletions
diff --git a/ChangeLog b/ChangeLog
index 33bc245..b1f0d95 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
12007-09-06 Sergey Poznyakoff <gray@gnu.org.ua>
2
3 * bootstrap: Update
4 * doc/wydawca.texi: Update
5 * src/wydawca.h (notify_project_owner): Remove
6 (enum notification_target): New data type
7 (find_message_template, register_notification)
8 (notification_event_str, notification_target_str): New functions.
9 * src/config.c: Redo message template statements
10 * src/mail.c: Redo notifications
11 * src/mail.h (admin_stat_message_template): Change data type
12 (owner_notification_flags,user_message_template): Remove
13 * src/wydawca.rc: Moved to ...
14 * etc/wydawca.rc: ... here
15 * etc/messages.rc: New file
16
12007-09-05 Sergey Poznyakoff <gray@gnu.org.ua> 172007-09-05 Sergey Poznyakoff <gray@gnu.org.ua>
2 18
3 * doc/wydawca.texi: Update. 19 * doc/wydawca.texi: Update.
diff --git a/bootstrap b/bootstrap
index 5be1664..2199382 100755
--- a/bootstrap
+++ b/bootstrap
@@ -42,7 +42,7 @@ fi
42test -d m4 || mkdir m4 || exit 1 42test -d m4 || mkdir m4 || exit 1
43test -d gnu || mkdir gnu || exit 1 43test -d gnu || mkdir gnu || exit 1
44 44
45svn export http://svn.gnu.org.ua/sources/gsc/trunk/lib lib && 45svn export --force http://svn.gnu.org.ua/sources/gsc/trunk/lib lib &&
46 gnulib-tool --source-base=gnu --import \ 46 gnulib-tool --source-base=gnu --import \
47 xalloc obstack getopt hash error progname getline mkdtemp save-cwd \ 47 xalloc obstack getopt hash error progname getline mkdtemp save-cwd \
48 backupfile strerror vasprintf inttostr strftime && 48 backupfile strerror vasprintf inttostr strftime &&
diff --git a/doc/wydawca.texi b/doc/wydawca.texi
index cc7b04c..b313e4f 100644
--- a/doc/wydawca.texi
+++ b/doc/wydawca.texi
@@ -969,6 +969,7 @@ from the name of the user @command{wydawca} runs as (usually
969 969
970@menu 970@menu
971* mailer:: 971* mailer::
972* templates::
972* admin notification:: 973* admin notification::
973* user notification:: 974* user notification::
974@end menu 975@end menu
@@ -977,7 +978,7 @@ from the name of the user @command{wydawca} runs as (usually
977@subsection Mailer 978@subsection Mailer
978@cindex mailer 979@cindex mailer
979@kwindex mailer 980@kwindex mailer
980 To send messages @command{wydawca} uses a special logical entity 981 To send messages, @command{wydawca} uses a special logical entity
981called @dfn{mailer}. It is set in the configuration file using 982called @dfn{mailer}. It is set in the configuration file using
982@code{mailer} keyword: 983@code{mailer} keyword:
983 984
@@ -1038,19 +1039,86 @@ mailer smtp://remote.server.net:24
1038@end group 1039@end group
1039@end smallexample 1040@end smallexample
1040 1041
1042@node templates
1043@subsection Message Templates
1044@cindex templates, notification messages
1045@cindex notification message template
1046@cindex message template
1047 Each notification message is build from a message template, by
1048expanding any occurrances of @samp{%@{@var{name}@}} within it with the value
1049of macro-variable @var{name}. The sets of defined macro-variables
1050depend on the type of the notification and are described below.
1051
1052@kwindex define-message
1053 Message templates are defined using @code{define-message}
1054statement. Its syntax is as follows:
1055
1056@smallexample
1057define-message @var{id} [-]@var{delimiter}
1058@var{lines}
1059@var{delimiter}
1060@end smallexample
1061
1062 The @var{id} is a symbolic identifier used to refer to this message
1063in another configuration statements, @var{delimiter} is a delimiter
1064used to mark the end of the message template, and @var{lines} are any
1065number of lines that form the message template. If @var{delimiter} is
1066prefixed by a minus sign, any leading whitespace will be removed from
1067each template line, thus allowing to indent it in a natural
1068way. Furthermore, the @var{delimiter} itself is optional. If it is
1069omitted, the string @samp{end} is used to delimit the message.
1070The following example illustrates the simplest way to define a message
1071template:
1072
1073@smallexample
1074define-message my-message
1075Subject: test
1076
1077This is a test message.
1078end
1079@end smallexample
1080
1081 Following is the same message template, but indented in a more
1082natural way. @samp{EOT} is used as a message delimiter:
1083
1084@smallexample
1085define-message my-message -EOT
1086 Subject: test
1087
1088 This is a test message.
1089EOT
1090@end smallexample
1091
1092 It is important to notice, that the message template must supply
1093both @acronym{RFC} 822 headers, and message body, so it must always
1094consist of two parts, separated by a single empty line. If you do not
1095wish to supply any headers (which is unlikely, because a mail should
1096at least have a @code{Subject} header), simply begin the message text
1097with an empty line, like this:
1098
1099@smallexample
1100define-message my-message -EOT
1101
1102 This is a test message.
1103EOT
1104@end smallexample
1105
1041@node admin notification 1106@node admin notification
1042@subsection Admin Notification 1107@subsection Admin Notification
1043@kwindex mail-admin-stat 1108@kwindex mail-admin-stat
1044 Sending notifications to the system administrator is enabled by 1109 Sending notifications to the system administrator is enabled by
1045@code{mail-admin-stat} statement. It takes as its argument a list of 1110@code{mail-admin-stat} statement. It takes two or more arguments.
1046statistics keywords as described in @ref{statistics}. The notification 1111The first argument supplies the identifier of a message template,
1047will be sent only if statistics counters for at least one of the 1112which should be previously defined by a @code{define-message}.
1048requested categories are not zero. For example, the following 1113The rest of arguments is a list of statistics keywords as described in
1049statement requires sending notifications only if there ocurred any 1114@ref{statistics}. The notification will be sent only if statistics
1050errors or access violation attempts, or any bad signature was uploaded: 1115counters for at least one of the requested categories are not
1116zero. For example, the following statement requires sending
1117notifications only if there ocurred any errors or access violation
1118attempts, or any bad signature was uploaded:
1051 1119
1052@smallexample 1120@smallexample
1053mail-admin-stat errors access-violations bad-signatures 1121mail-admin-stat stat-msg errors access-violations bad-signatures
1054@end smallexample 1122@end smallexample
1055 1123
1056@kwindex 1124@kwindex
@@ -1063,36 +1131,8 @@ addresses, e.g.:
1063admin-address root@@gnu.org.ua, ftp-adm@@gnu.org.ua 1131admin-address root@@gnu.org.ua, ftp-adm@@gnu.org.ua
1064@end smallexample 1132@end smallexample
1065 1133
1066@kwindex admin-stat-message 1134@cindex meta-variables in admin notifications
1067 Finally, the text of the notification is given using 1135The meta-variables available for use in admin notifications are:
1068@code{admin-stat-message} statement. As any block statement,
1069it ends with an @code{end} keyword on a line by itself. The lines
1070between @code{admin-stat-message} and @code{end} statements compose
1071the notification text. This text must consist of two parts, separated
1072by a single empty line. The part before the empty line gives any
1073@acronym{RFC} 822 headers, and the part after it supplies the email
1074body. It is important that both parts be always present. If you do not
1075wish to supply any headers, simply begin the message text with an
1076empty line. Following is a simple example of the
1077@code{admin-stat-message} statement:
1078
1079@smallexample
1080admin-stat-message
1081Subject: Wydawca stats
1082
1083On my recent run I have noticed some events that may
1084need your attention.
1085
1086Regards,
1087Wydawca
1088end
1089@end smallexample
1090
1091@cindex meta-variables in @code{admin-stat-message}
1092 Any occurrence of @samp{%@{@var{name}@}} in the text is replaced
1093with the value of the meta-variable @var{name}. If such meta-variable
1094is not defined, this string is passed unchanged. The meta-variables
1095available for use in @code{admin-stat-message} text are:
1096 1136
1097@multitable @columnfractions 0.50 0.50 1137@multitable @columnfractions 0.50 0.50
1098@headitem Variable @tab Replaced with 1138@headitem Variable @tab Replaced with
@@ -1129,11 +1169,10 @@ triplets.
1129@item stat:rmsymlinks @tab Number of symbolic links removed. 1169@item stat:rmsymlinks @tab Number of symbolic links removed.
1130@end multitable 1170@end multitable
1131 1171
1132 These macro-variables can make the notification text be more 1172 An example definition of the admin notification template follows:
1133informative, as shown in the following example:
1134 1173
1135@smallexample 1174@smallexample
1136admin-stat-message 1175define-message stat-msg
1137Subject: Wydawca stats 1176Subject: Wydawca stats
1138 1177
1139This is to notify you that my run on %@{date@} 1178This is to notify you that my run on %@{date@}
@@ -1496,21 +1535,29 @@ Sets the sender address for mail notifications.
1496@xref{notification}, for more information on this statement. 1535@xref{notification}, for more information on this statement.
1497@end deffn 1536@end deffn
1498 1537
1499@deffn {Wydawca Statement} mail-admin-stat @var{condition-list} 1538@deffn {Wydawca Statement} mail-admin-stat @var{msg-id} @var{condition-list}
1500