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()),
|
||||
},
|
||||
},
|
||||
self_presence: true,
|
||||
just_created: false, // TODO we don't know this for sure at this point
|
||||
}],
|
||||
..Default::default()
|
||||
};
|
||||
|
@ -166,6 +168,8 @@ mod tests {
|
|||
resource: Some(conn.user.xmpp_resource.clone()),
|
||||
},
|
||||
},
|
||||
self_presence: true,
|
||||
just_created: false,
|
||||
}],
|
||||
..Default::default()
|
||||
};
|
||||
|
@ -216,6 +220,8 @@ mod tests {
|
|||
resource: Some(conn.user.xmpp_resource.clone()),
|
||||
},
|
||||
},
|
||||
self_presence: true,
|
||||
just_created: false,
|
||||
}],
|
||||
..Default::default()
|
||||
};
|
||||
|
|
|
@ -135,22 +135,16 @@ impl<T: FromXml> Parser for MessageParser<T> {
|
|||
}
|
||||
}
|
||||
}
|
||||
Event::End(_) => {
|
||||
if let Some(body) = state.body {
|
||||
Continuation::Final(Ok(Message {
|
||||
from: state.from,
|
||||
id: state.id,
|
||||
to: state.to,
|
||||
r#type: state.r#type,
|
||||
lang: state.lang,
|
||||
subject: state.subject,
|
||||
body: Some(body),
|
||||
custom: state.custom,
|
||||
}))
|
||||
} else {
|
||||
Continuation::Final(Err(ffail!("Body not found")))
|
||||
}
|
||||
}
|
||||
Event::End(_) => Continuation::Final(Ok(Message {
|
||||
from: state.from,
|
||||
id: state.id,
|
||||
to: state.to,
|
||||
r#type: state.r#type,
|
||||
lang: state.lang,
|
||||
subject: state.subject,
|
||||
body: state.body,
|
||||
custom: state.custom,
|
||||
})),
|
||||
Event::Empty(_) => {
|
||||
let parser = T::parse();
|
||||
match parser.consume(namespace, event) {
|
||||
|
|
|
@ -148,6 +148,10 @@ impl FromXml for X {
|
|||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct XUser {
|
||||
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 {
|
||||
fn serialize(&self, output: &mut Vec<Event<'static>>) {
|
||||
|
@ -155,6 +159,16 @@ impl ToXml for XUser {
|
|||
tag.push_attribute(("xmlns", XMLNS_USER));
|
||||
output.push(Event::Start(tag));
|
||||
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")));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue