This repository has been archived by the owner on Jun 29, 2020. It is now read-only.
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
2 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
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,27 @@ | ||
import requests | ||
from django.core.exceptions import ImproperlyConfigured | ||
from django.conf import settings | ||
|
||
ENDPOINT = '/api/users.admin.invite' | ||
|
||
|
||
def invite_to_slack(email): | ||
token = getattr(settings, 'SLACK_ADMIN_TOKEN', None) | ||
base_url = getattr(settings, 'SLACK_BASE_URL', None) | ||
if not token: | ||
raise ImproperlyConfigured('SLACK_ADMIN_TOKEN is not set') | ||
if not base_url: | ||
raise ImproperlyConfigured('SLACK_BASE_URL is not set') | ||
url = "#{}#{}".format(base_url, ENDPOINT) | ||
params = { | ||
'email': email, | ||
'token': token, | ||
'set_active': True | ||
} | ||
try: | ||
requests.post(url, params) | ||
except: | ||
# fail silently | ||
pass | ||
|
||
|