def send(self) -> None: file = self._get_inline_screenshot() channel = self._get_channel() body = self._get_body() try: client = WebClient(token=app.config["SLACK_API_TOKEN"], proxy=app.config["SLACK_PROXY"]) # files_upload returns SlackResponse as we run it in sync mode. if file: response = cast( SlackResponse, client.files_upload( channels=channel, file=file, initial_comment=body, title="subject", ), ) assert response["file"], str(response) # the uploaded file else: response = cast( SlackResponse, client.chat_postMessage(channel=channel, text=body), ) assert response["message"]["text"], str(response) logger.info("Report sent to slack") except SlackClientError as ex: raise NotificationError(ex)
def send(self) -> None: files = self._get_inline_files() title = self._content.name channel = self._get_channel() body = self._get_body() file_type = "csv" if self._content.csv else "png" try: token = app.config["SLACK_API_TOKEN"] if callable(token): token = token() client = WebClient(token=token, proxy=app.config["SLACK_PROXY"]) # files_upload returns SlackResponse as we run it in sync mode. if files: for file in files: client.files_upload( channels=channel, file=file, initial_comment=body, title=title, filetype=file_type, ) else: client.chat_postMessage(channel=channel, text=body) logger.info("Report sent to slack") except SlackClientError as ex: raise NotificationError(ex) from ex
def send(self) -> None: file = self._get_inline_screenshot() channel = self._get_channel() body = self._get_body() try: token = app.config["SLACK_API_TOKEN"] if callable(token): token = token() client = WebClient(token=token, proxy=app.config["SLACK_PROXY"]) # files_upload returns SlackResponse as we run it in sync mode. if file: client.files_upload( channels=channel, file=file, initial_comment=body, title="subject", ) else: client.chat_postMessage(channel=channel, text=body) logger.info("Report sent to slack") except SlackClientError as ex: raise NotificationError(ex)
def send(self) -> None: subject = self._get_subject() content = self._get_content() to = self._get_to() try: send_email_smtp( to, subject, content.body, app.config, files=[], data=content.data, images=content.images, bcc="", mime_subtype="related", dryrun=False, ) logger.info("Report sent to email") except Exception as ex: raise NotificationError(ex)