diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-09-06 13:05:56 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2007-09-06 13:05:56 +0000 |
commit | 747e41693d7f2a808b3314cf82b3af38f98daf2d (patch) | |
tree | a023fea0ac96b2abdc2c98141d90a841544dbbf9 | |
parent | afd4995c30c273a02f81e80a972688936907853a (diff) | |
download | wydawca-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-- | ChangeLog | 16 | ||||
-rwxr-xr-x | bootstrap | 2 | ||||
-rw-r--r-- | doc/wydawca.texi | 143 | ||||
-rw-r--r-- | etc/messages.rc (renamed from src/wydawca.rc) | 110 | ||||
-rw-r--r-- | etc/wydawca.rc | 63 | ||||
-rw-r--r-- | src/config.c | 167 | ||||
-rw-r--r-- | src/mail.c | 172 | ||||
-rw-r--r-- | src/mail.h | 4 | ||||
-rw-r--r-- | src/wydawca.h | 18 |
9 files changed, 491 insertions, 204 deletions
@@ -1,3 +1,19 @@ | |||
1 | 2007-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 | |||
1 | 2007-09-05 Sergey Poznyakoff <gray@gnu.org.ua> | 17 | 2007-09-05 Sergey Poznyakoff <gray@gnu.org.ua> |
2 | 18 | ||
3 | * doc/wydawca.texi: Update. | 19 | * doc/wydawca.texi: Update. |
@@ -42,7 +42,7 @@ fi | |||
42 | test -d m4 || mkdir m4 || exit 1 | 42 | test -d m4 || mkdir m4 || exit 1 |
43 | test -d gnu || mkdir gnu || exit 1 | 43 | test -d gnu || mkdir gnu || exit 1 |
44 | 44 | ||
45 | svn export http://svn.gnu.org.ua/sources/gsc/trunk/lib lib && | 45 | svn 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 |
981 | called @dfn{mailer}. It is set in the configuration file using | 982 | called @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 | ||
1048 | expanding any occurrances of @samp{%@{@var{name}@}} within it with the value | ||
1049 | of macro-variable @var{name}. The sets of defined macro-variables | ||
1050 | depend on the type of the notification and are described below. | ||
1051 | |||
1052 | @kwindex define-message | ||
1053 | Message templates are defined using @code{define-message} | ||
1054 | statement. Its syntax is as follows: | ||
1055 | |||
1056 | @smallexample | ||
1057 | define-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 | ||
1063 | in another configuration statements, @var{delimiter} is a delimiter | ||
1064 | used to mark the end of the message template, and @var{lines} are any | ||
1065 | number of lines that form the message template. If @var{delimiter} is | ||
1066 | prefixed by a minus sign, any leading whitespace will be removed from | ||
1067 | each template line, thus allowing to indent it in a natural | ||
1068 | way. Furthermore, the @var{delimiter} itself is optional. If it is | ||
1069 | omitted, the string @samp{end} is used to delimit the message. | ||
1070 | The following example illustrates the simplest way to define a message | ||
1071 | template: | ||
1072 | |||
1073 | @smallexample | ||
1074 | define-message my-message | ||
1075 | Subject: test | ||
1076 | |||
1077 | This is a test message. | ||
1078 | end | ||
1079 | @end smallexample | ||
1080 | |||
1081 | Following is the same message template, but indented in a more | ||
1082 | natural way. @samp{EOT} is used as a message delimiter: | ||
1083 | |||
1084 | @smallexample | ||
1085 | define-message my-message -EOT | ||
1086 | Subject: test | ||
1087 | |||
1088 | This is a test message. | ||
1089 | EOT | ||
1090 | @end smallexample | ||
1091 | |||
1092 | It is important to notice, that the message template must supply | ||
1093 | both @acronym{RFC} 822 headers, and message body, so it must always | ||
1094 | consist of two parts, separated by a single empty line. If you do not | ||
1095 | wish to supply any headers (which is unlikely, because a mail should | ||
1096 | at least have a @code{Subject} header), simply begin the message text | ||
1097 | with an empty line, like this: | ||
1098 | |||
1099 | @smallexample | ||
1100 | define-message my-message -EOT | ||
1101 | |||
1102 | This is a test message. | ||
1103 | EOT | ||
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. |
1046 | statistics keywords as described in @ref{statistics}. The notification | 1111 | The first argument supplies the identifier of a message template, |
1047 | will be sent only if statistics counters for at least one of the | 1112 | which should be previously defined by a @code{define-message}. |
1048 | requested categories are not zero. For example, the following | 1113 | The rest of arguments is a list of statistics keywords as described in |
1049 | statement requires sending notifications only if there ocurred any | 1114 | @ref{statistics}. The notification will be sent only if statistics |
1050 | errors or access violation attempts, or any bad signature was uploaded: | 1115 | counters for at least one of the requested categories are not |
1116 | zero. For example, the following statement requires sending | ||
1117 | notifications only if there ocurred any errors or access violation | ||
1118 | attempts, or any bad signature was uploaded: | ||
1051 | 1119 | ||
1052 | @smallexample | 1120 | @smallexample |
1053 | mail-admin-stat errors access-violations bad-signatures | 1121 | mail-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.: | |||
1063 | admin-address root@@gnu.org.ua, ftp-adm@@gnu.org.ua | 1131 | admin-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 | 1135 | The meta-variables available for use in admin notifications are: |
1068 | @code{admin-stat-message} statement. As any block statement, | ||
1069 | it ends with an @code{end} keyword on a line by itself. The lines | ||
1070 | between @code{admin-stat-message} and @code{end} statements compose | ||
1071 | the notification text. This text must consist of two parts, separated | ||
1072 | by 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 | ||
1074 | body. It is important that both parts be always present. If you do not | ||
1075 | wish to supply any headers, simply begin the message text with an | ||
1076 | empty line. Following is a simple example of the | ||
1077 | @code{admin-stat-message} statement: | ||
1078 | |||
1079 | @smallexample | ||
1080 | admin-stat-message | ||
1081 | Subject: Wydawca stats | ||
1082 | |||
1083 | On my recent run I have noticed some events that may | ||
1084 | need your attention. | ||
1085 | |||
1086 | Regards, | ||
1087 | Wydawca | ||
1088 | end | ||
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 | ||
1093 | with the value of the meta-variable @var{name}. If such meta-variable | ||
1094 | is not defined, this string is passed unchanged. The meta-variables | ||
1095 | available 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: |
1133 | informative, as shown in the following example: | ||
1134 | 1173 | ||
1135 | @smallexample | 1174 | @smallexample |
1136 | admin-stat-message | 1175 | define-message stat-msg |
1137 | Subject: Wydawca stats | 1176 | Subject: Wydawca stats |
1138 | 1177 | ||
1139 | This is to notify you that my run on %@{date@} | 1178 | This 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 |