-
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
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.