@@ -61,6 +61,8 @@ public class EmailPlugin {
61
61
62
62
private static AtomicInteger ai = new AtomicInteger (0 );
63
63
private static List <Integer > javaeeObjHashList = new ArrayList <Integer >();
64
+ private static AlertPack lastPack ;
65
+ private static long lastSentTimestamp ;
64
66
65
67
public EmailPlugin () {
66
68
if (ai .incrementAndGet () == 1 ) {
@@ -155,6 +157,41 @@ public void run() {
155
157
title = "An object has been inactivated." ;
156
158
msg = pack .message .substring (0 , pack .message .indexOf ("OBJECT" ) - 1 );
157
159
}
160
+
161
+ try {
162
+ String ignoreNamePattern = conf .getValue ("ext_plugin_ignore_name_patterns" );
163
+ String ignoreTitlePattern = conf .getValue ("ext_plugin_ignore_title_patterns" );
164
+
165
+ if (ignoreNamePattern != null && !"" .equals (ignoreNamePattern )) {
166
+ for (String pattern : ignoreNamePattern .split ("," )) {
167
+ if (name .matches (".*[" + pattern .replaceAll ("-" , "\\ \\ -" ) + "].*" )) {
168
+ return ;
169
+ }
170
+ }
171
+ }
172
+
173
+ if (ignoreTitlePattern != null && !"" .equals (ignoreTitlePattern )) {
174
+ for (String pattern : ignoreTitlePattern .split ("," )) {
175
+ if (title .matches (".*[" + pattern .replaceAll ("-" , "\\ \\ -" ) + "].*" )) {
176
+ return ;
177
+ }
178
+ }
179
+ }
180
+
181
+ if (conf .getBoolean ("ext_plugin_ignore_continuous_dup_alert" , false ) && lastPack != null ) {
182
+ long diff = System .currentTimeMillis () - lastSentTimestamp ;
183
+ if (lastPack .objHash == pack .objHash
184
+ && lastPack .title .equals (pack .title )
185
+ && diff < DateUtil .MILLIS_PER_HOUR ) {
186
+ return ;
187
+ }
188
+ }
189
+
190
+ lastPack = pack ;
191
+ } catch (Exception e ) {
192
+ // ignore
193
+ println ("[Error] : " + e .getMessage ());
194
+ }
158
195
159
196
// Make email message
160
197
String message = "[TYPE] : " + pack .objType .toUpperCase () + "\n " +
@@ -186,7 +223,8 @@ public void run() {
186
223
187
224
// Send the email
188
225
email .send ();
189
-
226
+
227
+ lastSentTimestamp = System .currentTimeMillis ();
190
228
println ("Email sent to [" + to + "] successfully." );
191
229
} catch (Exception e ) {
192
230
println ("[Error] : " + e .getMessage ());
0 commit comments