Commit graph

1419 commits

Author SHA1 Message Date
Mouse Reeve
42dd199084 Unit test that identifies clashes between links and mentions 2023-03-29 08:28:45 -07:00
Mouse Reeve
30a3096b25
Merge pull request #2749 from bookwyrm-social/redirects
Add helper to refer views back to http referers safely
2023-03-27 06:20:26 -07:00
Mouse Reeve
05e154f93e Uses referer redirect for some admin views 2023-03-20 13:58:20 -07:00
Mouse Reeve
219f78755f Fixes args in list view redirect 2023-03-20 11:15:27 -07:00
Mouse Reeve
4e9fad2091 Updates views that currently use the validator to use the redirect
helper
2023-03-20 10:27:52 -07:00
Mouse Reeve
2de115fc1e Add helper to refer views back to http referers safely
In most cases, we want to return back to where we came from after
performing an action. It's not safe to return to an arbitrary referer,
so this streamlines using the util validator to verify the redirect and
fall back on regular redirect params if the referer is outside our
domain.
2023-03-20 10:25:38 -07:00
Wesley Aptekar-Cassels
60fee54da9 Optimize CSV export query
Splitting this into five separate queries avoids the large join that
prevents us from using indexes, and requires materializing to disk.

Fixes: #2157 (hopefully)
2023-03-13 15:45:21 -04:00
Wesley Aptekar-Cassels
0b9e4d617e Use context processor for 500 page
By default, Django doesn't run any context processors for server errors,
to make the error path as simple as possible. However, this has the
downside that our template does not load correctly. To fix this, I added
a custom 500 error handler, which will run the context processor.

Fixes: #2736
2023-03-13 03:47:23 -04:00
Mouse Reeve
12af5992a3
Merge pull request #2524 from chdorner/feature/tag-support
Initial hashtag support
2023-03-12 16:37:39 -07:00
Mouse Reeve
6345beb90d
Merge pull request #2714 from WesleyAC/celery-ignore-results
Ignore Celery task results
2023-03-12 16:26:20 -07:00
Mouse Reeve
84b8a5c433
Merge pull request #2713 from WesleyAC/buffer-csv-export
Change CSV export to buffer instead of streaming
2023-03-12 16:17:53 -07:00
Wesley Aptekar-Cassels
50a81bdfdd Change CSV export to buffer instead of streaming
The idea behind a streaming CSV export was to reduce the amount of
memory used, by avoiding building the entire CSV file in memory before
sending it to the client. However, it didn't work out this way in
practice: the query objects that were created to represent each line
caused Postgres to generate a very large (~200MB on bookwyrm.social)
temp file, not to mention the memory being used by the Query object
likely being similar to, if not larger than that used by the finalized
CSV row.

While we should in the long term run our CSV exports as a Celery task,
this change should allow CSV exports to work on large servers without
causing disk-space problems.

Fixes: #2157
2023-03-08 21:37:56 -05:00
Wesley Aptekar-Cassels
4af4f30cde Broaden except section for HTTP request in dashboard
get_data can return exceptions other than ConnectorException, and when
it does, we want to simply not show the update section, rather than
crashing.

Related: #2717
2023-03-08 21:32:41 -05:00
Wesley Aptekar-Cassels
9cbff312a5 Ignore Celery task results
Since we don't use the results of our Celery tasks (all of them return
None implicitly), it's prudent to set the ignore_result flag, for a
potential performance improvement. See the Celery docs for details [1].

We could do this with the global CELERY_IGNORE_RESULT setting, but it
offers more flexibility if we want to use task results in the future to
set it on a per-task basis.

[1]: https://docs.celeryq.dev/en/stable/userguide/tasks.html#ignore-results-you-don-t-want
2023-03-08 02:12:13 -05:00
Christof Dorner
9ca9883e0b Enable finding existing hashtags case-insensitive
We should store hashtags case-sensitive, but ensures that an existing
hashtag with different case are found and re-used. for example,
an existing #BookWyrm hashtag will be found and used even if the
status content is using #bookwyrm.
2023-03-07 13:16:45 +01:00
Christof Dorner
f3334b1550 Render hashtag links with data-mention="hashtag" attribute 2023-03-07 13:16:45 +01:00
Christof Dorner
499aace9fb Add basic view listing activities from a given hashtag 2023-03-07 12:59:32 +01:00
Christof Dorner
ba0fcccfc5 Link hashtags in status content 2023-03-07 12:55:36 +01:00
Christof Dorner
c68304a99b Parse hashtags and store them in CreateStatus view 2023-03-07 12:55:36 +01:00
Mouse Reeve
c402433587
Merge pull request #2683 from bookwyrm-social/resolve-local-tasks-synchronously
Attempt to complete inbox requests synchronously
2023-03-06 19:20:16 -08:00
Mouse Reeve
b167364c5c Use a separate queue for broadcasts
I think this will go a long way to solve the federation delay problems
we're seeing on b.s. I'm not sure at what point adding more queues will
create more problems than it solves, but I do think in this case the
queues are out of balance and moving broadcasts (which are the most
common type of `medium_priority` task at the moment) to their own queue
will be an improvement.
2023-02-20 12:58:41 -08:00
Mouse Reeve
779d2b0694 Attempt to complete inbox requests synchronously
When an inbox activity comes in from another fediverse instance, the
behavior prior to this commit was always to immediately give a 200
response to the external server and then create a celery activity
(usually in the MEDIUM_PRIORITY queue) to complete it.

Instead, this would receive a request and try to complete it without
making any http requests (which would make the request take too long to
process). If an external request is required to complete the activity, a
task is created and added to the queue.

Ideally, this will cause some tasks to happen very promptly, and reduce
the load on celery, which would help queued tasks happen more quickly as
well.

One downside is that this will make completing http requests from
external servers slowing (since it's doing a bunch of thinking before
responding).
2023-02-20 11:05:18 -08:00
Mouse Reeve
2c2daf5fdf
Merge pull request #2644 from rrgeorge/rrgeorge/csp
Add Content-Security-Policy headers and secure cookies
2023-02-10 16:37:39 -08:00
Dustin Steiner
d1f85e4317 fix: books can have non-decimal series numbers 2023-02-07 12:05:20 +00:00
Dustin
b20b52af7f
Merge branch 'main' into book-series-v1 2023-02-07 11:57:39 +00:00
Robert George
b82231202c lint 2023-02-03 12:03:52 -08:00
Robert George
afe651cd6d Added img-src * csp exception to search 2023-02-03 11:53:41 -08:00
Christof Dorner
f9a916db09
Merge pull request #2639 from bookwyrm-social/celery-ping
Celery ping
2023-02-03 09:40:25 +01:00
Mouse Reeve
fd59fea94e
Update bookwyrm/views/admin/celery_status.py
Co-authored-by: Christof Dorner <christof@chdorner.com>
2023-02-02 16:46:36 -08:00
Robert George
6b97702cc4 Fix long line 2023-02-01 13:19:57 -08:00
Robert George
36605efd20 Added support for secure cookies and django-csp 2023-02-01 12:59:10 -08:00
Dustin Steiner
90f996ac90
chore: multi line comment for linter 2023-01-31 10:16:44 +00:00
Dustin Steiner
c2a81d88bb
Merge branch 'main' into book-series-v1 2023-01-31 10:06:07 +00:00
Mouse Reeve
006ff697b9
Merge pull request #2636 from 0x29a/redundant-db-queries
Remove redundant DB queries
2023-01-30 09:03:18 -08:00
Mouse Reeve
c1090703e2 Adds a ping-able celery url
This will let admins set up a check to notify you if celery is not
running.
2023-01-30 08:27:40 -08:00
Dustin Steiner
e0505722e1
chore: formatting 2023-01-30 14:45:30 +00:00
0x29a
3c52426a1c Optimize get_suggested_books 2023-01-30 06:45:44 +01:00
Dustin Steiner
0628ccad41
chore: sort editions with series number before edition rank 2023-01-29 11:43:56 +00:00
Dustin
c0e541c7ed
Merge branch 'main' into admin-manually-activate-user 2023-01-29 11:21:31 +00:00
Dustin
23e04c2e62
Merge branch 'main' into book-series-v1 2023-01-29 09:36:52 +00:00
Dustin Steiner
4b64b70753
fix: sort series by float 2023-01-29 09:35:02 +00:00
Dustin Steiner
f2902e8de5
fix: sort series number as int 2023-01-28 08:38:57 +00:00
Dustin Steiner
952dd0dcdf
style: fix unused parameter linter error 2023-01-28 08:31:41 +00:00
0x29a
cbd75dc766 Minor performance improvements 2023-01-27 20:24:53 +01:00
Dustin Steiner
54aea0654a
style: run linter 2023-01-27 15:47:22 +00:00
Dustin Steiner
07f4300176
feat: button in admin view to manually activate pending user 2023-01-27 15:43:34 +00:00
Dustin Steiner
ba2ff7e7a5
Merge branch 'main' into book-series-v1 2023-01-26 16:40:32 +00:00
Dustin Steiner
5cc158e3be
Merge branch 'main' into book-series-v1 2023-01-26 16:36:19 +00:00
Mouse Reeve
ef48149844 Show import queue in Celery admin 2023-01-26 07:52:37 -08:00
Mouse Reeve
e55e4429b1
Merge pull request #2604 from rrgeorge/redis-sockets
Add support to connecting to redis via unix socket
2023-01-26 06:39:15 -08:00
Mouse Reeve
4b6678903f
Merge pull request #2617 from bookwyrm-social/follow-priority
Make follow activities a high priority
2023-01-26 06:03:57 -08:00
Dustin
1d909ee8e1
Merge branch 'main' into book-series-v1 2023-01-26 06:50:22 +00:00
Dustin Steiner
eb4672ff18
style: format 2023-01-26 06:49:55 +00:00
Mouse Reeve
b89cab1ee5 Fixes args passed to inbox activity task 2023-01-25 07:39:43 -08:00
Mouse Reeve
858bf70d62 Make follow activities a high priority
This should go a long way towards fixing the problems with follows not
going through to remote servers. All it does is move relationship
related activities from the medium priority queue, which gets
backlogged easily, to the high priority queue, which is less backlogged.

The risk here is that the high priority queue could end up getting
backlogged, so this isn't the last word on fixing this, but I think the
volume of activities that this will add to it will be manageable.
2023-01-24 08:46:29 -08:00
Dustin
aad934fa59
Merge branch 'main' into book-series-v1 2023-01-24 13:14:28 +00:00
Dustin Steiner
cd13e6f523
style: run linter 2023-01-24 13:14:06 +00:00
Dustin Steiner
35d30a41f3
feat: first version of a book series list by author 2023-01-24 13:00:18 +00:00
Giebisch
3d99908d27 Fixed Object Selection for RSS Feeds 2023-01-23 15:17:20 +01:00
Giebisch
5d61003ce7 Merge branch 'main' into rss-feed 2023-01-20 23:29:33 +01:00
Mouse Reeve
0594152f47
Merge pull request #2511 from Giebisch/import-limit
Added Import Limit
2023-01-19 11:16:58 -08:00
Giebisch
18c786f63f Added RSS API 2023-01-17 21:59:05 +01:00
Alexander Ward
1f50a2dbfc
Email Config Has a Typo
There's an errant capital "E" preventing the SMTP user from appearing on the settings page.
2023-01-16 15:47:24 -08:00
Giebisch
d0adb370cd Merge branch 'main' into import-limit 2023-01-16 02:05:18 +01:00
Mouse Reeve
10322cdff3
Merge pull request #2572 from chdorner/fix/create-edit-book-cover-url
Ensure transient `cover_url` field value gets persisted across form renders
2023-01-14 18:08:22 -08:00
Robert George
207abed654 Add support for specifying redis url to support unix sockets 2023-01-14 14:52:54 -08:00
Mouse Reeve
5c8145b79d
Merge pull request #2586 from asmaloney/fix-duplicate-suggestions
{list} Fix duplicate suggestions in Add Books section
2023-01-11 08:40:32 -08:00
Giebisch
b22d060d93 Merge branch 'main' into import-limit 2023-01-11 16:22:08 +01:00
Andy Maloney
e5539a6faf Fix spelling in various comments 2023-01-10 17:24:02 -05:00
Andy Maloney
dd23bc4d0f {list} Fix duplicate suggestions in Add Books section
Fixes #2584

(Also fix a spelling mistake in a comment in book_search.py)
2023-01-10 11:08:11 -05:00
Giebisch
5200ea585a Import Limit Bugfix and lint 2023-01-05 23:37:43 +01:00
Christof Dorner
1c6548a0ad Ensure transient cover_url field value gets persisted across form renders
Given this field doesn't map to an `Edition` model field it lost its values when re-rendering the form.
It worked only when the form was valid and rendered as part of the confirmation screen, which is due to
the context data value being set in `add_authors` which was only getting called after the form validation.

I've opted to pull it out into a separate new function that gets called before form validation.
2023-01-04 18:02:04 +01:00
Joachim
bc19d7c658 Black 2023-01-01 19:45:12 +01:00
Joachim
f266c71da9 Replace hidden field with HTTP Referrer value 2023-01-01 19:42:03 +01:00
Joachim
78c214a6d4 Add validation before using url 2022-12-30 17:56:25 +01:00
Joachim
f5a79dfa82 Redirect to "next" value in view 2022-12-23 21:35:28 +01:00
Mouse Reeve
d4351cfcb4
Merge branch 'main' into import-limit 2022-12-16 12:44:57 -08:00
Giebisch
df54df8309 Added Import Limit 2022-12-15 23:43:25 +01:00
Mouse Reeve
89478ac87e
Merge pull request #2491 from chdorner/register-tz-support
Detect preferred timezone via JavaScript on register
2022-12-11 14:49:29 -08:00
Christof Dorner
13b262bb7b Detect preferred timezone via JavaScript on register 2022-12-11 23:32:07 +01:00
Mouse Reeve
3a9a344089
Merge pull request #2478 from bookwyrm-social/admin-roles
Adds "owner" role
2022-12-11 13:05:39 -08:00
Mouse Reeve
3e62cbe8b6 Fixes incorrect import from merge 2022-12-11 12:39:33 -08:00
Mouse Reeve
a9846e7805
Merge pull request #2498 from bookwyrm-social/use-reactivate
Use user.reactivate when a user confirms their email address
2022-12-11 12:10:21 -08:00
Mouse Reeve
58e8c0b5ec Merge branch 'main' into admin-roles 2022-12-11 11:58:54 -08:00
Mouse Reeve
734fb5ad34
Merge pull request #2489 from chdorner/user-reviews-comments-tab
Add new user tab listing only reviews and comments
2022-12-11 11:53:31 -08:00
Mouse Reeve
50a42dc0a2 Use user.reactivate when a user confirms their email address
This is cleaner and easier to maintain.
2022-12-11 11:44:04 -08:00
Mouse Reeve
c314c9b5e3
Adds email config admin view (#2494)
This view lets you see your email configuration and send a test email.
2022-12-11 11:37:09 -08:00
Jascha Urbach
ac8b060d58
Isfdb ID for books and authors (#2482)
* New ID: Audible ASIN

Audible belongs to Amazon BUT they do not share the same IDs. The Audible ASIN of an audiobook is never the same as the Amazon ASIN.

Yeah, I know, Amazon is great. The fact that the ASIN is a good distinction for different works and editions bothers me more than I will ever be willing to admint.

* New ID "ISFDB"

Internet Speculative Ficiton Database ID for books and authors.
Links to the entry if set.

* Added aasin to test

Added aasin to test

* the answer expects more emptxy fields...
2022-12-11 11:33:33 -08:00
Christof Dorner
fbd8e22b97 Add new user tab listing only reviews and comments 2022-12-11 20:24:00 +01:00
Mouse Reeve
845bd2cc0d Only show themes to sys admin 2022-12-05 17:11:15 -08:00
Mouse Reeve
933cb6440f Creates admin views for owner and admin registration settings 2022-12-05 16:58:11 -08:00
Mouse Reeve
5172f67c35
Merge pull request #2450 from bookwyrm-social/impressum
Adds database fields for legal page/impressum
2022-12-04 12:12:26 -08:00
Mouse Reeve
df42712b8e
Merge pull request #2449 from bookwyrm-social/empty-csv
Don't start imports with empty CSVs
2022-11-25 12:31:13 -08:00
Mouse Reeve
70d639440e Show impressum 2022-11-25 12:06:32 -08:00
Mouse Reeve
015af2c1e7 Don't start imports with empty csvs
Fixes #2353
2022-11-25 10:35:16 -08:00
Mouse Reeve
81ab08aaa3 Fixes editing links 2022-11-25 08:28:45 -08:00
Joel Bradshaw
55bab0b70d Slice queryset before we resolve it
This was accidentally querying ALL books in the database to generate
suggestions if we didn't have enough, which broke some stuff
2022-11-23 19:26:09 +00:00
Mouse Reeve
1e5a6ec744
Merge branch 'main' into show-2fa-code 2022-11-19 10:09:27 -08:00
Mouse Reeve
9c5fe7610b Fixes reference to site model 2022-11-17 15:41:30 -08:00
Mouse Reeve
28567e2d8e Disable imports in the UI and view 2022-11-17 15:19:42 -08:00