Metadata-Version: 2.4
Name: django-loknotify
Version: 0.1.0
Summary: Reusable Django notification framework with pluggable providers (Discord, Mailgun, and more), rules, previews, and layered configuration
Author-email: Loknus Labs LLC <loknuslabs@gmail.com>
License-Expression: GPL-3.0-or-later
Project-URL: Homepage, https://github.com/loknuslabs/django-loknotify
Project-URL: Documentation, https://github.com/loknuslabs/django-loknotify#readme
Project-URL: Repository, https://github.com/loknuslabs/django-loknotify
Keywords: django,notifications,discord,mailgun,webhooks
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 6.0
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Communications
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Django>=6.0.6
Requires-Dist: djangorestframework>=3.17.1
Requires-Dist: requests>=2.32.0
Requires-Dist: cryptography>=44.0.0
Provides-Extra: celery
Requires-Dist: celery>=5.4.0; extra == "celery"
Provides-Extra: example
Requires-Dist: gunicorn>=23.0.0; extra == "example"
Provides-Extra: dev
Requires-Dist: black==26.10.1; extra == "dev"
Requires-Dist: flake8>=7.3.0; extra == "dev"
Requires-Dist: mypy>=1.19.0; extra == "dev"
Requires-Dist: django-stubs>=5.2.0; extra == "dev"
Requires-Dist: djangorestframework-stubs>=3.16.0; extra == "dev"
Requires-Dist: types-requests; extra == "dev"
Requires-Dist: pytest>=9.0.3; extra == "dev"
Requires-Dist: pytest-django>=4.12.0; extra == "dev"
Requires-Dist: responses>=0.25.0; extra == "dev"
Requires-Dist: pip-audit>=2.10.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Dynamic: license-file

# django-loknotify

A reusable Django notification framework. Your app decides **which events exist**, **which providers can deliver
them** (Discord and Mailgun are bundled; add your own), **who may send**, and **how messages look**. Administrators
then connect channels, write rules for when they fire, preview the message, and send tests, all inside the limits the
host app sets.

- Provider-agnostic: a small `Provider` class is all a new channel (Slack, Teams, SMS, ...) needs.
- Domain-agnostic: no built-in business events. You register your own with `register_event`.
- Layered configuration: defaults, settings and environment variables, an optional host config source, then the
  admin database. Admins can only narrow or tune inside the host ceiling, and the host can lock any setting.
- Optional multi-user mode: non-admin users manage their own channels and preferences under a host policy.
  It is off by default.
- Safe by default: encrypted channel secrets, SSRF guards, mention and header-injection protection, redacted logs,
  rate limits, retry with backoff, and automatic channel disabling.
- Interfaces: DRF API, generated Django admin screens, and management commands.

## Install

```bash
pip install django-loknotify            # add [celery] for the Celery dispatcher
```

```python
# settings.py
INSTALLED_APPS = [..., "rest_framework", "loknotify"]

# urls.py
path("api/", include("loknotify.urls")),
```

```bash
python manage.py migrate
python manage.py check
```

## Quick start

Register an event (anywhere that loads at startup, or in a `loknotify_events.py` module in any installed app):

```python
from loknotify import register_event

register_event(
    "order.paid",
    label="Order paid",
    context={"order_id": "string", "total": "float"},
    filterable=["total"],
    sample_context={"order_id": "A-1001", "total": 49.5},
    default_templates={"discord": {"embed_title": "Order {{ order_id }} paid"}},
)
```

Emit it from your code:

```python
from loknotify import emit

emit("order.paid", application="my-shop", context={"order_id": "A-1001", "total": 49.5})
```

In the Django admin, add a channel (for example a Discord webhook), add a rule for `order.paid`, preview it, and send
a test. See `example/` for a runnable host project and [docs/GUIDE.md](docs/GUIDE.md) for everything else.

## Documentation

- [docs/README.md](docs/README.md): concepts and how a notification travels from `emit()` to the provider.
- [docs/GUIDE.md](docs/GUIDE.md): configuration reference, providers, formatting, multi-user mode, API, commands,
  deployment, and "Writing a provider".

## Development

```bash
py -3.13 -m venv .venv
.venv\Scripts\python -m pip install -e ".[dev]"
.venv\Scripts\python -m pytest loknotify/tests -q
.venv\Scripts\python -m black loknotify example && .venv\Scripts\python -m flake8 loknotify example
.venv\Scripts\python -m mypy
.venv\Scripts\python manage.py check          # runs the example project in example/
```

License: GPL-3.0-or-later.
