Commit graph libervia-backend/sat/plugins/plugin_comp_ap_gateway
Author SHA1 Message Date
Goffi
2cee9c9519 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
2022-07-22 15:42:59 +02:00
Goffi
9089a6494e component AP gateway: handle Like and Undo/Like activities:
rel 370
2022-07-21 18:07:35 +02:00
Goffi
a945d3cb67 component AP gateway (pubsub): only emit a Follow activity for microblog subscription:
this avoid to emit Follow subscription when an entity wants to subscribe to attachments
or other special nodes.

rel 370
2022-07-21 18:05:20 +02:00
Goffi
d841a51a1a component AP gateway: handle XMPP attachments -> AP likes conversion:
convert `noticed` attachments coming from XMPP to suitable `Like` activities. Virtual node
is created in cache when necessary, and virtual items published to virtual JID mapping AP
accounts are cached too.

rel 370
2022-07-20 17:53:12 +02:00
Goffi
51f786bc21 component AP gateway: when a repeated blog post is retracted, it converted to suitable Activity:
when a retract item is received, the former item is now retrieve from cache, and if it was
a "repeat" blog post, it is converted to the suitable `Undo` of `Announce` activity
(instead of the default `Delete` activity).

rel 370
2022-07-14 12:55:30 +02:00
Goffi
ee898b120d component AP gateway: "repeat" to "Announce" conversion:
when an XMPP blog post is marked as repeated, it is converted to an AP Announce activity

rel 370
2022-07-14 12:55:30 +02:00
Goffi
e73d4ebeff component AP gateway: fix wrong exception + use of mb_data["xml"] when it may be absent 2022-07-14 12:55:30 +02:00
Goffi
eb5b89d113 component AP gateway: we need to use actor and not attributedTo for activities:
`attributedTo` may not be filled, notably when the object is a string URL
2022-07-14 12:55:30 +02:00
Goffi
9a5801fedd component AP gateway: get items when not found in cache in apGetLocalObject:
rel 370
2022-07-14 12:55:30 +02:00
Goffi
9f6d69c75d component AP gateway: use the new priority argument of addManagedNode:
priority is needed because we'll need to inspect former items on retract to check the
Acitivy to use (it may be an `Undo` activity is some cases), and this must be done before
the cache is updated by pubsub cache plugin.

rel 370
2022-07-14 12:55:30 +02:00
Goffi
cd9d1d27e3 component AP gateway: new verbose attribute in AP gateway to activate debug logs:
when verbose is not null, object posted or returned on GET request are logged. Check
comments for vebosity level
2022-07-14 12:55:30 +02:00
Goffi
f4af47a929 component AP gateway: return item when item URL is used:
a request on an `item` type URL will return the suitable cached item.

rel 370
2022-07-14 12:55:30 +02:00
Goffi
7bd01dd06c component AP gateway: use createActivity in mbdata2APitem 2022-07-14 12:55:30 +02:00
Goffi
6e74e19c73 component AP gateway: Announce activity implementation:
`Announce` and `Undo` of `Announce` are now implemented and converted to suitable XEP-0277
"repeat" items, or retract.

rel 370
2022-07-14 12:55:30 +02:00
Goffi
575c3fe768 component AP gateway: getAPAccountFromId now works with local IDs:
rel 370
2022-07-14 12:55:30 +02:00
Goffi
fe4dc35f5c component AP gateway: apGetObject and apGetList now work with local object:
When a local item is linked, it is found from database instead of doing an HTTP request.

rel 370
2022-07-14 12:55:30 +02:00
Goffi
9e2f4571f6 component AP gateway: convert XMPP mentions to AP:
When a XEP-0372 mention is received, the linked pubsub item is looked after in cache, and
if found, it is send to mentioned entity with `mention` tag added.

However, this doesn't work in some cases (see incoming doc for details). To work around
that, `@user@server.tld` type mention are also scanned in body, and mentions are added
when found (this can be disabled with `auto_mentions` setting).

Mention are only scanned in "public" messages, i.e. for pubsub items, and not direct
messages.

rel 369
2022-07-10 16:15:06 +02:00
Goffi
2c654e017d component AP gateway: convert AP mention to XEP-0372 mentions:
when a mentions are found in AP items (either with people specified directly as target, of
with `mention` tags as in
https://www.w3.org/TR/activitystreams-vocabulary/#microsyntaxes), they are converted to
XEP-0372 `mention` references.

This is only done for Pubsub items (i.e. not for private messages).

rel 369
2022-07-10 15:16:15 +02:00
Goffi
a5381c8c86 tests (unit/ap-gateway): tests for XMPP identity/vCard4 <=> AP actor data conversion:
rel 368
2022-06-29 14:06:33 +02:00
Goffi
68c627570d component AP: convert AP identity data to XMPP:
metadata are converted to vCard4 (XEP-0292).
Avatar is converted to User Avatar (XEP-0084), it is downloaded, resized, converted and
cached on first request.

If avatar is bigger than 5 Mio, it won't be used.

rel 368
2022-06-29 12:12:09 +02:00
Goffi
303e25f72e component AP: XMPP identity => AP actor data converstion:
XMPP identity data (coming from various XEPs, notably XEP-0292 (vCard4) and XEP-0084 (User
Avatar)) are now used to complete actor data.

Avatar files can now be delivered with the `avatar` type in URL.

rel 368
2022-06-29 12:06:21 +02:00
Goffi
c02dcf3d94 component AP gateway typing + remove unused activity arg from newAPDeleteItem
rel 367
2022-06-17 15:50:34 +02:00
Goffi
bfd9168449 component AP gateway: AP delete activity => message retract:
handle retractation of messages. As it is not possible to know from the AP item alone if
we need to to a message retractation (XEP-0424) or a pubsub retractation (XEP-0060), we
now cache sent message, and decide which method to use according to how the item is cached
(i.e. in message history or in pubsub cache).

rel 367
2022-06-17 14:15:23 +02:00
Goffi
8869b1b05d component AP gateway: message retractation => AP deletion
Convert XEP-0424 message retractation request to suitable AP delete activity.

The message workflow and its triggers are now used instead of a direct observer, as it is
now possible to do so with component, and this let other plugin to parse and eventually
update metadata.

rel 367
2022-06-17 14:15:23 +02:00
Goffi
7d3e66dc28 component AP gateway: set POST default response code to 202 (accepted) 2022-06-17 14:15:23 +02:00
Goffi
408dc04ee6 component AP gateway: convert Delete AP activities to corresponding Pubsub retract:
when a `Delete` actity is received, the item is removed from cache, and the corresponding
item `retract` is sent to local XMPP subscribers.

rel 367
2022-06-17 14:15:23 +02:00
Goffi
4e0c1fe7bf comp AP gateway: convert pubsub item retractation to AP Delete activity:
when an item `retract` is received from a node from which an AP actor is subscribed, a
corresponding `Delete` activity is created and sent to AP followers.

Trying to retract an item from a virtual node of the gateway pubsub service now return a
`forbidden` stanza error (those nodes are handled on AP side and thus are not owned by
XMPP entities).

rel 367
2022-06-17 14:15:23 +02:00
Goffi
fa81d96d79 comp AP gateway: message conversion:
Convert direct AP items to XMPP `<message>` stanzas, and vice versa.
Documentation will follow soon to explain the behaviour.

rel 366
2022-05-24 17:57:36 +02:00
Goffi
0114769fa4 comp AP gateway: publish, (un)subscribe/(un)follow, public subscription/following/followers:
this patch implements those major features:

- `publish` is implemented on virtual pubsub service, thus XMPP entities can now publish
  to AP using this service
- replies to XMPP items are managed
- `inReplyTo` is filled when converting XMPP items to AP objects
- `follow` and `unfollow` (actually an `undo` activity) are implemented and mapped to
  XMPP's (un)subscribe. On subscription, AP actor's `outbox` collection is converted to
  XMPP and put in cache. Subscriptions are always public.
- `following` and `followers` collections are mapped to XMPP's Public Pubsub Subscription
  (which should be XEP-0465, but the XEP is not yet published at the time of commit), in
  both directions.
- new helper methods to check if an URL is local and to get JID from actor ID

doc will follow to explain behaviour

rel 365
2022-05-13 19:12:33 +02:00
Goffi
8a2154ccca comp AP gateway: signature checking, caching and threads management:
- HTTP signature is checked for incoming messages
- AP actor can now be followed using pubsub subscription. When following is accepted, the
  node is cached
- replies to posts are put in cached pubsub comment nodes, with a `comments_max_depth`
  option to limit the number of comment nodes for a root message (documentation will come
  to explain this).

ticket 364
2022-03-22 17:00:42 +01:00
Goffi
5ca925996d comp AP: helper methods to get AP objects:
rel 364
2022-03-22 17:00:42 +01:00
Goffi
16664ab939 comp AP gateway: regular expression to parse Signature header:
rel 364
2022-03-22 17:00:42 +01:00
Goffi
3801db7835 component AP gateway: split plugin in several files:
constants, HTTP server and Pubsub service have been put in separated files.

rel: 363
2022-01-31 18:35:49 +01:00