def init_slack_map(unleash_instance): settings = queries.get_app_interface_settings() slack_notifications = unleash_instance['notifications']['slack'] slack_map = {} for slack_info in slack_notifications: slack_integrations = slack_info['workspace']['integrations'] slack_config = \ [i for i in slack_integrations if i['name'] == QONTRACT_INTEGRATION] [slack_config] = slack_config token = slack_config['token'] channel = slack_info['channel'] icon_emoji = slack_info['icon_emoji'] username = slack_info['username'] slack = SlackApi(token, settings=settings, init_usergroups=False, channel=channel, icon_emoji=icon_emoji, username=username) slack_map[channel] = slack return slack_map
def init_slack(jira_board): settings = queries.get_app_interface_settings() slack_info = jira_board['slack'] workspace = slack_info['workspace'] workspace_name = workspace['name'] slack_integrations = workspace['integrations'] jira_config = \ [i for i in slack_integrations if i['name'] == QONTRACT_INTEGRATION] [jira_config] = jira_config token = jira_config['token'] default_channel = jira_config['channel'] icon_emoji = jira_config['icon_emoji'] username = jira_config['username'] channel = slack_info.get('channel') or default_channel slack = SlackApi(workspace_name, token, settings=settings, init_usergroups=False, channel=channel, icon_emoji=icon_emoji, username=username) return slack
def get_slack_map(): permissions = get_permissions() slack_map = {} for sp in permissions: workspace = sp['workspace'] workspace_name = workspace['name'] if workspace_name in slack_map: continue workspace_spec = { "slack": SlackApi(workspace['token']), "managed_usergroups": workspace['managedUsergroups'] } slack_map[workspace_name] = workspace_spec return slack_map
def get_slack_map(): settings = queries.get_app_interface_settings() permissions = get_permissions() slack_map = {} for sp in permissions: workspace = sp['workspace'] workspace_name = workspace['name'] if workspace_name in slack_map: continue workspace_spec = { "slack": SlackApi(workspace['token'], settings=settings), "managed_usergroups": workspace['managedUsergroups'] } slack_map[workspace_name] = workspace_spec return slack_map
def _init_slack(self, slack_info): slack_integrations = slack_info['workspace']['integrations'] saas_deploy_config = \ [i for i in slack_integrations if i['name'] == self.integration] [saas_deploy_config] = saas_deploy_config token = saas_deploy_config['token'] default_channel = saas_deploy_config['channel'] icon_emoji = saas_deploy_config['icon_emoji'] username = saas_deploy_config['username'] channel = slack_info.get('channel') or default_channel slack = SlackApi(token, settings=self.settings, init_usergroups=False, channel=channel, icon_emoji=icon_emoji, username=username) return slack
def init_slack(slack_info, integration): settings = queries.get_app_interface_settings() slack_integrations = slack_info['workspace']['integrations'] slack_config = \ [i for i in slack_integrations if i['name'] == integration] [slack_config] = slack_config token = slack_config['token'] default_channel = slack_config['channel'] icon_emoji = slack_config['icon_emoji'] username = slack_config['username'] channel = slack_info.get('channel') or default_channel slack = SlackApi(token, settings=settings, init_usergroups=False, channel=channel, icon_emoji=icon_emoji, username=username) return slack