mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Extracted carbons handling
This commit is contained in:
parent
ac940c2c8a
commit
a0c872edf8
@ -608,20 +608,16 @@ _private_chat_handler(xmpp_stanza_t * const stanza, const char * const fulljid)
|
||||
xmpp_free(ctx, message);
|
||||
}
|
||||
|
||||
static int
|
||||
_chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata)
|
||||
static gboolean
|
||||
_handle_carbons(xmpp_stanza_t * const stanza)
|
||||
{
|
||||
// ignore if type not chat or absent
|
||||
char *type = xmpp_stanza_get_type(stanza);
|
||||
if (!(g_strcmp0(type, "chat") == 0 || type == NULL)) {
|
||||
return 1;
|
||||
xmpp_stanza_t *carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS);
|
||||
if (!carbons) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// check if carbon message
|
||||
xmpp_stanza_t *carbons = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_CARBONS);
|
||||
if (carbons) {
|
||||
char *name = xmpp_stanza_get_name(carbons);
|
||||
if ((g_strcmp0(name, "received") == 0) || (g_strcmp0(name, "sent")) == 0){
|
||||
if ((g_strcmp0(name, "received") == 0) || (g_strcmp0(name, "sent")) == 0) {
|
||||
xmpp_stanza_t *forwarded = xmpp_stanza_get_child_by_ns(carbons, STANZA_NS_FORWARD);
|
||||
xmpp_stanza_t *message = xmpp_stanza_get_child_by_name(forwarded, STANZA_NAME_MESSAGE);
|
||||
|
||||
@ -657,8 +653,26 @@ _chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * con
|
||||
jid_destroy(jid_from);
|
||||
jid_destroy(jid_to);
|
||||
jid_destroy(my_jid);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static int
|
||||
_chat_handler(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza, void * const userdata)
|
||||
{
|
||||
// ignore if type not chat or absent
|
||||
char *type = xmpp_stanza_get_type(stanza);
|
||||
if (!(g_strcmp0(type, "chat") == 0 || type == NULL)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// check if carbon message
|
||||
gboolean res = _handle_carbons(stanza);
|
||||
if (res) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
// ignore handled namespaces
|
||||
|
Loading…
Reference in New Issue
Block a user