replaced empty ns hack with the actual namespace used

All children of a message/presence/iq are in the jabber:client namespace
in a c2s stream unless xmlns is specified.
This commit is contained in:
Emmanuel Gil Peyrot 2021-10-11 14:07:16 +02:00 committed by Jasper
parent fab8efe5fb
commit 9d2dcfb21c
1 changed files with 11 additions and 9 deletions

View File

@ -231,7 +231,7 @@ impl JitsiConference {
pub async fn set_muted(&self, media_type: MediaType, muted: bool) -> Result<()> { pub async fn set_muted(&self, media_type: MediaType, muted: bool) -> Result<()> {
self self
.send_presence(vec![ .send_presence(vec![
Element::builder(media_type.jitsi_muted_presence_element_name(), "") Element::builder(media_type.jitsi_muted_presence_element_name(), ns::DEFAULT_NS)
.append(muted.to_string()) .append(muted.to_string())
.build(), .build(),
]) ])
@ -408,13 +408,13 @@ impl StanzaFilter for JitsiConference {
#[tracing::instrument(level = "trace")] #[tracing::instrument(level = "trace")]
fn filter(&self, element: &Element) -> bool { fn filter(&self, element: &Element) -> bool {
element.attr("from") == Some(self.config.focus.to_string().as_str()) element.attr("from") == Some(self.config.focus.to_string().as_str())
&& element.is("iq", "jabber:client") && element.is("iq", ns::DEFAULT_NS)
|| element || element
.attr("from") .attr("from")
.and_then(|from| from.parse::<BareJid>().ok()) .and_then(|from| from.parse::<BareJid>().ok())
.map(|jid| jid == self.config.muc) .map(|jid| jid == self.config.muc)
.unwrap_or_default() .unwrap_or_default()
&& (element.is("presence", "jabber:client") || element.is("iq", "jabber:client")) && (element.is("presence", ns::DEFAULT_NS) || element.is("iq", ns::DEFAULT_NS))
} }
#[tracing::instrument(level = "trace", err)] #[tracing::instrument(level = "trace", err)]
@ -449,15 +449,15 @@ impl StanzaFilter for JitsiConference {
let mut presence = vec![ let mut presence = vec![
Muc::new().into(), Muc::new().into(),
ECaps2::new(vec![jitsi_disco_hash]).into(), ECaps2::new(vec![jitsi_disco_hash]).into(),
Element::builder("stats-id", "").append("gst-meet").build(), Element::builder("stats-id", ns::DEFAULT_NS).append("gst-meet").build(),
Element::builder("jitsi_participant_codecType", "") Element::builder("jitsi_participant_codecType", ns::DEFAULT_NS)
.append(self.config.video_codec.as_str()) .append(self.config.video_codec.as_str())
.build(), .build(),
Element::builder("jitsi_participant_region", "") Element::builder("jitsi_participant_region", ns::DEFAULT_NS)
.append(self.config.region.as_str()) .append(self.config.region.as_str())
.build(), .build(),
Element::builder("audiomuted", "").append("false").build(), Element::builder("audiomuted", ns::DEFAULT_NS).append("false").build(),
Element::builder("videomuted", "").append("false").build(), Element::builder("videomuted", ns::DEFAULT_NS).append("false").build(),
Element::builder("nick", "http://jabber.org/protocol/nick") Element::builder("nick", "http://jabber.org/protocol/nick")
.append(self.config.nick.as_str()) .append(self.config.nick.as_str())
.build(), .build(),
@ -470,7 +470,9 @@ impl StanzaFilter for JitsiConference {
.config .config
.extra_muc_features .extra_muc_features
.iter() .iter()
.map(|feature| Element::builder("feature", "").attr("var", feature).build()), .cloned()
.map(|var| Feature { var })
.map(|feature| feature.into()),
); );
self.send_presence(presence).await?; self.send_presence(presence).await?;
self.inner.lock().await.state = JoiningMuc; self.inner.lock().await.state = JoiningMuc;