diff --git a/frontend/src/components/EntryCard.tsx b/frontend/src/components/EntryCard.tsx
index 6d8a059..6814a6f 100644
--- a/frontend/src/components/EntryCard.tsx
+++ b/frontend/src/components/EntryCard.tsx
@@ -75,7 +75,7 @@ function LiveCard({ entry: e }: { entry: Entry }) {
{report.form}
-
{linkify(e.content)}
+
{linkify(e.content, e.mentions)}
{e.preview &&
}
{e.filepath &&

}
diff --git a/frontend/src/docs/info.html b/frontend/src/docs/info.html
index 9ffa4ff..e3e93c9 100644
--- a/frontend/src/docs/info.html
+++ b/frontend/src/docs/info.html
@@ -24,6 +24,7 @@
Neu: Benachrichtigungen. Antwortet jemand auf deinen Beitrag, zählt die Glocke in der Navigation mit; ein Klick auf die Meldung führt zur Antwort
Benachrichtigungen nennen jetzt den Handle der Antwortenden und melden auch, wenn jemand deinen Beitrag repostet
Benachrichtigungen übersichtlicher: was passiert ist fett, darunter Auszug und Datum, mehr Abstand, keine Unterstreichung
+
Erwähnungen: Mit @handle im Beitrag erwähnst du jemanden. Der Name wird zum Profil-Link, die Person bekommt eine Benachrichtigung
07.11.2026
diff --git a/frontend/src/format.tsx b/frontend/src/format.tsx
index 5ea364b..736fc73 100644
--- a/frontend/src/format.tsx
+++ b/frontend/src/format.tsx
@@ -32,20 +32,30 @@ export function formatTime(unix: number): string {
const urlPattern = /https?:\/\/[^\s<]+/g;
// Hashtag wie in der Suche (internal/httpapi/search.go): Buchstaben, Ziffern,
-// _, davor keines davon -- "a#b" ist kein Tag.
-const tagPattern = /(^|[^\p{L}\p{N}_])#([\p{L}\p{N}_]+)/gu;
+// _; Erwähnung wie im Backend (internal/httpapi/mentions.go): @ und Handle.
+// Davor jeweils keines dieser Zeichen -- "a#b" ist kein Tag, "mail@bob.org"
+// keine Erwähnung.
+const tagPattern = /(^|[^\p{L}\p{N}_])(?:#([\p{L}\p{N}_]+)|@([A-Za-z0-9_]+))/gu;
+
+// Mentions: Handle, wie er im Text steht (klein) -> heutiger Handle derselben
+// Person (Entry.mentions).
+export type Mentions = Record;
// tagify verlinkt die Hashtags eines Textstücks auf die Suche nach genau
-// diesem Tag.
-function tagify(text: string, key: string): ReactNode[] {
+// diesem Tag und die Erwähnungen aus mentions aufs Profil; unbekannte @…
+// bleiben Text.
+function tagify(text: string, key: string, mentions: Mentions): ReactNode[] {
const out: ReactNode[] = [];
let last = 0;
for (const m of text.matchAll(tagPattern)) {
const start = m.index + m[1].length;
+ const [tag, handle] = [m[2], m[3]];
+ const to = tag ? `/search?tag=${encodeURIComponent(tag)}` : mentions[handle.toLowerCase()];
+ if (!to) continue;
if (start > last) out.push(text.slice(last, start));
out.push(
-
- #{m[2]}
+
+ {tag ? `#${tag}` : `@${handle}`}
,
);
last = m.index + m[0].length;
@@ -54,16 +64,17 @@ function tagify(text: string, key: string): ReactNode[] {
return out;
}
-// linkify macht aus URLs im Text Links, aus Hashtags Links auf die Suche und
-// aus Zeilenumbrüchen
. Den Text escaped React selbst.
-export function linkify(text: string): ReactNode[] {
+// linkify macht aus URLs im Text Links, aus Hashtags Links auf die Suche, aus
+// bekannten Erwähnungen Links aufs Profil und aus Zeilenumbrüchen
. Den
+// Text escaped React selbst.
+export function linkify(text: string, mentions: Mentions = {}): ReactNode[] {
const out: ReactNode[] = [];
text.split("\n").forEach((line, i) => {
if (i > 0) out.push(
);
let last = 0;
for (const m of line.matchAll(urlPattern)) {
const start = m.index;
- if (start > last) out.push(...tagify(line.slice(last, start), `${i}-${last}`));
+ if (start > last) out.push(...tagify(line.slice(last, start), `${i}-${last}`, mentions));
out.push(
{m[0]}
@@ -71,7 +82,7 @@ export function linkify(text: string): ReactNode[] {
);
last = start + m[0].length;
}
- if (last < line.length) out.push(...tagify(line.slice(last), `${i}-${last}`));
+ if (last < line.length) out.push(...tagify(line.slice(last), `${i}-${last}`, mentions));
});
return out;
}
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index f7fcbe3..9d4dad8 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -16,6 +16,8 @@ export interface Entry {
handle: string;
display_name: string;
avatar: string;
+ // Erwähnte Handles, wie im Text (klein) -> heutiger Handle.
+ mentions?: Record;
// Vorschau des ersten Links, sobald der Server sie geholt hat.
preview?: LinkPreview;
// Der Server holt die Vorschau noch (siehe previewPoll).
diff --git a/internal/database/schema.sql b/internal/database/schema.sql
index 8d7073c..20b393b 100644
--- a/internal/database/schema.sql
+++ b/internal/database/schema.sql
@@ -161,8 +161,9 @@ CREATE INDEX IF NOT EXISTS idx_message_pair ON message(sender, recipient, id);
CREATE INDEX IF NOT EXISTS idx_message_recipient ON message(recipient, id);
CREATE INDEX IF NOT EXISTS idx_message_created ON message(created_at);
--- Benachrichtigungen an uid. kind: reply (Antwort auf einen eigenen Beitrag)
--- oder bump (eigener Beitrag repostet). actor: wer geantwortet hat, 0 =
+-- Benachrichtigungen an uid. kind: reply (Antwort auf einen eigenen Beitrag),
+-- mention (in einem Beitrag erwähnt) oder bump (eigener Beitrag repostet).
+-- actor: wer geantwortet bzw. erwähnt hat, 0 =
-- unbekannt (Reposts werden niemandem zugeordnet). excerpt: Anfang des
-- zitierten Beitrags; den Text setzt erst der Abruf zusammen, damit er den
-- aktuellen Handle zeigt. link ist ein interner Pfad (/e/), pid der
@@ -183,6 +184,17 @@ CREATE TABLE IF NOT EXISTS notification (
CREATE INDEX IF NOT EXISTS idx_notification_uid ON notification(uid, id);
CREATE INDEX IF NOT EXISTS idx_notification_pid ON notification(pid);
+-- Erwähnungen (@handle) in Beiträgen. handle steht so im Text (klein), uid ist
+-- wer ihn beim Schreiben trug: nach einer Umbenennung führt der alte Link so
+-- weiter zur richtigen Person, nicht zu dem, der den Handle neu bekommt.
+CREATE TABLE IF NOT EXISTS mention (
+ pid BIGINT NOT NULL,
+ handle TEXT NOT NULL,
+ uid BIGINT NOT NULL,
+ PRIMARY KEY (pid, handle)
+);
+CREATE INDEX IF NOT EXISTS idx_mention_uid ON mention(uid);
+
-- Indizes für die häufigen Zugriffspfade; ohne sie werden Feed (ORDER BY
-- last_activity), Thread (WHERE reply_to) und Vote-Zähler (WHERE pid) mit
-- wachsender Tabelle zu Full-Table-Scans. handle/session.value/vote(uid,pid)
diff --git a/internal/httpapi/entries.go b/internal/httpapi/entries.go
index 6c30f63..15ba56b 100644
--- a/internal/httpapi/entries.go
+++ b/internal/httpapi/entries.go
@@ -3,6 +3,7 @@ package httpapi
import (
"context"
"database/sql"
+ "encoding/json"
"errors"
"fmt"
"net/http"
@@ -29,6 +30,9 @@ type Entry struct {
Handle string `json:"handle"`
DisplayName string `json:"display_name"`
Avatar string `json:"avatar"`
+ // Mentions ordnet jedem erwähnten Handle, wie er im Text steht (klein),
+ // den heutigen Handle derselben Person zu, siehe mentions.go.
+ Mentions map[string]string `json:"mentions,omitempty"`
// Preview ist die fertige Vorschau des ersten Links.
Preview *linkpreview.Preview `json:"preview,omitempty"`
// PreviewPending: Der Worker holt die Vorschau gerade noch; das Frontend
@@ -62,8 +66,9 @@ var (
errEntryNotOwned = apperr.Forbidden("entry.not_owner", "Das ist nicht dein Beitrag.")
)
-// entrySelect liest Beiträge samt Autor und Linkvorschau. LEFT JOIN +
-// COALESCE, damit soft-gelöschte Beiträge (uid auf 0 gesetzt) als
+// entrySelect liest Beiträge samt Autor, Linkvorschau und Erwähnungen (als
+// JSON-Objekt, über den Primärschlüssel von mention). LEFT JOIN + COALESCE,
+// damit soft-gelöschte Beiträge (uid auf 0 gesetzt) als
// [deleted]-Platzhalter erhalten bleiben und Threads nicht verwaisen.
const entrySelect = `
SELECT e.pid, e.uid, e.created_at, e.content, e.filepath,
@@ -71,7 +76,9 @@ const entrySelect = `
e.bump_count, e.last_bump,
COALESCE(u.handle, ''), COALESCE(u.display_name, ''), COALESCE(u.avatar, ''),
COALESCE(lp.url, ''), COALESCE(lp.kind, ''), COALESCE(lp.title, ''),
- COALESCE(lp.site, ''), COALESCE(lp.thumb, ''), COALESCE(lp.status, '')
+ COALESCE(lp.site, ''), COALESCE(lp.thumb, ''), COALESCE(lp.status, ''),
+ (SELECT jsonb_object_agg(m.handle, a.handle) FROM mention m
+ JOIN account a ON a.uid = m.uid WHERE m.pid = e.pid)
FROM entry e LEFT JOIN account u ON u.uid = e.uid
LEFT JOIN link_preview lp ON lp.url = e.link_url`
@@ -83,10 +90,14 @@ func scanEntry(row interface{ Scan(...any) error }) (Entry, error) {
var e Entry
var p linkpreview.Preview
var status string
+ var mentions []byte
err := row.Scan(&e.PID, &e.UID, &e.CreatedAt, &e.Content, &e.Filepath,
&e.ReplyTo, &e.ReplyCount, &e.LastActivity, &e.Deleted,
&e.BumpCount, &e.LastBump, &e.Handle, &e.DisplayName, &e.Avatar,
- &p.URL, &p.Kind, &p.Title, &p.Site, &p.Thumb, &status)
+ &p.URL, &p.Kind, &p.Title, &p.Site, &p.Thumb, &status, &mentions)
+ if err == nil && mentions != nil {
+ err = json.Unmarshal(mentions, &e.Mentions)
+ }
switch {
case p.Title != "" && status != linkpreview.StatusNone:
e.Preview = &p
diff --git a/internal/httpapi/entry_write.go b/internal/httpapi/entry_write.go
index 673f92a..a311fd6 100644
--- a/internal/httpapi/entry_write.go
+++ b/internal/httpapi/entry_write.go
@@ -92,7 +92,7 @@ func (s *Server) readNewEntry(r *http.Request) (newEntry, error) {
// insertEntry speichert den Beitrag und liefert seine pid. Eine Antwort hebt
// reply_count und last_activity aller Vorfahren mit an und benachrichtigt den
-// Autor des Elternbeitrags.
+// Autor des Elternbeitrags; Erwähnte erfahren es in jedem Fall.
func (s *Server) insertEntry(ctx context.Context, in newEntry) (int64, error) {
var pid int64
err := database.InTx(ctx, s.DB, func(tx *sql.Tx) error {
@@ -100,6 +100,9 @@ func (s *Server) insertEntry(ctx context.Context, in newEntry) (int64, error) {
if pid, err = insertWithFreshPID(ctx, tx, in); err != nil {
return err
}
+ if err := syncMentions(ctx, tx, pid, in.uid, in.replyTo, in.content, in.created); err != nil {
+ return err
+ }
if in.replyTo == 0 {
return nil
}
@@ -173,9 +176,11 @@ func (s *Server) handleEditEntry(w http.ResponseWriter, r *http.Request) error {
`UPDATE entry SET content = $1, link_url = $2 WHERE pid = $3`, content, linkURL, e.PID); err != nil {
return err
}
- _, err := tx.ExecContext(r.Context(),
- `UPDATE notification SET excerpt = $1 WHERE pid = $2`, excerpt(content), e.PID)
- return err
+ if _, err := tx.ExecContext(r.Context(),
+ `UPDATE notification SET excerpt = $1 WHERE pid = $2`, excerpt(content), e.PID); err != nil {
+ return err
+ }
+ return syncMentions(r.Context(), tx, e.PID, e.UID, e.ReplyTo, content, s.Now().Unix())
}); err != nil {
return apperr.Internal(err)
}
@@ -210,13 +215,17 @@ func (s *Server) handleDeleteEntry(w http.ResponseWriter, r *http.Request) error
if err != nil {
return err
}
- // Mit dem Beitrag verschwindet auch die Benachrichtigung, die ihn zitiert.
+ // Mit dem Beitrag verschwinden seine Erwähnungen und die Benachrichtigungen,
+ // die ihn zitieren.
if err := database.InTx(r.Context(), s.DB, func(tx *sql.Tx) error {
if _, err := tx.ExecContext(r.Context(),
`UPDATE entry SET deleted = 1, content = '', filepath = '', link_url = '', uid = 0 WHERE pid = $1`,
e.PID); err != nil {
return err
}
+ if _, err := tx.ExecContext(r.Context(), `DELETE FROM mention WHERE pid = $1`, e.PID); err != nil {
+ return err
+ }
_, err := tx.ExecContext(r.Context(), `DELETE FROM notification WHERE pid = $1`, e.PID)
return err
}); err != nil {
diff --git a/internal/httpapi/mentions.go b/internal/httpapi/mentions.go
new file mode 100644
index 0000000..d4e5a92
--- /dev/null
+++ b/internal/httpapi/mentions.go
@@ -0,0 +1,113 @@
+package httpapi
+
+import (
+ "context"
+ "database/sql"
+ "fmt"
+ "regexp"
+ "strings"
+
+ "kver/internal/account"
+)
+
+// maxMentions: mehr Erwähnungen pro Beitrag werden ignoriert, damit ein
+// Beitrag nicht die halbe Nutzerschaft benachrichtigen kann.
+const maxMentions = 10
+
+// mentionRe findet @handle; davor kein Buchstabe, keine Ziffer, kein "_" --
+// "mail@example.org" erwähnt niemanden. Das Frontend (format.tsx) nutzt
+// dieselbe Regel.
+var mentionRe = regexp.MustCompile(`(?:^|[^\p{L}\p{N}_])@([A-Za-z0-9_]+)`)
+
+// parseMentions liefert die gültigen Handles im Text, klein, ohne Doppelte,
+// höchstens maxMentions.
+func parseMentions(content string) []string {
+ var out []string
+ seen := map[string]bool{}
+ for _, m := range mentionRe.FindAllStringSubmatch(content, -1) {
+ h := strings.ToLower(m[1])
+ if !account.ValidHandle(h) || seen[h] {
+ continue
+ }
+ seen[h] = true
+ out = append(out, h)
+ if len(out) == maxMentions {
+ break
+ }
+ }
+ return out
+}
+
+// syncMentions gleicht die Erwähnungen des Beitrags pid mit seinem Text ab:
+// weggefallene verschwinden, neue werden mit der uid gespeichert, die den
+// Handle jetzt trägt. Benachrichtigt wird, wer vorher nicht erwähnt war --
+// nicht der Autor selbst und nicht der Autor des Elternbeitrags, der schon von
+// der Antwort erfährt. Wer gar nicht mehr erwähnt ist, verliert die
+// Benachrichtigung. Bestehende Erwähnungen behalten ihre uid, auch wenn der
+// Handle inzwischen jemand anderem gehört.
+func syncMentions(ctx context.Context, tx *sql.Tx, pid, author, replyTo int64, content string, now int64) error {
+ handles := parseMentions(content)
+ if handles == nil {
+ handles = []string{}
+ }
+ before, err := mentionedUIDs(ctx, tx, pid)
+ if err != nil {
+ return err
+ }
+ if _, err := tx.ExecContext(ctx,
+ `DELETE FROM mention WHERE pid = $1 AND NOT (handle = ANY($2))`, pid, handles); err != nil {
+ return fmt.Errorf("erwähnungen abgleichen: %w", err)
+ }
+ if _, err := tx.ExecContext(ctx,
+ `INSERT INTO mention (pid, handle, uid)
+ SELECT $1, handle, uid FROM account WHERE handle = ANY($2)
+ ON CONFLICT DO NOTHING`, pid, handles); err != nil {
+ return fmt.Errorf("erwähnungen speichern: %w", err)
+ }
+ if _, err := tx.ExecContext(ctx,
+ `DELETE FROM notification WHERE pid = $1 AND kind = 'mention'
+ AND uid NOT IN (SELECT uid FROM mention WHERE pid = $1)`, pid); err != nil {
+ return fmt.Errorf("erwähnungen abgleichen: %w", err)
+ }
+ after, err := mentionedUIDs(ctx, tx, pid)
+ if err != nil {
+ return err
+ }
+ var parentAuthor int64
+ if replyTo != 0 {
+ if err := tx.QueryRowContext(ctx,
+ `SELECT uid FROM entry WHERE pid = $1`, replyTo).Scan(&parentAuthor); err != nil {
+ return fmt.Errorf("elternbeitrag lesen: %w", err)
+ }
+ }
+ for uid := range after {
+ if before[uid] || uid == author || uid == parentAuthor {
+ continue
+ }
+ if _, err := tx.ExecContext(ctx,
+ `INSERT INTO notification (uid, kind, actor, excerpt, link, pid, created_at)
+ VALUES ($1, 'mention', $2, $3, $4, $5, $6)`,
+ uid, author, excerpt(content), fmt.Sprintf("/e/%d", pid), pid, now); err != nil {
+ return fmt.Errorf("benachrichtigung anlegen: %w", err)
+ }
+ }
+ return nil
+}
+
+// mentionedUIDs liefert, wer im Beitrag pid erwähnt ist.
+func mentionedUIDs(ctx context.Context, tx *sql.Tx, pid int64) (map[int64]bool, error) {
+ rows, err := tx.QueryContext(ctx, `SELECT DISTINCT uid FROM mention WHERE pid = $1`, pid)
+ if err != nil {
+ return nil, fmt.Errorf("erwähnungen lesen: %w", err)
+ }
+ defer rows.Close()
+ uids := map[int64]bool{}
+ for rows.Next() {
+ var uid int64
+ if err := rows.Scan(&uid); err != nil {
+ return nil, fmt.Errorf("erwähnungen lesen: %w", err)
+ }
+ uids[uid] = true
+ }
+ return uids, rows.Err()
+}
diff --git a/internal/httpapi/mentions_test.go b/internal/httpapi/mentions_test.go
new file mode 100644
index 0000000..5d426e8
--- /dev/null
+++ b/internal/httpapi/mentions_test.go
@@ -0,0 +1,112 @@
+package httpapi
+
+import (
+ "fmt"
+ "net/http"
+ "net/url"
+ "slices"
+ "testing"
+)
+
+func TestParseMentions(t *testing.T) {
+ t.Parallel()
+ tests := []struct {
+ in string
+ want []string
+ }{
+ {"hallo @Bob, und @carol!", []string{"bob", "carol"}},
+ {"@bob @BOB @bob", []string{"bob"}},
+ {"mail@bob.org x@bob", nil},
+ {"@ab @" + "abcdefghijklmnopqrstu", nil}, // zu kurz, zu lang
+ {"(@bob) #tag @_x_", []string{"bob", "_x_"}},
+ }
+ for _, tt := range tests {
+ if got := parseMentions(tt.in); !slices.Equal(got, tt.want) {
+ t.Errorf("parseMentions(%q) = %q, erwartet %q", tt.in, got, tt.want)
+ }
+ }
+ many := ""
+ for i := range 15 {
+ many += fmt.Sprintf(" @user%02d", i)
+ }
+ if n := len(parseMentions(many)); n != maxMentions {
+ t.Errorf("%d Erwähnungen, erwartet höchstens %d", n, maxMentions)
+ }
+}
+
+// mentionsOf liest die Erwähnungen eines Beitrags aus dem Thread.
+func mentionsOf(t *testing.T, c *http.Client, srv *testServer, pid int64) map[string]string {
+ t.Helper()
+ var th struct {
+ Entry struct {
+ Mentions map[string]string `json:"mentions"`
+ } `json:"entry"`
+ }
+ getAs(t, c, fmt.Sprintf("%s/api/entry/%d/thread", srv.URL, pid), &th)
+ return th.Entry.Mentions
+}
+
+func notificationsOf(t *testing.T, c *http.Client, srv *testServer) []notificationJSON {
+ t.Helper()
+ var list notificationList
+ getAs(t, c, srv.URL+"/api/notifications", &list)
+ return list.Notifications
+}
+
+func TestMentions(t *testing.T) {
+ t.Parallel()
+ srv := newTestServer(t)
+ alice := registerAndLogin(t, srv, "alice")
+ bob := registerAndLogin(t, srv, "bob")
+ carol := registerAndLogin(t, srv, "carol")
+
+ root := createEntry(t, alice, srv, post("hallo @Bob und @carol, @alice, mail@bob.org, @niemand"))
+ if got := mentionsOf(t, alice, srv, root); len(got) != 3 || got["bob"] != "bob" || got["alice"] != "alice" {
+ t.Errorf("mentions: %v", got)
+ }
+ for _, c := range []*http.Client{bob, carol} {
+ n := notificationsOf(t, c, srv)
+ if len(n) != 1 || n[0].Kind != "mention" || n[0].Message != "@alice hat dich erwähnt." ||
+ n[0].Link != fmt.Sprintf("/e/%d", root) {
+ t.Errorf("erwähnt: %+v", n)
+ }
+ }
+ if n := notificationsOf(t, alice, srv); len(n) != 0 {
+ t.Errorf("selbst erwähnt: %+v", n)
+ }
+
+ // Antwort samt Erwähnung des Elternautors: nur die Antwort-Benachrichtigung.
+ createEntry(t, bob, srv, reply(root, "danke @alice"))
+ if n := notificationsOf(t, alice, srv); len(n) != 1 || n[0].Kind != "reply" {
+ t.Errorf("antwort mit erwähnung: %+v", n)
+ }
+
+ // Umbenennen: der alte Link führt zur selben Person, nicht zum neuen
+ // Träger des Handles.
+ for _, r := range []struct {
+ c *http.Client
+ handle string
+ }{{bob, "robert"}, {carol, "bob"}} {
+ resp := postForm(t, r.c, srv.URL+"/api/user/handle", url.Values{"handle": {r.handle}})
+ resp.Body.Close()
+ }
+ if got := mentionsOf(t, alice, srv, root); got["bob"] != "robert" || got["carol"] != "bob" {
+ t.Errorf("nach umbenennen: %v", got)
+ }
+
+ // Bearbeiten: weggefallene Erwähnung verschwindet samt Benachrichtigung.
+ resp := postForm(t, alice, fmt.Sprintf("%s/api/entry/%d/edit", srv.URL, root),
+ url.Values{"content": {"hallo @robert"}})
+ resp.Body.Close()
+ if got := mentionsOf(t, alice, srv, root); len(got) != 1 || got["robert"] != "robert" {
+ t.Errorf("nach bearbeiten: %v", got)
+ }
+ if n := notificationsOf(t, carol, srv); len(n) != 0 {
+ t.Errorf("carol nach bearbeiten: %+v", n)
+ }
+ // robert war schon als @bob erwähnt: die Benachrichtigung bleibt die alte
+ // (schon gesehene), keine zweite.
+ if n := notificationsOf(t, bob, srv); len(n) != 1 || !n[0].Seen {
+ t.Errorf("robert nach bearbeiten: %+v", n)
+ }
+}
diff --git a/internal/httpapi/notifications.go b/internal/httpapi/notifications.go
index 54523f1..8028b0c 100644
--- a/internal/httpapi/notifications.go
+++ b/internal/httpapi/notifications.go
@@ -49,8 +49,11 @@ func notificationMessage(kind, actor string) string {
if actor != "" {
who = "@" + actor
}
- if kind == "reply" {
+ switch kind {
+ case "reply":
return who + " hat auf deinen Beitrag geantwortet."
+ case "mention":
+ return who + " hat dich erwähnt."
}
return who + " hat deinen Beitrag repostet."
}
diff --git a/internal/httpapi/users.go b/internal/httpapi/users.go
index 5b8ded9..4e1b9eb 100644
--- a/internal/httpapi/users.go
+++ b/internal/httpapi/users.go
@@ -279,6 +279,7 @@ func deleteAccount(ctx context.Context, tx *sql.Tx, uid int64) error {
`DELETE FROM message WHERE sender = $1 OR recipient = $1`,
// Vor dem UPDATE auf entry: danach stehen die Beiträge auf uid 0.
`DELETE FROM notification WHERE uid = $1 OR actor = $1 OR pid IN (SELECT pid FROM entry WHERE uid = $1)`,
+ `DELETE FROM mention WHERE uid = $1 OR pid IN (SELECT pid FROM entry WHERE uid = $1)`,
`UPDATE entry SET deleted = 1, content = '', filepath = '', link_url = '', uid = 0 WHERE uid = $1`,
`DELETE FROM account WHERE uid = $1`,
} {
diff --git a/notes/api.md b/notes/api.md
index aa68e4a..13a2ce1 100644
--- a/notes/api.md
+++ b/notes/api.md
@@ -138,6 +138,16 @@ Profil-Feed):
---
+### Erwähnungen
+
+`@handle` im Text (davor kein Buchstabe, keine Ziffer, kein `_`) erwähnt den
+Nutzer, höchstens 10 pro Beitrag. Gespeichert wird beim Anlegen bzw.
+Bearbeiten, wem der Handle in diesem Moment gehört (Tabelle `mention`). Jeder
+Beitrag trägt `mentions`: geschriebener Handle (klein) → heutiger Handle
+derselben Person, z. B. `{"bob": "robert"}` nach einer Umbenennung. Das
+Frontend verlinkt nur diese; unbekannte `@…` bleiben Text. Ohne Erwähnungen
+fehlt das Feld.
+
## Nutzer
| Methode | Pfad | Auth | Request | Erfolg |
@@ -206,12 +216,16 @@ sie stündlich. Senden ist gedrosselt (60/min pro IP).
## Benachrichtigungen
-Zwei Arten (`kind`):
+Drei Arten (`kind`):
- `reply`: jemand hat auf einen eigenen Beitrag geantwortet (nicht bei
Antworten an sich selbst), `message` etwa „@bob hat auf deinen Beitrag
geantwortet.“, `excerpt` der Anfang der Antwort; `link` führt zur Antwort. Der Handle ist der
aktuelle, auch nach einer Umbenennung.
+- `mention`: jemand hat einen in einem Beitrag erwähnt: „@alice hat dich
+ erwähnt.“, `excerpt` der Anfang des Beitrags. Nicht für den Autor selbst
+ und nicht für den Autor des Elternbeitrags (der bekommt `reply`); wer
+ schon erwähnt war, wird beim Bearbeiten nicht erneut benachrichtigt.
- `bump`: jemand hat einen eigenen Beitrag repostet (nicht beim eigenen
Repost): „Jemand hat deinen Beitrag repostet.“, `excerpt` der Anfang des
Beitrags. Wer repostet, speichert der Server nicht.