Skip to content

Commit

Permalink
fix multiple issues from user exports config changes
Browse files Browse the repository at this point in the history
- improve nginx config
- fix DATA_UPLOAD_MAX_MEMORY_SIZE default not being an int
- translate fallback value in id_to_username template tag
- make location of setting to turn on user exports easier to locate for admins

fixes #3227
fixes #3231
fixes #3232
fixes #3236
  • Loading branch information
hughrun committed Jan 20, 2024
1 parent fd0b1d9 commit ddc35a7
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 11 deletions.
5 changes: 3 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ TWO_FACTOR_LOGIN_MAX_SECONDS=60
# and AWS_S3_CUSTOM_DOMAIN (if used) are added by default.
# Value should be a comma-separated list of host names.
CSP_ADDITIONAL_HOSTS=
# The last number here means "megabytes"

# Increase if users are having trouble uploading BookWyrm export files.
DATA_UPLOAD_MAX_MEMORY_SIZE = (1024**2 * 100)
# Default value is 2.5MB, this value is 100MB
DATA_UPLOAD_MAX_MEMORY_SIZE=104857600
2 changes: 1 addition & 1 deletion bookwyrm/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,4 @@
# user with the same username - in which case you should change it!
INSTANCE_ACTOR_USERNAME = "bookwyrm.instance.actor"

DATA_UPLOAD_MAX_MEMORY_SIZE = env.int("DATA_UPLOAD_MAX_MEMORY_SIZE", (1024**2 * 100))
DATA_UPLOAD_MAX_MEMORY_SIZE = env.int("DATA_UPLOAD_MAX_MEMORY_SIZE", 104857600)
7 changes: 7 additions & 0 deletions bookwyrm/templates/preferences/export-user.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ <h2 class="is-size-5">Your file will not include:</h2>
{% if not site.user_exports_enabled %}
<p class="notification is-danger">
{% trans "New user exports are currently disabled." %}
{% if perms.bookwyrm.edit_instance_settings %}
{% spaceless %}
{% blocktrans%}
<br/>User exports settings can be changed from <a href="/settings/imports">the Imports page</a> in the Admin dashboard.
{% endblocktrans %}
{% endspaceless %}
{% endif%}
</p>
{% elif next_available %}
<p class="notification is-warning">
Expand Down
2 changes: 1 addition & 1 deletion bookwyrm/templatetags/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def id_to_username(user_id):
value = f"{name}@{domain}"

return value
return "a new user account"
return _("a new user account")


@register.filter(name="get_file_size")
Expand Down
14 changes: 11 additions & 3 deletions nginx/development
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,25 @@ server {
proxy_pass http://web;
}

# directly serve images and static files from the
# directly serve static files from the
# bookwyrm filesystem using sendfile.
# make the logs quieter by not reporting these requests
location ~ \.(bmp|ico|jpg|jpeg|png|svg|tif|tiff|ttf|webp|css|js)$ {
location ~ ^/static/ {
root /app;
try_files $uri =404;
add_header X-Cache-Status STATIC;
access_log off;
}

# block access to any non-image files from images or static
# same with image files not in static folder
location ~ \.(bmp|ico|jpg|jpeg|png|svg|tif|tiff|webp)$ {
root /app;
try_files $uri =404;
add_header X-Cache-Status STATIC;
access_log off;
}

# block access to any non-image files from images
location ~ ^/images/ {
return 403;
}
Expand Down
16 changes: 12 additions & 4 deletions nginx/production
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,27 @@ server {
# proxy_pass http://web;
# }
#
# # directly serve images and static files from the
# # directly serve static files from the
# # bookwyrm filesystem using sendfile.
# # make the logs quieter by not reporting these requests
# location ~ \.(bmp|ico|jpg|jpeg|png|svg|tif|tiff|ttf|webp|css|js)$ {
# location ~ ^/static/ {
# root /app;
# try_files $uri =404;
# add_header X-Cache-Status STATIC;
# access_log off;
# }

# # block access to any non-image files from images or static
# # same with image files not in static folder
# location ~ \.(bmp|ico|jpg|jpeg|png|svg|tif|tiff|webp)$ {
# root /app;
# try_files $uri =404;
# add_header X-Cache-Status STATIC;
# access_log off;
# }

# # block access to any non-image files from images
# location ~ ^/images/ {
# return 403;
# return 403;
# }
#
# # monitor the celery queues with flower, no caching enabled
Expand Down

0 comments on commit ddc35a7

Please sign in to comment.