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
Hello!
Suppose you are building workflow (order / task / payment) processing system with the following requirements:
Each workflow con...
New
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
Hi all,
I’m working on a Phoenix project where I need to make external HTTP requests and I’m trying to choose between Req and HTTPoison....
New
How do I tell Hologram not to escape HTML when substituting into templates?
{Textile.render(@product.long_description)}
escapes the HTM...
New
Hi,
we run different LLM models across a cluster, with each node loading a configurable subset. Model-specific queues let nodes consume ...
New
Hello
I’ve been coding in Elixir for almost two years now because of my current job where we implemented Elixir in our application. But ...
New
Hi all, I’m new here and would like to hear peoples views on my Elixir/Phoenix based game-engine! :smiley:
Mutonex gamedesign was finish...
New
Other Trending Topics
Hey there,
I haven’t seen a list of useful Elixir specific skills for the popular AI tools yet so I’m starting one here with my first.
...
New
Hi everyone :waving_hand:
I wanted to share something I’ve been building — NowBlind, a random chat app designed to help people discover ...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
Localize is the next generation localisation library for Elixir. Think of it as ex_cldr version 3.0. The first version will be released ...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
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
- #code-sync
- #discussion
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #blog-post
- #elixirconf-us
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #security
- #elixirconf-eu
- #api
- #forms
- #hex










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