Stop making superfluous requests when joining a MUC
Don't request legacy bookmarks on every muc join (when again setting autojoin) fixes #260 Don't query member/admin/owner affiliations on every MUC join
This commit is contained in:
parent
e40de72631
commit
975b37c498
|
@ -54,7 +54,8 @@ public class MucManager : StreamInteractionModule, Object {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Muc.JoinResult? join(Account account, Jid jid, string? nick, string? password) {
|
// already_autojoin: Without this flag we'd be retrieving bookmarks (to check for autojoin) from the sender on every join
|
||||||
|
public async Muc.JoinResult? join(Account account, Jid jid, string? nick, string? password, bool already_autojoin = false) {
|
||||||
XmppStream? stream = stream_interactor.get_stream(account);
|
XmppStream? stream = stream_interactor.get_stream(account);
|
||||||
if (stream == null) return null;
|
if (stream == null) return null;
|
||||||
|
|
||||||
|
@ -84,7 +85,7 @@ public class MucManager : StreamInteractionModule, Object {
|
||||||
if (res.nick != null) {
|
if (res.nick != null) {
|
||||||
// Join completed
|
// Join completed
|
||||||
enter_errors.unset(jid);
|
enter_errors.unset(jid);
|
||||||
set_autojoin(account, stream, jid, nick, password);
|
if (!already_autojoin) set_autojoin(account, stream, jid, nick, password);
|
||||||
stream_interactor.get_module(MessageProcessor.IDENTITY).send_unsent_muc_messages(account, jid);
|
stream_interactor.get_module(MessageProcessor.IDENTITY).send_unsent_muc_messages(account, jid);
|
||||||
|
|
||||||
Conversation joined_conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.GROUPCHAT);
|
Conversation joined_conversation = stream_interactor.get_module(ConversationManager.IDENTITY).create_conversation(jid, account, Conversation.Type.GROUPCHAT);
|
||||||
|
@ -487,7 +488,7 @@ public class MucManager : StreamInteractionModule, Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!is_active || !is_joined(conference.jid, account)) {
|
if (!is_active || !is_joined(conference.jid, account)) {
|
||||||
join.begin(account, conference.jid, conference.nick, conference.password);
|
join.begin(account, conference.jid, conference.nick, conference.password, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,7 +561,7 @@ public class MucManager : StreamInteractionModule, Object {
|
||||||
Timeout.add_seconds(10, () => {
|
Timeout.add_seconds(10, () => {
|
||||||
if (joined || !mucs_todo.has_key(account) || stream_interactor.get_stream(account) != stream) return false;
|
if (joined || !mucs_todo.has_key(account) || stream_interactor.get_stream(account) != stream) return false;
|
||||||
|
|
||||||
join.begin(account, jid.bare_jid, jid.resourcepart, null);
|
join.begin(account, jid.bare_jid, jid.resourcepart, null, true);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,11 +342,6 @@ public class Module : XmppStreamModule {
|
||||||
if (status_codes.contains(StatusCode.SELF_PRESENCE)) {
|
if (status_codes.contains(StatusCode.SELF_PRESENCE)) {
|
||||||
Jid bare_jid = presence.from.bare_jid;
|
Jid bare_jid = presence.from.bare_jid;
|
||||||
if (flag.get_enter_id(bare_jid) != null) {
|
if (flag.get_enter_id(bare_jid) != null) {
|
||||||
|
|
||||||
query_affiliation.begin(stream, bare_jid, "member");
|
|
||||||
query_affiliation.begin(stream, bare_jid, "admin");
|
|
||||||
query_affiliation.begin(stream, bare_jid, "owner");
|
|
||||||
|
|
||||||
flag.finish_muc_enter(bare_jid);
|
flag.finish_muc_enter(bare_jid);
|
||||||
var join_result = new JoinResult() { nick=presence.from.resourcepart, newly_created=status_codes.contains(StatusCode.NEW_ROOM_CREATED) };
|
var join_result = new JoinResult() { nick=presence.from.resourcepart, newly_created=status_codes.contains(StatusCode.NEW_ROOM_CREATED) };
|
||||||
flag.enter_futures[bare_jid].set_value(join_result);
|
flag.enter_futures[bare_jid].set_value(join_result);
|
||||||
|
@ -458,7 +453,6 @@ public class Module : XmppStreamModule {
|
||||||
.put_attribute("affiliation", affiliation))
|
.put_attribute("affiliation", affiliation))
|
||||||
) { to=jid };
|
) { to=jid };
|
||||||
|
|
||||||
|
|
||||||
Iq.Stanza iq_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
|
Iq.Stanza iq_result = yield stream.get_module(Iq.Module.IDENTITY).send_iq_async(stream, iq);
|
||||||
if (iq_result.is_error()) return null;
|
if (iq_result.is_error()) return null;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ public class Module : BookmarksProvider, XmppStreamModule {
|
||||||
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0048_bookmarks_module");
|
public static ModuleIdentity<Module> IDENTITY = new ModuleIdentity<Module>(NS_URI, "0048_bookmarks_module");
|
||||||
|
|
||||||
public async Set<Conference>? get_conferences(XmppStream stream) {
|
public async Set<Conference>? get_conferences(XmppStream stream) {
|
||||||
|
|
||||||
StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns();
|
StanzaNode get_node = new StanzaNode.build("storage", NS_URI).add_self_xmlns();
|
||||||
StanzaNode? result_node = yield stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node);
|
StanzaNode? result_node = yield stream.get_module(PrivateXmlStorage.Module.IDENTITY).retrieve(stream, get_node);
|
||||||
if (result_node == null) return null;
|
if (result_node == null) return null;
|
||||||
|
@ -38,7 +37,7 @@ public class Module : BookmarksProvider, XmppStreamModule {
|
||||||
conference_node.put_node(new StanzaNode.build("nick", NS_URI)
|
conference_node.put_node(new StanzaNode.build("nick", NS_URI)
|
||||||
.put_node(new StanzaNode.text(conference.nick)));
|
.put_node(new StanzaNode.text(conference.nick)));
|
||||||
}
|
}
|
||||||
// TODO (?) Bookmarks 2 currently don't define a password
|
// TODO (?) Bookmarks 2 currently doesn't define a password
|
||||||
storage_node.put_node(conference_node);
|
storage_node.put_node(conference_node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue