summarylogtreecommitdiffstats
path: root/0004-Use-proper-Presence-structure-when-receiving-stanzas.patch
blob: 4c4dde65954c3b55e5a9c8e7489e68cdeaec0a74 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
From a57ae24b572e080df71622e3896159c80ba6c883 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= <pep@bouah.net>
Date: Thu, 5 Sep 2019 23:59:07 +0200
Subject: [PATCH 4/6] Use proper Presence structure when receiving stanzas
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
---
 src/xmpp.rs | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/xmpp.rs b/src/xmpp.rs
index 3952e64..d6b8f66 100644
--- a/src/xmpp.rs
+++ b/src/xmpp.rs
@@ -1,4 +1,5 @@
 use std::str::FromStr;
+use std::convert::TryFrom;
 use futures::{Future, Sink, Stream, sync::mpsc};
 use tokio_xmpp::{Client, Packet, Event};
 use xmpp_parsers::{Jid, Element};
@@ -34,8 +35,9 @@ impl Agent {
                     }
                     Event::Stanza(el) => {
                         if el.is("presence", "jabber:client") {
-                            if el.attr("from") == Some(&muc_jid_str) {
-                                if el.attr("type") == PresenceType::Error {
+                            let presence = Presence::try_from(el).unwrap();
+                            if presence.from == Some(Jid::Bare(muc_jid.clone())) {
+                                if presence.type_ == PresenceType::Error {
                                     info!("Failed to enter MUC {:?}", muc_jid);
                                 } else {
                                     info!("Entered MUC {:?}", muc_jid);
-- 
2.23.0