benoittgt
Hello
I wrote a very simple tool on Elixir to get notified on Slack when someone mention you in and issue on Github.
The project use Plug and I recently added a fix for a specific behavior of the github’s api but I’m not sure about what I did.
The change is small (don’t be scared about the 187 lines it’s the fixture) and simple but I would to get some feedbacks.
https://github.com/benoittgt/PhubMe/pull/16
Feel free to make any comments. I have already shared some doubts on the pull request.
Thanks
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
Aludel 0.7.0 is released :tada:
Since 0.5.0, Aludel has grown into a much more complete LLM evaluation toolkit for Elixir and Phoenix app...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
thomasbrus
Hey!
I have a few comments on web.ex as a whole:
web.ex:27cond can simply be an if/else expressionweb.ex:50-55should be possible to split this method using pattern matching (e.g.def valid_github_payload?(%{"issue" => _issue} = body_params, [{"x-github-event", "issue_comment", ...}])),You can then have one function definition per case (last one matches on any body_params and simply returns false). This way the function is easier to digest and it’s more obvious what the different scenarios are.
The function definition might get a bit long if you’re gonna pattern match on the complete request headers, so perhaps an idea is to leave out the
{"content-type", "application/json"}part.I agree about perhaps refactoring the
valid_github_payload?function cause it indeed does two things now. Just looking at that function name alone I think it makes sense it either returns true or false (not a tuple).The request handler could then (when true) invoke
handle_github_payload, which sends the private message, or does nothing. Again pattern matching can be used.Finally, a few subjective remarks:
web.ex:15remove space after_web.ex:20andweb.ex:22would both have them in the same style instead of only one via the, do:shorthand… Actually, I don’t think you need the
portmethod at all, this would do the job as well:benoittgt
Awesome. Thanks a lot Thomas ! Will make the changes now.
Thanks a lot
benoittgt
I made the changes : Fix first github call when creating webhook by benoittgt · Pull Request #16 · benoittgt/PhubMe · GitHub
It’s much better now. I see a little bit of duplication between valid_github_payload? and handle_github_payload. But the method are readable.
thomasbrus
Sure! You’re welcome. It’s not perfect but a good step in the right direction I’d say