forked from lavina/lavina
feat(xmpp): improve disco responses
This commit is contained in:
parent
f71d098420
commit
2b54260f0b
|
@ -25,7 +25,7 @@ use crate::prelude::*;
|
|||
use crate::protos::xmpp;
|
||||
use crate::protos::xmpp::bind::{BindResponse, Jid, Name, Resource, Server};
|
||||
use crate::protos::xmpp::client::{Iq, Presence};
|
||||
use crate::protos::xmpp::disco::{Feature, InfoQuery, Item, ItemQuery};
|
||||
use crate::protos::xmpp::disco::*;
|
||||
use crate::protos::xmpp::roster::RosterQuery;
|
||||
use crate::protos::xmpp::session::Session;
|
||||
use crate::protos::xmpp::stream::*;
|
||||
|
@ -314,7 +314,7 @@ fn handle_packet(output: &mut Vec<Event<'static>>, packet: ClientPacket) -> bool
|
|||
};
|
||||
response.serialize(output);
|
||||
false
|
||||
},
|
||||
}
|
||||
proto::ClientPacket::StreamEnd => {
|
||||
ServerStreamEnd.serialize(output);
|
||||
true
|
||||
|
@ -394,9 +394,16 @@ fn handle_iq(output: &mut Vec<Event<'static>>, iq: Iq<IqClientBody>) {
|
|||
}
|
||||
|
||||
fn disco_info(to: Option<&str>, req: &InfoQuery) -> InfoQuery {
|
||||
let feature = match to {
|
||||
let identity;
|
||||
let feature;
|
||||
match to {
|
||||
Some("localhost") => {
|
||||
vec![
|
||||
identity = vec![Identity {
|
||||
category: "server".into(),
|
||||
name: None,
|
||||
r#type: "im".into(),
|
||||
}];
|
||||
feature = vec![
|
||||
Feature::new("http://jabber.org/protocol/disco#info"),
|
||||
Feature::new("http://jabber.org/protocol/disco#items"),
|
||||
Feature::new("iq"),
|
||||
|
@ -404,17 +411,25 @@ fn disco_info(to: Option<&str>, req: &InfoQuery) -> InfoQuery {
|
|||
]
|
||||
}
|
||||
Some("rooms.localhost") => {
|
||||
vec![
|
||||
identity = vec![Identity {
|
||||
category: "conference".into(),
|
||||
name: Some("Chat rooms".into()),
|
||||
r#type: "text".into(),
|
||||
}];
|
||||
feature = vec![
|
||||
Feature::new("http://jabber.org/protocol/disco#info"),
|
||||
Feature::new("http://jabber.org/protocol/disco#items"),
|
||||
Feature::new("http://jabber.org/protocol/muc"),
|
||||
]
|
||||
}
|
||||
_ => vec![],
|
||||
_ => {
|
||||
identity = vec![];
|
||||
feature = vec![];
|
||||
}
|
||||
};
|
||||
InfoQuery {
|
||||
node: None,
|
||||
identity: vec![],
|
||||
identity,
|
||||
feature,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -132,9 +132,9 @@ impl ToXml for InfoQuery {
|
|||
|
||||
#[derive(PartialEq, Eq, Debug)]
|
||||
pub struct Identity {
|
||||
category: String,
|
||||
name: Option<String>,
|
||||
r#type: String,
|
||||
pub category: String,
|
||||
pub name: Option<String>,
|
||||
pub r#type: String,
|
||||
}
|
||||
|
||||
impl FromXml for Identity {
|
||||
|
|
Loading…
Reference in New Issue