Moderation: Bilder hinter einen Hinweis legen

Manche Bilder verstoßen gegen keine Regel, müssen aber nicht jedem
ungefragt begegnen. kver cover-image <pid> <hinweis> legt eine stark
verpixelte Variante an (12 Blöcke an der langen Kante) und speichert den
Hinweis am Beitrag; das Frontend zeigt dann die Variante mit Hinweis und
"Inhalt anzeigen" und lädt das Bild selbst erst nach dem Klick.
kver uncover-image nimmt beides zurück.

Löschen von Beitrag oder Konto räumt die Variante mit ab.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-21 21:07:49 +01:00
co-authored by Claude Opus 5.5
parent 532a2ba276
commit d08d16f7a0
14 changed files with 325 additions and 15 deletions
+11 -7
View File
@@ -16,11 +16,15 @@ import (
)
type Entry struct {
PID int64 `json:"pid"`
UID int64 `json:"uid"`
CreatedAt int64 `json:"created_at"`
Content string `json:"content"`
Filepath string `json:"filepath"`
PID int64 `json:"pid"`
UID int64 `json:"uid"`
CreatedAt int64 `json:"created_at"`
Content string `json:"content"`
Filepath string `json:"filepath"`
// ImageWarning steht vor dem Bild; ImageCover ist dann seine verpixelte
// Variante, die das Frontend zuerst zeigt.
ImageWarning string `json:"image_warning,omitempty"`
ImageCover string `json:"image_cover,omitempty"`
ReplyTo int64 `json:"reply_to"`
ReplyCount int64 `json:"reply_count"`
LastActivity int64 `json:"last_activity"`
@@ -72,7 +76,7 @@ var (
// [deleted]-Platzhalter erhalten bleiben und Threads nicht verwaisen.
const entrySelect = `
SELECT e.pid, e.uid, e.created_at, e.content, e.filepath,
e.reply_to, e.reply_count, e.last_activity, e.deleted,
e.image_warning, e.image_cover, e.reply_to, e.reply_count, e.last_activity, e.deleted,
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, ''),
@@ -92,7 +96,7 @@ func scanEntry(row interface{ Scan(...any) error }) (Entry, error) {
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.ImageWarning, &e.ImageCover, &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, &mentions)
if err == nil && mentions != nil {
+2 -1
View File
@@ -225,7 +225,7 @@ func (s *Server) handleDeleteEntry(w http.ResponseWriter, r *http.Request) error
// 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`,
`UPDATE entry SET deleted = 1, content = '', filepath = '', image_warning = '', image_cover = '', link_url = '', uid = 0 WHERE pid = $1`,
e.PID); err != nil {
return err
}
@@ -241,6 +241,7 @@ func (s *Server) handleDeleteEntry(w http.ResponseWriter, r *http.Request) error
return apperr.Internal(err)
}
s.removeMedia(e.Filepath)
s.removeMedia(e.ImageCover)
writeJSON(w, http.StatusOK, status{"deleted"})
return nil
}
+5 -3
View File
@@ -246,11 +246,13 @@ func (s *Server) checkPassword(ctx context.Context, uid int64, pass, field strin
return nil
}
// userMedia liefert die Mediendateien eines Nutzers: Beitragsbilder, Profil-
// und Header-Bild.
// userMedia liefert die Mediendateien eines Nutzers: Beitragsbilder samt
// verpixelter Varianten, Profil- und Header-Bild.
func (s *Server) userMedia(ctx context.Context, uid int64) ([]string, error) {
rows, err := s.DB.QueryContext(ctx,
`SELECT filepath FROM entry WHERE uid = $1 AND filepath <> ''
UNION ALL
SELECT image_cover FROM entry WHERE uid = $1 AND image_cover <> ''
UNION ALL
SELECT avatar FROM account WHERE uid = $1 AND avatar <> ''
UNION ALL
@@ -281,7 +283,7 @@ func deleteAccount(ctx context.Context, tx *sql.Tx, uid int64) error {
`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)`,
`DELETE FROM entry_tag WHERE pid IN (SELECT pid FROM entry WHERE uid = $1)`,
`UPDATE entry SET deleted = 1, content = '', filepath = '', link_url = '', uid = 0 WHERE uid = $1`,
`UPDATE entry SET deleted = 1, content = '', filepath = '', image_warning = '', image_cover = '', link_url = '', uid = 0 WHERE uid = $1`,
`DELETE FROM account WHERE uid = $1`,
} {
if _, err := tx.ExecContext(ctx, q, uid); err != nil {