Commit graph libervia-backend/sat/plugins/plugin_xep_0045.py
Author SHA1 Message Date
Goffi
dc86957043 date update 2021-03-19 15:45:14 +01:00
Goffi
88072e0453 core, frontends: avatar refactoring:
/!\ huge commit

Avatar logic has been reworked around the IDENTITY plugin: plugins able to handle avatar
or other identity related metadata (like nicknames) register to IDENTITY plugin in the
same way as for other features like download/upload. Once registered, IDENTITY plugin will
call them when suitable in order of priority, and handle caching.

Methods to manage those metadata from frontend now use serialised data.

For now `avatar` and `nicknames` are handled:

- `avatar` is now a dict with `path` + metadata like `media_type`, instead of just a string
  path
- `nicknames` is now a list of nicknames in order of priority. This list is never empty,
  and `nicknames[0]` should be the preferred nickname to use by frontends in most cases.
  In addition to contact specified nicknames, user set nickname (the one set in roster) is
  used in priority when available.

Among the side changes done with this commit, there are:

- a new `contactGet` bridge method to get roster metadata for a single contact
- SatPresenceProtocol.send returns a Deferred to check when it has actually been sent
- memory's methods to handle entities data now use `client` as first argument
- metadata filter can be specified with `getIdentity`
- `getAvatar` and `setAvatar` are now part of the IDENTITY plugin instead of XEP-0054 (and
  there signature has changed)
- `isRoom` and `getBareOrFull` are now part of XEP-0045 plugin
- jp avatar/get command uses `xdg-open` first when available for `--show` flag
- `--no-cache` has been added to jp avatar/get and identity/get
- jp identity/set has been simplified, explicit options (`--nickname` only for now) are
  used instead of `--field`. `--field` may come back in the future if necessary for extra
  data.
- QuickContactList `SetContact` now handle None as a value, and doesn't use it to delete the
  metadata anymore
- improved cache handling for `metadata` and `nicknames` in quick frontend
- new `default` argument in QuickContactList `getCache`
2020-04-14 21:00:33 +02:00
Goffi
3b64263f3b core: renamed "MessageReceived" trigger to "messageReceived" for consistency. 2020-02-18 18:13:19 +01:00
Goffi
e1a44cf4e4 fixed shebangs 2020-01-29 10:07:00 +01:00
Goffi
a39349fe64 dates update 2020-01-29 09:50:54 +01:00
Goffi
efe52d755d plugin XEP-0045: added room statuses to metadata:
room statuses are now sent with other metadata on bridge signals, and saved in Room
instance. They give useful data on the room, for instance they can be used to know if a
full jid is used in this room.
2019-12-30 20:44:02 +01:00
Goffi
26c01ca4dc plugin XEP-0045: show join error even if it's not a StanzaError, log it with warning instead of error 2019-12-20 12:28:04 +01:00
Goffi
dc930b1890 plugin XEP-0045: don't fail on item-not-found with MAM:
Some servers don't store permanently the whole history of MUC with MAM. As a result, an
"item-not-found" stanza error can be received when message id used as reference doesn't exist
anymore on the server.
When this case happens, the history is retrieved in the same way as for a newly joined room
(i.e. last 50 messages are requested).
2019-12-05 23:05:16 +01:00
Goffi
f065ba4ff6 plugin XEP-0045: join / MAM history improvements:
- fixed use of history_d deferred so MAM history is stored in database as soon as possible
  and in right order
- get MAM history with pages of 20 messages instead of 100
- if a message can't be parsed, an error message is logged (with a dump of the stanza),
  and the message is ignored, avoiding a crash and the impossibility the join the room at
  all
- a new `mucRoomPrepareJoin` signal, containing room jid and profile, is sent when a room
  joining is started, this allow better UX as the frontend can show the room immediately,
  and lock it with a waiting message until it is fully available. The `mucRoomJoined` is
  still sent when the room is fully joined/avaiable, meaning that the frontend can unlock
  it and let the user interact with it
2019-10-18 14:45:07 +02:00
Goffi
fbfe96c505 Python 3 port:
/!\ this is a huge commit
/!\ starting from this commit, SàT is needs Python 3.6+
/!\ SàT maybe be instable or some feature may not work anymore, this will improve with time

This patch port backend, bridge and frontends to Python 3.

Roughly this has been done this way:

- 2to3 tools has been applied (with python 3.7)
- all references to python2 have been replaced with python3 (notably shebangs)
- fixed files not handled by 2to3 (notably the shell script)
- several manual fixes
- fixed issues reported by Python 3 that where not handled in Python 2
- replaced "async" with "async_" when needed (it's a reserved word from Python 3.7)
- replaced zope's "implements" with @implementer decorator
- temporary hack to handle data pickled in database, as str or bytes may be returned,
  to be checked later
- fixed hash comparison for password
- removed some code which is not needed anymore with Python 3
- deactivated some code which needs to be checked (notably certificate validation)
- tested with jp, fixed reported issues until some basic commands worked
- ported Primitivus (after porting dependencies like urwid satext)
- more manual fixes
2019-08-13 19:08:41 +02:00
Goffi
adc5204b1a plugin XEP-0045: fixed a bad attribute in a log message. 2019-07-19 23:01:57 +02:00
Goffi
9e2a35f6e5 plugins XEP-0045, XEP-0198: rejoin MUC rooms while a hot reconnection is done:
when resuming is not possible with stream management, a hot reconnection is done
(reconnecting without restarting every plugin). This was causing trouble for joined MUC
rooms, which were not accessible anymore (because they were not re-joined).
This patch fixes it by clearing rooms first (to avoid considering the room joined and
broadcasting the initial presence to them), then re-joining them.

fix 322
2019-07-16 21:59:30 +02:00
Goffi
692a5b34fc plugin 0249: fixed invitation handling + some improvments:
- properly retrieve payload by namespace
- now use a trigger instead of observer, so the message workflow is stopped if an invitation is found
- namespace is registered

fix 241
2019-07-14 11:23:25 +02:00
Goffi
5e43c6c98c core, plugin XEP-0045: fixed message type autodetection + ENTITY_TYPE_MUC constant:
an old hardcoded value was used in several places to detect if an entity is a MUC, but this
value was not valid anymore. This has been fixed, and ENTITY_TYPE_MUC constant is now used
instead. This fixes message type autodetection for "groupchat" messages.

fixes 300
2019-07-09 09:06:45 +02:00
Goffi
eb08ab4927 plugin XEP-0045: avoid sending useless presence signals:
- presence signals were sent twice (from XEP-0045 itself + core), this is now avoided by
  cancelling presence workflow in core when presence if from a joined room.
- filter out cached presences if no status or show information is set (occupants are
  already specified in mucRoomJoined signal)
2019-07-07 15:39:53 +02:00
Goffi
c857c375fc plugin XEP-0045: log "failure" on configure error 2019-07-06 15:51:48 +02:00
Goffi
b8a858d639 plugin XEP-0045: added a warning if a message is discarded because the room has not been found 2019-07-02 19:36:27 +02:00
Goffi
c226b72b20 core, plugin XEP-0045: fix crashes when changing URIs:
When adding missing URIs in message, the "children" property was used instead of elements(). "children" not only return elements, and this was causing crashes.
This may fix bug 294

rel 294
2019-06-30 15:52:30 +02:00
Goffi
6b83ef5c51 plugins: removed useless execute permission 2019-04-14 08:21:51 +02:00
Goffi
89aa5e4079 plugin XEP-0045: added getRoomOccupants/mucOccupantsGet method to retrieve occupants of a joined room. 2019-03-09 16:24:17 +01:00
Goffi
cf914b58eb plugin XEP-0045: fixed item-not-found exception when creating a room:
MAM was checked on the room itself, this patch changes it by checking the MUC service instead.
2019-03-01 17:32:15 +01:00
Goffi
079d04f6ca plugin XEP-0045: fixed message type filtering when getting last stanza_id to retrieve history with MAM 2019-03-01 16:17:00 +01:00
Goffi
fe2e5dd8ce plugin XEP-0045: cache presences if they are received before the room is fully joined:
presences are then replayed (only the last one) once the room is fully joined.
2019-03-01 12:16:57 +01:00
Goffi
409118f255 plugin XEP-0045: fixed issue with deepcopy by using new xml_tools.elementCopy method 2019-02-28 18:57:04 +01:00
Goffi
198db6c2ca plugin XEP-0045: fixed crash when <delay> is used at an unexpected time. 2019-01-26 20:07:45 +01:00
Goffi
8e338bf913 date update 2019-01-12 12:25:31 +01:00
Goffi
d3d39bad5d plugin XEP-0045: fixed bad MAM detection on join 2018-12-26 17:21:39 +01:00
Goffi
bea35db274 plugin XEP-0045: don't loop when initiating MAM archive 2018-12-12 08:58:52 +01:00
Goffi
8cc39ea3a5 plugin XEP-0045: request 50 *last* MAM messages if new archive 2018-12-12 01:13:15 +01:00
Goffi
c77bc72490 plugin XEP-0313, XEP-0045: loop MAM requests until whole archive is retrieved:
- plugin xep-0313: new serialise method
-                : getArchives now returns an extra mam_response dict with "complete" and "stable" status
-                : MAMGet now return a new metadata dict before profile (with serialised RSM and MAM response)
2018-12-10 20:34:45 +01:00
Goffi
35e15c664c plugin XEP-0045: MAM implementation for MUC 2018-12-07 19:13:28 +01:00
Goffi
3a07122da9 plugin XEP-0199: implementation of XMPP Ping 2018-11-10 10:16:38 +01:00
Goffi
784e99fa49 plugin XEP-0045: fixed crash when muc service is not found 2018-06-21 01:21:44 +02:00
Goffi
8f70b2528f plugin XEP-0045: display a note when no configuration is available on the room 2018-05-11 18:18:06 +02:00
Goffi
cd78b78abf plugin XEP-0045: fixed room configuration cancellation 2018-05-11 17:24:37 +02:00
Goffi
515add5c7e plugin XEP-0045: fixed joining workflow:
- room keep joining workflow state, and display warning when something is received at unexpected moment
- state is change immediatly when subject is received (which must be the last thing before live messages), avoiding timing issue if history storage in database is taking too much time
- user joined/left data are not saved anymore in history as it takes a lot of space for little interest. A future option may allow to re-enable it if needed.
2018-05-11 17:11:47 +02:00
Goffi
80ef13612b core, setup: huge cleaning:
- moved directories from src and frontends/src to sat and sat_frontends, which is the recommanded naming convention
- move twisted directory to root
- removed all hacks from setup.py, and added missing dependencies, it is now clean
- use https URL for website in setup.py
- removed "Environment :: X11 Applications :: GTK", as wix is deprecated and removed
- renamed sat.sh to sat and fixed its installation
- added python_requires to specify Python version needed
- replaced glib2reactor which use deprecated code by gtk3reactor

sat can now be installed directly from virtualenv without using --system-site-packages anymore \o/
2018-04-02 19:44:50 +02:00
Renamed from src/plugins/plugin_xep_0045.py (Browse further)