component AP gateway: fix item ID for XMPP items on Announce:
if an Announced item is from XMPP, the AP id must be parsed to retrieve the XMPP original ID. rel 370
This commit is contained in:
parent
9089a6494e
commit
2cee9c9519
1 changed files with 28 additions and 1 deletions
|
|
@ -288,6 +288,33 @@ class HTTPAPGServer(web_resource.Resource):
|
|||
# from post author in this case
|
||||
sender_jid = await self.apg.getJIDFromId(sender)
|
||||
repeater_jid = await self.apg.getJIDFromId(signing_actor)
|
||||
repeated_item_id = obj["id"]
|
||||
if self.apg.isLocalURL(repeated_item_id):
|
||||
# the repeated object is from XMPP, we need to parse the URL to find
|
||||
# the right ID
|
||||
url_type, url_args = self.apg.parseAPURL(repeated_item_id)
|
||||
if url_type != "item":
|
||||
raise exceptions.DataError(
|
||||
"local URI is not an item: {repeated_id}"
|
||||
)
|
||||
try:
|
||||
url_account, url_item_id = url_args
|
||||
if not url_account or not url_item_id:
|
||||
raise ValueError
|
||||
except (RuntimeError, ValueError):
|
||||
raise exceptions.DataError(
|
||||
"local URI is invalid: {repeated_id}"
|
||||
)
|
||||
else:
|
||||
url_jid, url_node = await self.apg.getJIDAndNode(url_account)
|
||||
if ((url_jid != sender_jid
|
||||
or url_node and url_node != self.apg._m.namespace)):
|
||||
raise exceptions.DataError(
|
||||
"announced ID doesn't match sender ({sender}): "
|
||||
f"[repeated_item_id]"
|
||||
)
|
||||
|
||||
repeated_item_id = url_item_id
|
||||
|
||||
obj["_repeated"] = {
|
||||
"by": repeater_jid.full(),
|
||||
|
|
@ -296,7 +323,7 @@ class HTTPAPGServer(web_resource.Resource):
|
|||
"pubsub",
|
||||
path=sender_jid.full(),
|
||||
node=self.apg._m.namespace,
|
||||
item=obj["id"]
|
||||
item=repeated_item_id
|
||||
)
|
||||
}
|
||||
# we must use activity's id and targets, not the original item ones
|
||||
|
|
|
|||
Loading…
Reference in a new issue