()
| 78 | |
| 79 | @app.route("/slack/events", methods=["POST"]) |
| 80 | def slack_app(): |
| 81 | if not signature_verifier.is_valid( |
| 82 | body=request.get_data(), |
| 83 | timestamp=request.headers.get("X-Slack-Request-Timestamp"), |
| 84 | signature=request.headers.get("X-Slack-Signature"), |
| 85 | ): |
| 86 | return make_response("invalid request", 403) |
| 87 | |
| 88 | raw_body = request.data.decode("utf-8") |
| 89 | body = parse_body(body=raw_body, content_type=extract_content_type(request.headers)) |
| 90 | rotate_tokens( |
| 91 | enterprise_id=extract_enterprise_id(body), |
| 92 | team_id=extract_team_id(body), |
| 93 | user_id=extract_user_id(body), |
| 94 | is_enterprise_install=extract_is_enterprise_install(body), |
| 95 | ) |
| 96 | |
| 97 | if "command" in request.form and request.form["command"] == "/token-rotation-modal": |
| 98 | try: |
| 99 | enterprise_id = request.form.get("enterprise_id") |
| 100 | team_id = request.form["team_id"] |
| 101 | bot = installation_store.find_bot( |
| 102 | enterprise_id=enterprise_id, |
| 103 | team_id=team_id, |
| 104 | ) |
| 105 | bot_token = bot.bot_token if bot else None |
| 106 | if not bot_token: |
| 107 | return make_response("Please install this app first!", 200) |
| 108 | |
| 109 | client = WebClient(token=bot_token) |
| 110 | trigger_id = request.form["trigger_id"] |
| 111 | response = client.views_open( |
| 112 | trigger_id=trigger_id, |
| 113 | view={ |
| 114 | "type": "modal", |
| 115 | "callback_id": "modal-id", |
| 116 | "title": {"type": "plain_text", "text": "Awesome Modal"}, |
| 117 | "submit": {"type": "plain_text", "text": "Submit"}, |
| 118 | "close": {"type": "plain_text", "text": "Cancel"}, |
| 119 | "blocks": [ |
| 120 | { |
| 121 | "type": "input", |
| 122 | "block_id": "b-id", |
| 123 | "label": { |
| 124 | "type": "plain_text", |
| 125 | "text": "Input label", |
| 126 | }, |
| 127 | "element": { |
| 128 | "action_id": "a-id", |
| 129 | "type": "plain_text_input", |
| 130 | }, |
| 131 | } |
| 132 | ], |
| 133 | }, |
| 134 | ) |
| 135 | return make_response("", 200) |
| 136 | except SlackApiError as e: |
| 137 | code = e.response["error"] |
nothing calls this directly
no test coverage detected