8000 feat(imports): import webhooks with per-namespace tokens by adeelahmad · Pull Request #155 · adeelahmad/lense · GitHub
[go: up one dir, main page]

Skip to content

feat(imports): import webhooks with per-namespace tokens - #155

Merged
adeelahmad merged 2 commits into
mainfrom
claude/project-thread-09gtp0
Oct 5, 2026
Merged

adeelahmad merged 2 commits into
mainfrom
claude/project-thread-09gtp0

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Requested by Adeel · project thread

Description

Before: to get something into Lens you had to sign in and upload it, or set up a watched source. Other services (a scanner, a phone shortcut, Zapier/n8n, a conversion node) had no way to push files in.

After: a namespace's owners can make import webhooks. Each has its own token (shown once, only a hash kept), and anything with the token can POST /api/v1/hooks/import:

  • a file as the raw body (?filename=, Content-Disposition or X-Filename), or multipart form files: audio, video, documents and images go through the same path as uploads (dedupe, encryption at rest, the namespace's pipeline); .srt/.vtt/.json/.jsonl/.ics are imported as transcripts;
  • JSON {url}: a PDF link or web page kept as a document (pages need Chromium; a PDF link doesn't);
  • JSON {text}: imported as a transcript, like pasted text.

Hooks can be paused, given a new token, or deleted under /api/v1/namespaces/{name}/import-hooks. Each import is audited as import.hook under the hook (import_hook:<id>), not a person.

How: a new import_hook table and app/domain/import_hooks.py; files are spooled to the uploads disk (bounded by uploads.max_mb) and handed to a new uploads.take(), which runs the normal upload finish. The web app page to manage hooks follows in the next PR; a callback for a remote conversion node after that.

Motivation and Context

Adeel asked for an import webhook alongside offloading conversion to a separate anytopdf node, keeping Lens light on a Raspberry Pi. Nothing heavy is added: no new dependency, no background work.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change; ! in the title)

Checklist:

  • The title is a Conventional Commit.
  • My code follows the code style of this project (ruff, ruff format, mypy clean).
  • I added or updated tests (tests/api/test_import_hooks.py; full backend suite passes locally except test_conversion's Office case, which fails on main too in this container's LibreOffice).
  • My change requires documentation updates, and I have updated docs/ accordingly (docs/api.md#import-webhooks).
  • Users need more than the title to understand it, so I wrote it under ## Unreleased in CHANGELOG.md.

OpenAPI and the client were regenerated with make openapi.

🤖 Generated with Claude Code

https://claude.ai/code/session_012n4GFU7rnEd6r6S44JXnYa


Generated by Claude Code

A namespace's owners make import webhooks (name, optional collection and
pipeline) and get a token shown once; only its hash is kept. Anything with
the token can POST /api/v1/hooks/import a file (raw body or multipart),
a web address or text, which lands in the namespace as an upload or
import would, audited as the hook. Hooks can be paused, re-keyed or
deleted.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012n4GFU7rnEd6r6S44JXnYa
@adeelahmad adeelahmad self-assigned this Oct 5, 2026
Copy link
Copy Markdown
Owner Author

Local CI: green. The self-hosted runner is down, so I replayed every PR job from .github/workflows (ci.yml, pre-commit.yml, pr-title.yml) with ci/local-ci.sh --pr 155 (#181). It tests the head merged into the latest main, which is what GitHub's pull_request event tests.

Local CI on PR #155 head db1b7b1 merged into main f69d6af, 2026-10-05 08:28 UTC

Job Result Time
FastAPI (embedded SurrealDB) pass 403s
FastAPI (SurrealDB server) pass 284s
Next.js pass 186s
pre-commit pass 70s
PR title pass 0s

Generated by Claude Code

@adeelahmad
adeelahmad merged commit 9dd7f24 into main Oct 5, 2026
7 checks passed
@adeelahmad
adeelahmad deleted the claude/project-thread-09gtp0 branch October 5, 2026 12:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0