mirror of
https://github.com/profanity-im/profanity.git
synced 2024-11-03 19:37:16 -05:00
Make muc config update after form submit
Muc configuration in profanity used to not update until next login, ie: make muc non_anonymous and members_only but be unable to start omemo until next login. Now a disco info request is sent after forrm submit and chatroom details are changed accordingly. Fixes https://github.com/profanity-im/profanity/issues/1347
This commit is contained in:
parent
b4523d6c42
commit
4839093a8b
@ -892,13 +892,6 @@ _caps_response_id_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
|||||||
log_debug("Capabilities not cached: %s, storing", given_sha1);
|
log_debug("Capabilities not cached: %s, storing", given_sha1);
|
||||||
EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query);
|
EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query);
|
||||||
|
|
||||||
// Update window name
|
|
||||||
ProfMucWin* win = wins_get_muc(from);
|
|
||||||
if (win != NULL) {
|
|
||||||
free(win->room_name);
|
|
||||||
win->room_name = strdup(capabilities->identity->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
caps_add_by_ver(given_sha1, capabilities);
|
caps_add_by_ver(given_sha1, capabilities);
|
||||||
caps_destroy(capabilities);
|
caps_destroy(capabilities);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@
|
|||||||
#include "xmpp/connection.h"
|
#include "xmpp/connection.h"
|
||||||
#include "xmpp/xmpp.h"
|
#include "xmpp/xmpp.h"
|
||||||
#include "xmpp/form.h"
|
#include "xmpp/form.h"
|
||||||
|
#include "xmpp/iq.h"
|
||||||
|
|
||||||
#ifdef HAVE_OMEMO
|
#ifdef HAVE_OMEMO
|
||||||
#include "xmpp/omemo.h"
|
#include "xmpp/omemo.h"
|
||||||
@ -1006,6 +1007,28 @@ _handle_captcha(xmpp_stanza_t* const stanza)
|
|||||||
xmpp_free(ctx, message);
|
xmpp_free(ctx, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle changes to muc configuration
|
||||||
|
static int
|
||||||
|
_room_config_handler(xmpp_stanza_t* const stanza, void* const userdata)
|
||||||
|
{
|
||||||
|
const char* from = xmpp_stanza_get_from(stanza);
|
||||||
|
xmpp_stanza_t* query = xmpp_stanza_get_child_by_name(stanza, STANZA_NAME_QUERY);
|
||||||
|
EntityCapabilities* capabilities = stanza_create_caps_from_query_element(query);
|
||||||
|
|
||||||
|
// Update window name
|
||||||
|
ProfMucWin* win = wins_get_muc(from);
|
||||||
|
if (win != NULL) {
|
||||||
|
free(win->room_name);
|
||||||
|
win->room_name = strdup(capabilities->identity->name);
|
||||||
|
|
||||||
|
// Update features
|
||||||
|
muc_set_features(from, capabilities->features);
|
||||||
|
}
|
||||||
|
caps_destroy(capabilities);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_handle_groupchat(xmpp_stanza_t* const stanza)
|
_handle_groupchat(xmpp_stanza_t* const stanza)
|
||||||
{
|
{
|
||||||
@ -1037,6 +1060,28 @@ _handle_groupchat(xmpp_stanza_t* const stanza)
|
|||||||
char* broadcast;
|
char* broadcast;
|
||||||
broadcast = xmpp_message_get_body(stanza);
|
broadcast = xmpp_message_get_body(stanza);
|
||||||
if (!broadcast) {
|
if (!broadcast) {
|
||||||
|
xmpp_stanza_t* x = xmpp_stanza_get_child_by_name(stanza, "x");
|
||||||
|
|
||||||
|
if (x) {
|
||||||
|
xmpp_stanza_t* status = xmpp_stanza_get_child_by_name(x, "status");
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
const char* code = xmpp_stanza_get_attribute(status, "code");
|
||||||
|
|
||||||
|
if (code) {
|
||||||
|
// If configuration change notification send disco info to get updated info of the muc
|
||||||
|
char* disqo_info_id = connection_create_stanza_id();
|
||||||
|
xmpp_stanza_t* iq = stanza_create_disco_info_iq(ctx, disqo_info_id, room_jid, NULL);
|
||||||
|
iq_id_handler_add(disqo_info_id, _room_config_handler, NULL, NULL);
|
||||||
|
free(disqo_info_id);
|
||||||
|
iq_send_stanza(iq);
|
||||||
|
xmpp_stanza_release(iq);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
jid_destroy(from_jid);
|
jid_destroy(from_jid);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user