new: Contact event reporter

pull/471/head
Raphaël Vinot 2019-08-28 16:02:20 +02:00
parent cebdc2ef3f
commit a5d4910c1f
2 changed files with 10 additions and 0 deletions

View File

@ -241,6 +241,13 @@ class ExpandedPyMISP(PyMISP):
response = self._prepare_request('POST', f'events/publish/{event_id}')
return self._check_response(response, expect_json=True)
def contact_event_reporter(self, event: Union[MISPEvent, int, str, UUID], message: str):
"""Send a message to the reporter of an event"""
event_id = self.__get_uuid_or_id_from_abstract_misp(event)
to_post = {'message': message}
response = self._prepare_request('POST', f'events/contact/{event_id}', data=to_post)
return self._check_response(response, expect_json=True)
# ## END Event ###
# ## BEGIN Object ###

View File

@ -794,6 +794,9 @@ class TestComprehensive(unittest.TestCase):
self.assertEqual(events[0].info, 'foo bar blah')
self.assertEqual(events[0].attributes, [])
# Contact reporter
r = self.user_misp_connector.contact_event_reporter(events[0].id, 'This is a test')
self.assertEqual(r['message'], 'Email sent to the reporter.')
finally:
# Delete event
self.admin_misp_connector.delete_event(first)