-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bugfix/filter-not-showing-tags-in-counter
- Loading branch information
Showing
8 changed files
with
51 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,18 @@ | |
:license: Apache, see LICENSE for more details. | ||
.. moduleauthor:: Kevin Glisson <[email protected]> | ||
""" | ||
|
||
from blockkit import Message | ||
import io | ||
import json | ||
import logging | ||
from typing import List, Optional, Any | ||
from slack_sdk.errors import SlackApiError | ||
from sqlalchemy.orm import Session | ||
|
||
from dispatch.auth.models import DispatchUser | ||
from dispatch.case.models import Case | ||
from dispatch.config import DISPATCH_UI_URL | ||
from dispatch.conversation.enums import ConversationCommands | ||
from dispatch.decorators import apply, counter, timer | ||
from dispatch.plugin import service as plugin_service | ||
|
@@ -97,6 +101,23 @@ def create_threaded(self, case: Case, conversation_id: str, db_session: Session) | |
blocks=message, | ||
) | ||
case.signal_thread_ts = signal_response.get("timestamp") | ||
try: | ||
client.files_upload( | ||
channels=conversation_id, | ||
thread_ts=case.signal_thread_ts, | ||
initial_comment=f"First alert in `{case.name}` (see all in <{DISPATCH_UI_URL}/{case.project.organization.slug}/cases/{case.name}|Dispatch UI>):", | ||
filetype="json", | ||
file=io.BytesIO(json.dumps(case.signal_instances[0].raw, indent=4).encode()), | ||
) | ||
except SlackApiError as e: | ||
if e.response["error"] == SlackAPIErrorCode.MISSING_SCOPE: | ||
logger.exception( | ||
f"Error uploading alert JSON to the Case thread due to missing scope: {e}" | ||
) | ||
else: | ||
logger.exception(f"Error uploading alert JSON to the Case thread: {e}") | ||
except Exception as e: | ||
logger.exception(f"Error uploading alert JSON to the Case thread: {e}") | ||
db_session.commit() | ||
return response | ||
|
||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.