MantisSMTPServer : send email alert to sender on error adding his note
Benjamin Renard

Benjamin Renard commited on 2012-04-20 15:56:46
Showing 1 changed files, with 18 additions and 0 deletions.

... ...
@@ -152,7 +152,25 @@ class MantisSMTPServer(smtpd.SMTPServer):
152 152
 				self.add_attachment_to_issue(issue_id,msg)
153 153
 				return issue_id
154 154
 			else:
155
+				self.alert_sender(
156
+					msg,
157
+					u"[Mantis] Error occured adding your note to issue %s" % issue_id,
158
+					u"An error occured adding your note to issue %s. Your note has not been added.\n\nSubject : %s\n--\n%s" % (issue_id,msg.subject(),msg.get_text())
159
+				)
155 160
 				logging.error('Error adding issue')
161
+		except MantisWS.MantisWSError, e:
162
+			if e.type == 'unknown_issue_note_add':
163
+				subject = u"[Mantis] Issue %s does not exists. Can't add your note." % issue_id
164
+				content = u"Issue %s does not exists. Can't add your note :\n\nSubject : %s\n--\n%s" % (issue_id,msg.subject(),msg.get_text())
165
+
166
+			else:
167
+				subject = u"[Mantis] WS error occured adding your note to issue %s" % issue_id
168
+                                content = u"An WS error occured adding your note to issue %s. Your note has not been added.\n\nSubject : %s\n--\n%s" % (issue_id,msg.subject(),msg.get_text())
169
+			self.alert_sender(
170
+				msg,
171
+				subject,
172
+				content
173
+			)
156 174
 
157 175
 	def add_attachment_to_issue(self,issue_id,msg):
158 176
 		for attachment in msg.get_attachments():
159 177