WebhookSender.h header

#include <ew/app/WebhookSender.h>

Namespace ew::app

WebhookOutcome struct

struct ew::app::WebhookOutcome

What happened to one webhook post.

Members

QString ew::app::webhook::WebhookOutcome::destination

The destination it was addressed to, for a report that names which one failed.

bool ew::app::webhook::WebhookOutcome::delivered = false

Whether the service accepted it.

QString ew::app::webhook::WebhookOutcome::error

Why not, in words the user can act on. Empty when delivered.

WebhookSender class

class ew::app::WebhookSender

Sends notifications to the user's configured destinations.

An interface, so the sending can be tested without a network. The interesting behaviour here is which destinations get used and what happens when one fails – not Qt's HTTP stack – and a test that needed a live server would test the wrong thing and be skipped the first time it was slow.

Members

ew::app::webhook::WebhookSender::WebhookSender()=default

Creates the sender.

virtual ew::app::webhook::WebhookSender::~WebhookSender()=default

Destroys the sender.

ew::app::webhook::WebhookSender::WebhookSender(const WebhookSender &)=delete

Interface type: non-copyable and non-movable (held via pointer).

ew::app::webhook::WebhookSender::WebhookSender(WebhookSender &&)=delete

Not movable.

WebhookSender & ew::app::webhook::WebhookSender::operator=(const WebhookSender &)=delete

Not copyable.

WebhookSender & ew::app::webhook::WebhookSender::operator=(WebhookSender &&)=delete

Not movable.

virtual void ew::app::webhook::WebhookSender::send(const std::vector< WebhookDestination > &destinations, const QString &message, std::function< void(std::vector< WebhookOutcome >)> onFinished)=0

Posts message to every enabled destination in destinations, reporting each outcome to onFinished once they have all settled.

A disabled or malformed destination is skipped, not failed. Somebody who switched a channel off asked for silence, and reporting that as an error every time would train them to ignore the report – which is the one thing it cannot afford, since it is the only way they learn a real delivery failed.

Functions

std::unique_ptr< WebhookSender > ew::app::webhook::makeWebhookSender(ew::app::net::HttpClient &http)

Creates a sender that posts through http.

http must outlive the sender. Kept as a reference rather than owned so the caller's single client is shared, which is what lets Qt reuse connections instead of opening one per message.