Add /history clean (and per-jid variant) to wipe existing chat history #124
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
After PR #116 (
feat/no-db-backlog-114),/history offis a real kill switch: it setsPREF_HISTORY=false,PREF_DBLOG=off,PREF_CHLOG=false, so new writes to the DB and to plain chatlogs stop. Backend switching via/privacy logging on|flatfilealso takes effect at runtime without reconnect. Both are intentional improvements over master's behaviour.What's still missing: the on-disk state from before the switch is not touched. After
/history off:~/.local/share/profanity/<account>/chatlog.db(sqlite) or the flatfile backend directory remains on disk with all prior plaintext rows (including decrypted OMEMO / PGP / OTR content).chatlogs/<account>/plain-text files remain untouched.chatwin_db_history()keeps returning prior rows on scroll-up.This is by-design —
offmeans "stop writing", not "delete past" — but the mental model of a user reaching for "turn off history" often includes "and forget what was recorded". A separate, explicitcleanaction closes that gap without overloadingoff.Proposal
Add
cleanas a sub-command of/history, sitting next to/history off|on|switchintroduced/normalised in #116:/privacy logging cleanis an alternative location, but placing it under/historykeeps it adjacent to the kill-switch it complements.Behaviour
log_database_close().chatlogs/<account>/plain-text directory.PREF_GRLOG).PREF_DBLOG != "off", re-initialize the backend so subsequent messages are recorded into a fresh store.DELETE FROM ChatLogs WHERE from_jid = ? OR to_jid = ?(parameterised, not concatenated).<jid>.logfiles in the backend dir.chatlogs/<account>/<jid>.log.Backend hooks
Add to the
db_backendvtable insrc/database.h:Implement in
src/database_sqlite.candsrc/database_flatfile.c.Affected files
src/database.{c,h}— public API + backend dispatch.src/database_sqlite.c,src/database_flatfile.c— backend implementations.src/chatlog.c— plain-chatlog directory removal helper.src/command/cmd_funcs.c::cmd_history— sub-command wiring.src/command/cmd_defs.c— help text + autocomplete.docs/profanity.1— manpage entry.Interaction with #116
/history offonly becomes a true persistence kill-switch after #116 merges, which is the prerequisite forcleanto be coherent./historytree (on/off/switch/ ...) is the natural home forclean.[sqlite] / [flatfile]indicator (PREF_STATUSBAR_SHOW_DBBACKENDfrom #116) should reflect the post-clean state — backend may be re-initialized empty, or closed ifPREF_DBLOG=off.Interaction with PR #123 (scroll-state)
After
clean,chatwin_db_history()on scroll-down returnsDB_RESPONSE_EMPTYandWIN_SCROLL_REACHED_BOTTOMfires correctly — the indicator-reset paths from #123 keep working unchanged.Out of scope / follow-ups
/history retain <days>— drop rows older than N days. Reduces the surface area without manual wipes.redactless of a workaround for on-disk privacy.