Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

[BUG] Interactive messages don't have 'action_id' #13

Closed
Kludex opened this issue Nov 10, 2020 · 4 comments
Closed

[BUG] Interactive messages don't have 'action_id' #13

Kludex opened this issue Nov 10, 2020 · 4 comments

Comments

@Kludex
Copy link

Kludex commented Nov 10, 2020

Hello there!

I've found an issue. When I have an action type being interactive_message, the data I receive doesn't contain an action_id, only name, type and selected_options, therefore I receive this error:

INFO:     34.207.162.7:0 - "POST /slack/actions HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 389, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 45, in __call__
    return await self.app(scope, receive, send)
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/fastapi/applications.py", line 149, in __call__
    await super().__call__(scope, receive, send)
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/starlette/applications.py", line 102, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/starlette/middleware/errors.py", line 181, in __call__
    raise exc from None
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/starlette/exceptions.py", line 82, in __call__
    raise exc from None
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/starlette/routing.py", line 550, in __call__
    await route.handle(scope, receive, send)
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/starlette/routing.py", line 227, in handle
    await self.app(scope, receive, send)
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/starlette/routing.py", line 41, in app
    response = await func(request)
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/fastapi/routing.py", line 196, in app
    raw_response = await run_endpoint_function(
  File "/home/marcelo/anaconda3/envs/coinprice/lib/python3.8/site-packages/fastapi/routing.py", line 148, in run_endpoint_function
    return await dependant.call(**values)
  File "/home/marcelo/Development/fastapi/slackers/src/slackers/server.py", line 47, in post_actions
    triggered_events = [
  File "/home/marcelo/Development/fastapi/slackers/src/slackers/server.py", line 48, in <listcomp>
    f"{action.type}:{triggered_action['action_id']}"

Can someone help me?

Changing the conditionals on the server.actions solves the problem:

@router.post(
    "/actions",
    status_code=HTTP_200_OK,
    dependencies=[Depends(verify_signature), Depends(check_timeout)],
)
async def post_actions(request: Request) -> Response:
    form = await request.form()
    form_data = json.loads(form["payload"])
    # have the convenience of pydantic validation
    action = SlackAction(**form_data)
    _events = [action.type]
    if action.callback_id:
        _events.append(f"{action.type}:{action.callback_id}")
    elif action.actions: 
        triggered_events = [
            f"{action.type}:{triggered_action['action_id']}"
            for triggered_action in action.actions
        ]
        _events.extend(triggered_events)

@uhavin are you still maintaining this package?

@uhavin
Copy link
Owner

uhavin commented Nov 11, 2020

@Kludex Hi, thanks for reporting. I am happy to look into this. If you could wait a couple of days; it's more of a side project for me. This weekend I should have some spare hours, so if you can wait that long I'll see what I can do.

As for maintaining, I am no longer an active user myself - I had a use probable use case, but in the end it didn't come to actually using it. Any errors I am happy to look into but I am not proactively maintaining it.

@Kludex
Copy link
Author

Kludex commented Nov 12, 2020

Thank you! 👍

@uhavin
Copy link
Owner

uhavin commented Nov 14, 2020

Hi @Kludex, Just now I added support for interactive messages. Your error should be resolved and I've added some events to act on interactive messages more conveniently. Please let me know how this works for you. If you have suggestions to further improve the interactive message handling (or any other part of slackers), please don't hesitate to ask.

https://github.com/uhavin/slackers#interactive-messages

@Kludex
Copy link
Author

Kludex commented Nov 14, 2020

@uhavin Thank you very much! :)

@Kludex Kludex closed this as completed Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants