views.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:tunga-api 作者: tunga-io 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号