From f1713231c4be1952960e2b6b512e1915817176f0 Mon Sep 17 00:00:00 2001 From: xmppftw Date: Sat, 16 Dec 2023 15:14:28 +0100 Subject: [PATCH] Add Private XML Storage (XEP-0049) support for legacy bookmarks (XEP-0048 v1.0) --- parsers/src/lib.rs | 3 +++ parsers/src/ns.rs | 3 +++ parsers/src/private.rs | 36 ++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 parsers/src/private.rs diff --git a/parsers/src/lib.rs b/parsers/src/lib.rs index 3a1c1a39..81c199d7 100644 --- a/parsers/src/lib.rs +++ b/parsers/src/lib.rs @@ -70,6 +70,9 @@ pub mod ibb; /// XEP-0048: Bookmarks pub mod bookmarks; +/// XEP-0049: Private XML storage +pub mod private; + /// XEP-0059: Result Set Management pub mod rsm; diff --git a/parsers/src/ns.rs b/parsers/src/ns.rs index e2304e59..f163b0cb 100644 --- a/parsers/src/ns.rs +++ b/parsers/src/ns.rs @@ -43,6 +43,9 @@ pub const IBB: &str = "http://jabber.org/protocol/ibb"; /// XEP-0048: Bookmarks pub const BOOKMARKS: &str = "storage:bookmarks"; +/// XEP-0049: Private XML Storage +pub const PRIVATE: &str = "jabber:iq:private"; + /// XEP-0059: Result Set Management pub const RSM: &str = "http://jabber.org/protocol/rsm"; diff --git a/parsers/src/private.rs b/parsers/src/private.rs new file mode 100644 index 00000000..a0c6bc46 --- /dev/null +++ b/parsers/src/private.rs @@ -0,0 +1,36 @@ +// Copyright (c) 2023 xmppftw +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +//! +//! This module implements [Private XML Storage](https://xmpp.org/extensions/xep-0049.html) from +//! XEP-0049. +//! +//! However, only legacy bookmarks storage from [XEP-0048 +//! v1.0](https://xmpp.org/extensions/attic/xep-0048-1.0.html) is supported at the moment. +//! This should only be used when `urn:xmpp:bookmarks:1#compat` is not advertised on the user's +//! BareJID in a disco info request. +//! +//! See [ModernXMPP docs](https://docs.modernxmpp.org/client/groupchat/#bookmarks) on how to handle +//! all historic and newer specifications for your clients handling of chatroom bookmarks. + +use crate::{ + bookmarks::Storage, + iq::{IqGetPayload, IqResultPayload, IqSetPayload}, +}; + +generate_element!( + /// A Private XML Storage query. Only supports XEP-0048 bookmarks. + Query, "query", PRIVATE, + attributes: [], + children: [ + /// XEP-0048 bookmarks in a [`Storage`] element + storage: Required = ("storage", BOOKMARKS) => Storage, + ] +); + +impl IqSetPayload for Query {} +impl IqGetPayload for Query {} +impl IqResultPayload for Query {}