mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
_handle_groupchat(): get correct origin-id stanza
The problem is that in _handle_groupchat() we look for STANZA_NS_STABLE_ID which will result in origin-id or stanza-id. It seems like prosody servers send origin-id first, so this worked in all my tests. But actually we cannot be sure of the order. So far we stopped after the first element was found. I only found xmpp_stanza_get_child_by_ns() and xmpp_stanza_get_child_by_name() in libstrophe. But we need a combination of both. So I created stanza_get_child_by_name_and_ns() for Profanity. I need to remember to upstream this to libstrophe later (if they really don't have such a function). Fix https://github.com/profanity-im/profanity/issues/1223
This commit is contained in:
parent
cbd85ffd1a
commit
68af0aad65
@ -755,8 +755,8 @@ _handle_groupchat(xmpp_stanza_t *const stanza)
|
||||
const char *id = xmpp_stanza_get_id(stanza);
|
||||
char *originid = NULL;
|
||||
|
||||
xmpp_stanza_t *origin = xmpp_stanza_get_child_by_ns(stanza, STANZA_NS_STABLE_ID);
|
||||
if (origin && g_strcmp0(xmpp_stanza_get_name(origin), STANZA_NAME_ORIGIN_ID) == 0) {
|
||||
xmpp_stanza_t *origin = stanza_get_child_by_name_and_ns(stanza, STANZA_NAME_ORIGIN_ID, STANZA_NS_STABLE_ID);
|
||||
if (origin) {
|
||||
originid = (char*)xmpp_stanza_get_attribute(origin, STANZA_ATTR_ID);
|
||||
}
|
||||
|
||||
|
@ -2478,3 +2478,21 @@ _stanza_create_sha1_hash(char *str)
|
||||
|
||||
return b64;
|
||||
}
|
||||
|
||||
xmpp_stanza_t*
|
||||
stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza, const char * const name, const char * const ns)
|
||||
{
|
||||
xmpp_stanza_t *child;
|
||||
const char *child_ns;
|
||||
|
||||
for (child = xmpp_stanza_get_children(stanza); child; child = xmpp_stanza_get_next(child)) {
|
||||
if (strcmp(name, xmpp_stanza_get_name(child)) == 0) {
|
||||
child_ns = xmpp_stanza_get_ns(child);
|
||||
if (child_ns && strcmp(ns, child_ns) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return child;
|
||||
}
|
||||
|
@ -349,4 +349,6 @@ char* stanza_text_strdup(xmpp_stanza_t *stanza);
|
||||
XMPPCaps* stanza_parse_caps(xmpp_stanza_t *const stanza);
|
||||
void stanza_free_caps(XMPPCaps *caps);
|
||||
|
||||
xmpp_stanza_t* stanza_get_child_by_name_and_ns(xmpp_stanza_t * const stanza, const char * const name, const char * const ns);
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user