plugin XEP-0402: ignore missing item when removing a bookmark

This commit is contained in:
Goffi 2026-10-06 22:53:16 +02:00
commit 571588f8a1

View file

@ -20,7 +20,7 @@ from typing import Iterator, Self, cast
from pydantic import BaseModel, Field, RootModel
from twisted.internet import defer
from twisted.words.protocols.jabber import jid
from twisted.words.protocols.jabber import error, jid
from twisted.words.protocols.jabber.xmlstream import TimeoutError
from twisted.words.xish import domish
from tx_xmpp import pubsub
@ -360,9 +360,17 @@ class XEP_0402:
if await self.host.memory.disco.has_feature(
client, NS_BOOKMARKS2_COMPAT, pep_jid
):
await self._p.retract_items(
client, client.jid.userhostJID(), NS_BOOKMARKS2, [bookmark_jid.full()]
)
try:
await self._p.retract_items(
client,
client.jid.userhostJID(),
NS_BOOKMARKS2,
[bookmark_jid.full()],
)
except error.StanzaError as e:
if e.condition != "item-not-found":
raise
# no bookmark to remove, nothing to do
else:
log.debug(
f"[{client.profile}] No compatibility layer found, we use legacy "