Summary:
This module allows Drupal to receive and execute commands sent from Slack via their Outgoing Webhooks integration. Developers can use this module as a launching point for things like executing Drush commands and printing the output into a Slack channel, or for creating their own Drupal-powered SlackBots.
Slack will send POST data to a menu callback in Drupal which this module enables at /slack_receive. If the post contains the correct Slack Token, Slack Receive will then execute any functions that are implemented via hook_slack_receive_api.
Note: this module is a an API module and doesn't do anything on its own. The included slack_receive_example module contains working examples of functionality that are possible via Slack Receive.
Difference from existing Slack module:
The existing Slack module is meant for sending information from Drupal to Slack - this module does the opposite. I think keeping the modules separate makes sense as site maintainers may want one ability but not the other. Also, since the integration endpoints (and Tokens used for access) are totally different - it's effectively a completely different API on both ends.
Project Link: Slack Receive
Git clone link: git clone --branch 7.x-1.x https://git.drupal.org/sandbox/pninny2001/2677166.git
Comments
Comment #2
PA robot commentedThere are some errors reported by automated review tools, did you already check them? See http://pareview.sh/pareview/httpgitdrupalorgsandboxpninny20012677166git
We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)
Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).
I'm a robot and this is an automated message from Project Applications Scraper.
Comment #3
msherron commentedComment #4
msherron commentedI've pushed some updates based on the PAReview bot. Thanks!
Comment #5
msherron commentedComment #6
msherron commentedComment #7
rgristroph commentedMinor issues only --
1) There is a misspelling of "receive" on line 5 of the README.txt, also a typo on line 5 of slack_receive_admin.inc
2) Should there be a slack_receive.api.inc file ? It seems that the slack_example does a better job of documenting that, and I didn't see anything about api.inc files in the code standards. This might be a non-issue.
I also installed the module locally, did some basic testing.
Comment #8
pankajsachdeva commentedAutomated Review
Found some issues, you can see on this link : http://pareview.sh/pareview/httpgitdrupalorgsandboxpninny20012677166git
Manual Review
This review uses the Project Application Review Template.
Comment #9
msherron commentedComment #10
msherron commentedDocs update, added slack_receive.api.inc, and slack_receive_help per feedback.
Comment #11
steven.wichers commentedSome quick things:
Example module is missing t() around some translatable strings.
Main module menu item implementation should probably leverage 'file path' instead of putting the path in the file name.
Receive callback should implement a different delivery callback to ensure proper headers and site behavior. See ajax_deliver https://api.drupal.org/api/drupal/includes!ajax.inc/function/ajax_deliver/7 for an example. I believe right now if there is an error then your receive callback will render a Drupal error page.
Comment #12
msherron commentedAdded some t() and better file path handling per feedback. drupal_json_output() sets headers like you described and just to be sure, I've tested to make sure errors are printed normally without bootstrapping a whole page. Thanks!
Comment #13
pankajsachdeva commentedHi @msherron,
I am getting an error message when I am accessing front page of my website:
Comment #14
pankajsachdeva commentedComment #15
msherron commentedI added a check to test if the token is empty. I also made a change to force JSON headers from within the delivery callback before the hook is created.
Comment #16
msherron commentedComment #17
steven.wichers commentedComment #18
ayesh commentedHi Michael,
I reviewed your module well, and I must say almost everything looks quite good! I really hope this would be a good example for others to get a project reviewed quickly.
I also agree with Steven marking this RTBC (#17). However, there are few points I have to mention. Not blockers IMO.
- It is not clear how Slack responds to different types of HTTP response codes. But this module always sends a 200 code, which can make Slack assume everything went well. Since you override the delivery callback of the router for the incoming hook, it becomes the new delivery callbacks responsibility to properly send a valid and appropriate response code. The site offline case could send a 503, invalid token could use a 403, and so on.
- In
slack_receive()I don't think copying the $_POST data to $data is necessary. It requires twice the memory as the payload.- A flood protection to block the IP address after a certain number of wrong token would be nice.
Comment #19
msherron commentedHi @Ayesh,
I implemented some of your and @steven.wichers suggestions, and if you have some time, I'd love for you to give some feedback on the changes:
Thanks for the help!
Comment #20
ayesh commentedHi Michael,
The 200 HTTP status thing I mentioned merely for the semantics of similar RESTful services. If Slack is working differently, by all means, please feel free to adjust it anyway you'd like.
Since this was in RTBC for 2 whole months and no objections...
Thanks for your contribution, Michael!
I updated your account so you can promote this to a full project and also create new projects as either a sandbox or a "full" project.
Here are some recommended readings to help with excellent maintainership:
You can find lots more contributors chatting on IRC in #drupal-contribute. So, come hang out and stay involved!
Thanks, also, for your patience with the review process. Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.
Thanks to the dedicated reviewer(s) as well.
Comment #21
msherron commentedHi @Ayesh,
Thanks for the role! I really appreciated the feedback.