Compare commits

...

5 Commits

Author SHA1 Message Date
14fb6e3b41 fix(disco): clean up autoping warning message handling
Remove unused return value from _disco_autoping_warning_message by
changing its return type to void. Rename local variable from
users_prefers_warning to user_prefers_warning for correct grammar.

Use g_ascii_strcasecmp instead of g_strcmp0 for the domain match
check, so the warning fires correctly regardless of case differences
between the stanza 'from' field and the bound domain.

Remove duplicate autoping warning display from cons_notify_setting(),
keeping it only in cons_autoping_setting() where it belongs.
2026-06-23 10:57:59 +00:00
19bfad76ba test(autoping): add test for autoping warning exclusion on subdomain services
All checks were successful
CI Code / Check spelling (pull_request) Successful in 15s
CI Code / Check coding style (pull_request) Successful in 30s
CI Code / Code Coverage (pull_request) Successful in 3m47s
CI Code / Linux (debian) (pull_request) Successful in 5m11s
CI Code / Linux (ubuntu) (pull_request) Successful in 5m16s
CI Code / Linux (arch) (pull_request) Successful in 7m9s
The new test verifies that disco#info responses from subdomain services
(e.g., conference servers) do not trigger the autoping warning, ensuring
the check is correctly restricted to the server's own domain.
2026-06-22 09:17:49 +00:00
b5bbad8d2c fix(xmpp): prevent autoping warning repetition on disco items
All checks were successful
CI Code / Check spelling (pull_request) Successful in 17s
CI Code / Check coding style (pull_request) Successful in 31s
CI Code / Code Coverage (pull_request) Successful in 4m0s
CI Code / Linux (debian) (pull_request) Successful in 5m5s
CI Code / Linux (ubuntu) (pull_request) Successful in 5m12s
CI Code / Linux (arch) (pull_request) Successful in 6m55s
The previous logic triggered warnings for disco items. This change restricts the check to only the connection domain, ensuring that auto-discovered items do not trigger duplicate warnings.
2026-06-21 15:37:16 +00:00
7fd0cded3d test(autoping): add test for autoping warning exclusion on user JIDs
All checks were successful
CI Code / Check spelling (pull_request) Successful in 18s
CI Code / Check coding style (pull_request) Successful in 31s
CI Code / Code Coverage (pull_request) Successful in 3m33s
CI Code / Linux (debian) (pull_request) Successful in 5m7s
CI Code / Linux (ubuntu) (pull_request) Successful in 5m12s
CI Code / Linux (arch) (pull_request) Successful in 7m9s
2026-06-20 20:47:05 +00:00
2012e15c0b fix(disco): avoid autoping warning on disco#info responses from users
The autoping availability warning should only trigger for disco#info
responses from the XMPP server (no 'from' attribute), otherwise the
warning message is displayed excessive amount of times.

Refs #80
2026-06-20 19:32:40 +00:00
4 changed files with 59 additions and 7 deletions

View File

@@ -99,11 +99,11 @@ static void _disco_items_result_handler(xmpp_stanza_t* const stanza);
static void _last_activity_get_handler(xmpp_stanza_t* const stanza);
static void _version_get_handler(xmpp_stanza_t* const stanza);
static void _ping_get_handler(xmpp_stanza_t* const stanza);
static void _disco_autoping_warning_message(GHashTable* features);
static int _version_result_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
static int _disco_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
static int _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* const userdata);
static int _disco_autoping_warning_message(GHashTable* features);
static int _http_upload_response_id_handler(xmpp_stanza_t* const stanza, void* const upload_ctx);
static int _last_activity_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
static int _room_info_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata);
@@ -2430,7 +2430,11 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con
}
child = xmpp_stanza_get_next(child);
}
_disco_autoping_warning_message(features);
// Prevent repetitions by avoiding checks of disco items (from connection_set_disco_items)
if (from && g_ascii_strcasecmp(from, connection_get_domain()) == 0) {
_disco_autoping_warning_message(features);
}
}
connection_features_received(from);
@@ -2438,20 +2442,19 @@ _disco_info_response_id_handler_onconnect(xmpp_stanza_t* const stanza, void* con
return 0;
}
static int
static void
_disco_autoping_warning_message(GHashTable* features)
{
gboolean server_supports_ping = g_hash_table_contains(features, "urn:xmpp:ping");
gboolean users_prefers_warning = prefs_get_boolean(PREF_AUTOPING_WARNING);
gboolean user_prefers_warning = prefs_get_boolean(PREF_AUTOPING_WARNING);
gboolean is_autoping_enabled = prefs_get_autoping() != 0;
if (!is_autoping_enabled && server_supports_ping && users_prefers_warning) {
if (!is_autoping_enabled && server_supports_ping && user_prefers_warning) {
cons_show("This server supports XEP-0199: XMPP Ping (better keepalive detection),\n"
"but autoping feature is currently disabled in settings.\n"
"Consider enabling it (e.g., `/autoping set 30`) for improved connection stability.\n"
"Use `/autoping warning off` to disable this message.");
}
return 0;
}
static int

View File

@@ -155,6 +155,8 @@ main(int argc, char* argv[])
PROF_FUNC_TEST(autoping_warning_not_shown_when_server_unsupported),
PROF_FUNC_TEST(autoping_warning_not_shown_when_autoping_enabled),
PROF_FUNC_TEST(autoping_warning_not_shown_when_user_disabled),
PROF_FUNC_TEST(autoping_warning_not_shown_for_user_jid),
PROF_FUNC_TEST(autoping_warning_not_shown_for_subdomain_service),
/* Service Discovery - XEP-0030 */
PROF_FUNC_TEST(disco_info_shows_identity),

View File

@@ -194,7 +194,7 @@ autoping_warning_not_shown_when_autoping_enabled(void** state)
void
autoping_warning_not_shown_when_user_disabled(void** state)
{
// User opted out -> no warning. Command takes on|off ("enable|disable" doc is wrong).
// User opted out -> no warning.
_stub_server_disco(TRUE);
prof_input("/autoping set 0");
@@ -208,3 +208,48 @@ autoping_warning_not_shown_when_user_disabled(void** state)
prof_timeout(NEGATIVE_ASSERT_TIMEOUT);
assert_false(prof_output_regex(AUTOPING_WARNING_MATCH));
}
void
autoping_warning_not_shown_for_user_jid(void** state)
{
// disco#info from a user JID (with '@') should not trigger the warning,
// only server responses (no '@') should.
stbbr_for_query("http://jabber.org/protocol/disco#info",
"<iq to='stabber@localhost/profanity' type='result' from='buddy1@localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='person' type='chat' name='Buddy1'/>"
"<feature var='urn:xmpp:ping'/>"
"</query>"
"</iq>"
);
prof_input("/autoping set 0");
assert_true(prof_output_exact("Autoping disabled."));
prof_connect();
prof_timeout(NEGATIVE_ASSERT_TIMEOUT);
assert_false(prof_output_regex(AUTOPING_WARNING_MATCH));
}
void
autoping_warning_not_shown_for_subdomain_service(void** state)
{
// disco#info from a subdomain service should not trigger the warning, only the server's own domain should
stbbr_for_query("http://jabber.org/protocol/disco#info",
"<iq to='stabber@localhost/profanity' type='result' from='conf.localhost'>"
"<query xmlns='http://jabber.org/protocol/disco#info'>"
"<identity category='conference' type='text' name='Conference Service'/>"
"<feature var='urn:xmpp:ping'/>"
"</query>"
"</iq>"
);
prof_input("/autoping set 0");
assert_true(prof_output_exact("Autoping disabled."));
prof_connect();
prof_timeout(NEGATIVE_ASSERT_TIMEOUT);
assert_false(prof_output_regex(AUTOPING_WARNING_MATCH));
}

View File

@@ -8,3 +8,5 @@ void autoping_warning_shown_when_disabled(void** state);
void autoping_warning_not_shown_when_server_unsupported(void** state);
void autoping_warning_not_shown_when_autoping_enabled(void** state);
void autoping_warning_not_shown_when_user_disabled(void** state);
void autoping_warning_not_shown_for_user_jid(void** state);
void autoping_warning_not_shown_for_subdomain_service(void** state);