Similar to how `engineio` provides a JSON-compatible module, this change
adds a custom JSON encoder with support for additional types.
Changing SocketIO's JSON module fixes the encoding issue when the
scanning process tried to send a datetime, failing and the frontend not
displaying the scanned game (commonly, when it had sibling games)
The OIDC email verified check now fails if the email is explicitly
unverified, or if the `email_verified` claim is supported and the email
is not explicitly verified.
Previously, the OIDC implementation failed for any OIDC provider that
did not include the `email_verified` claim in the userinfo response.
Providers like Synology do not include this claim, so the check always
failed with error "Email is not verified."
I haven't found a formal specification for the `email_verified` claim,
and how it should be handled, but this implementation should be more
robust and work with more OIDC providers.
Fixes#1446.
Fix `json_array_contains_value` function to use the `@>` operator for
checking if a JSON array contains a value in PostgreSQL. This is
necessary because the `has_key` function only works for string values.
Also, remove `get_rom_collections` method, as it was doing the same
thing as `get_collections_by_rom_id`.
Fixes#1441.
The previous function name `get_matched_roms_by_id` was misleading as it
returned a list of matched ROMs, but searching by ID should always
return either one result or none.
This change introduces PostgreSQL compatibility, by implementing the
following changes:
* Use `JSONB` instead of `JSON` for PostgreSQL databases. This is
achieved by creating a custom `CustomJSON` type that uses `JSONB` on
PostgreSQL and `JSON` on other databases, leveraging the variant
mechanism of SQLAlchemy.
* Add `is_postgresql` function to check if the current database is
PostgreSQL. Commonly used for migrations, but can be used to determine
how to build queries based on the database engine.
* Add `json_array_contains_value` function to check if a JSON array
includes a specific value. This function is needed as it's
engine-specific.
Support for PostgreSQL is on a best-effort basis, and it relies on the
community for continued support and testing. The project's main database
is MariaDB.
Closes#667.
The key `romm:twitch_token_expires_at` is not needed, as we already
set an expiration time for the token key itself. If the token is still
present in Redis, it is valid. If not, it means we either never fetched
it, or it was too close to expiration.
With this change, fetching the Twitch token makes a single Redis call
instead of two.