@@ -61,6 +61,8 @@ public class EmailPlugin {
6161
6262 private static AtomicInteger ai = new AtomicInteger (0 );
6363 private static List <Integer > javaeeObjHashList = new ArrayList <Integer >();
64+ private static AlertPack lastPack ;
65+ private static long lastSentTimestamp ;
6466
6567 public EmailPlugin () {
6668 if (ai .incrementAndGet () == 1 ) {
@@ -155,6 +157,41 @@ public void run() {
155157 title = "An object has been inactivated." ;
156158 msg = pack .message .substring (0 , pack .message .indexOf ("OBJECT" ) - 1 );
157159 }
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+ }
158195
159196 // Make email message
160197 String message = "[TYPE] : " + pack .objType .toUpperCase () + "\n " +
@@ -186,7 +223,8 @@ public void run() {
186223
187224 // Send the email
188225 email .send ();
189-
226+
227+ lastSentTimestamp = System .currentTimeMillis ();
190228 println ("Email sent to [" + to + "] successfully." );
191229 } catch (Exception e ) {
192230 println ("[Error] : " + e .getMessage ());
0 commit comments