fix(history): address PR #116 review feedback
All checks were successful
CI Code / Check coding style (pull_request) Successful in 33s
CI Code / Check spelling (pull_request) Successful in 20s
CI Code / Code Coverage (pull_request) Successful in 2m44s
CI Code / Linux (debian) (pull_request) Successful in 4m40s
CI Code / Linux (ubuntu) (pull_request) Successful in 4m55s
CI Code / Linux (arch) (pull_request) Successful in 5m42s

- console: drop orphaned `Chat logging (/logging chat)` lines from
  cons_logging_setting() and cons_privacy_setting() — the /logging chat
  subcommand was removed, PREF_CHLOG now tracks PREF_HISTORY implicitly
- command: deprecate /logging command. It now prints a single notice
  pointing to /history; CMD_PREAMBLE trimmed (min_args=0, no
  setting_func, syntax/args/examples dropped); subcommand 'group'
  removed from autocomplete
- sqlite: gate LMC merge in _sqlite_get_previous_chat() on
  PREF_CORRECTION_ALLOW. When /correction is off, return original and
  correction rows as separate messages instead of merging via
  COALESCE/LEFT JOIN — matches the flatfile load path and the PR's
  stated semantics for /correction off
This commit is contained in:
2026-05-16 17:16:44 +03:00
parent 102c32c744
commit d8ce4ca80e
5 changed files with 21 additions and 35 deletions

View File

@@ -1147,8 +1147,6 @@ cmd_ac_init(void)
autocomplete_add(status_state_ac, "xa");
autocomplete_add(status_state_ac, "dnd");
autocomplete_add(logging_ac, "group");
autocomplete_add(privacy_ac, "logging");
autocomplete_add(privacy_ac, "os");

View File

@@ -1660,19 +1660,14 @@ static const struct cmd_t command_defs[] = {
},
{ CMD_PREAMBLE("/logging",
parse_args, 2, 3, &cons_logging_setting)
parse_args, 0, 3, NULL)
CMD_MAINFUNC(cmd_logging)
CMD_TAGS(
CMD_TAG_CHAT)
CMD_SYN(
"/logging group on|off")
"/logging")
CMD_DESC(
"Configure groupchat (MUC) logging. "
"Regular chat logging is controlled by /history.")
CMD_ARGS(
{ "group on|off", "Enable/Disable groupchat (room) logging." })
CMD_EXAMPLES(
"/logging group off")
"Deprecated. Use '/history' instead.")
},
{ CMD_PREAMBLE("/states",

View File

@@ -6731,17 +6731,7 @@ cmd_privacy(ProfWin* window, const char* const command, gchar** args)
gboolean
cmd_logging(ProfWin* window, const char* const command, gchar** args)
{
if (args[0] == NULL) {
cons_logging_setting();
return TRUE;
}
if (g_strcmp0(args[0], "group") == 0 && args[1] != NULL) {
_cmd_set_boolean_preference(args[1], "Groupchat logging", PREF_GRLOG);
return TRUE;
}
cons_bad_cmd_usage(command);
cons_show("The '/logging' command is deprecated, use '/history' instead.");
return TRUE;
}

View File

@@ -384,16 +384,29 @@ _sqlite_get_previous_chat(const gchar* const contact_barejid, const gchar* start
const gchar* sort2 = !flip ? "ASC" : "DESC";
GDateTime* now = g_date_time_new_now_local();
auto_gchar gchar* end_date_fmt = end_time ? g_strdup(end_time) : g_date_time_format_iso8601(now);
// When LMC is disabled, return original and correction rows as separate
// messages instead of merging the correction text into the original.
// Otherwise the user sees corrected text in history even with
// /correction off.
const gboolean lmc_allowed = prefs_get_boolean(PREF_CORRECTION_ALLOW);
const char* msg_expr = lmc_allowed ? "COALESCE(B.`message`, A.`message`)" : "A.`message`";
const char* join_clause = lmc_allowed
? "LEFT JOIN `ChatLogs` AS B ON (A.`replaced_by_db_id` = B.`id` AND A.`from_jid` = B.`from_jid`) "
: "";
const char* replaces_filter = lmc_allowed ? "(A.`replaces_db_id` IS NULL) AND " : "";
auto_sqlite gchar* query = sqlite3_mprintf("SELECT * FROM ("
"SELECT COALESCE(B.`message`, A.`message`) AS message, "
"SELECT %s AS message, "
"A.`timestamp`, A.`from_jid`, A.`from_resource`, A.`to_jid`, A.`to_resource`, A.`type`, A.`encryption`, A.`stanza_id` FROM `ChatLogs` AS A "
"LEFT JOIN `ChatLogs` AS B ON (A.`replaced_by_db_id` = B.`id` AND A.`from_jid` = B.`from_jid`) "
"WHERE (A.`replaces_db_id` IS NULL) "
"AND ((A.`from_jid` = %Q AND A.`to_jid` = %Q) OR (A.`from_jid` = %Q AND A.`to_jid` = %Q)) "
"%s"
"WHERE %s"
"((A.`from_jid` = %Q AND A.`to_jid` = %Q) OR (A.`from_jid` = %Q AND A.`to_jid` = %Q)) "
"AND A.`timestamp` < %Q "
"AND (%Q IS NULL OR A.`timestamp` > %Q) "
"ORDER BY A.`timestamp` %s LIMIT %d) "
"ORDER BY `timestamp` %s;",
msg_expr, join_clause, replaces_filter,
contact_barejid, myjid->barejid, myjid->barejid, contact_barejid, end_date_fmt, start_time, start_time, sort1, MESSAGES_TO_RETRIEVE, sort2);
g_date_time_unref(now);

View File

@@ -1951,11 +1951,6 @@ cons_log_setting(void)
void
cons_logging_setting(void)
{
if (prefs_get_boolean(PREF_CHLOG))
cons_show("Chat logging (/logging chat) : ON");
else
cons_show("Chat logging (/logging chat) : OFF");
if (prefs_get_boolean(PREF_GRLOG))
cons_show("Groupchat logging (/logging group) : ON");
else
@@ -2862,11 +2857,6 @@ cons_privacy_setting(void)
{
cons_show("Database logging : %s", prefs_get_string(PREF_DBLOG));
if (prefs_get_boolean(PREF_CHLOG)) {
cons_show("Chat logging (/logging chat) : ON");
} else {
cons_show("Chat logging (/logging chat) : OFF");
}
if (prefs_get_boolean(PREF_HISTORY)) {
cons_show("Chat history (/history) : ON");
} else {