예제 #1
0
from busy_beaver.apps.upcoming_events.workflow import (
    generate_next_event_message,
    generate_upcoming_events_message,
)
from busy_beaver.config import (
    FULL_INSTALLATION_WORKSPACE_IDS,
    GITHUB_CLIENT_ID,
    GITHUB_REDIRECT_URI,
    MEETUP_GROUP_NAME,
)
from busy_beaver.extensions import db
from busy_beaver.models import GitHubSummaryUser, SlackInstallation
from busy_beaver.toolbox import EventEmitter

logger = logging.getLogger(__name__)
slash_command_dispatcher = EventEmitter()

ACCOUNT_ALREADY_ASSOCIATED = (
    "You have already associated a GitHub account with your Slack handle. "
    "Please use `/busybeaver reconnect` to link to a different account.")
NO_ASSOCIATED_ACCOUNT = (
    "No associated account. Use `/busybeaver connect` to link your account.")
VERIFY_ACCOUNT = (
    "Follow the link below to validate your GitHub account. "
    "I'll reference your GitHub username to track your public activity.")
HELP_TEXT = (
    "`/busybeaver next`\t\t Retrieve next event\n"
    "`/busybeaver events`\t\t Retrieve list of upcoming event\n"
    "`/busybeaver connect`\t\t Connect GitHub Account\n"
    "`/busybeaver reconnect`\t\t Connect to difference GitHub Account\n"
    "`/busybeaver disconnect`\t\t Disconenct GitHub Account\n"
예제 #2
0
import logging

from flask import jsonify, request
from flask.views import MethodView

from .decorators import github_verification_required
from busy_beaver import chipy_slack
from busy_beaver.apps.github_webhook.workflow import (
    generate_new_issue_message,
    generate_new_pull_request_message,
)
from busy_beaver.exceptions import UnverifiedWebhookRequest
from busy_beaver.toolbox import EventEmitter

logger = logging.getLogger(__name__)
github_event_dispatcher = EventEmitter()


class GitHubEventSubscriptionResource(MethodView):
    """Callback endpoint for GitHub event subscriptions"""

    decorators = [github_verification_required]

    def post(self):
        data = request.json
        logger.info("[Busy Beaver] Received GitHub event",
                    extra={"req_json": data})

        event_type = request.headers.get("X-GitHub-Event", None)
        if not event_type:
            raise UnverifiedWebhookRequest("Missing GitHub event type")
예제 #3
0
def event_emitter():
    return EventEmitter()
예제 #4
0
from flask import jsonify, request
from flask.views import MethodView

from .decorators import slack_verification_required
from .slash_command import HELP_TEXT
from busy_beaver.adapters import SlackAdapter
from busy_beaver.apps.external_integrations.state_machine import (
    SlackInstallationOnboardUserWorkflow, )
from busy_beaver.apps.external_integrations.workflow import (
    GITHUB_SUMMARY_CHANNEL_JOIN_MESSAGE, )
from busy_beaver.extensions import db
from busy_beaver.models import GitHubSummaryConfiguration, SlackInstallation
from busy_beaver.toolbox import EventEmitter

logger = logging.getLogger(__name__)
subscription_dispatch = EventEmitter()
event_dispatch = EventEmitter()


class SlackEventSubscriptionResource(MethodView):
    """Callback endpoint for Slack event subscriptions"""

    decorators = [slack_verification_required]

    def post(self):
        data = request.json
        logger.info("[Busy Beaver] Received event from Slack",
                    extra={"req_json": data})
        return subscription_dispatch.emit(data["type"],
                                          default="not_found",
                                          data=data)