armiiller / honeybadger-takehome

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

README

This project accepts a payload at /postmark/webhook. If it detects spam, it will send a Slack notification to the webhook of your choice.

See requirements

This project uses Ruby's pattern matching feature. See code in:

  • app/controllers/postmark_controller.rb
  • test/controllers/postmark_controller_test.rb

Install

cd honeybadger-takehome bin/setup

Setup

Make sure to setup an incoming url in slack. Use the url Slack gives your for the environment variable. The alert will be sent to this url when spam detected.

Running

SLACK_INCOMING_WEBHOOK_URL="https://hooks.slack.com/services/..." rails s

By default server will be spun up at localhost:3000

Endpoints

POST /postmark/webhook

curl --location 'http://localhost:3000/postmark/webhook' \
--header 'Content-Type: application/json' \
--data-raw '{
  "RecordType": "Bounce",
  "Type": "SpamNotification",
  "TypeCode": 512,
  "Name": "Spam notification",
  "Tag": "",
  "MessageStream": "outbound",
  "Description": "The message was delivered, but was either blocked by the user, or classified as spam, bulk mail, or had rejected content.",
  "Email": "zaphod@example.com",
  "From": "notifications@honeybadger.io",
  "BouncedAt": "2023-02-27T21:41:30Z"
}'

Testing

RAILS_ENV=test rails test

About


Languages

Language:Ruby 99.0%Language:HTML 1.0%