Commit graph

3,910 commits

Author SHA1 Message Date
Goffi
6eac59dc2d doc (components/AP Gateway): Ad-Hoc and Events:
New Ad-Hoc command is explained, and `Events` section specify how the conversion is done
between the 2 protocols.

fix 372
2022-09-22 12:03:12 +02:00
Goffi
b06f5cad04 doc (cli/event): update doc following changes:
rel 372
2022-09-22 12:01:44 +02:00
Goffi
c2e2f0c332 tests (unit/AP gateway): add tests for events:
rel 372
2022-09-22 00:01:48 +02:00
Goffi
a206196e9d tests (unit/AP gateway): fix tests:
rel 372
2022-09-22 00:01:48 +02:00
Goffi
4bae534e0f cli (event): update commands following changes in events:
- commands have been update to match changes in bridge method.
- arguments have been completely reworked for `create` and `modify` commands, making it
  possible to fine tune events.
- `list` has been removed in favor of `get` which can now display several events at once

rel 372
2022-09-22 00:01:48 +02:00
Goffi
093b9d83bc tools (common/date_utils) handle timestamp and in + delta2human:
regex used to parse datetimes has been improved to handle a unix time (which can be used
with `+ <delta>` or `- <delta>`), and the `in <delta>` (e.g. `in 6 days`).

`DEFAULT_DATETIME` has been removed as dateutil use current date by default, which is the
expected behaviour.

Add `delta2human` method which convert the difference of 2 unix times to a human friendly
approximate text.

rel 372
2022-09-22 00:01:48 +02:00
Goffi
adea3770de component AP gateway: events:
- XMPP Events <=> AP Events conversion
- `Join`/`Leave` activities are converted to RSVP attachments and vice versa
- fix caching/notification on item published on a virtual pubsub node
- add Ad-Hoc command to convert XMPP Jid/Node to virtual AP Account
- handle `Update` activity
- on `convertAndPostItems`, `Update` activity is used instead of `Create` if a version of
  the item is already present in cache
- `events` field is added to actor data (and to `endpoints`), it links the `outbox` of the
  actor mapping the same JID with the Events node (i.e. it links to the Events node of the
  entity)
- fix subscription to nodes which are not the microblog one

rel 372
2022-09-22 00:01:41 +02:00
Goffi
97c0d6a0e5 tools (xml_tools): handle required field in dataDict2dataForm:
rel 372
2022-09-21 22:43:55 +02:00
Goffi
7793a482a2 plugin events: update following Events protoXEP submission:
update the plugin to follow the specification proposed at
https://github.com/xsf/xeps/pull/1206

Events are internally converted to a dict following a format described in
`event_data_2_event_elt` docstring.

RSVP mechanism now uses Pubsub Attachments (XEP-0470), with a user extensible data form.

Bridge methods signatures have changed.

rel 372
2022-09-21 22:41:49 +02:00
Goffi
cfbbe66358 plugin XEP-0470: add create_attachments_node method:
this method create the attachments node if it doesn't already exists, and use same access
model as target item, and an `open` publish model.

rel 372
2022-09-21 22:36:30 +02:00
Goffi
2389f235f1 plugin XEP-0050: use coroutine + minor code readability improvments:
rel 372
2022-09-21 22:33:59 +02:00
Goffi
2502e5062a plugin XEP-0060: raise an NotFound exception instead of StanzaError in subscribe:
`exceptions.NotFound` is now raised in stead of `item-not-found` `StanzaError` for
consistency with `getItems` and because it's easier to catch (condition has to be checked
when `StanzaError` is received).

rel 372
2022-09-21 22:32:36 +02:00
Goffi
1e4fc213f6 tools (utils): helper parse_xmpp_date method:
This method converts an XMPP date(time) to a unix time

rel 372
2022-09-21 22:29:54 +02:00
Goffi
e80df24bb1 plugin XEP-0447: Stateless File Sharing implementation:
rel 379
2022-09-21 22:28:20 +02:00
Goffi
a884331ed2 plugin XEP-0446: File Metadata implementation:
rel 379
2022-09-21 22:27:28 +02:00
Goffi
d30b63b617 plugin XEP-0103: URL Address Information implementation:
rel 379
2022-09-21 22:26:48 +02:00
Goffi
fe1deb10cd plugin XEP-0080: User Location implementation:
rel 372
2022-09-21 22:23:57 +02:00
Goffi
a74f9327f2 core, CLI (base), tools (common/data_format): typing/core readability 2022-09-21 22:20:43 +02:00
Goffi
84e6d9ceb2 doc (components/AP gateway): "reactions":
fix 371
2022-08-31 17:07:03 +02:00
Goffi
4d2263f54b tests (AP gateway): reactions tests:
2 new tests check XMPP <=> AP reactions conversion

rel 371
2022-08-31 17:07:03 +02:00
Goffi
85afb52968 tests (AP gateway): fix tests following changes in gateway:
- `shareInbox` is now used when available, thus tests now check for that
- `client._ap_storage` is used, thus is added to the mockClient
  `ap_const.NS_AP_PUBLIC` is now in `cc` instead of `to` field

rel 371
2022-08-31 17:07:03 +02:00
Goffi
68fb304032 cli (pubsub/attachment/set): update reactions handling:
- reactions data has been updated following changes in XEP-0470 plugin
- it is now possible to remove a reaction using uppercase `-R`
- short option from `--replace` has been removed, as it is more handy to use `-R` to
  remove reactions

rel 371
2022-08-31 17:07:03 +02:00
Goffi
5e3d4ca581 component AP gateway: AP <=> XMPP reactions conversions:
- Pubsub Attachments plugin has been renamed to XEP-0470 following publication
- XEP-0470 has been updated to follow 0.2 changes
- AP reactions (as implemented in Pleroma) are converted to XEP-0470
- XEP-0470 events are converted to AP reactions (again, using "EmojiReact" from Pleroma)
- AP activities related to attachments (like/reactions) are cached in Libervia because
  it's not possible to retrieve them from Pleroma instances once they have been emitted
  (doing an HTTP get on their ID returns a 404). For now those cache are not flushed, this
  should be improved in the future.
- `sharedInbox` is used when available. Pleroma returns a 500 HTTP error when ``to`` or
  ``cc`` are used in a direct inbox.
- reactions and like are not currently used for direct messages, because they can't be
  emitted from Pleroma in this case, thus there is no point in implementing them for the
  moment.

rel 371
2022-08-31 17:07:03 +02:00
Goffi
7ddf0241c6 plugin XEP-0424: rename bridge method:
``messRetract`` is renamed to ``messageRetract`` for consistency with other message bridge
methods.
2022-08-31 17:07:03 +02:00
Goffi
943ef29e90 plugin XEP-0444: Message Reactions implementation:
rel 371
2022-08-31 17:07:03 +02:00
Goffi
c7acfc1b9f doc (components): the word "handle" is more adapted here 2022-08-31 17:07:03 +02:00
Goffi
1f03f3ee14 component AP gateway: work around encoding bug in Mastodon:
Mastodon in wrongly unquoting URL path in `(request-target)`, and thus Libervia was doing
the same to check signature. However that doesn't work with Pleroma which is using the
path value used in the request (percent-encoded), and thus Pleroma signature were
rejected.

To work around that, signature is first checked without unquoting, and if this fails a new
check is done with unquoting.

Bug has been reported at https://github.com/mastodon/mastodon/issues/18871

rel 371
2022-08-31 17:07:03 +02:00
Goffi
30774ae9ad component AP gateway: fix headers case in signature:
headers where not lower-cased in `headers` field of signature data, resulting in signature
being rejected by Pleroma (but it was working with Mastodon).

Also add `Content-Type` header.


rel 371
2022-08-31 17:07:03 +02:00
Goffi
d8a55dbcba component AP gateway: add aliases to webfinger data 2022-08-31 17:07:03 +02:00
Goffi
eb797103e6 component AP gateway: better verbose logging:
gather data to show according to verbosity and log it all at once with a small `<<<` or
`>>>` indicating the direction. With a verbosity of 3, headers are also shown.
2022-08-31 17:07:03 +02:00
Goffi
c437424053 component AP gateway: raise exceptions on apGet + fix exceptions catching in apGetLocalObject:
new `exceptions.ExternalRequestError` is raised when request done `apGet` has a return
code >= 300.

Fix wrong exception catched in `apGetLocalObject`.
2022-08-31 17:07:01 +02:00
Goffi
672174fb23 tools: renamed module sat.tools.datetime to date.tools.xmpp_datetime to avoid conflict with Python's standard lib 2022-08-31 13:18:56 +02:00
Goffi
ed3660c4a7 tools (datetime, utils): fix incorrect use of naive object:
`tools.datetime.format_datetime` was expecting aware datetime objects while
`tools.utils.xmpp_date` was returning naive datetime objects. A check has been added to
the former one, and latter one has been modified to return aware datetime objects.
2022-08-31 13:11:26 +02:00
Syndace
d1b5ff0c41 plugin XEP-0420: Implementation of Stanza Content Encryption:
Includes implementation of XEP-0082 (XMPP date and time profiles) and tests for both new plugins.
Everything is type checked, linted, format checked and unit tested.
Adds new dependency xmlschema.

fix 377
2022-08-23 12:04:11 +02:00
Goffi
b79a06e488 plugin mr mercurial: limit export to ancestors of working directory parent 2022-08-23 23:37:22 +02:00
Goffi
b6d57c0495 plugin merge-requests: fix await use on blocking method 2022-08-23 13:00:07 +02:00
Goffi
6bb76a2bd0 doc (components/AP gateway): "repeat" and "noticed/like":
fix 370
2022-07-22 17:40:03 +02:00
Goffi
4b8e1c2747 doc (cli/pubsub, cli/blog): attachments subcommands documentation:
rel 370
2022-07-22 17:16:28 +02:00
Goffi
fa5a0de7f7 doc (cli/blog): repeat documentation:
rel 370
2022-07-22 17:15:40 +02:00
Goffi
155c249884 tests (unit/AP gateway): tests for item repeat/announce and noticed/like conversion:
Add tests for

- XMPP blog post repeat => AP Announce conversion and vice versa
- XMPP pubsub `noticed` attachment => AP like conversion and vice versa

rel 370
2022-07-22 15:45:33 +02:00
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
c20e09fb22 plugin XEP-0060: sender can now be specified in sendItems and publish:
if not sended is set, `client.jid` is used.
2022-07-21 18:02:33 +02:00
Goffi
0aa9613693 cli (blog, pubsub): new attachments subcommands:
`pubsub/attachments` subcommands has a `get` and a `set` subcommand to manage attachments
of a pubsub item.

`blog` has the same subcommands, the only difference is that if `--node` is not specified,
the default blog namespace will be used.

rel 370
2022-07-20 17:55:11 +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
89f67ee50d plugin pubsub attachments: partial implementation of pubsub-attachments protoXEP:
This is an implementation of the "Basic Usage" of
https://xmpp.org/extensions/inbox/pubsub-attachments.html.

rel 370
2022-07-20 17:49:51 +02:00
Goffi
60a747b6f8 plugin pubsub cache: replace empty list by None in getItemsFromCache:
if an empty list is used, no item can be retrieved, this patch replace empty list by None
to avoid this case.
2022-07-20 17:46:58 +02:00
Goffi
8bae5e3d7e core (memory/sqla): add argument to getPubsubNode to auto-create a node:
if the node is not in cache, the new `create` and `create_kwargs` arguments can be used to
automatically call `setPubsubNode`

rel 370
2022-07-20 17:41:44 +02:00
Goffi
38c5cc2fba plugin XEP-0277: add a trigger to send method:
rel 370
2022-07-20 17:19:53 +02:00