bernard357 / shellbot

Fast, simple and lightweight micro bot-framework for Python.
Apache License 2.0
10 stars 3 forks source link

Issue when different domain is used #5

Closed guillain closed 7 years ago

guillain commented 7 years ago

When it's not the same domain used for the moderator and the bot an issue appears during the webhook registration.

Log:

21:46:51 https://api.ciscospark.com:443 "POST /v1/webhooks HTTP/1.1" 400 163
21:46:51 Unable to add webhook
21:46:51 Response Code [400] - The request was invalid or cannot be otherwise served. An accompanying error message will explain further.
Traceback (most recent call last):
  File "/var/www/shellbot/shellbot/spaces/ciscospark.py", line 614, in register
    filter='roomId='+self.id)
  File "/usr/lib/python2.7/site-packages/ciscosparkapi/api/webhooks.py", line 199, in create
    json_obj = self._session.post('webhooks', json=post_data)
  File "/usr/lib/python2.7/site-packages/ciscosparkapi/restsession.py", line 187, in post
    check_response_code(response, erc)
  File "/usr/lib/python2.7/site-packages/ciscosparkapi/utils.py", line 104, in check_response_code
    response=response)
SparkApiError: Response Code [400] - The request was invalid or cannot be otherwise served. An accompanying error message will explain further.
21:46:52 Speaker is working on 1
21:46:52 Posting message
21:46:52 - text: Welcome to this on-demand collaborative room
bernard357 commented 7 years ago

@guillain the current behavior of shellbot is that: room is created by the bot token, yet the webhook is registered by the personal token. Would you like to suggest another way to proceed?

guillain commented 7 years ago

Hi @bernard357 , Webhook and its token can be provided by bot to avoid this issue. An other advantage can be the bot migration because in that case when user change the bot and keep the same space the new bot will be able to create the webhook (but after to depend of the space integration and if it should be linked to the user or not).

guillain commented 7 years ago

Tests to renew since the new bot version.

guillain commented 7 years ago

The new bot version has solved effectively this defect. thanks