Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_xep_0048.py @ 4327:554a87ae17a6
plugin XEP-0048, XEP-0402; CLI (bookmarks): implement XEP-0402 (PEP Native Bookmarks):
- Former bookmarks implementation is now labeled as "legacy".
- XEP-0402 is now used for bookmarks when relevant namespaces are found, and it fallbacks
to legacy XEP-0048/XEP-0049 bookmarks otherwise.
- CLI legacy bookmark commands have been moved to `bookmarks legacy`
- CLI bookmarks commands now use the new XEP-0402 (with fallback to legacy one
automatically used if necessary).
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 20 Nov 2024 11:43:27 +0100 |
parents | 0d7bb4df2343 |
children |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0048.py Wed Nov 20 11:38:44 2024 +0100 +++ b/libervia/backend/plugins/plugin_xep_0048.py Wed Nov 20 11:43:27 2024 +0100 @@ -1,8 +1,8 @@ #!/usr/bin/env python3 -# SAT plugin for Bookmarks (xep-0048) -# Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) +# Libervia plugin for Bookmarks (xep-0048) +# Copyright (C) 2009-2024 Jérôme Poisson (goffi@goffi.org) # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -71,28 +71,30 @@ self.__selected_id = host.register_callback( self._bookmark_selected_cb, with_data=True ) + # XXX: We're transitionning to XEP-0402, so we mark bridge method as "legacy" + # here. host.bridge.add_method( - "bookmarks_list", + "bookmarks_legacy_list", ".plugin", in_sign="sss", out_sign="a{sa{sa{ss}}}", - method=self._bookmarks_list, + method=self.bookmarks_list, async_=True, ) host.bridge.add_method( - "bookmarks_remove", + "bookmarks_legacy_remove", ".plugin", in_sign="ssss", out_sign="", - method=self._bookmarks_remove, + method=self.bookmarks_remove, async_=True, ) host.bridge.add_method( - "bookmarks_add", + "bookmarks_legacy_add", ".plugin", in_sign="ssa{ss}ss", out_sign="", - method=self._bookmarks_add, + method=self.bookmarks_add, async_=True, ) try: @@ -419,7 +421,12 @@ if storage_type == "pubsub": raise NotImplementedError - def _bookmarks_list(self, type_, storage_location, profile_key=C.PROF_KEY_NONE): + def bookmarks_list( + self, + type_: str, + storage_location: str, + profile_key: str = C.PROF_KEY_NONE + ) -> defer.Deferred[dict]: """Return stored bookmarks @param type_: bookmark type, one of: @@ -458,7 +465,8 @@ if storage_location in ("all", _storage_location): ret[_storage_location] = {} if _storage_location in ("private",): - # we update distant bookmarks, just in case an other client added something + # we update distant bookmarks, just in case an other client added + # something d = self._get_server_bookmarks(_storage_location, client.profile) else: d = defer.succeed(None) @@ -467,7 +475,7 @@ return ret_d - def _bookmarks_remove( + def bookmarks_remove( self, type_, location, storage_location, profile_key=C.PROF_KEY_NONE ): """Return stored bookmarks @@ -487,7 +495,7 @@ location = jid.JID(location) return self.remove_bookmark(type_, location, storage_location, profile_key) - def _bookmarks_add( + def bookmarks_add( self, type_, location, data, storage_type="auto", profile_key=C.PROF_KEY_NONE ): if type_ == XEP_0048.MUC_TYPE: