Added check members only room to send mediated invites
This commit is contained in:
@@ -204,7 +204,16 @@ message_send_invite(const char * const roomjid, const char * const contact,
|
||||
{
|
||||
xmpp_conn_t * const conn = connection_get_conn();
|
||||
xmpp_ctx_t * const ctx = connection_get_ctx();
|
||||
xmpp_stanza_t *stanza = stanza_create_invite(ctx, roomjid, contact, reason);
|
||||
xmpp_stanza_t *stanza;
|
||||
|
||||
muc_member_type_t member_type = muc_member_type(roomjid);
|
||||
if (member_type == MUC_MEMBER_TYPE_PUBLIC) {
|
||||
log_debug("Sending direct invite to %s, for %s", contact, roomjid);
|
||||
stanza = stanza_create_invite(ctx, roomjid, contact, reason);
|
||||
} else {
|
||||
log_debug("Sending mediated invite to %s, for %s", contact, roomjid);
|
||||
stanza = stanza_create_mediated_invite(ctx, roomjid, contact, reason);
|
||||
}
|
||||
|
||||
xmpp_send(conn, stanza);
|
||||
xmpp_stanza_release(stanza);
|
||||
|
||||
@@ -440,6 +440,46 @@ stanza_create_invite(xmpp_ctx_t *ctx, const char * const room,
|
||||
return message;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *
|
||||
stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char * const room,
|
||||
const char * const contact, const char * const reason)
|
||||
{
|
||||
xmpp_stanza_t *message, *x, *invite;
|
||||
|
||||
message = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(message, STANZA_NAME_MESSAGE);
|
||||
xmpp_stanza_set_attribute(message, STANZA_ATTR_TO, room);
|
||||
char *id = create_unique_id(NULL);
|
||||
xmpp_stanza_set_id(message, id);
|
||||
free(id);
|
||||
|
||||
x = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(x, STANZA_NAME_X);
|
||||
xmpp_stanza_set_ns(x, STANZA_NS_MUC_USER);
|
||||
|
||||
invite = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(invite, STANZA_NAME_INVITE);
|
||||
xmpp_stanza_set_attribute(invite, STANZA_ATTR_TO, contact);
|
||||
|
||||
if (reason != NULL) {
|
||||
xmpp_stanza_t *reason_st = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_name(reason_st, STANZA_NAME_REASON);
|
||||
xmpp_stanza_t *reason_txt = xmpp_stanza_new(ctx);
|
||||
xmpp_stanza_set_text(reason_txt, reason);
|
||||
xmpp_stanza_add_child(reason_st, reason_txt);
|
||||
xmpp_stanza_release(reason_txt);
|
||||
xmpp_stanza_add_child(invite, reason_st);
|
||||
xmpp_stanza_release(reason_st);
|
||||
}
|
||||
|
||||
xmpp_stanza_add_child(x, invite);
|
||||
xmpp_stanza_release(invite);
|
||||
xmpp_stanza_add_child(message, x);
|
||||
xmpp_stanza_release(x);
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
xmpp_stanza_t *
|
||||
stanza_create_room_join_presence(xmpp_ctx_t * const ctx,
|
||||
const char * const full_room_jid, const char * const passwd)
|
||||
|
||||
@@ -215,6 +215,8 @@ xmpp_stanza_t* stanza_create_disco_info_iq(xmpp_ctx_t *ctx, const char * const i
|
||||
|
||||
xmpp_stanza_t* stanza_create_invite(xmpp_ctx_t *ctx, const char * const room,
|
||||
const char * const contact, const char * const reason);
|
||||
xmpp_stanza_t* stanza_create_mediated_invite(xmpp_ctx_t *ctx, const char * const room,
|
||||
const char * const contact, const char * const reason);
|
||||
|
||||
gboolean stanza_contains_chat_state(xmpp_stanza_t *stanza);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user