def get(self, request, resource=None):
app_integration = get_integration_token(
request.user, APP_INTEGRATION_PROVIDER_SLACK, task=request.GET.get('task')
)
if app_integration and app_integration.extra:
extra = json.loads(app_integration.extra)
slack_client = Slacker(app_integration.token)
response = None
if resource == 'channels':
channel_response = slack_client.channels.list(exclude_archived=True)
if channel_response.successful:
response = channel_response.body.get(slack_utils.KEY_CHANNELS, None)
else:
response = {
'team': {'name': extra.get('team_name'), 'id': extra.get('team_id', None)},
# 'incoming_webhook': {'channel': extra.get('incoming_webhook').get('channel')}
}
if response:
return Response(response, status.HTTP_200_OK)
return Response({'status': 'Failed'}, status.HTTP_400_BAD_REQUEST)
return Response({'status': 'Not implemented'}, status.HTTP_501_NOT_IMPLEMENTED)
评论列表
文章目录