-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
54 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,20 +18,23 @@ class BaseSettings: | |
SENTRY_URI = "" | ||
ASANA_TOKEN = os.environ.get("ASANA_TOKEN", "") | ||
ASANA_WORKSPACE = "1199978051314275" | ||
SLACK_TOKEN = os.environ.get("SLACK_TOKEN", "") | ||
SLACK_BLOCKS_CHANNEL = "" | ||
|
||
|
||
class ProductionSettings(BaseSettings): | ||
ENVIRONMENT = "production" | ||
|
||
SERVER_BASE_URI = "https://integrations.tesselo.com" | ||
SENTRY_URI = "https://[email protected]/5911249" # noqa: E501 | ||
SLACK_BLOCKS_CHANNEL = "C02GXT5UY22" | ||
|
||
|
||
class StagingSettings(BaseSettings): | ||
ENVIRONMENT = "staging" | ||
|
||
ASANA_WORKSPACE = "1199978051314275" | ||
SERVER_BASE_URI = "https://integrations-staging.tesselo.com" | ||
SLACK_BLOCKS_CHANNEL = "C021VUWGA3E" # dev-null | ||
|
||
|
||
class DevelopmentSettings(BaseSettings): | ||
|
@@ -41,6 +44,7 @@ class DevelopmentSettings(BaseSettings): | |
SQLALCHEMY_DATABASE_URI = os.getenv("GIGES_DATABASE_URI") or ( | ||
"postgresql://postgres@localhost:5432/giges_dev" | ||
) | ||
SLACK_BLOCKS_CHANNEL = "C021VUWGA3E" # dev-null | ||
|
||
|
||
class TestingSettings(BaseSettings): | ||
|
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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from typing import Any | ||
|
||
import structlog | ||
from flask import current_app | ||
from slack_sdk import WebClient | ||
from slack_sdk.errors import SlackApiError | ||
from slack_sdk.web import SlackResponse | ||
|
||
logger = structlog.get_logger(__file__) | ||
|
||
|
||
class SlackClient(WebClient): | ||
def __init__(self, **kwargs: Any): | ||
super().__init__(token=current_app.config["SLACK_TOKEN"], **kwargs) | ||
|
||
def send_message(self, channel: str, message: str) -> SlackResponse: | ||
try: | ||
return self.chat_postMessage(channel=channel, text=message) | ||
except SlackApiError as e: | ||
logger.error("Failed to send a message to slack", error=e) | ||
|
||
def send_to_road_blocks(self, message: str) -> SlackResponse: | ||
return self.send_message( | ||
current_app.config["SLACK_BLOCKS_CHANNEL"], message | ||
) |
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