aboutsummaryrefslogtreecommitdiff
path: root/xmpp-vala/src/module/xep/0410_muc_self_ping.vala
diff options
context:
space:
mode:
authorfiaxh <git@lightrise.org>2020-08-14 16:42:56 +0200
committerfiaxh <git@lightrise.org>2020-08-31 16:48:20 +0200
commite6a90fc25c19b4cfceff7b1d89c58927753ee98d (patch)
treeccdf16576088c7734e4ca0ec554a285d3ff0bf7f /xmpp-vala/src/module/xep/0410_muc_self_ping.vala
parentff9a9a0d667694cc9254db832655bddfbcabc909 (diff)
downloaddino-e6a90fc25c19b4cfceff7b1d89c58927753ee98d.tar.gz
dino-e6a90fc25c19b4cfceff7b1d89c58927753ee98d.zip
Implement MUC self ping
Diffstat (limited to 'xmpp-vala/src/module/xep/0410_muc_self_ping.vala')
-rw-r--r--xmpp-vala/src/module/xep/0410_muc_self_ping.vala18
1 files changed, 18 insertions, 0 deletions
diff --git a/xmpp-vala/src/module/xep/0410_muc_self_ping.vala b/xmpp-vala/src/module/xep/0410_muc_self_ping.vala
new file mode 100644
index 00000000..84772333
--- /dev/null
+++ b/xmpp-vala/src/module/xep/0410_muc_self_ping.vala
@@ -0,0 +1,18 @@
+namespace Xmpp.Xep.MucSelfPing {
+
+ public static async bool is_joined(XmppStream stream, Jid jid) {
+ Iq.Stanza iq_result = yield stream.get_module(Xmpp.Xep.Ping.Module.IDENTITY).send_ping(stream, jid);
+
+ if (!iq_result.is_error()) {
+ return true;
+ } else {
+ var error_stanza = iq_result.get_error();
+ if (error_stanza.condition in new string[] {ErrorStanza.CONDITION_SERVICE_UNAVAILABLE, ErrorStanza.CONDITION_FEATURE_NOT_IMPLEMENTED}) {
+ // the client is joined, but the pinged client does not implement XMPP Ping
+ return true;
+ }
+ }
+ return false;
+ }
+
+}