# Notifications flow

## Channels

| Channel | Delivery |
|---|---|
| In-app | Rows in `notifications`, shown at `/notifications` |
| Email | Through the configured mailer |
| Telegram | Through the Bot API, for administrator alerts |

Each channel can be enabled independently. With all of them off, the application still works — notifications are an amplifier, not a dependency.

## Events that notify

| Event | Who is notified |
|---|---|
| New answer on a question | The question's author and its followers |
| New comment | The parent content's author |
| New topic comment | The topic's followers, excluding the commenter |
| Answer accepted | The answer's author |
| New question | Administrators, when enabled |
| New report | Administrators and moderators |
| Contact message | The configured administrator address |

## Rules

- **The actor is never notified about their own action.**
- **No duplicate notification for one event.** A member who both authored and follows a topic is notified once.
- **Notification failure never fails the write.** If the mail server is down, the answer is still posted; the delivery failure is logged.
- **Preferences are honoured per member** through `notification_preferences`.

## Delivery

Delivery happens inline — no queue, no cron. That keeps deployment simple and puts an upper bound on how much work a single request may do: this is why slow work does not belong in a notification handler.

## Email

The From name resolves through the mailer factory: `mail.from_name`, falling back to `site.name`. Notification email and public runtime email therefore always agree.

See [SMTP and email](../03-configuration/SMTP-EMAIL.md).

## Telegram

Administrator alerts can go to a Telegram chat. The settings page tests the configuration and reports actionable, translated causes for the common failures:

| Result | Usual cause |
|---|---|
| 400 | Chat id malformed or wrong |
| 401 | Bot token invalid |
| 403 | The bot was never started by, or was blocked in, the target chat |
| transport error | cURL unavailable or outbound HTTPS blocked |

Tokens and provider response bodies are never written to logs.

See [Telegram](../03-configuration/TELEGRAM.md) and [Telegram bot setup](../09-recipes/TELEGRAM-BOT-SETUP.md).

## Extending

`notification.channels` filters the channel registry, so a plugin can add a delivery target. A channel must fail safely: log and continue, never throw into the write path.
