-
Notifications
You must be signed in to change notification settings - Fork 286
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #827 from vanessa/fix-787
Update Slack integration to use SDK
- Loading branch information
Showing
16 changed files
with
834 additions
and
551 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .event import Event, EventPageContent, EventPageMenu | ||
from .user import User, user_invite | ||
from .user import User, invite_user_to_slack | ||
|
||
__all__ = ["Event", "EventPageContent", "EventPageMenu", "User", "user_invite"] | ||
__all__ = ["Event", "EventPageContent", "EventPageMenu", "User", "invite_user_to_slack"] |
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 |
---|---|---|
@@ -1,8 +1,20 @@ | ||
from django.conf import settings | ||
from slacker import Slacker | ||
from slack_sdk import WebClient | ||
|
||
slack = Slacker(settings.SLACK_API_KEY) | ||
slack_client = WebClient(token=settings.SLACK_BOT_TOKEN) | ||
|
||
|
||
def user_invite(email, first_name): | ||
return slack.users.post("users.admin.invite", params={"email": email, "first_name": first_name, "set_active": True}) | ||
def invite_user_to_slack(email, first_name): | ||
return slack_client.admin_users_invite( | ||
channel_ids=settings.SLACK_INVITE_CHANNEL_IDS, | ||
team_id=settings.SLACK_TEAM_ID, | ||
email=email, | ||
first_name=first_name, | ||
set_active=True, | ||
) | ||
|
||
|
||
def post_message_to_slack(channel: str, message: str): | ||
return slack_client.chat_postMessage( | ||
channel=channel, text=message, username="Django Girls", icon_emoji=":django_heart:" | ||
) |
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 |
---|---|---|
|
@@ -188,7 +188,9 @@ def gettext(s): | |
DEFAULT_FROM_EMAIL = "[email protected]" | ||
|
||
ENABLE_SLACK_NOTIFICATIONS = sanitize(os.environ.get("ENABLE_SLACK_NOTIFICATIONS", False), bool) | ||
SLACK_API_KEY = os.environ.get("SLACK_API_KEY") | ||
SLACK_BOT_TOKEN = os.environ.get("SLACK_BOT_TOKEN") | ||
SLACK_TEAM_ID = os.environ.get("SLACK_TEAM_ID") | ||
SLACK_INVITE_CHANNEL_IDS = os.environ.get("SLACK_INVITE_CHANNEL_IDS", "").split(",") | ||
|
||
RECAPTCHA_PUBLIC_KEY = os.environ.get("RECAPTCHA_PUBLIC_KEY", "") | ||
RECAPTCHA_PRIVATE_KEY = os.environ.get("RECAPTCHA_PRIVATE_KEY", "") | ||
|
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
Oops, something went wrong.