aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2019-11-04 15:08:12 +0100
committerfiaxh <git@lightrise.org>2019-11-04 15:11:36 +0100
commit247a36815043deb15c19edc536f7b2ec3a2d02c8 (patch)
tree6f393e9a666664ef702f273721662e516bb4d3e7 /plugins
parent388cc56674487e7b9e339637369fc55f0e271daf (diff)
downloaddino-247a36815043deb15c19edc536f7b2ec3a2d02c8.tar.gz
dino-247a36815043deb15c19edc536f7b2ec3a2d02c8.zip
OMEMO: Don't set publish options, configure only bundle node instead
Diffstat (limited to 'plugins')
-rw-r--r--plugins/omemo/src/protocol/stream_module.vala23
1 files changed, 19 insertions, 4 deletions
diff --git a/plugins/omemo/src/protocol/stream_module.vala b/plugins/omemo/src/protocol/stream_module.vala
index fdfca30c..21476bd8 100644
--- a/plugins/omemo/src/protocol/stream_module.vala
+++ b/plugins/omemo/src/protocol/stream_module.vala
@@ -75,7 +75,7 @@ public class StreamModule : XmppStreamModule {
if (!am_on_devicelist) {
debug("Not on device list, adding id");
node.put_node(new StanzaNode.build("device", NS_URI).put_attribute("id", store.local_registration_id.to_string()));
- stream.get_module(Pubsub.Module.IDENTITY).publish.begin(stream, jid, NODE_DEVICELIST, id, node, Xmpp.Xep.Pubsub.ACCESS_MODEL_OPEN);
+ stream.get_module(Pubsub.Module.IDENTITY).publish.begin(stream, jid, NODE_DEVICELIST, id, node);
}
publish_bundles_if_needed(stream, jid);
}
@@ -254,7 +254,7 @@ public class StreamModule : XmppStreamModule {
}
if (changed) {
- publish_bundles(stream, (!)signed_pre_key_record, identity_key_pair, pre_key_records, (int32) store.local_registration_id);
+ publish_bundles.begin(stream, (!)signed_pre_key_record, identity_key_pair, pre_key_records, (int32) store.local_registration_id);
}
} catch (Error e) {
warning(@"Unexpected error while publishing bundle: $(e.message)\n");
@@ -262,7 +262,7 @@ public class StreamModule : XmppStreamModule {
stream.get_module(IDENTITY).active_bundle_requests.remove(jid.bare_jid.to_string() + @":$(store.local_registration_id)");
}
- public static void publish_bundles(XmppStream stream, SignedPreKeyRecord signed_pre_key_record, IdentityKeyPair identity_key_pair, Set<PreKeyRecord> pre_key_records, int32 device_id) throws Error {
+ public async void publish_bundles(XmppStream stream, SignedPreKeyRecord signed_pre_key_record, IdentityKeyPair identity_key_pair, Set<PreKeyRecord> pre_key_records, int32 device_id) throws Error {
ECKeyPair tmp;
StanzaNode bundle = new StanzaNode.build("bundle", NS_URI)
.add_self_xmlns()
@@ -281,7 +281,22 @@ public class StreamModule : XmppStreamModule {
}
bundle.put_node(prekeys);
- stream.get_module(Pubsub.Module.IDENTITY).publish.begin(stream, null, @"$NODE_BUNDLES:$device_id", "1", bundle, Xmpp.Xep.Pubsub.ACCESS_MODEL_OPEN);
+ yield stream.get_module(Pubsub.Module.IDENTITY).publish(stream, null, @"$NODE_BUNDLES:$device_id", "1", bundle);
+ yield try_make_bundle_public(stream, device_id);
+
+ }
+
+ private async void try_make_bundle_public(XmppStream stream, int32 device_id) {
+ DataForms.DataForm? data_form = yield stream.get_module(Pubsub.Module.IDENTITY).request_node_config(stream, null, @"$NODE_BUNDLES:$device_id");
+ if (data_form == null) return;
+
+ foreach (DataForms.DataForm.Field field in data_form.fields) {
+ if (field.var == "pubsub#access_model" && field.get_value_string() != Pubsub.ACCESS_MODEL_OPEN) {
+ field.set_value_string(Pubsub.ACCESS_MODEL_OPEN);
+ yield stream.get_module(Pubsub.Module.IDENTITY).submit_node_config(stream, data_form, @"$NODE_BUNDLES:$device_id");
+ break;
+ }
+ }
}
public override string get_ns() {