forked from lavina/lavina
fixes
This commit is contained in:
parent
6491c8819b
commit
77d159ec24
|
@ -107,6 +107,8 @@ impl<'a> XmppConnection<'a> {
|
||||||
resource: Some(self.user.xmpp_resource.clone()),
|
resource: Some(self.user.xmpp_resource.clone()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
self_presence: true,
|
||||||
|
just_created: false, // TODO we don't know this for sure at this point
|
||||||
}],
|
}],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
@ -166,6 +168,8 @@ mod tests {
|
||||||
resource: Some(conn.user.xmpp_resource.clone()),
|
resource: Some(conn.user.xmpp_resource.clone()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
self_presence: true,
|
||||||
|
just_created: false,
|
||||||
}],
|
}],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
@ -216,6 +220,8 @@ mod tests {
|
||||||
resource: Some(conn.user.xmpp_resource.clone()),
|
resource: Some(conn.user.xmpp_resource.clone()),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
self_presence: true,
|
||||||
|
just_created: false,
|
||||||
}],
|
}],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
|
@ -135,22 +135,16 @@ impl<T: FromXml> Parser for MessageParser<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Event::End(_) => {
|
Event::End(_) => Continuation::Final(Ok(Message {
|
||||||
if let Some(body) = state.body {
|
|
||||||
Continuation::Final(Ok(Message {
|
|
||||||
from: state.from,
|
from: state.from,
|
||||||
id: state.id,
|
id: state.id,
|
||||||
to: state.to,
|
to: state.to,
|
||||||
r#type: state.r#type,
|
r#type: state.r#type,
|
||||||
lang: state.lang,
|
lang: state.lang,
|
||||||
subject: state.subject,
|
subject: state.subject,
|
||||||
body: Some(body),
|
body: state.body,
|
||||||
custom: state.custom,
|
custom: state.custom,
|
||||||
}))
|
})),
|
||||||
} else {
|
|
||||||
Continuation::Final(Err(ffail!("Body not found")))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Event::Empty(_) => {
|
Event::Empty(_) => {
|
||||||
let parser = T::parse();
|
let parser = T::parse();
|
||||||
match parser.consume(namespace, event) {
|
match parser.consume(namespace, event) {
|
||||||
|
|
|
@ -148,6 +148,10 @@ impl FromXml for X {
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub struct XUser {
|
pub struct XUser {
|
||||||
pub item: XUserItem,
|
pub item: XUserItem,
|
||||||
|
/// The receiver is the user referred to in the presence stanza.
|
||||||
|
pub self_presence: bool,
|
||||||
|
/// The room from which the presence stanza was sent was just created.
|
||||||
|
pub just_created: bool,
|
||||||
}
|
}
|
||||||
impl ToXml for XUser {
|
impl ToXml for XUser {
|
||||||
fn serialize(&self, output: &mut Vec<Event<'static>>) {
|
fn serialize(&self, output: &mut Vec<Event<'static>>) {
|
||||||
|
@ -155,6 +159,16 @@ impl ToXml for XUser {
|
||||||
tag.push_attribute(("xmlns", XMLNS_USER));
|
tag.push_attribute(("xmlns", XMLNS_USER));
|
||||||
output.push(Event::Start(tag));
|
output.push(Event::Start(tag));
|
||||||
self.item.serialize(output);
|
self.item.serialize(output);
|
||||||
|
if self.self_presence {
|
||||||
|
let mut meg = BytesStart::new("status");
|
||||||
|
meg.push_attribute(("code", "110"));
|
||||||
|
output.push(Event::Empty(meg));
|
||||||
|
}
|
||||||
|
if self.just_created {
|
||||||
|
let mut meg = BytesStart::new("status");
|
||||||
|
meg.push_attribute(("code", "201"));
|
||||||
|
output.push(Event::Empty(meg));
|
||||||
|
}
|
||||||
output.push(Event::End(BytesEnd::new("x")));
|
output.push(Event::End(BytesEnd::new("x")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue