Introduce equals_our_barejid()

Instead of always repeating the same pattern, introduce a helper function.

Signed-off-by: Steffen Jaeckel <jaeckel-floss@eyet-services.de>
This commit is contained in:
Steffen Jaeckel
2023-12-05 12:59:51 +01:00
parent fdfe3e2ad9
commit bac24601da
9 changed files with 22 additions and 9 deletions

View File

@@ -101,7 +101,7 @@ static GHashTable* pubsub_event_handlers;
gchar*
get_display_name(const ProfMessage* const message, int* flags)
{
if (g_strcmp0(connection_get_barejid(), message->from_jid->barejid) == 0) {
if (equals_our_barejid(message->from_jid->barejid)) {
return g_strdup("me");
} else {
if (flags)
@@ -262,7 +262,7 @@ _message_handler(xmpp_conn_t* const conn, xmpp_stanza_t* const stanza, void* con
const char* const stanza_from = xmpp_stanza_get_from(stanza);
if (stanza_from) {
if (g_strcmp0(connection_get_barejid(), stanza_from) != 0) {
if (!equals_our_barejid(stanza_from)) {
log_warning("Invalid carbon received, from: %s", stanza_from);
msg_stanza = NULL;
} else {
@@ -1462,7 +1462,7 @@ _handle_chat(xmpp_stanza_t* const stanza, gboolean is_mam, gboolean is_carbon, c
if (message->plain || message->body || message->encrypted) {
if (is_carbon) {
// if we are the recipient, treat as standard incoming message
if (g_strcmp0(connection_get_barejid(), message->to_jid->barejid) == 0) {
if (equals_our_barejid(message->to_jid->barejid)) {
sv_ev_incoming_carbon(message);
// else treat as a sent message
} else {