Commit graph libervia-backend/sat/memory
Author SHA1 Message Date
Goffi
5cf43b2e2e core (memory/persistent): implement __repr__ (via __str__) 2021-09-08 11:17:04 +02:00
Goffi
211c9c8079 core (memory/cache): don't crash on EOFError in getMetadata 2021-06-17 10:35:42 +02:00
Goffi
7adbf3ead8 core, frontends: fix invalid translatable strings.
Some f-strings where used in translatable text, this has been fixed by using explicit
`format()` call (using a script based on `tokenize`).

As tokenize messes with spaces, a reformating tool (`black`) has been applied to some
files afterwards.
2021-06-14 18:35:12 +02:00
Goffi
d22bd6c96d memory(sqlite): fix encoding when loading pickled data 2021-06-09 10:01:56 +02:00
Goffi
fd4f70ac6c memory (sqlite): work around encoding issues with pickle 2021-06-04 14:07:58 +02:00
Goffi
838b4a7947 core (memory/sqlite): return 0 instead of None when user has no file yet 2021-05-06 21:39:08 +02:00
Goffi
06054ceeaf core (memory, sqlite): new fileGetUsedSpace method 2021-05-05 15:37:21 +02:00
Goffi
18cbbee1a5 memory: new getFilesOwner method:
this method is used by `getFiles` and `setFile` and fill `owner` when it's missing to
avoid getting accidentally files from other users.

`owner` is not filled in some case (no client, `file_id` or `parent` specified) and an
exception is raised if a component has neither `owner` nor `peer_jid` specified.
2021-04-16 18:32:37 +02:00
Goffi
018d09caaa Renamed the project from "Salut à Toi" to "Libervia":
This renaming follows the decision taken at the General Assemblee of January 27th 2021 (cf.
https://repos.goffi.org/sat_docs/raw-file/tip/association/2021-01-27%20-%20compte%20rendu%20de%20l%27AG%20extraordinaire.pdf)
2021-03-20 20:42:04 +01:00
Goffi
dc86957043 date update 2021-03-19 15:45:14 +01:00
Goffi
b6d26f3a67 core (memory/params): removed legacy "Register new account" label, it's not used anymore 2020-11-12 14:53:15 +01:00
Goffi
0250053e19 core (memory/memory): added getCachePath method to get a cache dir from a namespace. 2020-09-28 17:00:14 +02:00
Goffi
f3bb26f9d9 core (memory/memory): public_id should not be used when creating parent dirs 2020-09-17 23:07:12 +02:00
Goffi
280f86881a core (memory/memory): fixed directory creation in setFile 2020-09-17 21:40:23 +02:00
Goffi
a82f7108a2 core (memory/memory): use str for path in getFiles and setFile to allow use of Path instances 2020-09-17 16:34:22 +02:00
Goffi
35920d53af core (memory/memory): fixed assignations 2020-09-05 20:20:05 +02:00
Goffi
ba8496ae36 plugin XEP-0264: only log "fix orientation" when the option is used 2020-08-25 08:52:46 +02:00
Goffi
ea5e0a46f5 core (memory): setFileAccessModel implementation:
this method let change read permission using access model similar to what is used with
Pubsub.
2020-08-01 16:07:39 +02:00
Goffi
97375ee1db core (memory): getFileAffiliations and setFileAffiliations implementations:
those methods allow to change files permissions using affiliations similar to the ones
used with PubSub.
2020-08-01 16:06:12 +02:00
Goffi
800fbd3f7c core (memory): files are now public by default except for those in root directory:
using public permissions by default makes permissions change more easy as we don't have to
recursively change all permissions of sub files when changing directory. Root directories
are private by default.
2020-08-01 16:02:41 +02:00
Goffi
cb49365811 memory: new "affiliation" metadata for files:
this affiliation is similar to pubsub affiliation, for now only `owner` is used.
Affiliation is set when possible (peer_jid is set notably).
2020-07-17 12:58:57 +02:00
Goffi
4e48a889c0 core (memory): fixed recursive file deletion + log an error and continue when deleting a missing file 2020-06-19 14:55:30 +02:00
Goffi
d1521dde4b core (memory/sqlite): new database schema (v9):
this new schema brings the new `public_id` column, which will be used to serve files via
HTTP, splits `mime_type` in 2 (`media_type` and `media_subtype`) to make indexing/media
filtering easier, and fixes indexes for `files` table.
2020-05-29 21:50:49 +02:00
Goffi
a1eb68c1e7 core: replaced sat shell script by a python script:
the backend is now launched by `sat.core.launcher`, and the script is generated during
installation with a new entry point in `setup.py`.
2020-05-25 15:50:01 +02: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
68a4d8ea98 core (memory/persistent): fixed "items", added "all" + "adel" to LazyPersistentBinaryDict:
- `items` was returning the dict with all values, it now returns a Deferred with actual dict items()
- `all` new method does return the dict with all values (in a Deferred)
- `adel` has been added to LazyPersistentBinaryDict
2020-04-14 20:36:24 +02:00
Goffi
83260b827a core (memory/disco): fixed types of disco extensions:
typeCheck() is not automatically called on reception by Wokkel, as a result extensions
fields values may be strings instead of the field type. TypeCheck is now explicitly
called in memory.disco to avoid that. It is not called immediately on reception as the
string value is needed to calculate the capability hash
2020-04-14 20:25:05 +02:00
Goffi
b878c3327f core (memory/encryption): use utils.asDeferred for trust UI, so async coroutines can be used 2020-03-27 09:53:59 +01:00
Goffi
973beb4220 core (memory/persistent): added aset method in LazyPersistentBinaryDict:
this method does the same as `force` but is there to be consistent with PersistentDict.
`force` should be removed in the future.
2020-03-27 09:53:00 +01:00
Goffi
2f8902e0d6 core (memory/encryption): automatic start encryption if peer send encrypted message:
If peer sends encrypted message and we have no encryption activated, we automatically
start encryption to avoid sending plain text message when answering.

markAsEncrypted now needs the encryption algorithm namespace as mandatory argument.
2020-03-23 17:52:18 +01:00
Goffi
8e9905363e core (memory/encryption): set encrypted flag also for outgoing messages and put it in extra:
- `encrypted` flag is now put directly in extra, so that there is nothing to change when
  sending the message to bridge for frontends to be aware of it.
- this flag is now also set when markAsEncrypted is used, so frontend can display
  appropriate indicator to show that outgoing message is encrypted or not.
2020-03-23 16:53:03 +01:00
Goffi
900daa7ad9 core (memory/encryption): encryption session are now restored on client connection 2020-03-22 18:39:12 +01:00
Goffi
e754d16000 core (memory/persistent): implemented aset and adel:
those methods are async variants of __setitem__ and __delitem__, they return a Deferred
fired when the value is actually set/removed from storage.
2020-03-22 18:35:22 +01:00
Goffi
a56fc64ea5 core (memory/encryption): namespace can now be specified to test a specific algorithm in isEncryptionRequested 2020-03-18 19:54:07 +01:00
Goffi
46a8728d7c core (memory/cache): new removeFromCache method 2020-03-06 18:19:03 +01:00
Goffi
4b69d89138 core (memory/cache): purge cache metadata when the referenced file doesn't exist 2020-03-06 18:19:03 +01:00
Goffi
5a467b15d5 core, bridge: new devicesInfosGet method to get infos on known devices of an entity 2020-03-06 18:19:03 +01:00
Goffi
dfbdf8e455 core (memory/cache): added some metadata:
- creation/last_access are now set
- use filename to guess MIME type when suitable
2020-03-01 18:31:45 +01:00
Goffi
a1dc5a5c06 core (memory/disco): minor log message change 2020-02-28 10:06:38 +01:00
Goffi
9de55ff588 memory (sqlite): don't store empty messages 2020-02-26 22:03:15 +01:00
Goffi
48c56ee57e memory(cache): extend EOL when a file metadata is retrieved 2020-02-26 22:03:15 +01:00
Goffi
12fc57062d memory (cache): purge + pathlib:
- cache is now purged on backend startup (every file which has passed EOL will be deleted)
- use of pathlib, getPath now returns a Path
2020-02-26 15:54:43 +01:00
Goffi
619b6e9b4b core (memory/encryption): "isEncryptionRequested" helper method:
this method is similar to "isEncrypted" but for outgoing messages.
2020-02-23 17:48:26 +01:00
Goffi
8fa4cd0f86 core (memory/encryption): new "isEncrypted" method to check if encrypted flag is set in message data 2020-02-18 18:13:18 +01:00
Goffi
6a7d247754 core: use serialised dict for extra in messageNew and historyGet 2020-02-18 18:13:17 +01:00
Goffi
d684685e24 bridge: added methods to let frontends store/retrieve/delete private data 2020-02-10 22:01:53 +01:00
Goffi
d0741de2ad core (memory/crypto): replaced PyCrypto by cryptography:
`PyCrypto` is unmaintained for years but was used in SàT for password hashing. This patch
fixes that by replacing `PyCrypto` by the reference `cryptography` module which is well
maintained.

The behaviour stays the same (except that previously async `hash`, `encrypt` and `decrypt`
methods are now synchronous, as they are quick and using a deferToThread may actually be
more resource intensive than using blocking methods).

It is planed to improve `memory.crypto` by using more up-to-date cryptography/hashing
algorithms in the future.

PyCrypto is no more a dependency of SàT
2020-02-09 23:50:26 +01:00
Goffi
d75bbaec4c core (memory/disco): fixed checkFeature return Failure:
it seems that instanciating a Failure with a class name is not working anymore, so the
exceptions.FeatureNotFound is instanciated now.
2020-02-04 19:59:42 +01:00
Goffi
beb098b20a core (memory/disco): fixed failure creation in infosEb 2020-02-03 13:42:43 +01:00
Goffi
ec5a51bebb core: log filenames of read config files 2020-01-29 19:42:02 +01:00