Skip to content
This repository has been archived by the owner on Jun 29, 2020. It is now read-only.

Commit

Permalink
Slack招待用のメソッド実装
Browse files Browse the repository at this point in the history
  • Loading branch information
giginet committed Feb 10, 2016
1 parent 9634dd9 commit 6f12f25
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Empty file.
27 changes: 27 additions & 0 deletions src/kawaz/core/slack/utils.py
@@ -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


0 comments on commit 6f12f25

Please sign in to comment.