Commit Graph

1515 Commits

Author SHA1 Message Date
Michael Manganiello
beeb9f0c31 misc: Create enum for authorization scopes
Instead of using just strings, this change converts the scopes to a
`StrEnum`, to be compatible with places where a string is expected. This
avoids typos when using these scopes, simplifies searching for usages,
and improves type hints.

An extra change was the fix to the Firmware download endpoint, which
wasn't respecting the `DISABLE_DOWNLOAD_ENDPOINT_AUTH` flag.
2024-10-18 23:57:42 -03:00
Michael Manganiello
fc8cbb7226 Merge pull request #1242 from rommapp/fix/simplify-query-to-validate-username-exists
fix: Simplify query that validates new username already exists
2024-10-14 20:49:15 -03:00
Georges-Antoine Assi
5b73c4e6cb Merge pull request #1236 from yuri-becker/feature/configurable-upload-timeout
#1228 Configurable upload timeout
2024-10-14 16:37:26 -04:00
Michael Manganiello
eba2971ffb fix: Simplify query that validates new username already exists
Instead of fetching all users and checking if the new username is present
in the list, we can directly query the database for the username.
2024-10-14 01:10:31 -03:00
Michael Manganiello
2a24f5f128 Merge pull request #1241 from rommapp/fix/avoid-query-add_user-at-import-time
fix: Avoid query during import time to set add_user endpoint scopes
2024-10-14 00:43:07 -03:00
Georges-Antoine Assi
72182b9f22 Merge pull request #1240 from alisci01/add-offset-to-get-roms-endpoint
Add offset parameter to get_roms endpoint
2024-10-13 22:31:14 -04:00
Michael Manganiello
1df27079c4 fix: Avoid query during import time to set add_user endpoint scopes
The `add_user` endpoint was querying the database at import time, to
decide whether to enforce the `users.write` scope or not. This is
problematic because the database might not be ready at import time.

Also, the decided `scopes` was being maintained for the entire
application lifetime, which is not ideal, as users can be created
without having the `users.write` scope, until the application is
restarted.
2024-10-13 22:27:14 -03:00
Michael Manganiello
a594eff413 Merge pull request #1238 from rommapp/fix-save-small-artworks
fix: Correctly resize and save small artwork
2024-10-12 13:34:30 -03:00
Michael Manganiello
c91611fe99 Merge pull request #1234 from rommapp/fix/scanning-skip-if-already-scheduled
fix: Skip scanning task by checking against the correct function name
2024-10-12 13:17:22 -03:00
Yuri Becker
eb6a48eb3a Use seconds for UPLOAD_TIMEOUT 2024-10-12 12:50:56 +02:00
Ali Scissons
5acbdfdf8b add offset parameter to get_roms endpoint 2024-10-11 23:28:30 -05:00
Michael Manganiello
a9ac322618 fix: Correctly resize and save small artwork
The previous implementation was calling `resize_cover_to_small` within
the context manager that was writing the image to the filesystem. This
was causing `PIL` to raise an error because it could not identify the
open and temporarily created file as a valid image.

Instead of saving the original image to the filesystem and then resizing
it, we now open the image in memory, resize it, and then save it to the
filesystem. We also avoid reading the `BytesIO` object twice by saving
small and big images from the same initial `Image` object.

Fixes #1191.
2024-10-12 00:55:06 -03:00
Yuri Becker
f68033ed87 Add UPLOAD_TIMEOUT 2024-10-12 03:07:04 +02:00
Michael Manganiello
b81fbc5820 fix: Improve handling of Redis URL
This change replaces the creation of Redis URL, from a simple string
interpolation, to using `yarl.URL`. The main benefit, besides not
forgetting to set all five different variables on every Redis client
initialization, is that user credentials are correctly URL-encoded, if
present.

Up until now, if a password had special characters, it could break the
generated URL.

This change also introduces support for a `REDIS_SSL` setting, which
allows the user to specify if the Redis connection should use SSL or not.
2024-10-11 21:41:19 -03:00
Michael Manganiello
a26168ecc4 fix: Skip scanning task by checking against the correct function name
The `scan.py` module was moved to the `sockets` package, but this line
was not updated to reflect that change. This currently causes the
watcher to not skip queuing a new `scan_platforms` task if one is
already scheduled.
2024-10-11 20:40:42 -03:00
Michael Manganiello
149098fb31 fix: Improve memory usage during 7zip decompression
This change improves memory usage, by only keeping a single archive's
member file in memory at a time during 7zip decompression.

The `py7zr` library does not support streaming decompression yet, so
this change is the best we can do for now.

Potential fix for #1211, but it won't improve memory usage for
single-file 7zip archives.
2024-10-06 20:18:49 -03:00
Michael Manganiello
60ff832663 fix: Escape URLs when files are served by nginx
When serving files using the `X-Accel-Redirect` header in nginx, the
header values must be URL-encoded. Otherwise, nginx will not be able
to serve the files if they contain special characters.

This commit adds a new `FileRedirectResponse` class to the `utils.nginx`
module, to simplify the creation of responses that serve files using the
`X-Accel-Redirect` header.

Fixes #1212, #1223.
2024-10-06 13:29:42 -03:00
Michael Manganiello
a82489a9c4 feat: Add RAHasher and util to calculate RetroAchievements hashes
Build and include the `RAHasher` binary in the Docker image, to
calculate hashes for RetroAchievements. Also, add a service to
run `RAHasher` from Python.

Example usage:

```python
from adapters.services.rahasher import RAHasherError, RAHasherService

rahasher = RAHasherService()
try:
    hash = await rahasher.calculate_hash("nes", Path("path/to/rom.nes"))
except RAHasherError:
    # Handle error
    hash = None
```
2024-09-22 23:40:25 -03:00
Georges-Antoine Assi
8a13611d47 Merge pull request #1119 from rommapp/romm-1114
[ROMM-1114] Fetch and use age ratings in UI and filters
2024-09-21 12:53:33 -04:00
Georges-Antoine Assi
6880d11a73 Merge branch 'master' into romm-1114 2024-09-21 12:30:39 -04:00
Georges-Antoine Assi
6cb332efcf changes from reciew 2024-09-21 12:23:23 -04:00
Georges-Antoine Assi
b85b001c3b fix socket updates on scan 2024-09-21 11:15:32 -04:00
Georges-Antoine Assi
fc6455eccb Merge pull request #1137 from rommapp/romm-829
[ROMM-829] Status fields on rom user
2024-09-09 19:41:38 -04:00
Georges-Antoine Assi
0b2a822e98 remove timezone from config init 2024-09-09 11:22:32 -04:00
Georges-Antoine Assi
97496d1171 Merge pull request #1184 from rommapp/romm-1176
[ROMM-1176] Fetch video ID and place in carousel
2024-09-09 10:12:46 -04:00
Georges-Antoine Assi
8fc25cde99 use timezone aware datetimes 2024-09-09 10:11:46 -04:00
Georges-Antoine Assi
fc85fcb6a9 fix pytests 2024-09-09 00:01:37 -04:00
Georges-Antoine Assi
2765a6e2c3 [ROMM-1176] Fetch video ID and place in carousel 2024-09-08 23:47:25 -04:00
Georges-Antoine Assi
4a664ab790 [ROMM-1181] Skip hashing games on desktop platorms 2024-09-08 23:08:50 -04:00
Georges-Antoine Assi
4bdcc63d9b add working filter for hidden roms 2024-09-08 16:35:06 -04:00
Georges-Antoine Assi
d5dfb71b60 actually hide games 2024-09-08 16:20:27 -04:00
Georges-Antoine Assi
9086fa5f94 fix a bunch o types 2024-09-08 15:46:32 -04:00
Georges-Antoine Assi
8dae0a503c add simple emojis to cards 2024-09-08 13:59:10 -04:00
Georges-Antoine Assi
deae0b9f74 set docs and recod paths 2024-09-03 21:59:30 -04:00
Georges-Antoine Assi
e432bc32ac Merge branch 'master' into romm-1114 2024-09-03 19:13:33 -04:00
Georges-Antoine Assi
9b6b19eb27 Merge branch 'master' into romm-829 2024-09-03 18:58:06 -04:00
Georges-Antoine Assi
b470bfaf67 Merge pull request #1157 from rommapp/romm-1154
[ROMM-1154] Fix setting main sibling
2024-09-01 23:59:30 -04:00
Georges-Antoine Assi
ae05c6be8c [ROMM-1154] fix setting main sibling 2024-09-01 22:11:49 -04:00
Georges-Antoine Assi
00c8771e22 [ROMM0-1155] Patch zipfil + catch more 7zip errors 2024-09-01 21:58:22 -04:00
Georges-Antoine Assi
0ce3549f98 [ROMM-1123] Limit returned roms to 2500 2024-09-01 09:55:25 -04:00
Georges-Antoine Assi
64657133e0 Merge pull request #1139 from rommapp/dev-mode-env
Hack to get emujs working in dev mode
2024-08-31 23:56:38 -04:00
Georges-Antoine Assi
5544ae1011 Merge branch 'master' into romm-1114 2024-08-31 23:55:13 -04:00
Georges-Antoine Assi
f3f6b6e884 small tweaks to ui 2024-08-30 15:06:01 -04:00
Georges-Antoine Assi
a7aba7374d fix trunk issues 2024-08-30 14:49:58 -04:00
Georges-Antoine Assi
00d34d7388 hack to get emujs working in dev mode 2024-08-30 14:35:37 -04:00
SaraVieira
fd996e367c run trunk 2024-08-30 19:24:10 +01:00
SaraVieira
c63f62a813 update edit modal 2024-08-30 19:18:52 +01:00
Sara Vieira
6de94aa767 Apply suggestions from code review
Co-authored-by: Georges-Antoine Assi <3247106+gantoine@users.noreply.github.com>
2024-08-30 19:12:28 +01:00
SaraVieira
e70e2a7360 Merge branch 'master' of github.com:rommapp/romm into feat/unmatch-rom 2024-08-30 11:24:26 +01:00
SaraVieira
86aae89f15 feat - Allow user to unmatch rom 2024-08-30 11:21:18 +01:00