Compare commits

..

149 Commits
7.4.0 ... 7.5.2

Author SHA1 Message Date
Athou
728868784e release 7.5.2 2026-11-17 21:37:58 +01:00
Athou
e59948c68c fix youtube embeds (#2394) 2026-11-17 14:50:43 +01:00
renovate[bot]
d3ba47d200 Lock file maintenance 2026-11-16 17:22:20 +00:00
Athou
aa8d3a390c release 7.5.1 2026-11-16 18:20:18 +01:00
Athou
ec0e19fa4c only allow one entry context menu to be open at a time (#2393) 2026-11-16 18:19:09 +01:00
renovate[bot]
60ee632b78 Update dependency jsdom to v31.0.1 2026-11-16 12:02:06 +00:00
renovate[bot]
04860af353 Lock file maintenance 2026-11-16 04:05:03 +00:00
Jérémie Panzer
03d369659b Merge pull request #2392 from Athou/renovate/org.mock-server-mockserver-junit-jupiter-no-dependencies-9.x
Update dependency org.mock-server:mockserver-junit-jupiter-no-dependencies to v9.3.0
2026-11-16 05:03:45 +01:00
renovate[bot]
2c05b49c63 Update dependency org.mock-server:mockserver-junit-jupiter-no-dependencies to v9.3.0 2026-11-16 00:52:23 +00:00
renovate[bot]
0cde864b85 Update dependency maven to v3.10.1 2026-11-15 17:13:59 +00:00
renovate[bot]
8a2280ce2c Update dependency @testing-library/user-event to v14.6.10 2026-11-15 05:26:59 +00:00
Athou
423cc54dd5 release 7.5.0 2026-11-15 06:25:45 +01:00
renovate[bot]
a41117afb0 Update dependency @biomejs/biome to v2.6.7 2026-11-14 22:47:43 +00:00
renovate[bot]
37609f911d Update dependency io.github.hakky54:ayza-for-apache5 to v10.1.1 2026-11-14 09:12:25 +00:00
renovate[bot]
29067b1d19 Update dependency vite to v8.3.8 2026-11-14 03:37:07 +00:00
Jérémie Panzer
d12bd38358 Merge pull request #2391 from Athou/renovate/io.quarkiverse.playwright-quarkus-playwright-2.x
Update dependency io.quarkiverse.playwright:quarkus-playwright to v2.5.0
2026-11-13 23:59:53 +01:00
renovate[bot]
7c69ee3b4f Update dependency io.quarkiverse.playwright:quarkus-playwright to v2.5.0 2026-11-13 21:14:06 +00:00
renovate[bot]
53ec95f825 Update graalvm/setup-graalvm action to v1.6.9 2026-11-13 09:12:22 +00:00
renovate[bot]
c93c8fa604 Update dependency @testing-library/user-event to v14.6.9 2026-11-13 07:26:13 +00:00
Jérémie Panzer
ae68cb505b Merge pull request #2390 from jump-oss/fix/feed-discovery-redirect
Fix feed discovery after HTML redirects
2026-11-13 08:25:01 +01:00
gkj
3e376c698f Fix feed discovery after HTML redirects 2026-11-13 14:29:43 +08:00
renovate[bot]
2d7c9f423d Update dependency vite to v8.3.7 2026-11-13 04:08:15 +00:00
renovate[bot]
d397ecf9c7 Update dependency axios to v1.21.1 2026-11-12 23:02:03 +00:00
renovate[bot]
8ea7e93df3 Update ibm-semeru-runtimes:open-jdk-25.0.5.0-jre Docker digest to 03d2cb3 2026-11-12 15:22:18 +00:00
Jérémie Panzer
29258d30f0 Merge pull request #2388 from Athou/renovate/vitejs-plugin-react-6.x
Update dependency @vitejs/plugin-react to v6.3.0
2026-11-12 16:21:21 +01:00
Jérémie Panzer
8ba1b16a85 Merge pull request #2389 from Athou/renovate/mantine-monorepo
Update mantine monorepo to v9.8.0
2026-11-12 16:21:14 +01:00
renovate[bot]
11c4665340 Update mantine monorepo to v9.8.0 2026-11-12 12:06:54 +00:00
renovate[bot]
a1cdf05386 Update dependency @vitejs/plugin-react to v6.3.0 2026-11-12 12:06:44 +00:00
renovate[bot]
f618f46656 Update dependency @rolldown/plugin-babel to v0.3.1 2026-11-12 06:28:18 +00:00
Jérémie Panzer
2b412da69d Merge pull request #2387 from Athou/renovate/vite-plugin-checker-1.x
Update dependency vite-plugin-checker to v1
2026-11-12 07:27:08 +01:00
renovate[bot]
c4c53f6835 Update dependency vite-plugin-checker to v1 2026-11-12 00:43:43 +00:00
renovate[bot]
b27e4c23e8 Update Node.js to v26.13.1 2026-11-11 17:47:05 +00:00
Athou
ad19379318 use Mantine context menu instead of react-contexify (#2380) 2026-11-10 12:28:26 +01:00
Jérémie Panzer
46610146a9 Merge pull request #2378 from Athou/renovate/org.codehaus.mojo-properties-maven-plugin-1.x
Update dependency org.codehaus.mojo:properties-maven-plugin to v1.4.0
2026-11-10 08:19:23 +01:00
Jérémie Panzer
654b5f2826 Merge pull request #2377 from Athou/renovate/org.codehaus.mojo-exec-maven-plugin-3.x
Update dependency org.codehaus.mojo:exec-maven-plugin to v3.7.0
2026-11-10 08:19:16 +01:00
renovate[bot]
8f194dff8d Update ibm-semeru-runtimes:open-jdk-25.0.5.0-jre Docker digest to bdcbe98 2026-11-10 02:08:13 +00:00
renovate[bot]
af1adf5998 Update dependency org.codehaus.mojo:properties-maven-plugin to v1.4.0 2026-11-09 23:44:55 +00:00
renovate[bot]
eec0f7e688 Update dependency org.codehaus.mojo:exec-maven-plugin to v3.7.0 2026-11-09 23:44:49 +00:00
renovate[bot]
3009477e44 Lock file maintenance 2026-11-09 19:07:28 +00:00
renovate[bot]
e85d3d06c5 Update quarkus.version to v3.40.1.2 2026-11-09 17:53:53 +00:00
renovate[bot]
ae537ad864 Update dependency @biomejs/biome to v2.6.6 2026-11-09 14:29:53 +00:00
Athou
eb8626f0e1 fix "mark all as read" in tag views marking the wrong entries (#2374) 2026-11-09 06:08:40 +01:00
Athou
f6e30a77da fix the "Invalid prop propsFromTrigger supplied to React.Fragment. React.Fragment can only have key, ref, and children props." by bot using fragments in the menu 2026-11-09 05:55:19 +01:00
Jérémie Panzer
788ef941a1 Merge pull request #2376 from Athou/renovate/jsdom-31.x
Update dependency jsdom to v31
2026-11-09 05:43:58 +01:00
renovate[bot]
03ec9dcc65 Update dependency jsdom to v31 2026-11-08 16:54:36 +00:00
renovate[bot]
29df52beda Update dependency vite to v8.3.6 2026-11-08 12:15:57 +00:00
Athou
103ba252f8 generate OCI image labels with docker/metadata-action instead of hardcoding them in Dockerfiles 2026-11-08 13:12:33 +01:00
renovate[bot]
0be041c906 Update dependency npm to v12.2.2 2026-11-08 00:44:39 +00:00
renovate[bot]
a4e161ebb9 Update mantine monorepo to v9.7.5 2026-11-07 22:10:42 +00:00
renovate[bot]
3ef0802fc2 Update dependency @biomejs/biome to v2.6.5 2026-11-07 17:48:58 +00:00
Jérémie Panzer
4b12682873 Merge pull request #2373 from Athou/renovate/reduxjs-toolkit-2.x
Update dependency @reduxjs/toolkit to v2.14.0
2026-11-06 23:02:29 +01:00
renovate[bot]
f39b47c7db Update dependency @reduxjs/toolkit to v2.14.0 2026-11-06 17:09:23 +00:00
Jérémie Panzer
ec7a231ec3 Merge pull request #2359 from Athou/renovate/rolldown-plugin-babel-0.x
Update dependency @rolldown/plugin-babel to v0.3.0
2026-11-06 18:08:09 +01:00
renovate[bot]
c54135272e Update dependency @rolldown/plugin-babel to v0.3.0 2026-11-06 16:29:10 +00:00
Jérémie Panzer
857461a2fe Merge pull request #2369 from Athou/renovate/linguijs-monorepo
Update linguijs monorepo to v6.12.0
2026-11-06 17:28:01 +01:00
renovate[bot]
081bd6818f Update linguijs monorepo to v6.12.0 2026-11-06 16:16:24 +00:00
Jérémie Panzer
213e76bcaf Merge pull request #2372 from Athou/renovate/io.quarkiverse.playwright-quarkus-playwright-2.x
Update dependency io.quarkiverse.playwright:quarkus-playwright to v2.4.0
2026-11-06 11:16:30 +01:00
renovate[bot]
80ca93e181 Update dependency io.quarkiverse.playwright:quarkus-playwright to v2.4.0 2026-11-06 06:48:21 +00:00
Jérémie Panzer
6d13ac99b1 Merge pull request #2370 from Athou/renovate/vitest-monorepo
Update dependency vitest to v5.1.0
2026-11-06 04:24:52 +01:00
renovate[bot]
38fba97600 Update dependency vitest to v5.1.0 2026-11-05 23:04:39 +00:00
Jérémie Panzer
26a217c08f Merge pull request #2368 from Athou/renovate/docker-login-action-4.x
Update docker/login-action action to v4.8.0
2026-11-05 15:55:02 +01:00
renovate[bot]
d3ae68eda3 Update docker/login-action action to v4.8.0 2026-11-05 14:38:23 +00:00
renovate[bot]
e68268aa3f Update debian:13.7 Docker digest to 9c6e381 2026-11-05 10:32:12 +00:00
Jérémie Panzer
5dd870c9a9 Merge pull request #2367 from Athou/renovate/vitejs-plugin-react-6.x
Update dependency @vitejs/plugin-react to v6.2.1
2026-11-05 11:31:26 +01:00
renovate[bot]
c9ed8f9bfd Update dependency @vitejs/plugin-react to v6.2.1 2026-11-05 10:08:59 +00:00
renovate[bot]
e38c45e4d6 Update ibm-semeru-runtimes Docker tag to open-jdk-25.0.5.0-jre 2026-11-05 01:13:20 +00:00
Jérémie Panzer
6c54ae1e1e Merge pull request #2365 from jump-oss/fix/entries-loading
Reset entry loading state when requests fail
2026-11-04 15:01:27 +01:00
gkj
ef4fde24e3 Fix loading state after failed entry requests 2026-11-04 16:55:57 +08:00
Athou
f0fd987f4b restore empty categories when importing OPML files (#2364) 2026-11-04 09:02:10 +01:00
Athou
d691095746 prevent users from referencing categories owned by other users 2026-11-04 08:34:47 +01:00
Athou
ae707a2602 fix quadratic time when removing doctype declarations 2026-11-03 16:37:01 +01:00
Athou
69cf674a02 use 120 max line length for both server and client code (was 100 and 140) 2026-11-03 06:48:15 +01:00
Jérémie Panzer
29987a460d Merge pull request #2362 from Athou/renovate/org.jsoup-jsoup-1.x
Update dependency org.jsoup:jsoup to v1.24.1
2026-11-03 06:42:50 +01:00
renovate[bot]
fc8cd9c0a2 Update dependency org.jsoup:jsoup to v1.24.1 2026-11-03 04:47:00 +00:00
Jérémie Panzer
44c2893fff Merge pull request #2361 from Athou/renovate/com.diffplug.spotless-spotless-maven-plugin-3.x
Update dependency com.diffplug.spotless:spotless-maven-plugin to v3.11.0
2026-11-03 02:35:16 +01:00
renovate[bot]
2e66fd4702 Update dependency com.diffplug.spotless:spotless-maven-plugin to v3.11.0 2026-11-03 00:12:34 +00:00
Athou
01ac8d6ebd block NAT64 local-use prefix in SSRF protection 2026-11-02 13:09:31 +01:00
Athou
ddff408afe escape username in password recovery email 2026-11-02 12:34:14 +01:00
Athou
0c280c4dc4 invalidate existing sessions on password change 2026-11-02 12:17:45 +01:00
renovate[bot]
ca4642f7c9 Lock file maintenance 2026-11-02 00:55:45 +00:00
Jérémie Panzer
93edb47dca Merge pull request #2360 from Athou/renovate/linguijs-monorepo
Update linguijs monorepo to v6.11.0
2026-11-01 16:02:26 +01:00
renovate[bot]
801680e373 Update linguijs monorepo to v6.11.0 2026-11-01 14:10:40 +00:00
renovate[bot]
5704e1e1fa Update dependency @biomejs/biome to v2.6.4 2026-11-01 08:42:11 +00:00
Jérémie Panzer
a2a6720cd1 Merge pull request #2358 from Athou/renovate/com.puppycrawl.tools-checkstyle-14.x
Update dependency com.puppycrawl.tools:checkstyle to v14.4.0
2026-11-01 09:41:16 +01:00
renovate[bot]
4f8cddeb54 Update dependency com.puppycrawl.tools:checkstyle to v14.4.0 2026-10-31 21:57:58 +00:00
Athou
90d0846bad apply timeout to all queries 2026-10-31 08:46:39 +01:00
renovate[bot]
698b2f4dfd Update dependency react-router-dom to v7.18.5 2026-10-31 00:27:01 +00:00
renovate[bot]
0053c54ae4 Update dependency react-redux to v9.3.1 2026-10-30 22:37:38 +00:00
Athou
16b6077496 keep using ubuntu-24.04 (#2357) 2026-10-30 23:36:23 +01:00
Athou
edb4d5e178 speed up tree building by looking up unread counts in batches 2026-10-30 23:15:22 +01:00
Athou
4b091fb90b fix "Mark all as read" ignoring active search filter (#2354) 2026-10-30 21:08:27 +01:00
Athou
30c049d10a fix infinite scroll not loading more search results when entries are already read (#2353) 2026-10-30 20:54:56 +01:00
Athou
fa8a447787 prevent moving a category into one of its own descendants (#2355) 2026-10-30 20:51:45 +01:00
Athou
20ec5d3eb9 use mandrel instead of graalvm for better compatibility with quarkus
(cherry picked from commit c020b0ae08936d6f57b16c1b6bdd8aea17981ede)
2026-10-30 20:07:18 +01:00
Jérémie Panzer
796dc88c33 Merge pull request #2356 from Athou/renovate/com.google.googlejavaformat-google-java-format-2.x
Update dependency com.google.googlejavaformat:google-java-format to v2
2026-10-30 19:55:46 +01:00
Athou
f979f5426f reformat using google-java-format 2.0 2026-10-30 19:39:53 +01:00
renovate[bot]
8f9be28002 Update dependency com.google.googlejavaformat:google-java-format to v2 2026-10-30 17:25:44 +00:00
Jérémie Panzer
89845681be Merge pull request #2352 from Athou/renovate/axios-1.x
Update dependency axios to v1.21.0
2026-10-30 13:33:33 +01:00
renovate[bot]
8fdf63dd73 Update dependency axios to v1.21.0 2026-10-30 11:17:25 +00:00
Jérémie Panzer
8f07454270 Merge pull request #2350 from dajiaohuang/feat/2268-feed-settings-icon
Use a settings icon for feed controls
2026-10-30 07:23:37 +01:00
Jérémie Panzer
946d82d8ee Merge pull request #2351 from Athou/renovate/react-querybuilder
Update react-querybuilder to v8.26.0
2026-10-30 07:18:05 +01:00
renovate[bot]
f8d625b651 Update react-querybuilder to v8.26.0 2026-10-30 05:54:28 +00:00
dajiaohuang
eefdd40a02 Use settings icon for feed controls 2026-10-29 19:34:22 +08:00
renovate[bot]
08f2889f1d Update debian:13.7 Docker digest to 2dc419c 2026-10-29 01:59:45 +00:00
renovate[bot]
45453fcf4f Update mantine monorepo to v9.7.4 (#2349)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-10-29 01:59:27 +00:00
Jérémie Panzer
ef7bab4841 Merge pull request #2348 from Athou/renovate/node-26.x
Update Node.js to v26
2026-10-28 22:03:31 +01:00
renovate[bot]
ac277f9ca5 Update Node.js to v26 2026-10-28 20:44:59 +00:00
renovate[bot]
44dab0287b Update Node.js to v24.22.2 2026-10-28 19:20:32 +00:00
renovate[bot]
88b75ec0cb Update debian:13.7 Docker digest to 8c4733a 2026-10-28 05:34:10 +00:00
renovate[bot]
cbb45ce68c Update ibm-semeru-runtimes:open-jdk-25.0.4.15-jre Docker digest to c4f8cd5 2026-10-28 03:04:23 +00:00
renovate[bot]
b0c4dbf533 Update dependency @biomejs/biome to v2.6.3 2026-10-27 14:52:39 +00:00
renovate[bot]
1891b63a0e Update ibm-semeru-runtimes:open-jdk-25.0.4.15-jre Docker digest to 1e5bef9 2026-10-27 08:26:53 +00:00
Jérémie Panzer
c420fec8ee Merge pull request #2344 from Athou/renovate/dev.cel-cel-0.x
Update dependency dev.cel:cel to v0.15.0
2026-10-27 09:25:55 +01:00
Athou
2ee2a5dfbe standardCelRuntimeBuilder is deprecated 2026-10-27 07:23:50 +01:00
Jérémie Panzer
a5b98f9ea2 Merge pull request #2345 from Athou/renovate/org.mock-server-mockserver-junit-jupiter-no-dependencies-9.x
Update dependency org.mock-server:mockserver-junit-jupiter-no-dependencies to v9.2.0
2026-10-27 07:20:19 +01:00
renovate[bot]
baedab2960 Update dependency org.mock-server:mockserver-junit-jupiter-no-dependencies to v9.2.0 2026-10-27 02:09:09 +00:00
renovate[bot]
004e18bbb8 Update dependency dev.cel:cel to v0.15.0 2026-10-27 02:09:03 +00:00
Athou
72e364afe9 babel types are no longer needed now that linguijs does not require babel anymore 2026-10-26 20:15:32 +01:00
renovate[bot]
86ff2dfcb2 Update graalvm/setup-graalvm action to v1.6.8 2026-10-26 18:41:05 +00:00
renovate[bot]
69ce73012c Update dependency @babel/types to ^8.0.8 2026-10-26 17:46:09 +00:00
renovate[bot]
f3bd1a2e11 Update dependency org.apache.maven.plugins:maven-surefire-plugin to v3.6.1 2026-10-26 06:38:33 +00:00
renovate[bot]
a819283661 Update dependency org.apache.maven.plugins:maven-failsafe-plugin to v3.6.1 2026-10-26 04:33:45 +00:00
renovate[bot]
8255c1e929 Lock file maintenance 2026-10-26 00:53:26 +00:00
renovate[bot]
eb7990f8dc Update linguijs monorepo to v6.10.1 2026-10-25 16:24:22 +00:00
Jérémie Panzer
982476b2d0 Merge pull request #2343 from Athou/renovate/biomejs-biome-2.x
Update dependency @biomejs/biome to v2.6.2
2026-10-24 19:58:21 +02:00
renovate[bot]
3ec653c3b7 Update dependency @biomejs/biome to v2.6.2 2026-10-24 13:30:33 +00:00
renovate[bot]
5dc5b3795e Update dependency vite to v8.3.5 2026-10-24 08:49:46 +00:00
Jérémie Panzer
f5f77a80a3 Merge pull request #2341 from Athou/renovate/docker-login-action-4.x
Update docker/login-action action to v4.7.0
2026-10-23 20:36:02 +02:00
renovate[bot]
1d1099492e Update docker/login-action action to v4.7.0 2026-10-23 18:01:41 +00:00
Jérémie Panzer
ccc2564929 Merge pull request #2340 from Athou/renovate/com.ibm.icu-icu4j-79.x
Update dependency com.ibm.icu:icu4j to v79
2026-10-23 08:55:25 +02:00
renovate[bot]
084574ffd4 Update dependency com.ibm.icu:icu4j to v79 2026-10-22 20:43:24 +00:00
Athou
6a6978c491 release 7.4.1 2026-10-22 17:03:04 +02:00
Athou
0399375288 don't mark as read entries that the user explicitly marked as unread (#2337) 2026-10-22 09:04:57 +02:00
renovate[bot]
394346fbc1 Update dependency npm to v12.2.1 2026-10-22 01:00:28 +00:00
renovate[bot]
0feec109bd Update Node.js to v24.22.1 2026-10-21 12:22:26 +00:00
Jérémie Panzer
fdb5c9b536 Merge pull request #2339 from Athou/renovate/org.mock-server-mockserver-junit-jupiter-no-dependencies-9.x
Update dependency org.mock-server:mockserver-junit-jupiter-no-dependencies to v9.1.0
2026-10-21 14:21:44 +02:00
renovate[bot]
f7ad8aed60 Update dependency org.mock-server:mockserver-junit-jupiter-no-dependencies to v9.1.0 2026-10-21 11:48:07 +00:00
renovate[bot]
4621d7e79f Update debian:13.7 Docker digest to 4c25275 2026-10-21 05:25:57 +00:00
Jérémie Panzer
b64a49cfb0 Merge pull request #2338 from Athou/renovate/patch-mantine-monorepo
Update mantine monorepo to v9.7.3
2026-10-21 07:25:22 +02:00
renovate[bot]
aaddfbaf40 Update mantine monorepo to v9.7.3 2026-10-20 20:33:54 +00:00
Athou
994da5e1ee don't mark as read if we are still on the same entry (#2337) 2026-10-20 16:51:42 +02:00
Athou
811e282e28 mockserver already uses jackson3 2026-10-20 13:34:06 +02:00
Jérémie Panzer
892fcf8168 Merge pull request #2336 from Athou/renovate/linguijs-monorepo
Update linguijs monorepo to v6.10.0
2026-10-20 13:15:59 +02:00
renovate[bot]
032ee9243f Update linguijs monorepo to v6.10.0 2026-10-20 10:46:22 +00:00
renovate[bot]
30cdf34d56 Update quarkus.version to v3.40.1.1 2026-10-20 10:45:55 +00:00
Athou
fd52caa3fd use responseTimeout as the global timeout for the request 2026-10-20 08:47:59 +02:00
Athou
9788712808 add a global failsafe timeout to the feed fetching client 2026-10-20 08:28:15 +02:00
Jérémie Panzer
af9d086f05 Merge pull request #2335 from agross/add-oci-source-label
Add OCI source label for Renovate release-note discovery
2026-10-19 11:31:42 +02:00
Alexander Groß
fc7190868e Add OCI source label to container images 2026-10-19 10:35:18 +02:00
184 changed files with 4058 additions and 3681 deletions

View File

@@ -16,7 +16,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ "ubuntu-latest", "ubuntu-22.04-arm", "windows-latest" ] os: [ "ubuntu-24.04", "ubuntu-22.04-arm", "windows-latest" ]
database: [ "h2", "postgresql", "mysql", "mariadb" ] database: [ "h2", "postgresql", "mysql", "mariadb" ]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
@@ -29,10 +29,10 @@ jobs:
# Setup # Setup
- name: Set up GraalVM - name: Set up GraalVM
uses: graalvm/setup-graalvm@27b360dbb857524eaf0b4c4cef364d38e5b4f173 # v1.6.7 uses: graalvm/setup-graalvm@d6eca2595046623d69d636041513c80abf745406 # v1.6.9
with: with:
java-version: ${{ env.JAVA_VERSION }} java-version: ${{ env.JAVA_VERSION }}
distribution: "graalvm" distribution: "mandrel"
cache: "maven" cache: "maven"
- name: Set up NodeJS cache - name: Set up NodeJS cache
@@ -74,7 +74,7 @@ jobs:
# Upload artifacts # Upload artifacts
- name: Upload cross-platform app - name: Upload cross-platform app
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2 uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: matrix.os == 'ubuntu-latest' # we only need to upload the cross-platform artifact once per database if: matrix.os == 'ubuntu-24.04' # we only need to upload the cross-platform artifact once per database
with: with:
name: commafeed-${{ matrix.database }}-jvm name: commafeed-${{ matrix.database }}-jvm
path: commafeed-server/target/commafeed-*.zip path: commafeed-server/target/commafeed-*.zip
@@ -87,7 +87,7 @@ jobs:
- name: Upload pages - name: Upload pages
uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0 uses: actions/upload-pages-artifact@fc324d3547104276b827a68afc52ff2a11cc49c9 # v5.0.0
if: matrix.os == 'ubuntu-latest' && matrix.database == 'h2' # we only need to upload the pages once if: matrix.os == 'ubuntu-24.04' && matrix.database == 'h2' # we only need to upload the pages once
with: with:
path: target/pages path: target/pages
@@ -141,12 +141,18 @@ jobs:
# Docker # Docker
- name: Login to Container Registry - name: Login to Container Registry
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 uses: docker/login-action@8aa5831fb8d48d8f76594c7ddde61ae58019f550 # v4.8.0
if: ${{ env.DOCKERHUB_USERNAME != '' }} if: ${{ env.DOCKERHUB_USERNAME != '' }}
with: with:
username: ${{ secrets.DOCKERHUB_USERNAME }} username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }} password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker metadata
id: meta
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: athou/commafeed
## build but don't push for PRs and renovate ## build but don't push for PRs and renovate
- name: Docker build - native - name: Docker build - native
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
@@ -155,6 +161,7 @@ jobs:
file: commafeed-server/src/main/docker/Dockerfile.native file: commafeed-server/src/main/docker/Dockerfile.native
push: false push: false
platforms: linux/amd64,linux/arm64/v8 platforms: linux/amd64,linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
- name: Docker build - jvm - name: Docker build - jvm
uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0 uses: docker/build-push-action@c3c9e263c25d99ce0380d002d59b67737d91b0dc # v7.4.0
@@ -163,6 +170,7 @@ jobs:
file: commafeed-server/src/main/docker/Dockerfile.jvm file: commafeed-server/src/main/docker/Dockerfile.jvm
push: false push: false
platforms: linux/amd64,linux/arm64/v8 platforms: linux/amd64,linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
## build and push tag ## build and push tag
- name: Docker build and push tag - native - name: Docker build and push tag - native
@@ -173,6 +181,7 @@ jobs:
file: commafeed-server/src/main/docker/Dockerfile.native file: commafeed-server/src/main/docker/Dockerfile.native
push: ${{ env.DOCKERHUB_USERNAME != '' }} push: ${{ env.DOCKERHUB_USERNAME != '' }}
platforms: linux/amd64,linux/arm64/v8 platforms: linux/amd64,linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
tags: | tags: |
athou/commafeed:latest-${{ matrix.database }} athou/commafeed:latest-${{ matrix.database }}
athou/commafeed:${{ github.ref_name }}-${{ matrix.database }} athou/commafeed:${{ github.ref_name }}-${{ matrix.database }}
@@ -185,6 +194,7 @@ jobs:
file: commafeed-server/src/main/docker/Dockerfile.jvm file: commafeed-server/src/main/docker/Dockerfile.jvm
push: ${{ env.DOCKERHUB_USERNAME != '' }} push: ${{ env.DOCKERHUB_USERNAME != '' }}
platforms: linux/amd64,linux/arm64/v8 platforms: linux/amd64,linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
tags: | tags: |
athou/commafeed:latest-${{ matrix.database }}-jvm athou/commafeed:latest-${{ matrix.database }}-jvm
athou/commafeed:${{ github.ref_name }}-${{ matrix.database }}-jvm athou/commafeed:${{ github.ref_name }}-${{ matrix.database }}-jvm
@@ -198,6 +208,7 @@ jobs:
file: commafeed-server/src/main/docker/Dockerfile.native file: commafeed-server/src/main/docker/Dockerfile.native
push: ${{ env.DOCKERHUB_USERNAME != '' }} push: ${{ env.DOCKERHUB_USERNAME != '' }}
platforms: linux/amd64,linux/arm64/v8 platforms: linux/amd64,linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
tags: athou/commafeed:master-${{ matrix.database }} tags: athou/commafeed:master-${{ matrix.database }}
- name: Docker build and push master - jvm - name: Docker build and push master - jvm
@@ -208,6 +219,7 @@ jobs:
file: commafeed-server/src/main/docker/Dockerfile.jvm file: commafeed-server/src/main/docker/Dockerfile.jvm
push: ${{ env.DOCKERHUB_USERNAME != '' }} push: ${{ env.DOCKERHUB_USERNAME != '' }}
platforms: linux/amd64,linux/arm64/v8 platforms: linux/amd64,linux/arm64/v8
labels: ${{ steps.meta.outputs.labels }}
tags: athou/commafeed:master-${{ matrix.database }}-jvm tags: athou/commafeed:master-${{ matrix.database }}-jvm
release: release:

View File

@@ -1,3 +1,3 @@
wrapperVersion=3.3.4 wrapperVersion=3.3.4
distributionType=only-script distributionType=only-script
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.0/apache-maven-3.10.0-bin.zip distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.10.1/apache-maven-3.10.1-bin.zip

View File

@@ -1,5 +1,39 @@
# Changelog # Changelog
## [7.5.2]
- Fix Youtube embeds not loading and stealing focus (#2394)
## [7.5.1]
- Fix multiple entry context menus being open at the same time (#2393)
## [7.5.0]
- Empty categories are now restored when importing OPML files (#2364)
- Speed up the building of the subscription tree by looking up unread counts in batches
- Fix "mark all as read" ignoring the active search filter (#2354)
- Fix "mark all as read" in tag views marking the wrong entries (#2374)
- Fix infinite scroll not loading more search results when entries are already read (#2353)
- Fix the loading state not being reset after failed entry requests
- Fix feed discovery when the subscription URL redirects to an HTML page
- Prevent moving a category into one of its own descendants (#2355)
- Fix quadratic processing time when removing doctype declarations from feeds
- Apply the query timeout to all database queries
- Replace the custom context menu library with the Mantine context menu (#2380)
- Use a settings icon for the feed controls button
- Native executables are now built with Mandrel instead of GraalVM for better compatibility with Quarkus
- Security: prevent users from referencing categories owned by other users
- Security: invalidate existing sessions when a user changes their password
- Security: escape the username in password recovery emails
- Security: block the NAT64 local-use prefix (`64:ff9b:1::/48`) in SSRF protection
## [7.4.1]
- Fix entries being marked as read when scrolling back to an entry that was explicitly marked as unread (#2337)
- Add a global failsafe timeout to the new HTTP/2 client to prevent it from hanging indefinitely
- Add OCI source label to container images (#2335)
## [7.4.0] ## [7.4.0]
- Add support for HTTP/2 when fetching feeds (#2317) - Add support for HTTP/2 when fetching feeds (#2317)
@@ -260,12 +294,12 @@ compiled to a native binary, resulting in blazing fast startup times (around 0.3
50M). 50M).
- CommaFeed now has a different package for each supported database. - CommaFeed now has a different package for each supported database.
- If you are deploying CommaFeed with a precompiled package, please - If you are deploying CommaFeed with a precompiled package, please
read [this section of the README](https://github.com/Athou/commafeed/tree/master?tab=readme-ov-file#download-a-precompiled-package). read [this section of the README](https://github.com/Athou/commafeed/tree/master?tab=readme-ov-file#download-a-precompiled-package).
- If you are building CommaFeed from sources, please - If you are building CommaFeed from sources, please
read [this section of the README](https://github.com/Athou/commafeed/tree/master?tab=readme-ov-file#build-from-sources). read [this section of the README](https://github.com/Athou/commafeed/tree/master?tab=readme-ov-file#build-from-sources).
- If you are using the Docker image, please read the instructions on - If you are using the Docker image, please read the instructions on
the [Docker Hub page](https://hub.docker.com/r/athou/commafeed). the [Docker Hub page](https://hub.docker.com/r/athou/commafeed).
- Due to the switch to Quarkus, the way CommaFeed is configured is very different (the `config.yml` file is gone). - Due to the switch to Quarkus, the way CommaFeed is configured is very different (the `config.yml` file is gone).
Please Please
read [this section of the README](https://github.com/Athou/commafeed/tree/master?tab=readme-ov-file#configuration). read [this section of the README](https://github.com/Athou/commafeed/tree/master?tab=readme-ov-file#configuration).
@@ -333,8 +367,8 @@ compiled to a native binary, resulting in blazing fast startup times (around 0.3
## [4.3.0] ## [4.3.0]
- h2 (the embedded database) has been upgraded to 2.2.224 - h2 (the embedded database) has been upgraded to 2.2.224
- this version uses a different file format than 2.1.x, the first time you start CommaFeed with this version, the - this version uses a different file format than 2.1.x, the first time you start CommaFeed with this version, the
database will be automatically converted to the new format database will be automatically converted to the new format
- add a setting to completely disable scrolling to selected entry (#1157) - add a setting to completely disable scrolling to selected entry (#1157)
- add a css class reflecting the current view mode to ease custom css rules (#1232) - add a css class reflecting the current view mode to ease custom css rules (#1232)
- fix an issue that prevents new feeds from being added when mysql/mariadb is used as the database (#1239) - fix an issue that prevents new feeds from being added when mysql/mariadb is used as the database (#1239)

View File

@@ -1,10 +1,10 @@
{ {
"$schema": "https://biomejs.dev/schemas/2.5.15/schema.json", "$schema": "https://biomejs.dev/schemas/2.6.7/schema.json",
"formatter": { "formatter": {
"indentStyle": "space", "indentStyle": "space",
"indentWidth": 4, "indentWidth": 4,
"lineEnding": "lf", "lineEnding": "lf",
"lineWidth": 140 "lineWidth": 120
}, },
"javascript": { "javascript": {
"formatter": { "formatter": {

File diff suppressed because it is too large Load Diff

View File

@@ -17,20 +17,20 @@
"dependencies": { "dependencies": {
"@emotion/react": "11.14.0", "@emotion/react": "11.14.0",
"@fontsource/open-sans": "5.3.0", "@fontsource/open-sans": "5.3.0",
"@lingui/core": "6.9.1", "@lingui/core": "6.12.0",
"@lingui/react": "6.9.1", "@lingui/react": "6.12.0",
"@mantine/core": "9.7.2", "@mantine/core": "9.8.0",
"@mantine/dates": "9.7.2", "@mantine/dates": "9.8.0",
"@mantine/form": "9.7.2", "@mantine/form": "9.8.0",
"@mantine/hooks": "9.7.2", "@mantine/hooks": "9.8.0",
"@mantine/modals": "9.7.2", "@mantine/modals": "9.8.0",
"@mantine/notifications": "9.7.2", "@mantine/notifications": "9.8.0",
"@mantine/spotlight": "9.7.2", "@mantine/spotlight": "9.8.0",
"@monaco-editor/react": "4.7.0", "@monaco-editor/react": "4.7.0",
"@react-querybuilder/mantine": "8.25.0", "@react-querybuilder/mantine": "8.26.0",
"@reduxjs/toolkit": "2.13.0", "@reduxjs/toolkit": "2.14.0",
"@rolldown/plugin-babel": "0.2.4", "@rolldown/plugin-babel": "0.3.1",
"axios": "1.20.0", "axios": "1.21.1",
"dayjs": "1.11.23", "dayjs": "1.11.23",
"escape-string-regexp": "5.0.0", "escape-string-regexp": "5.0.0",
"interweave": "13.1.1", "interweave": "13.1.1",
@@ -38,14 +38,13 @@
"mousetrap": "1.6.5", "mousetrap": "1.6.5",
"react": "19.3.1", "react": "19.3.1",
"react-async-hook": "4.0.0", "react-async-hook": "4.0.0",
"react-contexify": "6.0.0",
"react-dom": "19.3.1", "react-dom": "19.3.1",
"react-draggable": "4.7.2", "react-draggable": "4.7.2",
"react-icons": "5.7.0", "react-icons": "5.7.0",
"react-infinite-scroller": "1.2.6", "react-infinite-scroller": "1.2.6",
"react-querybuilder": "8.25.0", "react-querybuilder": "8.26.0",
"react-redux": "9.3.0", "react-redux": "9.3.1",
"react-router-dom": "7.18.4", "react-router-dom": "7.18.5",
"react-swipeable": "7.0.2", "react-swipeable": "7.0.2",
"style-to-object": "2.0.2", "style-to-object": "2.0.2",
"throttle-debounce": "5.0.2", "throttle-debounce": "5.0.2",
@@ -54,26 +53,25 @@
"websocket-heartbeat-js": "1.1.3" "websocket-heartbeat-js": "1.1.3"
}, },
"devDependencies": { "devDependencies": {
"@babel/types": "^8.0.6", "@biomejs/biome": "2.6.7",
"@biomejs/biome": "2.5.15", "@lingui/cli": "6.12.0",
"@lingui/cli": "6.9.1", "@lingui/vite-plugin": "6.12.0",
"@lingui/vite-plugin": "6.9.1",
"@testing-library/jest-dom": "7.0.1", "@testing-library/jest-dom": "7.0.1",
"@testing-library/react": "16.3.3", "@testing-library/react": "16.3.3",
"@testing-library/user-event": "14.6.8", "@testing-library/user-event": "14.6.10",
"@types/mousetrap": "1.6.15", "@types/mousetrap": "1.6.15",
"@types/react": "19.3.0", "@types/react": "19.3.0",
"@types/react-dom": "19.3.0", "@types/react-dom": "19.3.0",
"@types/react-infinite-scroller": "1.2.5", "@types/react-infinite-scroller": "1.2.5",
"@types/throttle-debounce": "5.0.2", "@types/throttle-debounce": "5.0.2",
"@types/tinycon": "0.6.7", "@types/tinycon": "0.6.7",
"@vitejs/plugin-react": "6.1.2", "@vitejs/plugin-react": "6.3.0",
"babel-plugin-react-compiler": "^1.0.0", "babel-plugin-react-compiler": "^1.0.0",
"jsdom": "30.1.3", "jsdom": "31.0.1",
"typescript": "7.0.2", "typescript": "7.0.2",
"vite": "8.3.4", "vite": "8.3.8",
"vite-plugin-checker": "0.14.5", "vite-plugin-checker": "1.0.0",
"vitest": "5.0.5", "vitest": "5.1.0",
"yaml": "2.9.1" "yaml": "2.9.1"
}, },
"overrides": { "overrides": {

View File

@@ -6,16 +6,16 @@
<parent> <parent>
<groupId>com.commafeed</groupId> <groupId>com.commafeed</groupId>
<artifactId>commafeed</artifactId> <artifactId>commafeed</artifactId>
<version>7.4.0</version> <version>7.5.2</version>
</parent> </parent>
<artifactId>commafeed-client</artifactId> <artifactId>commafeed-client</artifactId>
<name>CommaFeed Client</name> <name>CommaFeed Client</name>
<properties> <properties>
<!-- renovate: datasource=node-version depName=node --> <!-- renovate: datasource=node-version depName=node -->
<node.version>v24.22.0</node.version> <node.version>v26.13.1</node.version>
<!-- renovate: datasource=npm depName=npm --> <!-- renovate: datasource=npm depName=npm -->
<npm.version>12.2.0</npm.version> <npm.version>12.2.2</npm.version>
</properties> </properties>
<build> <build>
@@ -110,7 +110,7 @@
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId> <artifactId>exec-maven-plugin</artifactId>
<version>3.6.4</version> <version>3.7.0</version>
<executions> <executions>
<execution> <execution>
<id>kill-biome</id> <id>kill-biome</id>

View File

@@ -38,7 +38,8 @@ function Providers(
children: React.ReactNode children: React.ReactNode
}> }>
) { ) {
const primaryColor = useAppSelector(state => state.user.settings?.primaryColor) || Constants.theme.defaultPrimaryColor const primaryColor =
useAppSelector(state => state.user.settings?.primaryColor) || Constants.theme.defaultPrimaryColor
return ( return (
<I18nProvider i18n={i18n}> <I18nProvider i18n={i18n}>
<MantineProvider <MantineProvider
@@ -87,7 +88,10 @@ function AppRoutes() {
<Route path="register" element={<RegistrationPage />} /> <Route path="register" element={<RegistrationPage />} />
<Route path="passwordRecovery" element={<PasswordRecoveryPage />} /> <Route path="passwordRecovery" element={<PasswordRecoveryPage />} />
<Route path="passwordReset" element={<PasswordResetPage />} /> <Route path="passwordReset" element={<PasswordResetPage />} />
<Route path="app" element={<Layout header={<Header />} sidebar={<Tree />} sidebarVisible={sidebarVisible} />}> <Route
path="app"
element={<Layout header={<Header />} sidebar={<Tree />} sidebarVisible={sidebarVisible} />}
>
<Route path="category"> <Route path="category">
<Route path=":id" element={<FeedEntriesPage sourceType="category" />} /> <Route path=":id" element={<FeedEntriesPage sourceType="category" />} />
<Route path=":id/details" element={<CategoryDetailsPage />} /> <Route path=":id/details" element={<CategoryDetailsPage />} />

View File

@@ -61,7 +61,8 @@ export const client = {
getRoot: async () => await axiosInstance.get<Category>("category/get"), getRoot: async () => await axiosInstance.get<Category>("category/get"),
modify: async (req: CategoryModificationRequest) => await axiosInstance.post("category/modify", req), modify: async (req: CategoryModificationRequest) => await axiosInstance.post("category/modify", req),
collapse: async (req: CollapseRequest) => await axiosInstance.post("category/collapse", req), collapse: async (req: CollapseRequest) => await axiosInstance.post("category/collapse", req),
getEntries: async (req: GetEntriesPaginatedRequest) => await axiosInstance.get<Entries>("category/entries", { params: req }), getEntries: async (req: GetEntriesPaginatedRequest) =>
await axiosInstance.get<Entries>("category/entries", { params: req }),
markEntries: async (req: MarkRequest) => await axiosInstance.post("category/mark", req), markEntries: async (req: MarkRequest) => await axiosInstance.post("category/mark", req),
add: async (req: AddCategoryRequest) => await axiosInstance.post("category/add", req), add: async (req: AddCategoryRequest) => await axiosInstance.post("category/add", req),
delete: async (req: IDRequest) => await axiosInstance.post("category/delete", req), delete: async (req: IDRequest) => await axiosInstance.post("category/delete", req),
@@ -76,7 +77,8 @@ export const client = {
feed: { feed: {
get: async (id: string) => await axiosInstance.get<Subscription>(`feed/get/${id}`), get: async (id: string) => await axiosInstance.get<Subscription>(`feed/get/${id}`),
modify: async (req: FeedModificationRequest) => await axiosInstance.post("feed/modify", req), modify: async (req: FeedModificationRequest) => await axiosInstance.post("feed/modify", req),
getEntries: async (req: GetEntriesPaginatedRequest) => await axiosInstance.get<Entries>("feed/entries", { params: req }), getEntries: async (req: GetEntriesPaginatedRequest) =>
await axiosInstance.get<Entries>("feed/entries", { params: req }),
markEntries: async (req: MarkRequest) => await axiosInstance.post("feed/mark", req), markEntries: async (req: MarkRequest) => await axiosInstance.post("feed/mark", req),
fetchFeed: async (req: FeedInfoRequest) => await axiosInstance.post<FeedInfo>("feed/fetch", req), fetchFeed: async (req: FeedInfoRequest) => await axiosInstance.post<FeedInfo>("feed/fetch", req),
refreshAll: async () => await axiosInstance.get("feed/refreshAll"), refreshAll: async () => await axiosInstance.get("feed/refreshAll"),
@@ -107,7 +109,8 @@ export const client = {
register: async (req: RegistrationRequest) => await axiosInstance.post("user/register", req), register: async (req: RegistrationRequest) => await axiosInstance.post("user/register", req),
initialSetup: async (req: InitialSetupRequest) => await axiosInstance.post("user/initialSetup", req), initialSetup: async (req: InitialSetupRequest) => await axiosInstance.post("user/initialSetup", req),
passwordReset: async (req: PasswordResetRequest) => await axiosInstance.post("user/passwordReset", req), passwordReset: async (req: PasswordResetRequest) => await axiosInstance.post("user/passwordReset", req),
passwordResetCallback: async (req: PasswordResetConfirmationRequest) => await axiosInstance.post("user/passwordResetCallback", req), passwordResetCallback: async (req: PasswordResetConfirmationRequest) =>
await axiosInstance.post("user/passwordResetCallback", req),
getSettings: async () => await axiosInstance.get<Settings>("user/settings"), getSettings: async () => await axiosInstance.get<Settings>("user/settings"),
saveSettings: async (settings: Settings) => await axiosInstance.post("user/settings", settings), saveSettings: async (settings: Settings) => await axiosInstance.post("user/settings", settings),
sendTestPushNotification: async (settings: PushNotificationSettings) => sendTestPushNotification: async (settings: PushNotificationSettings) =>
@@ -156,9 +159,13 @@ function isCommaFeedApplicationError(err: AxiosError): err is AxiosError<CommaFe
} }
function isMessageError(err: AxiosError): err is AxiosError<{ message: string }> { function isMessageError(err: AxiosError): err is AxiosError<{ message: string }> {
return !!err.response && !!err.response.data && typeof err.response.data === "object" && "message" in err.response.data return (
!!err.response && !!err.response.data && typeof err.response.data === "object" && "message" in err.response.data
)
} }
function isMessageArrayError(err: AxiosError): err is AxiosError<{ errors: string[] }> { function isMessageArrayError(err: AxiosError): err is AxiosError<{ errors: string[] }> {
return !!err.response && !!err.response.data && typeof err.response.data === "object" && "errors" in err.response.data return (
!!err.response && !!err.response.data && typeof err.response.data === "object" && "errors" in err.response.data
)
} }

View File

@@ -91,7 +91,6 @@ export const Constants = {
}, },
dom: { dom: {
entryId: (entry: Entry) => `entry-id-${entry.id}`, entryId: (entry: Entry) => `entry-id-${entry.id}`,
entryContextMenuId: (entry: Entry) => entry.id,
}, },
theme: { theme: {
defaultPrimaryColor: "orange", defaultPrimaryColor: "orange",

View File

@@ -89,6 +89,188 @@ describe("entries", () => {
expect(store.getState().entries.hasMore).toBe(false) expect(store.getState().entries.hasMore).toBe(false)
}) })
it("stops loading after an initial-load failure and allows a retry", async () => {
const response = {
data: {
entries: [{ id: "3" } as Entry],
hasMore: true,
name: "my-feed",
feedLink: "https://mysite.com/feed",
timestamp: 123,
},
} as AxiosResponse<Entries>
vi.mocked(client.feed.getEntries)
.mockRejectedValueOnce(new Error("Network error"))
.mockResolvedValueOnce(response)
const store = configureStore({ reducer: reducers })
const arg = { source: { type: "feed" as const, id: "feed-id" }, clearSearch: true }
const request = store.dispatch(loadEntries(arg))
expect(store.getState().entries.loading).toBe(true)
expect(loadEntries.rejected.match(await request)).toBe(true)
expect(store.getState().entries.loading).toBe(false)
expect(store.getState().entries.entries).toStrictEqual([])
expect(store.getState().entries.hasMore).toBe(true)
expect(loadEntries.fulfilled.match(await store.dispatch(loadEntries(arg)))).toBe(true)
expect(store.getState().entries.entries).toStrictEqual(response.data.entries)
expect(store.getState().entries.loading).toBe(false)
})
it("preserves entries after a pagination failure and allows a retry", async () => {
const response = {
data: {
entries: [{ id: "3", read: false } as Entry],
hasMore: true,
name: "my-feed",
feedLink: "https://mysite.com/feed",
timestamp: 123,
},
} as AxiosResponse<Entries>
vi.mocked(client.feed.getEntries)
.mockResolvedValueOnce(response)
.mockRejectedValueOnce(new Error("Network error"))
.mockResolvedValueOnce({
data: { ...response.data, entries: [{ id: "4" } as Entry], hasMore: false },
} as AxiosResponse<Entries>)
const store = configureStore({ reducer: reducers })
await store.dispatch(loadEntries({ source: { type: "feed", id: "feed-id" }, clearSearch: true }))
const previousState = store.getState().entries
const request = store.dispatch(loadMoreEntries())
expect(store.getState().entries.loading).toBe(true)
expect(loadMoreEntries.rejected.match(await request)).toBe(true)
expect(store.getState().entries.loading).toBe(false)
expect(store.getState().entries.entries).toStrictEqual(previousState.entries)
expect(store.getState().entries.hasMore).toBe(true)
expect(store.getState().entries.timestamp).toBe(123)
expect(store.getState().entries.sourceLabel).toBe("my-feed")
expect(store.getState().entries.sourceWebsiteUrl).toBe("https://mysite.com/feed")
expect(loadMoreEntries.fulfilled.match(await store.dispatch(loadMoreEntries()))).toBe(true)
expect(store.getState().entries.entries).toStrictEqual([{ id: "3", read: false }, { id: "4" }])
expect(store.getState().entries.hasMore).toBe(false)
expect(store.getState().entries.loading).toBe(false)
expect(vi.mocked(client.feed.getEntries).mock.calls[1][0]).toEqual(
vi.mocked(client.feed.getEntries).mock.calls[2][0]
)
})
describe.each(["initial load", "pagination"] as const)("overlapping %s requests", olderRequestType => {
it.each(["initial load", "pagination"] as const)(
"ignores an older failure while a newer %s is pending",
async newerRequestType => {
let rejectOlder!: (reason: Error) => void
vi.mocked(client.category.getEntries).mockReturnValueOnce(
new Promise<AxiosResponse<Entries>>((_, reject) => {
rejectOlder = reject
})
)
vi.mocked(client.category.getEntries).mockReturnValueOnce(new Promise<AxiosResponse<Entries>>(() => {}))
const store = configureStore({ reducer: reducers })
const arg = { source: { type: "category" as const, id: "all" }, clearSearch: true }
const older =
olderRequestType === "initial load"
? store.dispatch(loadEntries(arg))
: store.dispatch(loadMoreEntries())
const newer =
newerRequestType === "initial load"
? store.dispatch(loadEntries(arg))
: store.dispatch(loadMoreEntries())
rejectOlder(new Error("Older request failed"))
await older
expect(store.getState().entries.loading).toBe(true)
newer.abort()
await newer
expect(store.getState().entries.loading).toBe(false)
}
)
it("does not clear a newer request's loading state when an older request succeeds", async () => {
let resolveOlder!: (response: AxiosResponse<Entries>) => void
vi.mocked(client.category.getEntries).mockReturnValueOnce(
new Promise<AxiosResponse<Entries>>(resolve => {
resolveOlder = resolve
})
)
vi.mocked(client.category.getEntries).mockReturnValueOnce(new Promise<AxiosResponse<Entries>>(() => {}))
const store = configureStore({ reducer: reducers })
const arg = { source: { type: "category" as const, id: "all" }, clearSearch: true }
const older =
olderRequestType === "initial load"
? store.dispatch(loadEntries(arg))
: store.dispatch(loadMoreEntries())
const newer = store.dispatch(loadEntries(arg))
resolveOlder({
data: {
entries: [] as Entry[],
hasMore: true,
name: "old-category",
feedLink: "",
timestamp: 123,
errorCount: 0,
ignoredReadStatus: false,
},
} as AxiosResponse<Entries>)
await older
expect(store.getState().entries.loading).toBe(true)
newer.abort()
await newer
expect(store.getState().entries.loading).toBe(false)
})
it("ignores an older failure after the newer request succeeds", async () => {
let rejectOlder!: (reason: Error) => void
vi.mocked(client.category.getEntries).mockReturnValueOnce(
new Promise<AxiosResponse<Entries>>((_, reject) => {
rejectOlder = reject
})
)
vi.mocked(client.category.getEntries).mockResolvedValueOnce({
data: { entries: [{ id: "4" } as Entry], hasMore: false, name: "new-category", timestamp: 456 },
} as AxiosResponse<Entries>)
const store = configureStore({ reducer: reducers })
const arg = { source: { type: "category" as const, id: "all" }, clearSearch: true }
const older =
olderRequestType === "initial load"
? store.dispatch(loadEntries(arg))
: store.dispatch(loadMoreEntries())
await store.dispatch(loadEntries(arg))
const completedState = store.getState().entries
rejectOlder(new Error("Older request failed"))
await older
expect(store.getState().entries).toStrictEqual(completedState)
})
})
it("does not append entries already present when loading more entries", async () => {
vi.mocked(client.category.getEntries)
.mockResolvedValueOnce({
data: { entries: [{ id: "3" } as Entry], hasMore: true },
} as AxiosResponse<Entries>)
.mockResolvedValueOnce({
data: { entries: [{ id: "3" } as Entry, { id: "4" } as Entry], hasMore: false },
} as AxiosResponse<Entries>)
const store = configureStore({ reducer: reducers })
await store.dispatch(loadEntries({ source: { type: "category", id: "all" }, clearSearch: true }))
await store.dispatch(loadMoreEntries())
expect(store.getState().entries.entries).toStrictEqual([{ id: "3" }, { id: "4" }])
expect(store.getState().entries.loading).toBe(false)
expect(store.getState().entries.hasMore).toBe(false)
})
it("marks an entry as read", () => { it("marks an entry as read", () => {
const store = configureStore({ const store = configureStore({
reducer: reducers, reducer: reducers,
@@ -116,6 +298,30 @@ describe("entries", () => {
expect(client.entry.mark).toHaveBeenCalledWith({ id: "3", read: true }) expect(client.entry.mark).toHaveBeenCalledWith({ id: "3", read: true })
}) })
it("flags an entry marked as unread by the user until entries are reloaded", async () => {
vi.mocked(client.feed.getEntries).mockResolvedValue({
data: {
entries: [{ id: "3", read: true, markable: true } as Entry],
hasMore: false,
name: "my-feed",
errorCount: 0,
feedLink: "https://mysite.com/feed",
timestamp: 123,
ignoredReadStatus: false,
},
} as AxiosResponse<Entries>)
const store = configureStore({ reducer: reducers })
await store.dispatch(loadEntries({ source: { type: "feed", id: "feed-id" }, clearSearch: true }))
store.dispatch(markEntry({ entry: store.getState().entries.entries[0], read: false }))
expect(store.getState().entries.entries[0].keepUnread).toBe(true)
// reloading the entry list resets the flag
await store.dispatch(loadEntries({ source: { type: "feed", id: "feed-id" }, clearSearch: false }))
expect(store.getState().entries.entries[0].keepUnread).toBeUndefined()
})
it("marks all entries as read", () => { it("marks all entries as read", () => {
const store = configureStore({ const store = configureStore({
reducer: reducers, reducer: reducers,

View File

@@ -1,6 +1,14 @@
import { createSlice, type PayloadAction } from "@reduxjs/toolkit" import { createSlice, isAnyOf, type PayloadAction } from "@reduxjs/toolkit"
import { Constants } from "@/app/constants" import { Constants } from "@/app/constants"
import { loadEntries, loadMoreEntries, markAllEntries, markEntry, markMultipleEntries, starEntry, tagEntry } from "@/app/entries/thunks" import {
loadEntries,
loadMoreEntries,
markAllEntries,
markEntry,
markMultipleEntries,
starEntry,
tagEntry,
} from "@/app/entries/thunks"
import type { Entry } from "@/app/types" import type { Entry } from "@/app/types"
export type EntrySourceType = "category" | "feed" | "tag" export type EntrySourceType = "category" | "feed" | "tag"
@@ -10,7 +18,11 @@ export interface EntrySource {
id: string id: string
} }
export type ExpendableEntry = Entry & { expanded?: boolean } export type ExpendableEntry = Entry & {
expanded?: boolean
/** set when the user explicitly marks the entry as unread, prevents it from being marked as read again by scrolling in expanded mode until the entry list is reloaded */
keepUnread?: boolean
}
interface EntriesState { interface EntriesState {
/** selected source */ /** selected source */
@@ -26,6 +38,8 @@ interface EntriesState {
selectedEntryId?: string selectedEntryId?: string
hasMore: boolean hasMore: boolean
loading: boolean loading: boolean
/** identifies the request that owns the loading state */
currentRequestId?: string
search?: string search?: string
scrollingToEntry: boolean scrollingToEntry: boolean
markAllAsReadConfirmationDialogOpen: boolean markAllAsReadConfirmationDialogOpen: boolean
@@ -71,20 +85,26 @@ export const entriesSlice = createSlice({
builder.addCase(markEntry.pending, (state, action) => { builder.addCase(markEntry.pending, (state, action) => {
for (const e of state.entries.filter(e => e.id === action.meta.arg.entry.id)) { for (const e of state.entries.filter(e => e.id === action.meta.arg.entry.id)) {
e.read = action.meta.arg.read e.read = action.meta.arg.read
if (!action.meta.arg.read) e.keepUnread = true
} }
}) })
builder.addCase(markMultipleEntries.pending, (state, action) => { builder.addCase(markMultipleEntries.pending, (state, action) => {
for (const e of state.entries.filter(e => action.meta.arg.entries.some(e2 => e2.id === e.id))) { for (const e of state.entries.filter(e => action.meta.arg.entries.some(e2 => e2.id === e.id))) {
e.read = action.meta.arg.read e.read = action.meta.arg.read
if (!action.meta.arg.read) e.keepUnread = true
} }
}) })
builder.addCase(markAllEntries.pending, (state, action) => { builder.addCase(markAllEntries.pending, (state, action) => {
for (const e of state.entries.filter(e => (action.meta.arg.req.olderThan ? e.date < action.meta.arg.req.olderThan : true))) { for (const e of state.entries.filter(e =>
action.meta.arg.req.olderThan ? e.date < action.meta.arg.req.olderThan : true
)) {
e.read = true e.read = true
} }
}) })
builder.addCase(starEntry.pending, (state, action) => { builder.addCase(starEntry.pending, (state, action) => {
for (const e of state.entries.filter(e => action.meta.arg.entry.id === e.id && action.meta.arg.entry.feedId === e.feedId)) { for (const e of state.entries.filter(
e => action.meta.arg.entry.id === e.id && action.meta.arg.entry.feedId === e.feedId
)) {
e.starred = action.meta.arg.starred e.starred = action.meta.arg.starred
} }
}) })
@@ -97,9 +117,11 @@ export const entriesSlice = createSlice({
state.hasMore = true state.hasMore = true
state.selectedEntryId = undefined state.selectedEntryId = undefined
state.loading = true state.loading = true
state.currentRequestId = action.meta.requestId
}) })
builder.addCase(loadMoreEntries.pending, state => { builder.addCase(loadMoreEntries.pending, (state, action) => {
state.loading = true state.loading = true
state.currentRequestId = action.meta.requestId
}) })
builder.addCase(loadEntries.fulfilled, (state, action) => { builder.addCase(loadEntries.fulfilled, (state, action) => {
state.entries = action.payload.entries state.entries = action.payload.entries
@@ -107,20 +129,24 @@ export const entriesSlice = createSlice({
state.sourceLabel = action.payload.name state.sourceLabel = action.payload.name
state.sourceWebsiteUrl = action.payload.feedLink state.sourceWebsiteUrl = action.payload.feedLink
state.hasMore = action.payload.hasMore state.hasMore = action.payload.hasMore
state.loading = false
}) })
builder.addCase(loadMoreEntries.fulfilled, (state, action) => { builder.addCase(loadMoreEntries.fulfilled, (state, action) => {
// remove already existing entries // remove already existing entries
const entriesToAdd = action.payload.entries.filter(e => !state.entries.some(e2 => e.id === e2.id)) const entriesToAdd = action.payload.entries.filter(e => !state.entries.some(e2 => e.id === e2.id))
state.entries = [...state.entries, ...entriesToAdd] state.entries = [...state.entries, ...entriesToAdd]
state.hasMore = action.payload.hasMore state.hasMore = action.payload.hasMore
state.loading = false
}) })
builder.addCase(tagEntry.pending, (state, action) => { builder.addCase(tagEntry.pending, (state, action) => {
for (const e of state.entries.filter(e => +e.id === action.meta.arg.entryId)) { for (const e of state.entries.filter(e => +e.id === action.meta.arg.entryId)) {
e.tags = action.meta.arg.tags e.tags = action.meta.arg.tags
} }
}) })
builder.addMatcher(isAnyOf(loadEntries.settled, loadMoreEntries.settled), (state, action) => {
if (state.currentRequestId === action.meta.requestId) {
state.loading = false
state.currentRequestId = undefined
}
})
}, },
}) })

View File

@@ -40,7 +40,9 @@ export const loadMoreEntries = createAppAsyncThunk("entries/loadMore", async (_,
const state = thunkApi.getState() const state = thunkApi.getState()
const { source } = state.entries const { source } = state.entries
const offset = const offset =
state.user.settings?.readingMode === "all" || (source.type === "category" && source.id === "starred") state.user.settings?.readingMode === "all" ||
state.entries.search ||
(source.type === "category" && source.id === "starred")
? state.entries.entries.length ? state.entries.entries.length
: state.entries.entries.filter(e => !e.read).length : state.entries.entries.filter(e => !e.read).length
const endpoint = getEndpoint(state.entries.source.type) const endpoint = getEndpoint(state.entries.source.type)
@@ -124,8 +126,13 @@ export const markAllEntries = createAppAsyncThunk(
}, },
thunkApi thunkApi
) => { ) => {
const endpoint = arg.sourceType === "category" ? client.category.markEntries : client.feed.markEntries if (arg.sourceType === "tag") {
await endpoint(arg.req) await client.category.markEntries({ ...arg.req, id: Constants.categories.all.id, tag: arg.req.id })
} else if (arg.sourceType === "category") {
await client.category.markEntries(arg.req)
} else {
await client.feed.markEntries(arg.req)
}
thunkApi.dispatch(reloadEntries()) thunkApi.dispatch(reloadEntries())
thunkApi.dispatch(reloadTree()) thunkApi.dispatch(reloadTree())
} }
@@ -137,6 +144,7 @@ export const markAllAsReadWithConfirmationIfRequired = createAppAsyncThunk(
const state = thunkApi.getState() const state = thunkApi.getState()
const source = state.entries.source const source = state.entries.source
const entriesTimestamp = state.entries.timestamp ?? Date.now() const entriesTimestamp = state.entries.timestamp ?? Date.now()
const search = state.entries.search
const markAllAsReadConfirmation = state.user.settings?.markAllAsReadConfirmation const markAllAsReadConfirmation = state.user.settings?.markAllAsReadConfirmation
const markAllAsReadNavigateToNextUnread = state.user.settings?.markAllAsReadNavigateToNextUnread const markAllAsReadNavigateToNextUnread = state.user.settings?.markAllAsReadNavigateToNextUnread
@@ -151,6 +159,7 @@ export const markAllAsReadWithConfirmationIfRequired = createAppAsyncThunk(
read: true, read: true,
olderThan: Date.now(), olderThan: Date.now(),
insertedBefore: entriesTimestamp, insertedBefore: entriesTimestamp,
keywords: search,
}, },
}) })
) )
@@ -218,7 +227,9 @@ export const selectEntry = createAppAsyncThunk(
const entryIndex = state.entries.entries.indexOf(entry) const entryIndex = state.entries.entries.indexOf(entry)
const entriesToKeepOnTopWhenScrolling = const entriesToKeepOnTopWhenScrolling =
viewMode === "expanded" ? 0 : Math.min(state.user.settings?.entriesToKeepOnTopWhenScrolling ?? 0, entryIndex) viewMode === "expanded"
? 0
: Math.min(state.user.settings?.entriesToKeepOnTopWhenScrolling ?? 0, entryIndex)
const entryToScrollTo = state.entries.entries[entryIndex - entriesToKeepOnTopWhenScrolling] const entryToScrollTo = state.entries.entries[entryIndex - entriesToKeepOnTopWhenScrolling]
const entryElement = document.getElementById(Constants.dom.entryId(entry)) const entryElement = document.getElementById(Constants.dom.entryId(entry))
@@ -226,7 +237,8 @@ export const selectEntry = createAppAsyncThunk(
if (entryElement && entryElementToScrollTo) { if (entryElement && entryElementToScrollTo) {
const scrollMode = state.user.settings?.scrollMode const scrollMode = state.user.settings?.scrollMode
const entryEntirelyVisible = const entryEntirelyVisible =
Constants.layout.isTopVisible(entryElementToScrollTo) && Constants.layout.isBottomVisible(entryElement) Constants.layout.isTopVisible(entryElementToScrollTo) &&
Constants.layout.isBottomVisible(entryElement)
if (scrollMode === "always" || (scrollMode === "if_needed" && !entryEntirelyVisible)) { if (scrollMode === "always" || (scrollMode === "if_needed" && !entryEntirelyVisible)) {
const scrollSpeed = state.user.settings?.scrollSpeed const scrollSpeed = state.user.settings?.scrollSpeed
const margin = viewMode === "detailed" ? 8 : 3 const margin = viewMode === "detailed" ? 8 : 3
@@ -240,7 +252,12 @@ export const selectEntry = createAppAsyncThunk(
} }
) )
const scrollToEntry = (entryElement: HTMLElement, margin: number, scrollSpeed: number | undefined, onScrollEnded: () => void) => { const scrollToEntry = (
entryElement: HTMLElement,
margin: number,
scrollSpeed: number | undefined,
onScrollEnded: () => void
) => {
const header = document.getElementsByTagName("header").item(0)?.getBoundingClientRect() const header = document.getElementsByTagName("header").item(0)?.getBoundingClientRect()
const offset = (header?.bottom ?? 0) + margin const offset = (header?.bottom ?? 0) + margin
scrollToWithCallback({ scrollToWithCallback({

View File

@@ -2,11 +2,17 @@ import { createAppAsyncThunk } from "@/app/async-thunk"
import { Constants } from "@/app/constants" import { Constants } from "@/app/constants"
import { redirectTo } from "@/app/redirect/slice" import { redirectTo } from "@/app/redirect/slice"
export const redirectToLogin = createAppAsyncThunk("redirect/login", (_, thunkApi) => thunkApi.dispatch(redirectTo("/login"))) export const redirectToLogin = createAppAsyncThunk("redirect/login", (_, thunkApi) =>
thunkApi.dispatch(redirectTo("/login"))
)
export const redirectToRegistration = createAppAsyncThunk("redirect/register", (_, thunkApi) => thunkApi.dispatch(redirectTo("/register"))) export const redirectToRegistration = createAppAsyncThunk("redirect/register", (_, thunkApi) =>
thunkApi.dispatch(redirectTo("/register"))
)
export const redirectToInitialSetup = createAppAsyncThunk("redirect/initialSetup", (_, thunkApi) => thunkApi.dispatch(redirectTo("/setup"))) export const redirectToInitialSetup = createAppAsyncThunk("redirect/initialSetup", (_, thunkApi) =>
thunkApi.dispatch(redirectTo("/setup"))
)
export const redirectToApiDocumentation = createAppAsyncThunk("redirect/api", () => { export const redirectToApiDocumentation = createAppAsyncThunk("redirect/api", () => {
window.location.href = "api-documentation/" window.location.href = "api-documentation/"
@@ -38,15 +44,21 @@ export const redirectToFeedDetails = createAppAsyncThunk("redirect/feed/details"
thunkApi.dispatch(redirectTo(`/app/feed/${id}/details`)) thunkApi.dispatch(redirectTo(`/app/feed/${id}/details`))
) )
export const redirectToTag = createAppAsyncThunk("redirect/tag", (id: string, thunkApi) => thunkApi.dispatch(redirectTo(`/app/tag/${id}`))) export const redirectToTag = createAppAsyncThunk("redirect/tag", (id: string, thunkApi) =>
thunkApi.dispatch(redirectTo(`/app/tag/${id}`))
)
export const redirectToTagDetails = createAppAsyncThunk("redirect/tag/details", (id: string, thunkApi) => export const redirectToTagDetails = createAppAsyncThunk("redirect/tag/details", (id: string, thunkApi) =>
thunkApi.dispatch(redirectTo(`/app/tag/${id}/details`)) thunkApi.dispatch(redirectTo(`/app/tag/${id}/details`))
) )
export const redirectToAdd = createAppAsyncThunk("redirect/add", (_, thunkApi) => thunkApi.dispatch(redirectTo("/app/add"))) export const redirectToAdd = createAppAsyncThunk("redirect/add", (_, thunkApi) =>
thunkApi.dispatch(redirectTo("/app/add"))
)
export const redirectToSettings = createAppAsyncThunk("redirect/settings", (_, thunkApi) => thunkApi.dispatch(redirectTo("/app/settings"))) export const redirectToSettings = createAppAsyncThunk("redirect/settings", (_, thunkApi) =>
thunkApi.dispatch(redirectTo("/app/settings"))
)
export const redirectToAdminUsers = createAppAsyncThunk("redirect/admin/users", (_, thunkApi) => export const redirectToAdminUsers = createAppAsyncThunk("redirect/admin/users", (_, thunkApi) =>
thunkApi.dispatch(redirectTo("/app/admin/users")) thunkApi.dispatch(redirectTo("/app/admin/users"))
@@ -56,6 +68,10 @@ export const redirectToMetrics = createAppAsyncThunk("redirect/admin/metrics", (
thunkApi.dispatch(redirectTo("/app/admin/metrics")) thunkApi.dispatch(redirectTo("/app/admin/metrics"))
) )
export const redirectToDonate = createAppAsyncThunk("redirect/donate", (_, thunkApi) => thunkApi.dispatch(redirectTo("/app/donate"))) export const redirectToDonate = createAppAsyncThunk("redirect/donate", (_, thunkApi) =>
thunkApi.dispatch(redirectTo("/app/donate"))
)
export const redirectToAbout = createAppAsyncThunk("redirect/about", (_, thunkApi) => thunkApi.dispatch(redirectTo("/app/about"))) export const redirectToAbout = createAppAsyncThunk("redirect/about", (_, thunkApi) =>
thunkApi.dispatch(redirectTo("/app/about"))
)

View File

@@ -1,4 +1,7 @@
import { createAppAsyncThunk } from "@/app/async-thunk" import { createAppAsyncThunk } from "@/app/async-thunk"
import { client } from "@/app/client" import { client } from "@/app/client"
export const reloadServerInfos = createAppAsyncThunk("server/infos", async () => await client.server.getServerInfos().then(r => r.data)) export const reloadServerInfos = createAppAsyncThunk(
"server/infos",
async () => await client.server.getServerInfos().then(r => r.data)
)

View File

@@ -41,4 +41,5 @@ export type AppDispatch = typeof store.dispatch
export const useAppDispatch: () => AppDispatch = useDispatch export const useAppDispatch: () => AppDispatch = useDispatch
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector
export const useShallowEqualAppSelector: TypedUseSelectorHook<RootState> = selector => useSelector(selector, shallowEqual) export const useShallowEqualAppSelector: TypedUseSelectorHook<RootState> = selector =>
useSelector(selector, shallowEqual)

View File

@@ -6,7 +6,10 @@ import { incrementUnreadCount } from "@/app/tree/slice"
import type { CollapseRequest, Subscription } from "@/app/types" import type { CollapseRequest, Subscription } from "@/app/types"
import { flattenCategoryTree, visitCategoryTree } from "@/app/utils" import { flattenCategoryTree, visitCategoryTree } from "@/app/utils"
export const reloadTree = createAppAsyncThunk("tree/reload", async () => await client.category.getRoot().then(r => r.data)) export const reloadTree = createAppAsyncThunk(
"tree/reload",
async () => await client.category.getRoot().then(r => r.data)
)
export const collapseTreeCategory = createAppAsyncThunk( export const collapseTreeCategory = createAppAsyncThunk(
"tree/category/collapse", "tree/category/collapse",

View File

@@ -147,6 +147,7 @@ export interface MarkRequest {
insertedBefore?: number insertedBefore?: number
keywords?: string keywords?: string
excludedSubscriptions?: number[] excludedSubscriptions?: number[]
tag?: string
} }
export interface MetricCounter { export interface MetricCounter {

View File

@@ -2,14 +2,26 @@ import { createAppAsyncThunk } from "@/app/async-thunk"
import { client } from "@/app/client" import { client } from "@/app/client"
import type { Settings } from "@/app/types" import type { Settings } from "@/app/types"
export const reloadSettings = createAppAsyncThunk("settings/reload", async () => await client.user.getSettings().then(r => r.data)) export const reloadSettings = createAppAsyncThunk(
"settings/reload",
async () => await client.user.getSettings().then(r => r.data)
)
export const reloadProfile = createAppAsyncThunk("profile/reload", async () => await client.user.getProfile().then(r => r.data)) export const reloadProfile = createAppAsyncThunk(
"profile/reload",
async () => await client.user.getProfile().then(r => r.data)
)
export const reloadTags = createAppAsyncThunk("entries/tags", async () => await client.entry.getTags().then(r => r.data)) export const reloadTags = createAppAsyncThunk(
"entries/tags",
async () => await client.entry.getTags().then(r => r.data)
)
export const changeSettings = createAppAsyncThunk("settings/change", async (newSettings: Partial<Settings>, thunkApi) => { export const changeSettings = createAppAsyncThunk(
const { settings } = thunkApi.getState().user "settings/change",
if (!settings) return async (newSettings: Partial<Settings>, thunkApi) => {
await client.user.saveSettings({ ...settings, ...newSettings }) const { settings } = thunkApi.getState().user
}) if (!settings) return
await client.user.saveSettings({ ...settings, ...newSettings })
}
)

View File

@@ -43,13 +43,27 @@ export function categoryHasNewEntries(category?: TreeCategory): boolean {
.some(f => f.hasNewEntries) .some(f => f.hasNewEntries)
} }
export const calculatePlaceholderSize = ({ width, height, maxWidth }: { width?: number; height?: number; maxWidth: number }) => { export const calculatePlaceholderSize = ({
width,
height,
maxWidth,
}: {
width?: number
height?: number
maxWidth: number
}) => {
const placeholderWidth = width && Math.min(width, maxWidth) const placeholderWidth = width && Math.min(width, maxWidth)
const placeholderHeight = height && width && width > maxWidth ? height * (maxWidth / width) : height const placeholderHeight = height && width && width > maxWidth ? height * (maxWidth / width) : height
return { width: placeholderWidth, height: placeholderHeight } return { width: placeholderWidth, height: placeholderHeight }
} }
export const scrollToWithCallback = ({ options, onScrollEnded }: { options: ScrollToOptions; onScrollEnded: () => void }) => { export const scrollToWithCallback = ({
options,
onScrollEnded,
}: {
options: ScrollToOptions
onScrollEnded: () => void
}) => {
const offset = (options.top ?? 0).toFixed() const offset = (options.top ?? 0).toFixed()
const onScroll = throttle(100, () => { const onScroll = throttle(100, () => {

View File

@@ -1,6 +1,14 @@
import type { MessageDescriptor } from "@lingui/core" import type { MessageDescriptor } from "@lingui/core"
import { useLingui } from "@lingui/react" import { useLingui } from "@lingui/react"
import { ActionIcon, type ActionIconVariant, Box, Button, type ButtonVariant, Tooltip, useMantineTheme } from "@mantine/core" import {
ActionIcon,
type ActionIconVariant,
Box,
Button,
type ButtonVariant,
Tooltip,
useMantineTheme,
} from "@mantine/core"
import { forwardRef, type MouseEventHandler, type ReactNode } from "react" import { forwardRef, type MouseEventHandler, type ReactNode } from "react"
import { Constants } from "@/app/constants" import { Constants } from "@/app/constants"
import { useActionButton } from "@/hooks/useActionButton" import { useActionButton } from "@/hooks/useActionButton"

View File

@@ -13,7 +13,10 @@ export function MarkAllAsReadConfirmationDialog() {
const source = useAppSelector(state => state.entries.source) const source = useAppSelector(state => state.entries.source)
const sourceLabel = useAppSelector(state => state.entries.sourceLabel) const sourceLabel = useAppSelector(state => state.entries.sourceLabel)
const entriesTimestamp = useAppSelector(state => state.entries.timestamp) ?? Date.now() const entriesTimestamp = useAppSelector(state => state.entries.timestamp) ?? Date.now()
const markAllAsReadNavigateToNextUnread = useAppSelector(state => state.user.settings?.markAllAsReadNavigateToNextUnread) const search = useAppSelector(state => state.entries.search)
const markAllAsReadNavigateToNextUnread = useAppSelector(
state => state.user.settings?.markAllAsReadNavigateToNextUnread
)
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const onConfirm = async () => { const onConfirm = async () => {
@@ -26,12 +29,14 @@ export function MarkAllAsReadConfirmationDialog() {
read: true, read: true,
olderThan: Date.now() - threshold * 24 * 60 * 60 * 1000, olderThan: Date.now() - threshold * 24 * 60 * 60 * 1000,
insertedBefore: entriesTimestamp, insertedBefore: entriesTimestamp,
keywords: search,
}, },
}) })
) )
const isAllCategorySelected = source.type === "category" && source.id === Constants.categories.all.id const isAllCategorySelected = source.type === "category" && source.id === Constants.categories.all.id
if (markAllAsReadNavigateToNextUnread && !isAllCategorySelected) await dispatch(selectNextUnreadTreeItem({ direction: "forward" })) if (markAllAsReadNavigateToNextUnread && !isAllCategorySelected)
await dispatch(selectNextUnreadTreeItem({ direction: "forward" }))
} }
return ( return (
@@ -49,7 +54,8 @@ export function MarkAllAsReadConfirmationDialog() {
)} )}
{threshold > 0 && ( {threshold > 0 && (
<Trans> <Trans>
Are you sure you want to mark entries older than {threshold} days of <Code>{sourceLabel}</Code> as read? Are you sure you want to mark entries older than {threshold} days of{" "}
<Code>{sourceLabel}</Code> as read?
</Trans> </Trans>
)} )}
</Text> </Text>

View File

@@ -15,5 +15,12 @@ export const ReceivePushNotificationsChechbox = (props: CheckboxProps) => {
description = <Trans>Push notifications are not configured in your user settings.</Trans> description = <Trans>Push notifications are not configured in your user settings.</Trans>
} }
return <Checkbox label={<Trans>Receive push notifications</Trans>} disabled={disabled} description={description} {...props} /> return (
<Checkbox
label={<Trans>Receive push notifications</Trans>}
disabled={disabled}
description={description}
{...props}
/>
)
} }

View File

@@ -34,7 +34,11 @@ export function UserEdit(props: Readonly<UserEditProps>) {
<form onSubmit={form.onSubmit(saveUser.execute)}> <form onSubmit={form.onSubmit(saveUser.execute)}>
<Stack> <Stack>
<TextInput label={<Trans>Name</Trans>} {...form.getInputProps("name")} required /> <TextInput label={<Trans>Name</Trans>} {...form.getInputProps("name")} required />
<PasswordInput label={<Trans>Password</Trans>} {...form.getInputProps("password")} required={!props.user} /> <PasswordInput
label={<Trans>Password</Trans>}
{...form.getInputProps("password")}
required={!props.user}
/>
<TextInput type="email" label={<Trans>E-mail</Trans>} {...form.getInputProps("email")} /> <TextInput type="email" label={<Trans>E-mail</Trans>} {...form.getInputProps("email")} />
<Checkbox label={<Trans>Admin</Trans>} {...form.getInputProps("admin", { type: "checkbox" })} /> <Checkbox label={<Trans>Admin</Trans>} {...form.getInputProps("admin", { type: "checkbox" })} />
<Checkbox label={<Trans>Enabled</Trans>} {...form.getInputProps("enabled", { type: "checkbox" })} /> <Checkbox label={<Trans>Enabled</Trans>} {...form.getInputProps("enabled", { type: "checkbox" })} />

View File

@@ -15,7 +15,9 @@ describe("Content component", () => {
}) })
it("renders iframe tag when included in content", () => { it("renders iframe tag when included in content", () => {
const { container } = render(<Content content='<iframe src="https://example.com"></iframe>' />, { wrapper: MantineProvider }) const { container } = render(<Content content='<iframe src="https://example.com"></iframe>' />, {
wrapper: MantineProvider,
})
expect(container.querySelector("iframe")).toHaveAttribute("src", "https://example.com") expect(container.querySelector("iframe")).toHaveAttribute("src", "https://example.com")
}) })

View File

@@ -1,6 +1,14 @@
import { Box, Mark } from "@mantine/core" import { Box, Mark } from "@mantine/core"
import escapeStringRegexp from "escape-string-regexp" import escapeStringRegexp from "escape-string-regexp"
import { ALLOWED_TAG_LIST, type ChildrenNode, Interweave, Matcher, type MatchResponse, type Node, type TransformCallback } from "interweave" import {
ALLOWED_TAG_LIST,
type ChildrenNode,
Interweave,
Matcher,
type MatchResponse,
type Node,
type TransformCallback,
} from "interweave"
import React from "react" import React from "react"
import styleToObject from "style-to-object" import styleToObject from "style-to-object"
import { Constants } from "@/app/constants" import { Constants } from "@/app/constants"
@@ -98,7 +106,14 @@ const Content = React.memo((props: ContentProps) => {
return ( return (
<BasicHtmlStyles> <BasicHtmlStyles>
<Box className={classes.content}> <Box className={classes.content}>
<Interweave content={props.content} transform={transform} matchers={matchers} allowList={allowList} /> <Interweave
content={props.content}
transform={transform}
matchers={matchers}
allowList={allowList}
// attributes are already sanitized server-side
allowAttributes
/>
</Box> </Box>
</BasicHtmlStyles> </BasicHtmlStyles>
) )

View File

@@ -1,8 +1,7 @@
import { Trans } from "@lingui/react/macro" import { Trans } from "@lingui/react/macro"
import { Box } from "@mantine/core" import { Box } from "@mantine/core"
import { openModal } from "@mantine/modals" import { openModal } from "@mantine/modals"
import { useEffect } from "react" import { useEffect, useState } from "react"
import { useContextMenu } from "react-contexify"
import InfiniteScroll from "react-infinite-scroller" import InfiniteScroll from "react-infinite-scroller"
import { throttle } from "throttle-debounce" import { throttle } from "throttle-debounce"
import { Constants } from "@/app/constants" import { Constants } from "@/app/constants"
@@ -35,7 +34,6 @@ export function FeedEntries() {
const scrollMarks = useAppSelector(state => state.user.settings?.scrollMarks) const scrollMarks = useAppSelector(state => state.user.settings?.scrollMarks)
const scrollingToEntry = useAppSelector(state => state.entries.scrollingToEntry) const scrollingToEntry = useAppSelector(state => state.entries.scrollingToEntry)
const sidebarVisible = useAppSelector(state => state.tree.sidebarVisible) const sidebarVisible = useAppSelector(state => state.tree.sidebarVisible)
const customContextMenu = useAppSelector(state => state.user.settings?.customContextMenu)
const viewMode = useAppSelector(state => state.user.localSettings.viewMode) const viewMode = useAppSelector(state => state.user.localSettings.viewMode)
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const { openLinkInBackgroundTab } = useBrowserExtension() const { openLinkInBackgroundTab } = useBrowserExtension()
@@ -62,17 +60,6 @@ export function FeedEntries() {
} }
} }
const contextMenu = useContextMenu()
const headerRightClicked = (entry: ExpendableEntry, event: React.MouseEvent) => {
if (event.shiftKey || !customContextMenu) return
event.preventDefault()
contextMenu.show({
id: Constants.dom.entryContextMenuId(entry),
event,
})
}
const bodyClicked = (entry: ExpendableEntry) => { const bodyClicked = (entry: ExpendableEntry) => {
if (viewMode !== "expanded") return if (viewMode !== "expanded") return
@@ -91,12 +78,22 @@ export function FeedEntries() {
const swipedLeft = async (entry: ExpendableEntry) => await dispatch(markEntry({ entry, read: !entry.read })) const swipedLeft = async (entry: ExpendableEntry) => await dispatch(markEntry({ entry, read: !entry.read }))
// only one context menu can be opened at a time
const [contextMenuEntryId, setContextMenuEntryId] = useState<string>()
const contextMenuChanged = (entry: ExpendableEntry, opened: boolean) =>
setContextMenuEntryId(current => {
if (opened) return entry.id
return current === entry.id ? undefined : current
})
// close context menu on scroll // close context menu on scroll
useEffect(() => { useEffect(() => {
const listener = throttle(100, () => contextMenu.hideAll()) if (!contextMenuEntryId) return
const listener = throttle(100, () => setContextMenuEntryId(undefined))
window.addEventListener("scroll", listener) window.addEventListener("scroll", listener)
return () => window.removeEventListener("scroll", listener) return () => window.removeEventListener("scroll", listener)
}, [contextMenu]) }, [contextMenuEntryId])
useEffect(() => { useEffect(() => {
const listener = throttle(100, () => { const listener = throttle(100, () => {
@@ -111,12 +108,13 @@ export function FeedEntries() {
const el = document.getElementById(Constants.dom.entryId(e)) const el = document.getElementById(Constants.dom.entryId(e))
return el && !Constants.layout.isTopVisible(el) return el && !Constants.layout.isTopVisible(el)
}) })
if (currentEntry) { if (currentEntry && currentEntry.id !== selectedEntryId) {
dispatch( dispatch(
selectEntry({ selectEntry({
entry: currentEntry, entry: currentEntry,
expand: false, expand: false,
markAsRead: !!scrollMarks, // don't mark as read entries that the user explicitly marked as unread
markAsRead: !!scrollMarks && !currentEntry.keepUnread,
scrollToEntry: false, scrollToEntry: false,
}) })
) )
@@ -124,7 +122,7 @@ export function FeedEntries() {
}) })
window.addEventListener("scroll", listener) window.addEventListener("scroll", listener)
return () => window.removeEventListener("scroll", listener) return () => window.removeEventListener("scroll", listener)
}, [dispatch, entries, viewMode, scrollMarks, scrollingToEntry]) }, [dispatch, entries, viewMode, scrollMarks, scrollingToEntry, selectedEntryId])
useMousetrap("r", async () => await dispatch(reloadEntries())) useMousetrap("r", async () => await dispatch(reloadEntries()))
useMousetrap( useMousetrap(
@@ -299,12 +297,15 @@ export function FeedEntries() {
entry={entry} entry={entry}
expanded={!!entry.expanded || viewMode === "expanded"} expanded={!!entry.expanded || viewMode === "expanded"}
selected={entry.id === selectedEntryId} selected={entry.id === selectedEntryId}
showSelectionIndicator={entry.id === selectedEntryId && (!entry.expanded || viewMode === "expanded")} showSelectionIndicator={
entry.id === selectedEntryId && (!entry.expanded || viewMode === "expanded")
}
maxWidth={sidebarVisible ? Constants.layout.entryMaxWidth : undefined} maxWidth={sidebarVisible ? Constants.layout.entryMaxWidth : undefined}
onHeaderClick={event => headerClicked(entry, event)} onHeaderClick={event => headerClicked(entry, event)}
onHeaderRightClick={event => headerRightClicked(entry, event)}
onBodyClick={() => bodyClicked(entry)} onBodyClick={() => bodyClicked(entry)}
onSwipedLeft={async () => await swipedLeft(entry)} onSwipedLeft={async () => await swipedLeft(entry)}
contextMenuOpened={entry.id === contextMenuEntryId}
onContextMenuChange={opened => contextMenuChanged(entry, opened)}
/> />
))} ))}
</InfiniteScroll> </InfiniteScroll>

View File

@@ -19,9 +19,10 @@ interface FeedEntryProps {
showSelectionIndicator: boolean showSelectionIndicator: boolean
maxWidth?: number maxWidth?: number
onHeaderClick: (e: React.MouseEvent) => void onHeaderClick: (e: React.MouseEvent) => void
onHeaderRightClick: (e: React.MouseEvent) => void
onBodyClick: (e: React.MouseEvent) => void onBodyClick: (e: React.MouseEvent) => void
onSwipedLeft: () => void onSwipedLeft: () => void
contextMenuOpened: boolean
onContextMenuChange: (opened: boolean) => void
} }
const useStyles = tss const useStyles = tss
@@ -34,67 +35,80 @@ const useStyles = tss
maxWidth?: number maxWidth?: number
fontSizePercentage: number fontSizePercentage: number
}>() }>()
.create(({ theme, colorScheme, read, expanded, viewMode, rtl, showSelectionIndicator, maxWidth, fontSizePercentage }) => { .create(
let backgroundColor: string ({
if (colorScheme === "dark") { theme,
backgroundColor = read ? "inherit" : theme.colors.dark[5] colorScheme,
} else { read,
backgroundColor = read && !expanded ? theme.colors.gray[0] : "inherit" expanded,
} viewMode,
rtl,
showSelectionIndicator,
maxWidth,
fontSizePercentage,
}) => {
let backgroundColor: string
if (colorScheme === "dark") {
backgroundColor = read ? "inherit" : theme.colors.dark[5]
} else {
backgroundColor = read && !expanded ? theme.colors.gray[0] : "inherit"
}
let marginY = 10 let marginY = 10
if (viewMode === "title") { if (viewMode === "title") {
marginY = 2 marginY = 2
} else if (viewMode === "cozy") { } else if (viewMode === "cozy") {
marginY = 6 marginY = 6
} }
let mobileMarginY = 6 let mobileMarginY = 6
if (viewMode === "title") { if (viewMode === "title") {
mobileMarginY = 2 mobileMarginY = 2
} else if (viewMode === "cozy") { } else if (viewMode === "cozy") {
mobileMarginY = 4 mobileMarginY = 4
} }
let backgroundHoverColor = backgroundColor let backgroundHoverColor = backgroundColor
if (!expanded && !read) { if (!expanded && !read) {
backgroundHoverColor = colorScheme === "dark" ? theme.colors.dark[6] : theme.colors.gray[1] backgroundHoverColor = colorScheme === "dark" ? theme.colors.dark[6] : theme.colors.gray[1]
} }
let paperBorderLeftColor = "" let paperBorderLeftColor = ""
if (showSelectionIndicator) { if (showSelectionIndicator) {
const borderLeftColor = colorScheme === "dark" ? theme.colors[theme.primaryColor][4] : theme.colors[theme.primaryColor][6] const borderLeftColor =
paperBorderLeftColor = `${borderLeftColor} !important` colorScheme === "dark" ? theme.colors[theme.primaryColor][4] : theme.colors[theme.primaryColor][6]
} paperBorderLeftColor = `${borderLeftColor} !important`
}
return { return {
paper: { paper: {
backgroundColor, backgroundColor,
borderLeftColor: paperBorderLeftColor, borderLeftColor: paperBorderLeftColor,
marginTop: marginY, marginTop: marginY,
marginBottom: marginY, marginBottom: marginY,
[`@media (max-width: ${Constants.layout.mobileBreakpoint}px)`]: { [`@media (max-width: ${Constants.layout.mobileBreakpoint}px)`]: {
marginTop: mobileMarginY, marginTop: mobileMarginY,
marginBottom: mobileMarginY, marginBottom: mobileMarginY,
}, },
"@media (hover: hover)": { "@media (hover: hover)": {
"&:hover": { "&:hover": {
backgroundColor: backgroundHoverColor, backgroundColor: backgroundHoverColor,
},
}, },
}, },
}, headerLink: {
headerLink: { fontSize: `${fontSizePercentage}%`,
fontSize: `${fontSizePercentage}%`, color: "inherit",
color: "inherit", textDecoration: "none",
textDecoration: "none", },
}, body: {
body: { fontSize: `${fontSizePercentage}%`,
fontSize: `${fontSizePercentage}%`, direction: rtl ? "rtl" : "ltr",
direction: rtl ? "rtl" : "ltr", maxWidth: maxWidth ?? "100%",
maxWidth: maxWidth ?? "100%", },
}, }
} }
}) )
export function FeedEntry(props: Readonly<FeedEntryProps>) { export function FeedEntry(props: Readonly<FeedEntryProps>) {
const viewMode = useAppSelector(state => state.user.localSettings.viewMode) const viewMode = useAppSelector(state => state.user.localSettings.viewMode)
@@ -116,7 +130,9 @@ export function FeedEntry(props: Readonly<FeedEntryProps>) {
const showExternalLinkIcon = const showExternalLinkIcon =
externalLinkDisplayMode && ["always", mobile ? "on_mobile" : "on_desktop"].includes(externalLinkDisplayMode) externalLinkDisplayMode && ["always", mobile ? "on_mobile" : "on_desktop"].includes(externalLinkDisplayMode)
const showStarIcon = const showStarIcon =
props.entry.markable && starIconDisplayMode && ["always", mobile ? "on_mobile" : "on_desktop"].includes(starIconDisplayMode) props.entry.markable &&
starIconDisplayMode &&
["always", mobile ? "on_mobile" : "on_desktop"].includes(starIconDisplayMode)
const swipeHandlers = useSwipeable({ const swipeHandlers = useSwipeable({
onSwipedLeft: props.onSwipedLeft, onSwipedLeft: props.onSwipedLeft,
@@ -156,33 +172,42 @@ export function FeedEntry(props: Readonly<FeedEntryProps>) {
"show-selection-indicator": props.showSelectionIndicator, "show-selection-indicator": props.showSelectionIndicator,
})} })}
> >
<a <FeedEntryContextMenu
className={classes.headerLink} entry={props.entry}
href={props.entry.url} opened={props.contextMenuOpened}
target="_blank" onChange={props.onContextMenuChange}
rel="noreferrer"
onClick={props.onHeaderClick}
onAuxClick={props.onHeaderClick}
onContextMenu={props.onHeaderRightClick}
> >
<Box px={paddingX} py={paddingY} {...swipeHandlers}> <a
{compactHeader && ( className={classes.headerLink}
<FeedEntryCompactHeader href={props.entry.url}
entry={props.entry} target="_blank"
showStarIcon={showStarIcon} rel="noreferrer"
showExternalLinkIcon={showExternalLinkIcon} onClick={props.onHeaderClick}
/> onAuxClick={props.onHeaderClick}
)} onContextMenuCapture={e => {
{!compactHeader && ( // keep the browser context menu when shift is pressed
<FeedEntryHeader if (e.shiftKey) e.stopPropagation()
entry={props.entry} }}
expanded={props.expanded} >
showStarIcon={showStarIcon} <Box px={paddingX} py={paddingY} {...swipeHandlers}>
showExternalLinkIcon={showExternalLinkIcon} {compactHeader && (
/> <FeedEntryCompactHeader
)} entry={props.entry}
</Box> showStarIcon={showStarIcon}
</a> showExternalLinkIcon={showExternalLinkIcon}
/>
)}
{!compactHeader && (
<FeedEntryHeader
entry={props.entry}
expanded={props.expanded}
showStarIcon={showStarIcon}
showExternalLinkIcon={showExternalLinkIcon}
/>
)}
</Box>
</a>
</FeedEntryContextMenu>
{props.expanded && ( {props.expanded && (
<Box px={paddingX} pb={paddingY} onClick={props.onBodyClick}> <Box px={paddingX} pb={paddingY} onClick={props.onBodyClick}>
<Box className={`${classes.body} cf-content`}> <Box className={`${classes.body} cf-content`}>
@@ -192,8 +217,6 @@ export function FeedEntry(props: Readonly<FeedEntryProps>) {
<FeedEntryFooter entry={props.entry} /> <FeedEntryFooter entry={props.entry} />
</Box> </Box>
)} )}
<FeedEntryContextMenu entry={props.entry} />
</Paper> </Paper>
) )
} }

View File

@@ -1,105 +1,92 @@
import { Trans } from "@lingui/react/macro" import { Trans } from "@lingui/react/macro"
import { Group } from "@mantine/core" import { Menu } from "@mantine/core"
import { Item, Menu, Separator } from "react-contexify" import type { ReactElement } from "react"
import { TbArrowBarToDown, TbExternalLink, TbMail, TbMailOpened, TbRss, TbStar, TbStarOff } from "react-icons/tb" import { TbArrowBarToDown, TbExternalLink, TbMail, TbMailOpened, TbRss, TbStar, TbStarOff } from "react-icons/tb"
import { Constants } from "@/app/constants"
import { markEntriesUpToEntry, markEntry, starEntry } from "@/app/entries/thunks" import { markEntriesUpToEntry, markEntry, starEntry } from "@/app/entries/thunks"
import { redirectToFeed } from "@/app/redirect/thunks" import { redirectToFeed } from "@/app/redirect/thunks"
import { useAppDispatch, useAppSelector } from "@/app/store" import { useAppDispatch, useAppSelector } from "@/app/store"
import type { Entry } from "@/app/types" import type { Entry } from "@/app/types"
import { truncate } from "@/app/utils" import { truncate } from "@/app/utils"
import { useBrowserExtension } from "@/hooks/useBrowserExtension" import { useBrowserExtension } from "@/hooks/useBrowserExtension"
import { useColorScheme } from "@/hooks/useColorScheme"
import { tss } from "@/tss"
interface FeedEntryContextMenuProps { interface FeedEntryContextMenuProps {
entry: Entry entry: Entry
opened: boolean
onChange: (opened: boolean) => void
// element that opens the menu when right-clicked
children: ReactElement
} }
const iconSize = 16 const iconSize = 16
const useStyles = tss.create(({ theme, colorScheme }) => ({
menu: {
// apply mantine theme from MenuItem.styles.ts
fontSize: theme.fontSizes.sm,
"--contexify-item-color": `${colorScheme === "dark" ? theme.colors.dark[0] : theme.black} !important`,
"--contexify-activeItem-color": `${colorScheme === "dark" ? theme.colors.dark[0] : theme.black} !important`,
"--contexify-activeItem-bgColor": `${colorScheme === "dark" ? theme.colors.dark[4] : theme.colors.gray[1]} !important`,
},
}))
export function FeedEntryContextMenu(props: Readonly<FeedEntryContextMenuProps>) { export function FeedEntryContextMenu(props: Readonly<FeedEntryContextMenuProps>) {
const colorScheme = useColorScheme() const customContextMenu = useAppSelector(state => state.user.settings?.customContextMenu)
const { classes } = useStyles()
const sourceType = useAppSelector(state => state.entries.source.type) const sourceType = useAppSelector(state => state.entries.source.type)
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
const { openLinkInBackgroundTab } = useBrowserExtension() const { openLinkInBackgroundTab } = useBrowserExtension()
return ( return (
<Menu id={Constants.dom.entryContextMenuId(props.entry)} theme={colorScheme} animation={false} className={classes.menu}> <Menu position="bottom-start" opened={props.opened} onChange={props.onChange}>
<Item <Menu.ContextMenu disabled={!customContextMenu}>{props.children}</Menu.ContextMenu>
onClick={() => { <Menu.Dropdown>
window.open(props.entry.url, "_blank", "noreferrer") <Menu.Item
dispatch(markEntry({ entry: props.entry, read: true })) leftSection={<TbExternalLink size={iconSize} />}
}} onClick={() => {
> window.open(props.entry.url, "_blank", "noreferrer")
<Group> dispatch(markEntry({ entry: props.entry, read: true }))
<TbExternalLink size={iconSize} /> }}
>
<Trans>Open link in new tab</Trans> <Trans>Open link in new tab</Trans>
</Group> </Menu.Item>
</Item> <Menu.Item
<Item leftSection={<TbExternalLink size={iconSize} />}
onClick={() => { onClick={() => {
openLinkInBackgroundTab(props.entry.url) openLinkInBackgroundTab(props.entry.url)
dispatch(markEntry({ entry: props.entry, read: true })) dispatch(markEntry({ entry: props.entry, read: true }))
}} }}
> >
<Group>
<TbExternalLink size={iconSize} />
<Trans>Open link in new background tab</Trans> <Trans>Open link in new background tab</Trans>
</Group> </Menu.Item>
</Item>
<Separator /> <Menu.Divider />
{props.entry.markable && ( {props.entry.markable && (
<> <Menu.Item
<Item onClick={async () => await dispatch(starEntry({ entry: props.entry, starred: !props.entry.starred }))}> leftSection={props.entry.starred ? <TbStarOff size={iconSize} /> : <TbStar size={iconSize} />}
<Group> onClick={async () =>
{props.entry.starred ? <TbStarOff size={iconSize} /> : <TbStar size={iconSize} />} await dispatch(starEntry({ entry: props.entry, starred: !props.entry.starred }))
{props.entry.starred ? <Trans>Unstar</Trans> : <Trans>Star</Trans>} }
</Group> >
</Item> {props.entry.starred ? <Trans>Unstar</Trans> : <Trans>Star</Trans>}
<Item onClick={async () => await dispatch(markEntry({ entry: props.entry, read: !props.entry.read }))}> </Menu.Item>
<Group> )}
{props.entry.read ? <TbMail size={iconSize} /> : <TbMailOpened size={iconSize} />} {props.entry.markable && (
{props.entry.read ? <Trans>Keep unread</Trans> : <Trans>Mark as read</Trans>} <Menu.Item
</Group> leftSection={props.entry.read ? <TbMail size={iconSize} /> : <TbMailOpened size={iconSize} />}
</Item> onClick={async () => await dispatch(markEntry({ entry: props.entry, read: !props.entry.read }))}
</> >
)} {props.entry.read ? <Trans>Keep unread</Trans> : <Trans>Mark as read</Trans>}
<Item onClick={async () => await dispatch(markEntriesUpToEntry(props.entry))}> </Menu.Item>
<Group> )}
<TbArrowBarToDown size={iconSize} /> <Menu.Item
leftSection={<TbArrowBarToDown size={iconSize} />}
onClick={async () => await dispatch(markEntriesUpToEntry(props.entry))}
>
<Trans>Mark as read up to here</Trans> <Trans>Mark as read up to here</Trans>
</Group> </Menu.Item>
</Item>
{sourceType === "category" && ( {sourceType === "category" && <Menu.Divider />}
<> {sourceType === "category" && (
<Separator /> <Menu.Item
leftSection={<TbRss size={iconSize} />}
<Item
onClick={() => { onClick={() => {
dispatch(redirectToFeed(props.entry.feedId)) dispatch(redirectToFeed(props.entry.feedId))
}} }}
> >
<Group> <Trans>Go to {truncate(props.entry.feedName, 30)}</Trans>
<TbRss size={iconSize} /> </Menu.Item>
<Trans>Go to {truncate(props.entry.feedName, 30)}</Trans> )}
</Group> </Menu.Dropdown>
</Item>
</>
)}
</Menu> </Menu>
) )
} }

View File

@@ -1,7 +1,16 @@
import { msg } from "@lingui/core/macro" import { msg } from "@lingui/core/macro"
import { useLingui } from "@lingui/react" import { useLingui } from "@lingui/react"
import { Group, Indicator, Popover, TagsInput } from "@mantine/core" import { Group, Indicator, Popover, TagsInput } from "@mantine/core"
import { TbArrowBarToDown, TbExternalLink, TbMail, TbMailOpened, TbShare, TbStar, TbStarOff, TbTag } from "react-icons/tb" import {
TbArrowBarToDown,
TbExternalLink,
TbMail,
TbMailOpened,
TbShare,
TbStar,
TbStarOff,
TbTag,
} from "react-icons/tb"
import { markEntriesUpToEntry, markEntry, starEntry, tagEntry } from "@/app/entries/thunks" import { markEntriesUpToEntry, markEntry, starEntry, tagEntry } from "@/app/entries/thunks"
import { useAppDispatch, useAppSelector } from "@/app/store" import { useAppDispatch, useAppSelector } from "@/app/store"
import type { Entry } from "@/app/types" import type { Entry } from "@/app/types"
@@ -71,7 +80,12 @@ export function FeedEntryFooter(props: Readonly<FeedEntryFooterProps>) {
{tags && ( {tags && (
<Popover withArrow shadow="md" closeOnClickOutside={!mobile}> <Popover withArrow shadow="md" closeOnClickOutside={!mobile}>
<Popover.Target> <Popover.Target>
<Indicator label={props.entry.tags.length} disabled={props.entry.tags.length === 0} inline size={16}> <Indicator
label={props.entry.tags.length}
disabled={props.entry.tags.length === 0}
inline
size={16}
>
<ActionButton icon={<TbTag size={18} />} label={msg`Tags`} /> <ActionButton icon={<TbTag size={18} />} label={msg`Tags`} />
</Indicator> </Indicator>
</Popover.Target> </Popover.Target>

View File

@@ -104,7 +104,9 @@ export function ShareButtons(
}> }>
) { ) {
const sharingSettings = useAppSelector(state => state.user.settings?.sharingSettings) const sharingSettings = useAppSelector(state => state.user.settings?.sharingSettings)
const enabledSharingSites = (Object.keys(Constants.sharing) as Array<keyof SharingSettings>).filter(site => sharingSettings?.[site]) const enabledSharingSites = (Object.keys(Constants.sharing) as Array<keyof SharingSettings>).filter(
site => sharingSettings?.[site]
)
const url = encodeURIComponent(props.url) const url = encodeURIComponent(props.url)
const desc = encodeURIComponent(props.description) const desc = encodeURIComponent(props.description)
const clipboardAvailable = typeof navigator.clipboard !== "undefined" const clipboardAvailable = typeof navigator.clipboard !== "undefined"
@@ -119,7 +121,9 @@ export function ShareButtons(
{showNativeSection && ( {showNativeSection && (
<SimpleGrid cols={4}> <SimpleGrid cols={4}>
{clipboardAvailable && <CopyUrlButton url={props.url} />} {clipboardAvailable && <CopyUrlButton url={props.url} />}
{nativeSharingAvailable && <BrowserNativeShareButton url={props.url} description={props.description} />} {nativeSharingAvailable && (
<BrowserNativeShareButton url={props.url} description={props.description} />
)}
</SimpleGrid> </SimpleGrid>
)} )}

View File

@@ -36,7 +36,12 @@ export function AddCategory() {
<form onSubmit={form.onSubmit(addCategory.execute)}> <form onSubmit={form.onSubmit(addCategory.execute)}>
<Stack> <Stack>
<TextInput label={<Trans>Category</Trans>} placeholder={_(msg`Category`)} {...form.getInputProps("name")} required /> <TextInput
label={<Trans>Category</Trans>}
placeholder={_(msg`Category`)}
{...form.getInputProps("name")}
required
/>
<CategorySelect label={<Trans>Parent</Trans>} {...form.getInputProps("parentId")} clearable /> <CategorySelect label={<Trans>Parent</Trans>} {...form.getInputProps("parentId")} clearable />
<Group justify="center"> <Group justify="center">
<Button variant="default" onClick={async () => await dispatch(redirectToSelectedSource())}> <Button variant="default" onClick={async () => await dispatch(redirectToSelectedSource())}>

View File

@@ -44,8 +44,8 @@ export function ImportOpml() {
placeholder={_(msg`OPML file`)} placeholder={_(msg`OPML file`)}
description={ description={
<Trans> <Trans>
An opml file is an XML file containing feed URLs and categories. You can get an OPML file by exporting your An opml file is an XML file containing feed URLs and categories. You can get an OPML
data from other feed reading services. file by exporting your data from other feed reading services.
</Trans> </Trans>
} }
{...form.getInputProps("file")} {...form.getInputProps("file")}

View File

@@ -85,8 +85,8 @@ export function Subscribe() {
placeholder="https://www.mysite.com/rss" placeholder="https://www.mysite.com/rss"
description={ description={
<Trans> <Trans>
The URL for the feed you want to subscribe to. You can also use the website's url directly and CommaFeed The URL for the feed you want to subscribe to. You can also use the website's url
will try to find the feed in the page. directly and CommaFeed will try to find the feed in the page.
</Trans> </Trans>
} }
required required
@@ -101,8 +101,17 @@ export function Subscribe() {
> >
<Stack> <Stack>
<TextInput label={<Trans>Feed URL</Trans>} {...step1Form.getInputProps("url")} disabled /> <TextInput label={<Trans>Feed URL</Trans>} {...step1Form.getInputProps("url")} disabled />
<TextInput label={<Trans>Feed name</Trans>} {...step1Form.getInputProps("title")} required autoFocus /> <TextInput
<CategorySelect label={<Trans>Category</Trans>} {...step1Form.getInputProps("categoryId")} clearable /> label={<Trans>Feed name</Trans>}
{...step1Form.getInputProps("title")}
required
autoFocus
/>
<CategorySelect
label={<Trans>Category</Trans>}
{...step1Form.getInputProps("categoryId")}
clearable
/>
</Stack> </Stack>
</Stepper.Step> </Stepper.Step>
</Stepper> </Stepper>
@@ -117,7 +126,11 @@ export function Subscribe() {
</Button> </Button>
)} )}
{activeStep === 1 && ( {activeStep === 1 && (
<Button type="submit" leftSection={<TbRss size={16} />} loading={fetchFeed.loading || subscribe.loading}> <Button
type="submit"
leftSection={<TbRss size={16} />}
loading={fetchFeed.loading || subscribe.loading}
>
<Trans>Subscribe</Trans> <Trans>Subscribe</Trans>
</Button> </Button>
)} )}

View File

@@ -26,7 +26,16 @@ const fields: Field[] = [
{ name: "categoriesLower", label: "Categories (lower case)" }, { name: "categoriesLower", label: "Categories (lower case)" },
] ]
const textOperators = new Set(["=", "!=", "contains", "beginsWith", "endsWith", "doesNotContain", "doesNotBeginWith", "doesNotEndWith"]) const textOperators = new Set([
"=",
"!=",
"contains",
"beginsWith",
"endsWith",
"doesNotContain",
"doesNotBeginWith",
"doesNotEndWith",
])
function toCelString(query: RuleGroupType): string { function toCelString(query: RuleGroupType): string {
if (query.rules.length === 0) { if (query.rules.length === 0) {

View File

@@ -24,7 +24,10 @@ export function Star(
} }
return ( return (
<Tooltip label={props.entry.starred ? <Trans>Unstar</Trans> : <Trans>Star</Trans>} openDelay={Constants.tooltip.delay}> <Tooltip
label={props.entry.starred ? <Trans>Unstar</Trans> : <Trans>Star</Trans>}
openDelay={Constants.tooltip.delay}
>
<ActionIcon variant="transparent" onClick={onClick}> <ActionIcon variant="transparent" onClick={onClick}>
{props.entry.starred ? <TbStarFilled size={18} /> : <TbStar size={18} />} {props.entry.starred ? <TbStarFilled size={18} /> : <TbStar size={18} />}
</ActionIcon> </ActionIcon>

View File

@@ -17,7 +17,13 @@ import {
TbSortDescending, TbSortDescending,
TbUser, TbUser,
} from "react-icons/tb" } from "react-icons/tb"
import { markAllAsReadWithConfirmationIfRequired, reloadEntries, search, selectNextEntry, selectPreviousEntry } from "@/app/entries/thunks" import {
markAllAsReadWithConfirmationIfRequired,
reloadEntries,
search,
selectNextEntry,
selectPreviousEntry,
} from "@/app/entries/thunks"
import { useAppDispatch, useAppSelector } from "@/app/store" import { useAppDispatch, useAppSelector } from "@/app/store"
import { changeSettings } from "@/app/user/thunks" import { changeSettings } from "@/app/user/thunks"
import { ActionButton } from "@/components/ActionButton" import { ActionButton } from "@/components/ActionButton"
@@ -143,7 +149,13 @@ export function Header() {
onClick={toggleReadingMode} onClick={toggleReadingMode}
/> />
<ActionButton <ActionButton
icon={settings.readingOrder === "asc" ? <TbSortAscending size={iconSize} /> : <TbSortDescending size={iconSize} />} icon={
settings.readingOrder === "asc" ? (
<TbSortAscending size={iconSize} />
) : (
<TbSortDescending size={iconSize} />
)
}
label={settings.readingOrder === "asc" ? msg`Asc` : msg`Desc`} label={settings.readingOrder === "asc" ? msg`Asc` : msg`Desc`}
onClick={toggleReadingOrder} onClick={toggleReadingOrder}
/> />
@@ -160,7 +172,11 @@ export function Header() {
placeholder={_(msg`Search`)} placeholder={_(msg`Search`)}
{...searchForm.getInputProps("search")} {...searchForm.getInputProps("search")}
leftSection={<TbSearch size={iconSize} />} leftSection={<TbSearch size={iconSize} />}
rightSection={<CloseButton onClick={async () => await (searchFromStore && dispatch(search("")))} />} rightSection={
<CloseButton
onClick={async () => await (searchFromStore && dispatch(search("")))}
/>
}
autoFocus autoFocus
/> />
</form> </form>

View File

@@ -31,7 +31,13 @@ import {
} from "react-icons/tb" } from "react-icons/tb"
import { throttle } from "throttle-debounce" import { throttle } from "throttle-debounce"
import { client } from "@/app/client" import { client } from "@/app/client"
import { redirectToAbout, redirectToAdminUsers, redirectToDonate, redirectToMetrics, redirectToSettings } from "@/app/redirect/thunks" import {
redirectToAbout,
redirectToAdminUsers,
redirectToDonate,
redirectToMetrics,
redirectToSettings,
} from "@/app/redirect/thunks"
import { useAppDispatch, useAppSelector } from "@/app/store" import { useAppDispatch, useAppSelector } from "@/app/store"
import type { ViewMode } from "@/app/types" import type { ViewMode } from "@/app/types"
import { setFontSizePercentage, setViewMode } from "@/app/user/slice" import { setFontSizePercentage, setViewMode } from "@/app/user/slice"
@@ -124,7 +130,13 @@ export function ProfileMenu(props: Readonly<ProfileMenuProps>) {
} }
return ( return (
<Menu position="bottom-end" closeOnItemClick={false} opened={opened} onChange={setOpened} preventPositionChangeWhenVisible={false}> <Menu
position="bottom-end"
closeOnItemClick={false}
opened={opened}
onChange={setOpened}
preventPositionChangeWhenVisible={false}
>
<Menu.Target>{props.control}</Menu.Target> <Menu.Target>{props.control}</Menu.Target>
<Menu.Dropdown> <Menu.Dropdown>
{profile && <Menu.Label>{profile.name}</Menu.Label>} {profile && <Menu.Label>{profile.name}</Menu.Label>}
@@ -164,7 +176,9 @@ export function ProfileMenu(props: Readonly<ProfileMenuProps>) {
}} }}
> >
<Trans>Fetch all my feeds now</Trans> <Trans>Fetch all my feeds now</Trans>
{!forceRefreshEnabled && <span> ({dayjs.duration(nextAvailableForceRefresh - now.getTime()).format("HH:mm:ss")})</span>} {!forceRefreshEnabled && (
<span> ({dayjs.duration(nextAvailableForceRefresh - now.getTime()).format("HH:mm:ss")})</span>
)}
</Menu.Item> </Menu.Item>
<Divider /> <Divider />

View File

@@ -83,7 +83,11 @@ export function CustomCodeSettings() {
<Button variant="default" onClick={async () => await dispatch(redirectToSelectedSource())}> <Button variant="default" onClick={async () => await dispatch(redirectToSelectedSource())}>
<Trans>Cancel</Trans> <Trans>Cancel</Trans>
</Button> </Button>
<Button type="submit" leftSection={<TbDeviceFloppy size={16} />} loading={saveCustomCode.loading}> <Button
type="submit"
leftSection={<TbDeviceFloppy size={16} />}
loading={saveCustomCode.loading}
>
<Trans>Save</Trans> <Trans>Save</Trans>
</Button> </Button>
</Group> </Group>

View File

@@ -111,7 +111,11 @@ export function DisplaySettings() {
/> />
<Switch <Switch
label={<Trans>Navigate to the next category/feed with unread entries when marking all entries as read</Trans>} label={
<Trans>
Navigate to the next category/feed with unread entries when marking all entries as read
</Trans>
}
checked={settings.markAllAsReadNavigateToNextUnread} checked={settings.markAllAsReadNavigateToNextUnread}
onChange={e => dispatch(changeSettings({ markAllAsReadNavigateToNextUnread: e.currentTarget.checked }))} onChange={e => dispatch(changeSettings({ markAllAsReadNavigateToNextUnread: e.currentTarget.checked }))}
/> />

View File

@@ -1,6 +1,18 @@
import { useLingui } from "@lingui/react" import { useLingui } from "@lingui/react"
import { Trans } from "@lingui/react/macro" import { Trans } from "@lingui/react/macro"
import { Anchor, Box, Button, Checkbox, Divider, Group, Input, PasswordInput, Stack, Text, TextInput } from "@mantine/core" import {
Anchor,
Box,
Button,
Checkbox,
Divider,
Group,
Input,
PasswordInput,
Stack,
Text,
TextInput,
} from "@mantine/core"
import { useForm } from "@mantine/form" import { useForm } from "@mantine/form"
import { openConfirmModal } from "@mantine/modals" import { openConfirmModal } from "@mantine/modals"
import { useEffect } from "react" import { useEffect } from "react"
@@ -91,8 +103,9 @@ export function ProfileSettings() {
label={<Trans>API key</Trans>} label={<Trans>API key</Trans>}
description={ description={
<Trans> <Trans>
This is your API key. It can be used for some read-only API operations and grants access to the Fever API This is your API key. It can be used for some read-only API operations and grants access
and the Google Reader API. Use the form at the bottom of the page to generate a new API key to the Fever API and the Google Reader API. Use the form at the bottom of the page to
generate a new API key
</Trans> </Trans>
} }
readOnly readOnly
@@ -103,7 +116,8 @@ export function ProfileSettings() {
label={<Trans>OPML export</Trans>} label={<Trans>OPML export</Trans>}
description={ description={
<Trans> <Trans>
Export your subscriptions and categories as an OPML file that can be imported in other feed reading services Export your subscriptions and categories as an OPML file that can be imported in other
feed reading services
</Trans> </Trans>
} }
> >
@@ -118,8 +132,8 @@ export function ProfileSettings() {
label={<Trans>Fever API</Trans>} label={<Trans>Fever API</Trans>}
description={ description={
<Trans> <Trans>
CommaFeed is compatible with the Fever API. Use the following URL in your Fever-compatible mobile client. CommaFeed is compatible with the Fever API. Use the following URL in your
Login with your username and your <u>API key</u>. Fever-compatible mobile client. Login with your username and your <u>API key</u>.
</Trans> </Trans>
} }
> >
@@ -134,8 +148,8 @@ export function ProfileSettings() {
label={<Trans>Google Reader API</Trans>} label={<Trans>Google Reader API</Trans>}
description={ description={
<Trans> <Trans>
CommaFeed is compatible with the Google Reader API. Use the following URL in your Google Reader-compatible CommaFeed is compatible with the Google Reader API. Use the following URL in your Google
mobile client. Login with your username and your <u>API key</u>. Reader-compatible mobile client. Login with your username and your <u>API key</u>.
</Trans> </Trans>
} }
> >
@@ -165,8 +179,14 @@ export function ProfileSettings() {
description={<Trans>Changing password will generate a new API key</Trans>} description={<Trans>Changing password will generate a new API key</Trans>}
{...form.getInputProps("newPassword")} {...form.getInputProps("newPassword")}
/> />
<PasswordInput label={<Trans>Confirm password</Trans>} {...form.getInputProps("newPasswordConfirmation")} /> <PasswordInput
<Checkbox label={<Trans>Generate new API key</Trans>} {...form.getInputProps("newApiKey", { type: "checkbox" })} /> label={<Trans>Confirm password</Trans>}
{...form.getInputProps("newPasswordConfirmation")}
/>
<Checkbox
label={<Trans>Generate new API key</Trans>}
{...form.getInputProps("newApiKey", { type: "checkbox" })}
/>
<Group> <Group>
<Button variant="default" onClick={async () => await dispatch(redirectToSelectedSource())}> <Button variant="default" onClick={async () => await dispatch(redirectToSelectedSource())}>

View File

@@ -50,8 +50,8 @@ export function PushNotificationSettings() {
label={<Trans>Push notification service</Trans>} label={<Trans>Push notification service</Trans>}
description={ description={
<Trans> <Trans>
Receive push notifications when new feed entries are discovered. Enable "Receive push notifications" in the Receive push notifications when new feed entries are discovered. Enable "Receive push
settings of each feed for which you want to receive notifications. notifications" in the settings of each feed for which you want to receive notifications.
</Trans> </Trans>
} }
data={[ data={[
@@ -77,7 +77,12 @@ export function PushNotificationSettings() {
required required
{...form.getInputProps("serverUrl")} {...form.getInputProps("serverUrl")}
/> />
<TextInput label={<Trans>Topic</Trans>} placeholder="commafeed" required {...form.getInputProps("topic")} /> <TextInput
label={<Trans>Topic</Trans>}
placeholder="commafeed"
required
{...form.getInputProps("topic")}
/>
<TextInput label={<Trans>Access token</Trans>} {...form.getInputProps("userSecret")} /> <TextInput label={<Trans>Access token</Trans>} {...form.getInputProps("userSecret")} />
</> </>
)} )}

View File

@@ -119,8 +119,11 @@ export function Tree() {
const categoryNode = (category: Category, level = 0) => { const categoryNode = (category: Category, level = 0) => {
if (!isCategoryDisplayed(category)) return null if (!isCategoryDisplayed(category)) return null
const hasError = !category.expanded && flattenCategoryTree(category).some(c => c.feeds.some(f => f.errorCount > errorThreshold)) const hasError =
const hasWarning = !category.expanded && flattenCategoryTree(category).some(c => c.feeds.some(f => !!f.filterLegacy)) !category.expanded &&
flattenCategoryTree(category).some(c => c.feeds.some(f => f.errorCount > errorThreshold))
const hasWarning =
!category.expanded && flattenCategoryTree(category).some(c => c.feeds.some(f => !!f.filterLegacy))
return ( return (
<TreeNode <TreeNode
id={category.id} id={category.id}

View File

@@ -80,7 +80,11 @@ export function TreeNode(props: Readonly<TreeNodeProps>) {
data-type={props.type} data-type={props.type}
data-unread-count={props.unread} data-unread-count={props.unread}
> >
<Box mr={6} onClick={(e: React.MouseEvent) => props.onIconClick?.(e, props.id)} className="cf-treenode-icon"> <Box
mr={6}
onClick={(e: React.MouseEvent) => props.onIconClick?.(e, props.id)}
className="cf-treenode-icon"
>
<Center>{typeof props.icon === "string" ? <FeedFavicon url={props.icon} /> : props.icon}</Center> <Center>{typeof props.icon === "string" ? <FeedFavicon url={props.icon} /> : props.icon}</Center>
</Box> </Box>
<Box className={classes.nodeText}>{props.name}</Box> <Box className={classes.nodeText}>{props.name}</Box>

View File

@@ -2,7 +2,6 @@ import "@fontsource/open-sans"
import "@mantine/core/styles.css" import "@mantine/core/styles.css"
import "@mantine/notifications/styles.css" import "@mantine/notifications/styles.css"
import "@mantine/spotlight/styles.css" import "@mantine/spotlight/styles.css"
import "react-contexify/ReactContexify.css"
import dayjs from "dayjs" import dayjs from "dayjs"
import duration from "dayjs/plugin/duration" import duration from "dayjs/plugin/duration"
import relativeTime from "dayjs/plugin/relativeTime" import relativeTime from "dayjs/plugin/relativeTime"

View File

@@ -1,10 +1,26 @@
import { msg } from "@lingui/core/macro" import { msg } from "@lingui/core/macro"
import { Anchor, Box, Center, Container, Divider, Group, Image, Space, Title, useMantineColorScheme } from "@mantine/core" import {
Anchor,
Box,
Center,
Container,
Divider,
Group,
Image,
Space,
Title,
useMantineColorScheme,
} from "@mantine/core"
import { useAsyncCallback } from "react-async-hook" import { useAsyncCallback } from "react-async-hook"
import { SiGithub, SiX } from "react-icons/si" import { SiGithub, SiX } from "react-icons/si"
import { TbClock, TbKey, TbMoon, TbSettings, TbSun, TbUserPlus } from "react-icons/tb" import { TbClock, TbKey, TbMoon, TbSettings, TbSun, TbUserPlus } from "react-icons/tb"
import { client } from "@/app/client" import { client } from "@/app/client"
import { redirectToApiDocumentation, redirectToLogin, redirectToRegistration, redirectToRootCategory } from "@/app/redirect/thunks" import {
redirectToApiDocumentation,
redirectToLogin,
redirectToRegistration,
redirectToRootCategory,
} from "@/app/redirect/thunks"
import { useAppDispatch, useAppSelector } from "@/app/store" import { useAppDispatch, useAppSelector } from "@/app/store"
import welcomePageDark from "@/assets/welcome_page_dark.png" import welcomePageDark from "@/assets/welcome_page_dark.png"
import welcomePageLight from "@/assets/welcome_page_light.png" import welcomePageLight from "@/assets/welcome_page_light.png"

View File

@@ -69,7 +69,11 @@ export function AdminUsersPage() {
<Title order={3} mb="md"> <Title order={3} mb="md">
<Group> <Group>
<Trans>Manage users</Trans> <Trans>Manage users</Trans>
<ActionIcon color={theme.primaryColor} variant="subtle" onClick={() => openUserEditModal(<Trans>Add user</Trans>)}> <ActionIcon
color={theme.primaryColor}
variant="subtle"
onClick={() => openUserEditModal(<Trans>Add user</Trans>)}
>
<TbPlus size={20} /> <TbPlus size={20} />
</ActionIcon> </ActionIcon>
</Group> </Group>

View File

@@ -19,8 +19,10 @@ const shownGauges: Record<string, string> = {
"com.commafeed.backend.feed.FeedRefreshEngine.queue.size": "Feed Refresh Engine queue size", "com.commafeed.backend.feed.FeedRefreshEngine.queue.size": "Feed Refresh Engine queue size",
"com.commafeed.backend.feed.FeedRefreshEngine.worker.active": "Feed Refresh Engine active HTTP workers", "com.commafeed.backend.feed.FeedRefreshEngine.worker.active": "Feed Refresh Engine active HTTP workers",
"com.commafeed.backend.feed.FeedRefreshEngine.updater.active": "Feed Refresh Engine active database update workers", "com.commafeed.backend.feed.FeedRefreshEngine.updater.active": "Feed Refresh Engine active database update workers",
"com.commafeed.backend.feed.FeedRefreshEngine.notifier.active": "Feed Refresh Engine active push notifications workers", "com.commafeed.backend.feed.FeedRefreshEngine.notifier.active":
"com.commafeed.backend.feed.FeedRefreshEngine.notifier.queue": "Feed Refresh Engine queued push notifications workers", "Feed Refresh Engine active push notifications workers",
"com.commafeed.backend.feed.FeedRefreshEngine.notifier.queue":
"Feed Refresh Engine queued push notifications workers",
"com.commafeed.backend.HttpGetter.cache.size": "HttpGetter cached entries", "com.commafeed.backend.HttpGetter.cache.size": "HttpGetter cached entries",
"com.commafeed.backend.HttpGetter.cache.memoryUsage": "HttpGetter cache memory usage", "com.commafeed.backend.HttpGetter.cache.memoryUsage": "HttpGetter cache memory usage",
"com.commafeed.frontend.ws.WebSocketSessions.users": "WebSocket users", "com.commafeed.frontend.ws.WebSocketSessions.users": "WebSocket users",

View File

@@ -51,7 +51,12 @@ function NextUnreadBookmarklet() {
return ( return (
<Box> <Box>
<CategorySelect value={categoryId} onChange={c => c && setCategoryId(c)} withAll description={<Trans>Category</Trans>} /> <CategorySelect
value={categoryId}
onChange={c => c && setCategoryId(c)}
withAll
description={<Trans>Category</Trans>}
/>
<NativeSelect <NativeSelect
data={[ data={[
{ value: "desc", label: _(msg`Newest first`) }, { value: "desc", label: _(msg`Newest first`) },
@@ -73,7 +78,8 @@ function NextUnreadBookmarklet() {
export function AboutPage() { export function AboutPage() {
const version = useAppSelector(state => state.server.serverInfos?.version) const version = useAppSelector(state => state.server.serverInfos?.version)
const revision = useAppSelector(state => state.server.serverInfos?.gitCommit) const revision = useAppSelector(state => state.server.serverInfos?.gitCommit)
const { isBrowserExtensionInstalled, browserExtensionVersion, isBrowserExtensionInstallable } = useBrowserExtension() const { isBrowserExtensionInstalled, browserExtensionVersion, isBrowserExtensionInstallable } =
useBrowserExtension()
const dispatch = useAppDispatch() const dispatch = useAppDispatch()
return ( return (
@@ -100,7 +106,9 @@ export function AboutPage() {
</Trans> </Trans>
</Box> </Box>
<Box> <Box>
<Trans>If you encounter an issue, please report it on the issues page of the GitHub project.</Trans> <Trans>
If you encounter an issue, please report it on the issues page of the GitHub project.
</Trans>
</Box> </Box>
</Section> </Section>
<Section title={<Trans>Goodies</Trans>} icon={<TbPuzzle size={24} />}> <Section title={<Trans>Goodies</Trans>} icon={<TbPuzzle size={24} />}>

View File

@@ -1,7 +1,21 @@
import { msg } from "@lingui/core/macro" import { msg } from "@lingui/core/macro"
import { useLingui } from "@lingui/react" import { useLingui } from "@lingui/react"
import { Trans } from "@lingui/react/macro" import { Trans } from "@lingui/react/macro"
import { Anchor, Box, Button, Code, Container, Divider, Group, Input, NumberInput, Stack, Text, TextInput, Title } from "@mantine/core" import {
Anchor,
Box,
Button,
Code,
Container,
Divider,
Group,
Input,
NumberInput,
Stack,
Text,
TextInput,
Title,
} from "@mantine/core"
import { useForm } from "@mantine/form" import { useForm } from "@mantine/form"
import { openConfirmModal } from "@mantine/modals" import { openConfirmModal } from "@mantine/modals"
import { useEffect } from "react" import { useEffect } from "react"
@@ -37,6 +51,9 @@ export function CategoryDetailsPage() {
category = query.result && flattenCategoryTree(query.result.data).find(c => c.id === id) category = query.result && flattenCategoryTree(query.result.data).find(c => c.id === id)
} }
// a category cannot be moved under itself or one of its own descendants
const excludedCategoryIds = category ? flattenCategoryTree(category).map(c => c.id) : [id]
const form = useForm<CategoryModificationRequest>() const form = useForm<CategoryModificationRequest>()
const { setValues } = form const { setValues } = form
@@ -125,9 +142,14 @@ export function CategoryDetailsPage() {
label={<Trans>Parent Category</Trans>} label={<Trans>Parent Category</Trans>}
{...form.getInputProps("parentId")} {...form.getInputProps("parentId")}
clearable clearable
withoutCategoryIds={[id]} withoutCategoryIds={excludedCategoryIds}
/>
<NumberInput
label={<Trans>Position</Trans>}
{...form.getInputProps("position")}
required
min={0}
/> />
<NumberInput label={<Trans>Position</Trans>} {...form.getInputProps("position")} required min={0} />
</> </>
)} )}
@@ -137,7 +159,11 @@ export function CategoryDetailsPage() {
</Button> </Button>
{editable && ( {editable && (
<> <>
<Button type="submit" leftSection={<TbDeviceFloppy size={16} />} loading={modifyCategory.loading}> <Button
type="submit"
leftSection={<TbDeviceFloppy size={16} />}
loading={modifyCategory.loading}
>
<Trans>Save</Trans> <Trans>Save</Trans>
</Button> </Button>
<Divider orientation="vertical" /> <Divider orientation="vertical" />

View File

@@ -19,8 +19,8 @@ export function DonatePage() {
<Trans> <Trans>
<Box>Hey,</Box> <Box>Hey,</Box>
<Box mt="xs"> <Box mt="xs">
I'm Jérémie from Belgium and I've been working on CommaFeed in my free time for over 10 years now. Thanks for taking I'm Jérémie from Belgium and I've been working on CommaFeed in my free time for over 10 years
an interest in helping me continue supporting CommaFeed. now. Thanks for taking an interest in helping me continue supporting CommaFeed.
</Box> </Box>
</Trans> </Trans>

View File

@@ -133,7 +133,11 @@ export function FeedDetailsPage() {
<Input.Wrapper label={<Trans>Generated feed url</Trans>}> <Input.Wrapper label={<Trans>Generated feed url</Trans>}>
<Box> <Box>
{apiKey && ( {apiKey && (
<Anchor href={`rest/feed/entriesAsFeed?id=${feed.id}&apiKey=${apiKey}`} target="_blank" rel="noreferrer"> <Anchor
href={`rest/feed/entriesAsFeed?id=${feed.id}&apiKey=${apiKey}`}
target="_blank"
rel="noreferrer"
>
<Trans>Link</Trans> <Trans>Link</Trans>
</Anchor> </Anchor>
)} )}
@@ -146,10 +150,16 @@ export function FeedDetailsPage() {
<TextInput label={<Trans>Name</Trans>} {...form.getInputProps("name")} required /> <TextInput label={<Trans>Name</Trans>} {...form.getInputProps("name")} required />
<CategorySelect label={<Trans>Category</Trans>} {...form.getInputProps("categoryId")} clearable /> <CategorySelect label={<Trans>Category</Trans>} {...form.getInputProps("categoryId")} clearable />
<NumberInput label={<Trans>Position</Trans>} {...form.getInputProps("position")} required min={0} /> <NumberInput label={<Trans>Position</Trans>} {...form.getInputProps("position")} required min={0} />
<ReceivePushNotificationsChechbox {...form.getInputProps("pushNotificationsEnabled", { type: "checkbox" })} /> <ReceivePushNotificationsChechbox
{...form.getInputProps("pushNotificationsEnabled", { type: "checkbox" })}
/>
<NumberInput <NumberInput
label={<Trans>Auto-mark as read</Trans>} label={<Trans>Auto-mark as read</Trans>}
description={<Trans>Mark entries in this feed as read after this number of days. Leave empty to disable.</Trans>} description={
<Trans>
Mark entries in this feed as read after this number of days. Leave empty to disable.
</Trans>
}
suffix={` ${_(msg`days`)}`} suffix={` ${_(msg`days`)}`}
{...form.getInputProps("autoMarkAsReadAfterDays")} {...form.getInputProps("autoMarkAsReadAfterDays")}
min={1} min={1}
@@ -159,21 +169,25 @@ export function FeedDetailsPage() {
label={<Trans>Filtering expression</Trans>} label={<Trans>Filtering expression</Trans>}
description={ description={
<Trans> <Trans>
Build a filter expression to indicate what you want to read. Entries that don't match will be marked as read Build a filter expression to indicate what you want to read. Entries that don't match
automatically. will be marked as read automatically.
</Trans> </Trans>
} }
> >
{feed.filterLegacy && ( {feed.filterLegacy && (
<MantineAlert color="yellow" icon={<TbAlertTriangle />}> <MantineAlert color="yellow" icon={<TbAlertTriangle />}>
<Trans> <Trans>
This feed has a legacy filter that cannot be edited and is not applied. Please recreate the filter using This feed has a legacy filter that cannot be edited and is not applied. Please
the new expression editor. The legacy filter expression was: <Code>{feed.filterLegacy}</Code> recreate the filter using the new expression editor. The legacy filter expression
was: <Code>{feed.filterLegacy}</Code>
</Trans> </Trans>
</MantineAlert> </MantineAlert>
)} )}
<Box mt="xs"> <Box mt="xs">
<FilteringExpressionEditor initialValue={feed.filter} onChange={value => form.setFieldValue("filter", value)} /> <FilteringExpressionEditor
initialValue={feed.filter}
onChange={value => form.setFieldValue("filter", value)}
/>
</Box> </Box>
</Input.Wrapper> </Input.Wrapper>

View File

@@ -2,7 +2,7 @@ import { Trans } from "@lingui/react/macro"
import { ActionIcon, Box, Center, Divider, Group, Title, useMantineTheme } from "@mantine/core" import { ActionIcon, Box, Center, Divider, Group, Title, useMantineTheme } from "@mantine/core"
import { useViewportSize } from "@mantine/hooks" import { useViewportSize } from "@mantine/hooks"
import { useEffect } from "react" import { useEffect } from "react"
import { TbEdit } from "react-icons/tb" import { TbSettings } from "react-icons/tb"
import { useLocation, useParams } from "react-router-dom" import { useLocation, useParams } from "react-router-dom"
import { Constants } from "@/app/constants" import { Constants } from "@/app/constants"
import type { EntrySourceType } from "@/app/entries/slice" import type { EntrySourceType } from "@/app/entries/slice"
@@ -20,7 +20,8 @@ function NoSubscriptionHelp() {
<Box> <Box>
<Center> <Center>
<Trans> <Trans>
You don't have any subscriptions yet. Why not try adding one by clicking on the + sign at the top of the page? You don't have any subscriptions yet. Why not try adding one by clicking on the + sign at the top of
the page?
</Trans> </Trans>
</Center> </Center>
</Box> </Box>
@@ -51,7 +52,8 @@ export function FeedEntriesPage(props: Readonly<FeedEntriesPageProps>) {
const viewport = useViewportSize() const viewport = useViewportSize()
const theme = useMantineTheme() const theme = useMantineTheme()
const noSubscriptions = useAppSelector( const noSubscriptions = useAppSelector(
state => state.tree.rootCategory && flattenCategoryTree(state.tree.rootCategory).every(c => c.feeds.length === 0) state =>
state.tree.rootCategory && flattenCategoryTree(state.tree.rootCategory).every(c => c.feeds.length === 0)
) )
const sourceLabel = useAppSelector(state => state.entries.sourceLabel) const sourceLabel = useAppSelector(state => state.entries.sourceLabel)
const sourceWebsiteUrl = useAppSelector(state => state.entries.sourceWebsiteUrl) const sourceWebsiteUrl = useAppSelector(state => state.entries.sourceWebsiteUrl)
@@ -63,7 +65,8 @@ export function FeedEntriesPage(props: Readonly<FeedEntriesPageProps>) {
if (!root) return { unreadCount: 0, hasNewEntries: false } if (!root) return { unreadCount: 0, hasNewEntries: false }
if (props.sourceType === "category") { if (props.sourceType === "category") {
const category = id === Constants.categories.all.id ? root : flattenCategoryTree(root).find(c => c.id === id) const category =
id === Constants.categories.all.id ? root : flattenCategoryTree(root).find(c => c.id === id)
return { return {
unreadCount: categoryUnreadCount(category), unreadCount: categoryUnreadCount(category),
hasNewEntries: categoryHasNewEntries(category), hasNewEntries: categoryHasNewEntries(category),
@@ -138,7 +141,7 @@ export function FeedEntriesPage(props: Readonly<FeedEntriesPageProps>) {
</Title> </Title>
)} )}
<ActionIcon onClick={titleClicked} variant="subtle" color={theme.primaryColor}> <ActionIcon onClick={titleClicked} variant="subtle" color={theme.primaryColor}>
<TbEdit size={18} /> <TbSettings size={18} />
</ActionIcon> </ActionIcon>
{showUnreadCount && <UnreadCount unreadCount={unreadCount} showIndicator={hasNewEntries} />} {showUnreadCount && <UnreadCount unreadCount={unreadCount} showIndicator={hasNewEntries} />}
</Group> </Group>

View File

@@ -50,8 +50,8 @@ export function InitialSetupPage() {
</Title> </Title>
<Box mb="md"> <Box mb="md">
<Trans> <Trans>
Welcome! This appears to be the first time you're running CommaFeed. Please create an administrator account to get Welcome! This appears to be the first time you're running CommaFeed. Please create an
started. administrator account to get started.
</Trans> </Trans>
</Box> </Box>
{setup.error && ( {setup.error && (

View File

@@ -1,7 +1,19 @@
import { msg } from "@lingui/core/macro" import { msg } from "@lingui/core/macro"
import { useLingui } from "@lingui/react" import { useLingui } from "@lingui/react"
import { Trans } from "@lingui/react/macro" import { Trans } from "@lingui/react/macro"
import { Anchor, Box, Button, Center, Container, Group, Paper, PasswordInput, Stack, TextInput, Title } from "@mantine/core" import {
Anchor,
Box,
Button,
Center,
Container,
Group,
Paper,
PasswordInput,
Stack,
TextInput,
Title,
} from "@mantine/core"
import { useForm } from "@mantine/form" import { useForm } from "@mantine/form"
import { useAsyncCallback } from "react-async-hook" import { useAsyncCallback } from "react-async-hook"
import { Link } from "react-router-dom" import { Link } from "react-router-dom"
@@ -49,7 +61,11 @@ export function LoginPage() {
placeholder={_(msg`User Name or E-mail`)} placeholder={_(msg`User Name or E-mail`)}
{...form.getInputProps("name")} {...form.getInputProps("name")}
description={ description={
serverInfos?.demoAccountEnabled ? <Trans>Try out CommaFeed with the demo account: demo/demo</Trans> : "" serverInfos?.demoAccountEnabled ? (
<Trans>Try out CommaFeed with the demo account: demo/demo</Trans>
) : (
""
)
} }
size="md" size="md"
required required

View File

@@ -1,7 +1,19 @@
import { msg } from "@lingui/core/macro" import { msg } from "@lingui/core/macro"
import { useLingui } from "@lingui/react" import { useLingui } from "@lingui/react"
import { Trans } from "@lingui/react/macro" import { Trans } from "@lingui/react/macro"
import { Anchor, Box, Button, Center, Container, Group, Paper, PasswordInput, Stack, TextInput, Title } from "@mantine/core" import {
Anchor,
Box,
Button,
Center,
Container,
Group,
Paper,
PasswordInput,
Stack,
TextInput,
Title,
} from "@mantine/core"
import { useForm } from "@mantine/form" import { useForm } from "@mantine/form"
import { useAsyncCallback } from "react-async-hook" import { useAsyncCallback } from "react-async-hook"
import { Link } from "react-router-dom" import { Link } from "react-router-dom"
@@ -71,7 +83,13 @@ export function RegistrationPage() {
<form onSubmit={form.onSubmit(register.execute)}> <form onSubmit={form.onSubmit(register.execute)}>
<Stack> <Stack>
<TextInput label="User Name" placeholder="User Name" {...form.getInputProps("name")} size="md" required /> <TextInput
label="User Name"
placeholder="User Name"
{...form.getInputProps("name")}
size="md"
required
/>
<TextInput <TextInput
type="email" type="email"
label={<Trans>E-mail address</Trans>} label={<Trans>E-mail address</Trans>}

View File

@@ -6,18 +6,18 @@
<parent> <parent>
<groupId>com.commafeed</groupId> <groupId>com.commafeed</groupId>
<artifactId>commafeed</artifactId> <artifactId>commafeed</artifactId>
<version>7.4.0</version> <version>7.5.2</version>
</parent> </parent>
<artifactId>commafeed-server</artifactId> <artifactId>commafeed-server</artifactId>
<name>CommaFeed Server</name> <name>CommaFeed Server</name>
<packaging>quarkus</packaging> <packaging>quarkus</packaging>
<properties> <properties>
<quarkus.version>3.40.1</quarkus.version> <quarkus.version>3.40.1.2</quarkus.version>
<querydsl.version>7.7</querydsl.version> <querydsl.version>7.7</querydsl.version>
<rome.version>2.1.0</rome.version> <rome.version>2.1.0</rome.version>
<!-- renovate: depName=com.google.googlejavaformat:google-java-format --> <!-- renovate: depName=com.google.googlejavaformat:google-java-format -->
<google-java-format.version>1.36.1</google-java-format.version> <google-java-format.version>2.0.0</google-java-format.version>
<build.database>h2</build.database> <build.database>h2</build.database>
</properties> </properties>
@@ -64,7 +64,7 @@
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId> <artifactId>properties-maven-plugin</artifactId>
<version>1.3.1</version> <version>1.4.0</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
@@ -116,7 +116,7 @@
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId> <artifactId>exec-maven-plugin</artifactId>
<version>3.6.4</version> <version>3.7.0</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>io.quarkus</groupId> <groupId>io.quarkus</groupId>
@@ -164,7 +164,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>3.6.0</version> <version>3.6.1</version>
<configuration> <configuration>
<argLine>@{argLine}</argLine> <argLine>@{argLine}</argLine>
<systemPropertyVariables> <systemPropertyVariables>
@@ -176,7 +176,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId> <artifactId>maven-failsafe-plugin</artifactId>
<version>3.6.0</version> <version>3.6.1</version>
<executions> <executions>
<execution> <execution>
<goals> <goals>
@@ -245,7 +245,7 @@
<dependency> <dependency>
<groupId>com.puppycrawl.tools</groupId> <groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId> <artifactId>checkstyle</artifactId>
<version>14.3.0</version> <version>14.4.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<executions> <executions>
@@ -274,7 +274,7 @@
<plugin> <plugin>
<groupId>com.diffplug.spotless</groupId> <groupId>com.diffplug.spotless</groupId>
<artifactId>spotless-maven-plugin</artifactId> <artifactId>spotless-maven-plugin</artifactId>
<version>3.10.4</version> <version>3.11.0</version>
<?m2e ignore?> <?m2e ignore?>
<executions> <executions>
<execution> <execution>
@@ -290,6 +290,7 @@
<googleJavaFormat> <googleJavaFormat>
<version>${google-java-format.version}</version> <version>${google-java-format.version}</version>
<style>AOSP</style> <style>AOSP</style>
<maxLineLength>120</maxLineLength>
<reorderImports>true</reorderImports> <reorderImports>true</reorderImports>
</googleJavaFormat> </googleJavaFormat>
</java> </java>
@@ -302,7 +303,7 @@
<dependency> <dependency>
<groupId>com.commafeed</groupId> <groupId>com.commafeed</groupId>
<artifactId>commafeed-client</artifactId> <artifactId>commafeed-client</artifactId>
<version>7.4.0</version> <version>7.5.2</version>
</dependency> </dependency>
<!-- compile-time processors --> <!-- compile-time processors -->
@@ -404,7 +405,7 @@
<dependency> <dependency>
<groupId>dev.cel</groupId> <groupId>dev.cel</groupId>
<artifactId>cel</artifactId> <artifactId>cel</artifactId>
<version>0.14.0</version> <version>0.15.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.passay</groupId> <groupId>org.passay</groupId>
@@ -434,12 +435,12 @@
<dependency> <dependency>
<groupId>org.jsoup</groupId> <groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId> <artifactId>jsoup</artifactId>
<version>1.23.2</version> <version>1.24.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.ibm.icu</groupId> <groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId> <artifactId>icu4j</artifactId>
<version>78.3</version> <version>79.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.sourceforge.cssparser</groupId> <groupId>net.sourceforge.cssparser</groupId>
@@ -459,7 +460,7 @@
<dependency> <dependency>
<groupId>io.github.hakky54</groupId> <groupId>io.github.hakky54</groupId>
<artifactId>ayza-for-apache5</artifactId> <artifactId>ayza-for-apache5</artifactId>
<version>10.1.0</version> <version>10.1.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.seancfoley</groupId> <groupId>com.github.seancfoley</groupId>
@@ -476,13 +477,13 @@
<dependency> <dependency>
<groupId>io.quarkiverse.playwright</groupId> <groupId>io.quarkiverse.playwright</groupId>
<artifactId>quarkus-playwright</artifactId> <artifactId>quarkus-playwright</artifactId>
<version>2.3.10</version> <version>2.5.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.mock-server</groupId> <groupId>org.mock-server</groupId>
<artifactId>mockserver-junit-jupiter</artifactId> <artifactId>mockserver-junit-jupiter-no-dependencies</artifactId>
<version>7.6.0</version> <version>9.3.0</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>

View File

@@ -1,4 +1,5 @@
FROM ibm-semeru-runtimes:open-jdk-25.0.4.15-jre@sha256:630c738228597b4cd31d9823e479384729b03684bac23478b33fdbda13ae31b8 FROM ibm-semeru-runtimes:open-jdk-25.0.5.0-jre@sha256:03d2cb39ee2ab81500fa10ba648fa103b336b02fd4540b9bfd3b635c7416d005
EXPOSE 8082 EXPOSE 8082
RUN mkdir -p /commafeed/data RUN mkdir -p /commafeed/data

View File

@@ -1,4 +1,5 @@
FROM debian:13.7@sha256:913f6706df59a68922d1dd08f78c2476560a8d367897200a6005b00e5f67c2d5 FROM debian:13.7@sha256:9c6e381421d0f48d1b8133e573f33c185ee16cbf505eda9c4a8a4791b25ea8a6
ARG TARGETARCH ARG TARGETARCH
EXPOSE 8082 EXPOSE 8082

View File

@@ -34,16 +34,14 @@ public class CommaFeedApplication {
System.setProperty(SystemProperties.JDK_XML_MAX_GENERAL_ENTITY_SIZE_LIMIT, "0"); System.setProperty(SystemProperties.JDK_XML_MAX_GENERAL_ENTITY_SIZE_LIMIT, "0");
System.setProperty(SystemProperties.JDK_XML_TOTAL_ENTITY_SIZE_LIMIT, "0"); System.setProperty(SystemProperties.JDK_XML_TOTAL_ENTITY_SIZE_LIMIT, "0");
PasswordConstraintValidator.setMinimumPasswordLength( PasswordConstraintValidator.setMinimumPasswordLength(config.users().minimumPasswordLength());
config.users().minimumPasswordLength());
if (config.imageProxyEnabled()) { if (config.imageProxyEnabled()) {
ImageProxyUrl.generateKey(); ImageProxyUrl.generateKey();
} }
if (config.passwordRecoveryEnabled() && config.passwordRecoveryPublicBaseUrl().isEmpty()) { if (config.passwordRecoveryEnabled() && config.passwordRecoveryPublicBaseUrl().isEmpty()) {
throw new IllegalStateException( throw new IllegalStateException("password recovery is enabled but no public base url is set");
"password recovery is enabled but no public base url is set");
} }
feedRefreshEngine.start(); feedRefreshEngine.start();

View File

@@ -19,24 +19,20 @@ import java.util.Optional;
/** /**
* CommaFeed configuration * CommaFeed configuration
* *
* <p>Default values are for production, they can be overridden in application.properties for other * <p>Default values are for production, they can be overridden in application.properties for other profiles
* profiles
*/ */
@ConfigMapping(prefix = "commafeed") @ConfigMapping(prefix = "commafeed")
@ConfigRoot(phase = ConfigPhase.RUN_TIME) @ConfigRoot(phase = ConfigPhase.RUN_TIME)
public interface CommaFeedConfiguration { public interface CommaFeedConfiguration {
/** /** Whether to expose a robots.txt file that disallows web crawlers and search engine indexers. */
* Whether to expose a robots.txt file that disallows web crawlers and search engine indexers.
*/
@WithDefault("true") @WithDefault("true")
boolean hideFromWebCrawlers(); boolean hideFromWebCrawlers();
/** /**
* If enabled, images in feed entries will be proxied through the server instead of accessed * If enabled, images in feed entries will be proxied through the server instead of accessed directly by the
* directly by the browser. * browser.
* *
* <p>This is useful if commafeed is accessed through a restricting proxy that blocks some feeds * <p>This is useful if commafeed is accessed through a restricting proxy that blocks some feeds that are followed.
* that are followed.
*/ */
@WithDefault("false") @WithDefault("false")
boolean imageProxyEnabled(); boolean imageProxyEnabled();
@@ -50,9 +46,8 @@ public interface CommaFeedConfiguration {
boolean passwordRecoveryEnabled(); boolean passwordRecoveryEnabled();
/** /**
* The base URL of the application to use in the password recovery link in the email. We can't * The base URL of the application to use in the password recovery link in the email. We can't use the URL sent by
* use the URL sent by the browser of the user because of malicious Host header injection * the browser of the user because of malicious Host header injection attacks.
* attacks.
*/ */
Optional<String> passwordRecoveryPublicBaseUrl(); Optional<String> passwordRecoveryPublicBaseUrl();
@@ -87,16 +82,14 @@ public interface CommaFeedConfiguration {
Websocket websocket(); Websocket websocket();
/** /**
* Duration to wait for the feed refresh engine and the task scheduler to stop when the * Duration to wait for the feed refresh engine and the task scheduler to stop when the application is shutting
* application is shutting down. * down.
*/ */
@WithDefault("2s") @WithDefault("2s")
Duration shutdownTimeout(); Duration shutdownTimeout();
interface HttpClient { interface HttpClient {
/** /** User-Agent string that will be used by the http client, leave empty for the default one. */
* User-Agent string that will be used by the http client, leave empty for the default one.
*/
Optional<String> userAgent(); Optional<String> userAgent();
/** Time to wait for a connection to be established. */ /** Time to wait for a connection to be established. */
@@ -123,19 +116,15 @@ public interface CommaFeedConfiguration {
@WithDefault("1m") @WithDefault("1m")
Duration idleConnectionsEvictionInterval(); Duration idleConnectionsEvictionInterval();
/** /** If a feed is larger than this, it will be discarded to prevent memory issues while parsing the feed. */
* If a feed is larger than this, it will be discarded to prevent memory issues while
* parsing the feed.
*/
@WithDefault("5M") @WithDefault("5M")
MemorySize maxResponseSize(); MemorySize maxResponseSize();
/** /**
* Prevent access to local addresses to mitigate server-side request forgery (SSRF) attacks, * Prevent access to local addresses to mitigate server-side request forgery (SSRF) attacks, which could
* which could potentially expose internal resources. * potentially expose internal resources.
* *
* <p>You may want to enable this if you host a public instance of CommaFeed with * <p>You may want to enable this if you host a public instance of CommaFeed with registrations open.
* registrations open.
*/ */
@WithDefault("true") @WithDefault("true")
boolean blockLocalAddresses(); boolean blockLocalAddresses();
@@ -147,9 +136,8 @@ public interface CommaFeedConfiguration {
interface HttpClientCache { interface HttpClientCache {
/** /**
* Whether to enable the cache. This cache is used to avoid spamming feeds in short bursts * Whether to enable the cache. This cache is used to avoid spamming feeds in short bursts (e.g. when
* (e.g. when subscribing to a feed for the first time or when clicking "fetch all my feeds * subscribing to a feed for the first time or when clicking "fetch all my feeds now").
* now").
*/ */
@WithDefault("true") @WithDefault("true")
boolean enabled(); boolean enabled();
@@ -169,8 +157,7 @@ public interface CommaFeedConfiguration {
Duration interval(); Duration interval();
/** /**
* Maximum amount of time CommaFeed will wait before refreshing a feed. This is used as an * Maximum amount of time CommaFeed will wait before refreshing a feed. This is used as an upper bound when:
* upper bound when:
* *
* <ul> * <ul>
* <li>an error occurs while refreshing a feed and we're backing off exponentially * <li>an error occurs while refreshing a feed and we're backing off exponentially
@@ -182,10 +169,10 @@ public interface CommaFeedConfiguration {
Duration maxInterval(); Duration maxInterval();
/** /**
* If enabled, CommaFeed will calculate the next refresh time based on the feed's average * If enabled, CommaFeed will calculate the next refresh time based on the feed's average time between entries
* time between entries and the time since the last entry was published. The interval will * and the time since the last entry was published. The interval will be sometimes between the default refresh
* be sometimes between the default refresh interval (`commafeed.feed-refresh.interval`) and * interval (`commafeed.feed-refresh.interval`) and the maximum refresh interval
* the maximum refresh interval (`commafeed.feed-refresh.max-interval`). * (`commafeed.feed-refresh.max-interval`).
* *
* <p>See {@link FeedRefreshIntervalCalculator} for details. * <p>See {@link FeedRefreshIntervalCalculator} for details.
*/ */
@@ -207,8 +194,8 @@ public interface CommaFeedConfiguration {
int databaseThreads(); int databaseThreads();
/** /**
* Duration after which a user is considered inactive. Feeds for inactive users are not * Duration after which a user is considered inactive. Feeds for inactive users are not refreshed until they log
* refreshed until they log in again. * in again.
* *
* <p>0 to disable. * <p>0 to disable.
*/ */
@@ -216,15 +203,15 @@ public interface CommaFeedConfiguration {
Duration userInactivityPeriod(); Duration userInactivityPeriod();
/** /**
* Duration after which the evaluation of a filtering expresion to mark an entry as read is * Duration after which the evaluation of a filtering expresion to mark an entry as read is considered to have
* considered to have timed out. * timed out.
*/ */
@WithDefault("500ms") @WithDefault("500ms")
Duration filteringExpressionEvaluationTimeout(); Duration filteringExpressionEvaluationTimeout();
/** /**
* Duration after which the "Fetch all my feeds now" action is available again after use to * Duration after which the "Fetch all my feeds now" action is available again after use to avoid spamming
* avoid spamming feeds. * feeds.
*/ */
@WithDefault("0") @WithDefault("0")
Duration forceRefreshCooldownDuration(); Duration forceRefreshCooldownDuration();
@@ -240,10 +227,7 @@ public interface CommaFeedConfiguration {
@WithDefault("5") @WithDefault("5")
int threads(); int threads();
/** /** Maximum amount of notifications that can be queued before new notifications are discarded. */
* Maximum amount of notifications that can be queued before new notifications are
* discarded.
*/
@Min(1) @Min(1)
@WithDefault("100") @WithDefault("100")
int queueCapacity(); int queueCapacity();
@@ -256,8 +240,8 @@ public interface CommaFeedConfiguration {
int retriesBeforeBackoff(); int retriesBeforeBackoff();
/** /**
* Duration to wait before retrying after an error. Will be multiplied by the number of * Duration to wait before retrying after an error. Will be multiplied by the number of errors since the last
* errors since the last successful fetch. * successful fetch.
*/ */
@WithDefault("1h") @WithDefault("1h")
Duration backoffInterval(); Duration backoffInterval();
@@ -286,8 +270,7 @@ public interface CommaFeedConfiguration {
Duration entriesMaxAge(); Duration entriesMaxAge();
/** /**
* Maximum age of feed entry statuses (read/unread) in the database. Older statuses will * Maximum age of feed entry statuses (read/unread) in the database. Older statuses will be deleted.
* be deleted.
* *
* <p>0 to disable. * <p>0 to disable.
*/ */
@@ -320,9 +303,7 @@ public interface CommaFeedConfiguration {
boolean keepStarredEntries(); boolean keepStarredEntries();
default Instant statusesInstantThreshold() { default Instant statusesInstantThreshold() {
return statusesMaxAge().toMillis() > 0 return statusesMaxAge().toMillis() > 0 ? Instant.now().minus(statusesMaxAge()) : null;
? Instant.now().minus(statusesMaxAge())
: null;
} }
} }
} }
@@ -346,23 +327,17 @@ public interface CommaFeedConfiguration {
} }
interface Websocket { interface Websocket {
/** /** Enable websocket connection so the server can notify web clients that there are new entries for feeds. */
* Enable websocket connection so the server can notify web clients that there are new
* entries for feeds.
*/
@WithDefault("true") @WithDefault("true")
boolean enabled(); boolean enabled();
/** /** Interval at which the client will send a ping message on the websocket to keep the connection alive. */
* Interval at which the client will send a ping message on the websocket to keep the
* connection alive.
*/
@WithDefault("15m") @WithDefault("15m")
Duration pingInterval(); Duration pingInterval();
/** /**
* If the websocket connection is disabled or the connection is lost, the client will reload * If the websocket connection is disabled or the connection is lost, the client will reload the feed tree at
* the feed tree at this interval. * this interval.
*/ */
@WithDefault("30s") @WithDefault("30s")
Duration treeReloadInterval(); Duration treeReloadInterval();

View File

@@ -10,7 +10,10 @@ import io.quarkus.security.UnauthorizedException;
import jakarta.annotation.Priority; import jakarta.annotation.Priority;
import jakarta.validation.ValidationException; import jakarta.validation.ValidationException;
import jakarta.ws.rs.core.HttpHeaders;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.NewCookie; import jakarta.ws.rs.core.NewCookie;
import jakarta.ws.rs.core.UriInfo;
import jakarta.ws.rs.ext.Provider; import jakarta.ws.rs.ext.Provider;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -29,11 +32,9 @@ public class ExceptionMappers {
private final CommaFeedConfiguration config; private final CommaFeedConfiguration config;
@ServerExceptionMapper(CommaFeedApplicationException.class) @ServerExceptionMapper(CommaFeedApplicationException.class)
public RestResponse<CommaFeedApplicationError> applicationError( public RestResponse<CommaFeedApplicationError> applicationError(CommaFeedApplicationException e) {
CommaFeedApplicationException e) {
ResponseBuilder<CommaFeedApplicationError> response = ResponseBuilder<CommaFeedApplicationError> response =
ResponseBuilder.create( ResponseBuilder.create(e.type().status(), new CommaFeedApplicationError(e.type(), e.getMessage()));
e.type().status(), new CommaFeedApplicationError(e.type(), e.getMessage()));
if (e.type().status() == Status.UNAUTHORIZED) { if (e.type().status() == Status.UNAUTHORIZED) {
response.cookie(cookieService.buildLogoutCookie()); response.cookie(cookieService.buildLogoutCookie());
} }
@@ -43,14 +44,24 @@ public class ExceptionMappers {
@ServerExceptionMapper(UnauthorizedException.class) @ServerExceptionMapper(UnauthorizedException.class)
public RestResponse<UnauthorizedResponse> unauthorized(UnauthorizedException e) { public RestResponse<UnauthorizedResponse> unauthorized(UnauthorizedException e) {
return RestResponse.status( return RestResponse.status(
Status.UNAUTHORIZED, Status.UNAUTHORIZED, new UnauthorizedResponse(e.getMessage(), config.users().allowRegistrations()));
new UnauthorizedResponse(e.getMessage(), config.users().allowRegistrations()));
} }
@ServerExceptionMapper(AuthenticationFailedException.class) @ServerExceptionMapper(AuthenticationFailedException.class)
public RestResponse<AuthenticationFailed> authenticationFailed( public RestResponse<AuthenticationFailed> authenticationFailed(
AuthenticationFailedException e) { AuthenticationFailedException e, HttpHeaders headers, UriInfo uriInfo) {
NewCookie logoutCookie = cookieService.buildLogoutCookie(); NewCookie logoutCookie = cookieService.buildLogoutCookie();
// a browser navigating with an invalidated session would otherwise display the error
// instead of the page, retry the request now that the cookie is removed
if (headers.getAcceptableMediaTypes().stream()
.anyMatch(m -> MediaType.TEXT_HTML_TYPE.isCompatible(m) && !m.isWildcardType())) {
return ResponseBuilder.<AuthenticationFailed>create(Status.TEMPORARY_REDIRECT)
.location(uriInfo.getRequestUri())
.cookie(logoutCookie)
.build();
}
return ResponseBuilder.create(Status.UNAUTHORIZED, new AuthenticationFailed(e.getMessage())) return ResponseBuilder.create(Status.UNAUTHORIZED, new AuthenticationFailed(e.getMessage()))
.cookie(logoutCookie) .cookie(logoutCookie)
.build(); .build();

View File

@@ -56,28 +56,24 @@ public class HttpClientFactory {
private static final DnsResolver DNS_RESOLVER = SystemDefaultDnsResolver.INSTANCE; private static final DnsResolver DNS_RESOLVER = SystemDefaultDnsResolver.INSTANCE;
private static final IPAddress CGNAT_RANGE = new IPAddressString("100.64.0.0/10").getAddress(); private static final IPAddress CGNAT_RANGE = new IPAddressString("100.64.0.0/10").getAddress();
private static final IPAddress NAT64_LOCAL_USE_RANGE = new IPAddressString("64:ff9b:1::/48").getAddress();
private final CommaFeedConfiguration config; private final CommaFeedConfiguration config;
private final CommaFeedVersion version; private final CommaFeedVersion version;
public CloseableHttpAsyncClient newClient(int poolSize) { public CloseableHttpAsyncClient newClient(int poolSize) {
PoolingAsyncClientConnectionManager connectionManager = PoolingAsyncClientConnectionManager connectionManager = newConnectionManager(config, poolSize);
newConnectionManager(config, poolSize);
String userAgent = String userAgent =
config.httpClient() config.httpClient()
.userAgent() .userAgent()
.orElseGet( .orElseGet(() ->
() -> String.format(
String.format( "CommaFeed/%s (https://github.com/Athou/commafeed)", version.getVersion()));
"CommaFeed/%s (https://github.com/Athou/commafeed)",
version.getVersion()));
return newClient(config, connectionManager, userAgent); return newClient(config, connectionManager, userAgent);
} }
private CloseableHttpAsyncClient newClient( private CloseableHttpAsyncClient newClient(
CommaFeedConfiguration config, CommaFeedConfiguration config, PoolingAsyncClientConnectionManager connectionManager, String userAgent) {
PoolingAsyncClientConnectionManager connectionManager,
String userAgent) {
List<Header> headers = new ArrayList<>(); List<Header> headers = new ArrayList<>();
headers.add(new BasicHeader(HttpHeaders.ACCEPT_LANGUAGE, "en")); headers.add(new BasicHeader(HttpHeaders.ACCEPT_LANGUAGE, "en"));
headers.add(new BasicHeader(HttpHeaders.PRAGMA, "No-cache")); headers.add(new BasicHeader(HttpHeaders.PRAGMA, "No-cache"));
@@ -85,10 +81,8 @@ public class HttpClientFactory {
headers.add(new BasicHeader(HttpHeaders.ACCEPT, "*/*")); headers.add(new BasicHeader(HttpHeaders.ACCEPT, "*/*"));
headers.add(new BasicHeader(HttpHeaders.SEC_FETCH_MODE, "navigate")); headers.add(new BasicHeader(HttpHeaders.SEC_FETCH_MODE, "navigate"));
SequencedMap<String, UnaryOperator<AsyncDataConsumer>> contentDecoderMap = SequencedMap<String, UnaryOperator<AsyncDataConsumer>> contentDecoderMap = new LinkedHashMap<>();
new LinkedHashMap<>(); contentDecoderMap.put(ContentCoding.DEFLATE.token(), d -> new InflatingAsyncDataConsumer(d, null));
contentDecoderMap.put(
ContentCoding.DEFLATE.token(), d -> new InflatingAsyncDataConsumer(d, null));
contentDecoderMap.put(ContentCoding.GZIP.token(), InflatingGzipDataConsumer::new); contentDecoderMap.put(ContentCoding.GZIP.token(), InflatingGzipDataConsumer::new);
RedirectStrategy redirectStrategy = RedirectStrategy redirectStrategy =
@@ -106,8 +100,7 @@ public class HttpClientFactory {
.setDefaultHeaders(headers) .setDefaultHeaders(headers)
.setConnectionManager(connectionManager) .setConnectionManager(connectionManager)
.evictExpiredConnections() .evictExpiredConnections()
.evictIdleConnections( .evictIdleConnections(TimeValue.of(config.httpClient().idleConnectionsEvictionInterval()))
TimeValue.of(config.httpClient().idleConnectionsEvictionInterval()))
.setContentDecoderMap(new LinkedHashMap<>(contentDecoderMap)) .setContentDecoderMap(new LinkedHashMap<>(contentDecoderMap))
.setRedirectStrategy(redirectStrategy) .setRedirectStrategy(redirectStrategy)
.build(); .build();
@@ -115,10 +108,8 @@ public class HttpClientFactory {
return client; return client;
} }
private PoolingAsyncClientConnectionManager newConnectionManager( private PoolingAsyncClientConnectionManager newConnectionManager(CommaFeedConfiguration config, int poolSize) {
CommaFeedConfiguration config, int poolSize) { SSLFactory sslFactory = SSLFactory.builder().withUnsafeTrustMaterial().withUnsafeHostnameVerifier().build();
SSLFactory sslFactory =
SSLFactory.builder().withUnsafeTrustMaterial().withUnsafeHostnameVerifier().build();
DnsResolver dnsResolver = DnsResolver dnsResolver =
config.httpClient().blockLocalAddresses() config.httpClient().blockLocalAddresses()
? new BlockLocalAddressesDnsResolver(DNS_RESOLVER) ? new BlockLocalAddressesDnsResolver(DNS_RESOLVER)
@@ -130,14 +121,12 @@ public class HttpClientFactory {
ConnectionConfig.custom() ConnectionConfig.custom()
.setConnectTimeout(Timeout.of(config.httpClient().connectTimeout())) .setConnectTimeout(Timeout.of(config.httpClient().connectTimeout()))
.setSocketTimeout(Timeout.of(config.httpClient().socketTimeout())) .setSocketTimeout(Timeout.of(config.httpClient().socketTimeout()))
.setTimeToLive( .setTimeToLive(Timeout.of(config.httpClient().connectionTimeToLive()))
Timeout.of(config.httpClient().connectionTimeToLive()))
.build()) .build())
.setDefaultTlsConfig( .setDefaultTlsConfig(
TlsConfig.custom() TlsConfig.custom()
.setVersionPolicy(HttpVersionPolicy.NEGOTIATE) .setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
.setHandshakeTimeout( .setHandshakeTimeout(Timeout.of(config.httpClient().sslHandshakeTimeout()))
Timeout.of(config.httpClient().sslHandshakeTimeout()))
.build()) .build())
.setMaxConnPerRoute(poolSize) .setMaxConnPerRoute(poolSize)
.setMaxConnTotal(poolSize) .setMaxConnTotal(poolSize)
@@ -150,7 +139,11 @@ public class HttpClientFactory {
} }
private static boolean isLocalAddress(IPAddress ip) { private static boolean isLocalAddress(IPAddress ip) {
if (ip.isLocal() || ip.isLoopback() || ip.isMulticast() || CGNAT_RANGE.contains(ip)) { if (ip.isLocal()
|| ip.isLoopback()
|| ip.isMulticast()
|| CGNAT_RANGE.contains(ip)
|| NAT64_LOCAL_USE_RANGE.contains(ip)) {
return true; return true;
} }
@@ -186,8 +179,7 @@ public class HttpClientFactory {
InetAddress[] addresses = delegate.resolve(host); InetAddress[] addresses = delegate.resolve(host);
for (InetAddress addr : addresses) { for (InetAddress addr : addresses) {
if (isLocalAddress(addr)) { if (isLocalAddress(addr)) {
throw new UnknownHostException( throw new UnknownHostException("Access to local address blocked: " + addr.getHostAddress());
"Access to local address blocked: " + addr.getHostAddress());
} }
} }
return addresses; return addresses;
@@ -223,8 +215,7 @@ public class HttpClientFactory {
for (InetAddress addr : addresses) { for (InetAddress addr : addresses) {
if (isLocalAddress(addr)) { if (isLocalAddress(addr)) {
throw new HttpException( throw new HttpException("Access to local address blocked: " + addr.getHostAddress());
"Access to local address blocked: " + addr.getHostAddress());
} }
} }

View File

@@ -41,7 +41,6 @@ import org.apache.hc.core5.http.nio.AsyncRequestProducer;
import org.apache.hc.core5.http.nio.AsyncResponseConsumer; import org.apache.hc.core5.http.nio.AsyncResponseConsumer;
import org.apache.hc.core5.http.nio.entity.AbstractBinAsyncEntityConsumer; import org.apache.hc.core5.http.nio.entity.AbstractBinAsyncEntityConsumer;
import org.apache.hc.core5.http.nio.support.BasicResponseConsumer; import org.apache.hc.core5.http.nio.support.BasicResponseConsumer;
import org.apache.hc.core5.util.Timeout;
import org.jboss.resteasy.reactive.common.headers.CacheControlDelegate; import org.jboss.resteasy.reactive.common.headers.CacheControlDelegate;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
@@ -54,6 +53,8 @@ import java.time.InstantSource;
import java.util.Optional; import java.util.Optional;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/** Smart HTTP getter: handles gzip, ssl, last modified, and etag headers */ /** Smart HTTP getter: handles gzip, ssl, last modified, and etag headers */
@Singleton @Singleton
@@ -74,32 +75,22 @@ public class HttpGetter {
this.client = httpClientFactory.newClient(config.feedRefresh().httpThreads()); this.client = httpClientFactory.newClient(config.feedRefresh().httpThreads());
this.cache = newCache(config); this.cache = newCache(config);
metrics.registerGauge( metrics.registerGauge(MetricRegistry.name(getClass(), "cache", "size"), () -> cache == null ? 0 : cache.size());
MetricRegistry.name(getClass(), "cache", "size"),
() -> cache == null ? 0 : cache.size());
metrics.registerGauge( metrics.registerGauge(
MetricRegistry.name(getClass(), "cache", "memoryUsage"), MetricRegistry.name(getClass(), "cache", "memoryUsage"),
() -> () ->
cache == null cache == null
? 0 ? 0
: cache.asMap().values().stream() : cache.asMap().values().stream().mapToInt(e -> ArrayUtils.getLength(e.content)).sum());
.mapToInt(e -> ArrayUtils.getLength(e.content))
.sum());
} }
public HttpResult get(String url) public HttpResult get(String url)
throws IOException, throws IOException, NotModifiedException, TooManyRequestsException, SchemeNotAllowedException {
NotModifiedException,
TooManyRequestsException,
SchemeNotAllowedException {
return get(HttpRequest.builder(url).build()); return get(HttpRequest.builder(url).build());
} }
public HttpResult get(HttpRequest request) public HttpResult get(HttpRequest request)
throws IOException, throws IOException, NotModifiedException, TooManyRequestsException, SchemeNotAllowedException {
NotModifiedException,
TooManyRequestsException,
SchemeNotAllowedException {
URI uri = URI.create(request.getUrl()); URI uri = URI.create(request.getUrl());
ensureHttpScheme(uri.getScheme()); ensureHttpScheme(uri.getScheme());
@@ -162,7 +153,6 @@ public class HttpGetter {
HttpClientContext context = HttpClientContext.create(); HttpClientContext context = HttpClientContext.create();
context.setRequestConfig( context.setRequestConfig(
RequestConfig.custom() RequestConfig.custom()
.setResponseTimeout(Timeout.of(config.httpClient().responseTimeout()))
// causes issues with some feeds // causes issues with some feeds
// see https://github.com/Athou/commafeed/issues/1572 // see https://github.com/Athou/commafeed/issues/1572
// and https://issues.apache.org/jira/browse/HTTPCLIENT-2344 // and https://issues.apache.org/jira/browse/HTTPCLIENT-2344
@@ -178,8 +168,7 @@ public class HttpGetter {
FutureCallback<Message<org.apache.hc.core5.http.HttpResponse, byte[]>> callback = FutureCallback<Message<org.apache.hc.core5.http.HttpResponse, byte[]>> callback =
new FutureCallback<>() { new FutureCallback<>() {
@Override @Override
public void completed( public void completed(Message<org.apache.hc.core5.http.HttpResponse, byte[]> result) {}
Message<org.apache.hc.core5.http.HttpResponse, byte[]> result) {}
@Override @Override
public void failed(Exception ex) {} public void failed(Exception ex) {}
@@ -191,7 +180,8 @@ public class HttpGetter {
client.execute(req, resp, context, callback); client.execute(req, resp, context, callback);
try { try {
Message<org.apache.hc.core5.http.HttpResponse, byte[]> message = future.get(); Message<org.apache.hc.core5.http.HttpResponse, byte[]> message =
future.get(config.httpClient().responseTimeout().toSeconds(), TimeUnit.SECONDS);
byte[] content = message.getBody(); byte[] content = message.getBody();
int code = message.getHead().getCode(); int code = message.getHead().getCode();
@@ -245,7 +235,11 @@ public class HttpGetter {
future.cancel(true); future.cancel(true);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new RuntimeException("interrupted while fetching " + request.getUrl(), e); throw new RuntimeException("interrupted while fetching " + request.getUrl(), e);
} catch (TimeoutException e) {
future.cancel(true);
throw new IOException("timed out while fetching " + request.getUrl(), e);
} catch (ExecutionException e) { } catch (ExecutionException e) {
future.cancel(true);
throw Lombok.sneakyThrow(e.getCause()); throw Lombok.sneakyThrow(e.getCause());
} }
} }
@@ -278,16 +272,13 @@ public class HttpGetter {
} }
return CacheBuilder.newBuilder() return CacheBuilder.newBuilder()
.weigher( .weigher((HttpRequest key, HttpResponse value) -> value.content() != null ? value.content().length : 0)
(HttpRequest key, HttpResponse value) ->
value.content() != null ? value.content().length : 0)
.maximumWeight(cacheConfig.maximumMemorySize().asLongValue()) .maximumWeight(cacheConfig.maximumMemorySize().asLongValue())
.expireAfterWrite(cacheConfig.expiration()) .expireAfterWrite(cacheConfig.expiration())
.build(); .build();
} }
private record LimitedContentLengthEntityConsumer( private record LimitedContentLengthEntityConsumer(@Delegate AsyncEntityConsumer<byte[]> delegate, long maxBytes)
@Delegate AsyncEntityConsumer<byte[]> delegate, long maxBytes)
implements AsyncEntityConsumer<byte[]> { implements AsyncEntityConsumer<byte[]> {
@Override @Override
@@ -320,9 +311,7 @@ public class HttpGetter {
@Override @Override
protected void data(ByteBuffer src, boolean endOfStream) throws IOException { protected void data(ByteBuffer src, boolean endOfStream) throws IOException {
if (out.size() + src.remaining() > maxBytes) { if (out.size() + src.remaining() > maxBytes) {
throw new IOException( throw new IOException("Response size exceeds the maximum allowed size (%s bytes)".formatted(maxBytes));
"Response size exceeds the maximum allowed size (%s bytes)"
.formatted(maxBytes));
} }
byte[] chunk = new byte[src.remaining()]; byte[] chunk = new byte[src.remaining()];
src.get(chunk); src.get(chunk);
@@ -362,8 +351,7 @@ public class HttpGetter {
this(message, null, null); this(message, null, null);
} }
public NotModifiedException( public NotModifiedException(String message, String newLastModifiedHeader, String newEtagHeader) {
String message, String newLastModifiedHeader, String newEtagHeader) {
super(message); super(message);
this.newLastModifiedHeader = newLastModifiedHeader; this.newLastModifiedHeader = newLastModifiedHeader;
this.newEtagHeader = newEtagHeader; this.newEtagHeader = newEtagHeader;

View File

@@ -65,11 +65,7 @@ public class Urls {
try { try {
return URI.create(baseUrl).resolve(relativeUrl).toString(); return URI.create(baseUrl).resolve(relativeUrl).toString();
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
log.debug( log.debug("Unable to create absolute url from relative url: {} base: {}", relativeUrl, baseUrl, e);
"Unable to create absolute url from relative url: {} base: {}",
relativeUrl,
baseUrl,
e);
return null; return null;
} }
} }
@@ -86,8 +82,8 @@ public class Urls {
} }
/** /**
* Normalize the url. The resulting url is not meant to be fetched but rather used as a mean to * Normalize the url. The resulting url is not meant to be fetched but rather used as a mean to identify a feed and
* identify a feed and avoid duplicates * avoid duplicates
*/ */
public static String normalize(String url) { public static String normalize(String url) {
if (url == null) { if (url == null) {

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.FeedCategory; import com.commafeed.backend.model.FeedCategory;
import com.commafeed.backend.model.QFeedCategory; import com.commafeed.backend.model.QFeedCategory;
import com.commafeed.backend.model.QUser; import com.commafeed.backend.model.QUser;
@@ -17,8 +18,8 @@ public class FeedCategoryDAO extends GenericDAO<FeedCategory> {
private static final QFeedCategory CATEGORY = QFeedCategory.feedCategory; private static final QFeedCategory CATEGORY = QFeedCategory.feedCategory;
public FeedCategoryDAO(EntityManager entityManager) { public FeedCategoryDAO(EntityManager entityManager, CommaFeedConfiguration config) {
super(entityManager, FeedCategory.class); super(entityManager, FeedCategory.class, config);
} }
public List<FeedCategory> findAll(User user) { public List<FeedCategory> findAll(User user) {
@@ -30,9 +31,7 @@ public class FeedCategoryDAO extends GenericDAO<FeedCategory> {
} }
public FeedCategory findById(User user, Long id) { public FeedCategory findById(User user, Long id) {
return query().selectFrom(CATEGORY) return query().selectFrom(CATEGORY).where(CATEGORY.user.eq(user), CATEGORY.id.eq(id)).fetchOne();
.where(CATEGORY.user.eq(user), CATEGORY.id.eq(id))
.fetchOne();
} }
public FeedCategory findByName(User user, String name, FeedCategory parent) { public FeedCategory findByName(User user, String name, FeedCategory parent) {

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.Feed; import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.QFeed; import com.commafeed.backend.model.QFeed;
import com.commafeed.backend.model.QFeedSubscription; import com.commafeed.backend.model.QFeedSubscription;
@@ -20,8 +21,8 @@ public class FeedDAO extends GenericDAO<Feed> {
private static final QFeed FEED = QFeed.feed; private static final QFeed FEED = QFeed.feed;
private static final QFeedSubscription SUBSCRIPTION = QFeedSubscription.feedSubscription; private static final QFeedSubscription SUBSCRIPTION = QFeedSubscription.feedSubscription;
public FeedDAO(EntityManager entityManager) { public FeedDAO(EntityManager entityManager, CommaFeedConfiguration config) {
super(entityManager, Feed.class); super(entityManager, Feed.class, config);
} }
public List<Feed> findByIds(List<Long> id) { public List<Feed> findByIds(List<Long> id) {
@@ -35,10 +36,7 @@ public class FeedDAO extends GenericDAO<Feed> {
// join on subscriptions to only refresh feeds that have subscribers // join on subscriptions to only refresh feeds that have subscribers
.join(SUBSCRIPTION) .join(SUBSCRIPTION)
.on(SUBSCRIPTION.feed.eq(FEED)) .on(SUBSCRIPTION.feed.eq(FEED))
.where( .where(FEED.disabledUntil.isNull().or(FEED.disabledUntil.lt(Instant.now())));
FEED.disabledUntil
.isNull()
.or(FEED.disabledUntil.lt(Instant.now())));
if (lastLoginThreshold != null) { if (lastLoginThreshold != null) {
query.join(SUBSCRIPTION.user).where(SUBSCRIPTION.user.lastLogin.gt(lastLoginThreshold)); query.join(SUBSCRIPTION.user).where(SUBSCRIPTION.user.lastLogin.gt(lastLoginThreshold));
@@ -52,11 +50,7 @@ public class FeedDAO extends GenericDAO<Feed> {
} }
public Feed findByUrl(String normalizedUrl, String normalizedUrlHash) { public Feed findByUrl(String normalizedUrl, String normalizedUrlHash) {
return query() return query().selectFrom(FEED).where(FEED.normalizedUrlHash.eq(normalizedUrlHash)).fetch().stream()
.selectFrom(FEED)
.where(FEED.normalizedUrlHash.eq(normalizedUrlHash))
.fetch()
.stream()
.filter(f -> Strings.CS.equals(normalizedUrl, f.getNormalizedUrl())) .filter(f -> Strings.CS.equals(normalizedUrl, f.getNormalizedUrl()))
.findFirst() .findFirst()
.orElse(null); .orElse(null);

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.FeedEntryContent; import com.commafeed.backend.model.FeedEntryContent;
import com.commafeed.backend.model.QFeedEntry; import com.commafeed.backend.model.QFeedEntry;
import com.commafeed.backend.model.QFeedEntryContent; import com.commafeed.backend.model.QFeedEntryContent;
@@ -15,8 +16,8 @@ public class FeedEntryContentDAO extends GenericDAO<FeedEntryContent> {
private static final QFeedEntryContent CONTENT = QFeedEntryContent.feedEntryContent; private static final QFeedEntryContent CONTENT = QFeedEntryContent.feedEntryContent;
private static final QFeedEntry ENTRY = QFeedEntry.feedEntry; private static final QFeedEntry ENTRY = QFeedEntry.feedEntry;
public FeedEntryContentDAO(EntityManager entityManager) { public FeedEntryContentDAO(EntityManager entityManager, CommaFeedConfiguration config) {
super(entityManager, FeedEntryContent.class); super(entityManager, FeedEntryContent.class, config);
} }
public List<FeedEntryContent> findExisting(String contentHash, String titleHash) { public List<FeedEntryContent> findExisting(String contentHash, String titleHash) {

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.Feed; import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedEntry; import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.QFeedEntry; import com.commafeed.backend.model.QFeedEntry;
@@ -23,8 +24,8 @@ public class FeedEntryDAO extends GenericDAO<FeedEntry> {
private static final QFeedEntry ENTRY = QFeedEntry.feedEntry; private static final QFeedEntry ENTRY = QFeedEntry.feedEntry;
private static final int IN_CLAUSE_BATCH_SIZE = 1000; private static final int IN_CLAUSE_BATCH_SIZE = 1000;
public FeedEntryDAO(EntityManager entityManager) { public FeedEntryDAO(EntityManager entityManager, CommaFeedConfiguration config) {
super(entityManager, FeedEntry.class); super(entityManager, FeedEntry.class, config);
} }
public FeedEntry findExisting(String guidHash, Feed feed) { public FeedEntry findExisting(String guidHash, Feed feed) {
@@ -41,8 +42,7 @@ public class FeedEntryDAO extends GenericDAO<FeedEntry> {
} }
Set<String> result = new HashSet<>(); Set<String> result = new HashSet<>();
for (List<String> batch : for (List<String> batch : Lists.partition(new ArrayList<>(guidHashes), IN_CLAUSE_BATCH_SIZE)) {
Lists.partition(new ArrayList<>(guidHashes), IN_CLAUSE_BATCH_SIZE)) {
result.addAll( result.addAll(
query().select(ENTRY.guidHash) query().select(ENTRY.guidHash)
.from(ENTRY) .from(ENTRY)
@@ -52,8 +52,7 @@ public class FeedEntryDAO extends GenericDAO<FeedEntry> {
return result; return result;
} }
public List<FeedCapacity> findFeedsExceedingCapacity( public List<FeedCapacity> findFeedsExceedingCapacity(long maxCapacity, long max, boolean keepStarredEntries) {
long maxCapacity, long max, boolean keepStarredEntries) {
NumberExpression<Long> count = ENTRY.id.count(); NumberExpression<Long> count = ENTRY.id.count();
JPAQuery<Tuple> query = query().select(ENTRY.feed.id, count).from(ENTRY); JPAQuery<Tuple> query = query().select(ENTRY.feed.id, count).from(ENTRY);
@@ -67,8 +66,7 @@ public class FeedEntryDAO extends GenericDAO<FeedEntry> {
} }
public int delete(Long feedId, long max) { public int delete(Long feedId, long max) {
List<FeedEntry> list = List<FeedEntry> list = query().selectFrom(ENTRY).where(ENTRY.feed.id.eq(feedId)).limit(max).fetch();
query().selectFrom(ENTRY).where(ENTRY.feed.id.eq(feedId)).limit(max).fetch();
return delete(list); return delete(list);
} }
@@ -90,10 +88,7 @@ public class FeedEntryDAO extends GenericDAO<FeedEntry> {
/** Delete the oldest entries of a feed */ /** Delete the oldest entries of a feed */
public int deleteOldEntries(Long feedId, long max, boolean keepStarredEntries) { public int deleteOldEntries(Long feedId, long max, boolean keepStarredEntries) {
JPAQuery<FeedEntry> query = JPAQuery<FeedEntry> query =
query().selectFrom(ENTRY) query().selectFrom(ENTRY).where(ENTRY.feed.id.eq(feedId)).orderBy(ENTRY.published.asc()).limit(max);
.where(ENTRY.feed.id.eq(feedId))
.orderBy(ENTRY.published.asc())
.limit(max);
if (keepStarredEntries) { if (keepStarredEntries) {
query.where(Predicates.isNotStarred(ENTRY)); query.where(Predicates.isNotStarred(ENTRY));

View File

@@ -29,6 +29,7 @@ import org.apache.commons.collections4.CollectionUtils;
import java.time.Instant; import java.time.Instant;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -47,32 +48,24 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
private final CommaFeedConfiguration config; private final CommaFeedConfiguration config;
public FeedEntryStatusDAO( public FeedEntryStatusDAO(
EntityManager entityManager, EntityManager entityManager, FeedEntryTagDAO feedEntryTagDAO, CommaFeedConfiguration config) {
FeedEntryTagDAO feedEntryTagDAO, super(entityManager, FeedEntryStatus.class, config);
CommaFeedConfiguration config) {
super(entityManager, FeedEntryStatus.class);
this.feedEntryTagDAO = feedEntryTagDAO; this.feedEntryTagDAO = feedEntryTagDAO;
this.config = config; this.config = config;
} }
public FeedEntryStatus getStatus(User user, FeedSubscription sub, FeedEntry entry) { public FeedEntryStatus getStatus(User user, FeedSubscription sub, FeedEntry entry) {
List<FeedEntryStatus> statuses = List<FeedEntryStatus> statuses =
query().selectFrom(STATUS) query().selectFrom(STATUS).where(STATUS.entry.eq(entry), STATUS.subscription.eq(sub)).fetch();
.where(STATUS.entry.eq(entry), STATUS.subscription.eq(sub))
.fetch();
FeedEntryStatus status = statuses.stream().findFirst().orElse(null); FeedEntryStatus status = statuses.stream().findFirst().orElse(null);
return handleStatus(user, status, sub, entry); return handleStatus(user, status, sub, entry);
} }
/** creates an artificial "unread" status if status is null */ /** creates an artificial "unread" status if status is null */
private FeedEntryStatus handleStatus( private FeedEntryStatus handleStatus(User user, FeedEntryStatus status, FeedSubscription sub, FeedEntry entry) {
User user, FeedEntryStatus status, FeedSubscription sub, FeedEntry entry) {
if (status == null) { if (status == null) {
Instant statusesInstantThreshold = Instant statusesInstantThreshold = config.database().cleanup().statusesInstantThreshold();
config.database().cleanup().statusesInstantThreshold(); boolean read = statusesInstantThreshold != null && entry.getPublished().isBefore(statusesInstantThreshold);
boolean read =
statusesInstantThreshold != null
&& entry.getPublished().isBefore(statusesInstantThreshold);
status = new FeedEntryStatus(user, sub, entry); status = new FeedEntryStatus(user, sub, entry);
status.setRead(read); status.setRead(read);
status.setMarkable(!read); status.setMarkable(!read);
@@ -84,8 +77,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
private void fetchTags(User user, List<FeedEntryStatus> statuses) { private void fetchTags(User user, List<FeedEntryStatus> statuses) {
Map<Long, List<FeedEntryTag>> tagsByEntryIds = Map<Long, List<FeedEntryTag>> tagsByEntryIds =
feedEntryTagDAO.findByEntries( feedEntryTagDAO.findByEntries(user, statuses.stream().map(FeedEntryStatus::getEntry).toList());
user, statuses.stream().map(FeedEntryStatus::getEntry).toList());
for (FeedEntryStatus status : statuses) { for (FeedEntryStatus status : statuses) {
List<FeedEntryTag> tags = tagsByEntryIds.get(status.getEntry().getId()); List<FeedEntryTag> tags = tagsByEntryIds.get(status.getEntry().getId());
status.setTags(tags == null ? List.of() : tags); status.setTags(tags == null ? List.of() : tags);
@@ -129,8 +121,6 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
query.limit(limit); query.limit(limit);
} }
setTimeout(query, config.database().queryTimeout());
List<FeedEntryStatus> statuses = query.fetch(); List<FeedEntryStatus> statuses = query.fetch();
statuses.forEach(s -> s.setMarkable(true)); statuses.forEach(s -> s.setMarkable(true));
if (includeContent) { if (includeContent) {
@@ -207,8 +197,6 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
query.limit(limit); query.limit(limit);
} }
setTimeout(query, config.database().queryTimeout());
List<FeedEntryStatus> statuses = new ArrayList<>(); List<FeedEntryStatus> statuses = new ArrayList<>();
List<Tuple> tuples = query.fetch(); List<Tuple> tuples = query.fetch();
for (Tuple tuple : tuples) { for (Tuple tuple : tuples) {
@@ -238,19 +226,39 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
} }
} }
public UnreadCount getUnreadCount(FeedSubscription sub) { public Map<Long, UnreadCount> getUnreadCounts(List<FeedSubscription> subs) {
if (subs.isEmpty()) {
return Map.of();
}
Map<Long, List<FeedSubscription>> subsByFeedId =
subs.stream().collect(Collectors.groupingBy(s -> s.getFeed().getId()));
JPAQuery<Tuple> query = JPAQuery<Tuple> query =
query().select(ENTRY.count(), ENTRY.published.max()) query().select(ENTRY.feed.id, ENTRY.count(), ENTRY.published.max())
.from(ENTRY) .from(ENTRY)
.leftJoin(ENTRY.statuses, STATUS) .leftJoin(ENTRY.statuses, STATUS)
.on(STATUS.subscription.eq(sub)) .on(STATUS.subscription.in(subs))
.where(ENTRY.feed.eq(sub.getFeed())) .where(ENTRY.feed.id.in(subsByFeedId.keySet()))
.where(buildUnreadPredicate()); .where(buildUnreadPredicate())
.groupBy(ENTRY.feed.id);
Tuple tuple = query.fetchOne(); Map<Long, UnreadCount> result = new HashMap<>();
Long count = tuple.get(ENTRY.count()); for (Tuple tuple : query.fetch()) {
Instant published = tuple.get(ENTRY.published.max()); Long feedId = tuple.get(ENTRY.feed.id);
return new UnreadCount(sub.getId(), count == null ? 0 : count, published); Long count = tuple.get(ENTRY.count());
Instant published = tuple.get(ENTRY.published.max());
for (FeedSubscription sub : subsByFeedId.get(feedId)) {
result.put(sub.getId(), new UnreadCount(sub.getId(), count == null ? 0 : count, published));
}
}
// feeds with no unread entries are absent from the query result, default them to zero
for (FeedSubscription sub : subs) {
result.putIfAbsent(sub.getId(), new UnreadCount(sub.getId(), 0, null));
}
return result;
} }
private BooleanBuilder buildUnreadPredicate() { private BooleanBuilder buildUnreadPredicate() {
@@ -284,8 +292,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
where.and(SUBSCRIPTION.autoMarkAsReadAfterDays.gt(0)); where.and(SUBSCRIPTION.autoMarkAsReadAfterDays.gt(0));
NumberExpression<Integer> daysDiff = NumberExpression<Integer> daysDiff =
Expressions.numberTemplate( Expressions.numberTemplate(Integer.class, "TIMESTAMPDIFF(DAY, {0}, {1})", ENTRY.published, now);
Integer.class, "TIMESTAMPDIFF(DAY, {0}, {1})", ENTRY.published, now);
where.and(daysDiff.goe(SUBSCRIPTION.autoMarkAsReadAfterDays)); where.and(daysDiff.goe(SUBSCRIPTION.autoMarkAsReadAfterDays));
where.and(buildUnreadPredicate()); where.and(buildUnreadPredicate());
@@ -314,11 +321,7 @@ public class FeedEntryStatusDAO extends GenericDAO<FeedEntryStatus> {
.toList(); .toList();
if (!statusIdsToUpdate.isEmpty()) { if (!statusIdsToUpdate.isEmpty()) {
updated += updated += updateQuery(STATUS).where(STATUS.id.in(statusIdsToUpdate)).set(STATUS.read, true).execute();
updateQuery(STATUS)
.where(STATUS.id.in(statusIdsToUpdate))
.set(STATUS.read, true)
.execute();
} }
// Insert new statuses for entries without existing status // Insert new statuses for entries without existing status

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.FeedEntry; import com.commafeed.backend.model.FeedEntry;
import com.commafeed.backend.model.FeedEntryTag; import com.commafeed.backend.model.FeedEntryTag;
import com.commafeed.backend.model.QFeedEntryTag; import com.commafeed.backend.model.QFeedEntryTag;
@@ -17,8 +18,8 @@ public class FeedEntryTagDAO extends GenericDAO<FeedEntryTag> {
private static final QFeedEntryTag TAG = QFeedEntryTag.feedEntryTag; private static final QFeedEntryTag TAG = QFeedEntryTag.feedEntryTag;
public FeedEntryTagDAO(EntityManager entityManager) { public FeedEntryTagDAO(EntityManager entityManager, CommaFeedConfiguration config) {
super(entityManager, FeedEntryTag.class); super(entityManager, FeedEntryTag.class, config);
} }
public List<String> findByUser(User user) { public List<String> findByUser(User user) {
@@ -30,11 +31,7 @@ public class FeedEntryTagDAO extends GenericDAO<FeedEntryTag> {
} }
public Map<Long, List<FeedEntryTag>> findByEntries(User user, List<FeedEntry> entries) { public Map<Long, List<FeedEntryTag>> findByEntries(User user, List<FeedEntry> entries) {
return query() return query().selectFrom(TAG).where(TAG.user.eq(user), TAG.entry.in(entries)).fetch().stream()
.selectFrom(TAG)
.where(TAG.user.eq(user), TAG.entry.in(entries))
.fetch()
.stream()
.collect(Collectors.groupingBy(t -> t.getEntry().getId())); .collect(Collectors.groupingBy(t -> t.getEntry().getId()));
} }
} }

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.AbstractModel; import com.commafeed.backend.model.AbstractModel;
import com.commafeed.backend.model.Feed; import com.commafeed.backend.model.Feed;
import com.commafeed.backend.model.FeedCategory; import com.commafeed.backend.model.FeedCategory;
@@ -31,8 +32,8 @@ public class FeedSubscriptionDAO extends GenericDAO<FeedSubscription> {
private final EntityManager entityManager; private final EntityManager entityManager;
public FeedSubscriptionDAO(EntityManager entityManager) { public FeedSubscriptionDAO(EntityManager entityManager, CommaFeedConfiguration config) {
super(entityManager, FeedSubscription.class); super(entityManager, FeedSubscription.class, config);
this.entityManager = entityManager; this.entityManager = entityManager;
} }
@@ -83,9 +84,7 @@ public class FeedSubscriptionDAO extends GenericDAO<FeedSubscription> {
public FeedSubscription findByFeed(User user, Feed feed) { public FeedSubscription findByFeed(User user, Feed feed) {
List<FeedSubscription> subs = List<FeedSubscription> subs =
query().selectFrom(SUBSCRIPTION) query().selectFrom(SUBSCRIPTION).where(SUBSCRIPTION.user.eq(user), SUBSCRIPTION.feed.eq(feed)).fetch();
.where(SUBSCRIPTION.user.eq(user), SUBSCRIPTION.feed.eq(feed))
.fetch();
FeedSubscription sub = subs.stream().findFirst().orElse(null); FeedSubscription sub = subs.stream().findFirst().orElse(null);
return initRelations(sub); return initRelations(sub);
} }
@@ -103,15 +102,11 @@ public class FeedSubscriptionDAO extends GenericDAO<FeedSubscription> {
} }
public Long count(User user) { public Long count(User user) {
return query().select(SUBSCRIPTION.count()) return query().select(SUBSCRIPTION.count()).from(SUBSCRIPTION).where(SUBSCRIPTION.user.eq(user)).fetchOne();
.from(SUBSCRIPTION)
.where(SUBSCRIPTION.user.eq(user))
.fetchOne();
} }
public List<FeedSubscription> findByCategory(User user, FeedCategory category) { public List<FeedSubscription> findByCategory(User user, FeedCategory category) {
JPQLQuery<FeedSubscription> query = JPQLQuery<FeedSubscription> query = query().selectFrom(SUBSCRIPTION).where(SUBSCRIPTION.user.eq(user));
query().selectFrom(SUBSCRIPTION).where(SUBSCRIPTION.user.eq(user));
if (category == null) { if (category == null) {
query.where(SUBSCRIPTION.category.isNull()); query.where(SUBSCRIPTION.category.isNull());
} else { } else {
@@ -121,13 +116,9 @@ public class FeedSubscriptionDAO extends GenericDAO<FeedSubscription> {
} }
public List<FeedSubscription> findByCategories(User user, List<FeedCategory> categories) { public List<FeedSubscription> findByCategories(User user, List<FeedCategory> categories) {
Set<Long> categoryIds = Set<Long> categoryIds = categories.stream().map(AbstractModel::getId).collect(Collectors.toSet());
categories.stream().map(AbstractModel::getId).collect(Collectors.toSet());
return findAll(user).stream() return findAll(user).stream()
.filter( .filter(s -> s.getCategory() != null && categoryIds.contains(s.getCategory().getId()))
s ->
s.getCategory() != null
&& categoryIds.contains(s.getCategory().getId()))
.toList(); .toList();
} }

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.AbstractModel; import com.commafeed.backend.model.AbstractModel;
import com.querydsl.core.types.EntityPath; import com.querydsl.core.types.EntityPath;
import com.querydsl.jpa.impl.JPADeleteClause; import com.querydsl.jpa.impl.JPADeleteClause;
@@ -21,9 +22,15 @@ public abstract class GenericDAO<T extends AbstractModel> {
private final EntityManager entityManager; private final EntityManager entityManager;
private final Class<T> entityClass; private final Class<T> entityClass;
private final CommaFeedConfiguration config;
protected JPAQueryFactory query() { protected JPAQueryFactory query() {
return new JPAQueryFactory(entityManager); return new JPAQueryFactory(entityManager) {
@Override
public JPAQuery<?> query() {
return withTimeout(super.query(), config.database().queryTimeout());
}
};
} }
protected JPAUpdateClause updateQuery(EntityPath<T> entityPath) { protected JPAUpdateClause updateQuery(EntityPath<T> entityPath) {
@@ -57,9 +64,10 @@ public abstract class GenericDAO<T extends AbstractModel> {
return objects.size(); return objects.size();
} }
protected void setTimeout(JPAQuery<?> query, Duration timeout) { private JPAQuery<?> withTimeout(JPAQuery<?> query, Duration timeout) {
if (!timeout.isZero()) { if (!timeout.isZero()) {
query.setHint(SpecHints.HINT_SPEC_QUERY_TIMEOUT, Math.toIntExact(timeout.toMillis())); query.setHint(SpecHints.HINT_SPEC_QUERY_TIMEOUT, Math.toIntExact(timeout.toMillis()));
} }
return query;
} }
} }

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.QUser; import com.commafeed.backend.model.QUser;
import com.commafeed.backend.model.User; import com.commafeed.backend.model.User;
@@ -11,8 +12,8 @@ public class UserDAO extends GenericDAO<User> {
private static final QUser USER = QUser.user; private static final QUser USER = QUser.user;
public UserDAO(EntityManager entityManager) { public UserDAO(EntityManager entityManager, CommaFeedConfiguration config) {
super(entityManager, User.class); super(entityManager, User.class, config);
} }
public User findByName(String name) { public User findByName(String name) {

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.QUserRole; import com.commafeed.backend.model.QUserRole;
import com.commafeed.backend.model.User; import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserRole; import com.commafeed.backend.model.UserRole;
@@ -17,8 +18,8 @@ public class UserRoleDAO extends GenericDAO<UserRole> {
private static final QUserRole ROLE = QUserRole.userRole; private static final QUserRole ROLE = QUserRole.userRole;
public UserRoleDAO(EntityManager entityManager) { public UserRoleDAO(EntityManager entityManager, CommaFeedConfiguration config) {
super(entityManager, UserRole.class); super(entityManager, UserRole.class, config);
} }
public List<UserRole> findAll() { public List<UserRole> findAll() {

View File

@@ -1,5 +1,6 @@
package com.commafeed.backend.dao; package com.commafeed.backend.dao;
import com.commafeed.CommaFeedConfiguration;
import com.commafeed.backend.model.QUserSettings; import com.commafeed.backend.model.QUserSettings;
import com.commafeed.backend.model.User; import com.commafeed.backend.model.User;
import com.commafeed.backend.model.UserSettings; import com.commafeed.backend.model.UserSettings;
@@ -12,8 +13,8 @@ public class UserSettingsDAO extends GenericDAO<UserSettings> {
private static final QUserSettings SETTINGS = QUserSettings.userSettings; private static final QUserSettings SETTINGS = QUserSettings.userSettings;
public UserSettingsDAO(EntityManager entityManager) { public UserSettingsDAO(EntityManager entityManager, CommaFeedConfiguration config) {
super(entityManager, UserSettings.class); super(entityManager, UserSettings.class, config);
} }
public UserSettings findByUser(User user) { public UserSettings findByUser(User user) {

View File

@@ -37,9 +37,7 @@ public class FacebookFaviconFetcher implements FaviconFetcher {
return null; return null;
} }
String iconUrl = String iconUrl = String.format("https://graph.facebook.com/%s/picture?type=square&height=16", userName);
String.format(
"https://graph.facebook.com/%s/picture?type=square&height=16", userName);
try { try {
log.debug("Getting Facebook user's icon, {}", url); log.debug("Getting Facebook user's icon, {}", url);

View File

@@ -17,8 +17,7 @@ public record Favicon(byte[] icon, MediaType mediaType) {
try { try {
return MediaType.valueOf(contentType); return MediaType.valueOf(contentType);
} catch (Exception e) { } catch (Exception e) {
log.debug( log.debug("invalid content type '{}' received, returning default value", contentType, e);
"invalid content type '{}' received, returning default value", contentType, e);
return DEFAULT_MEDIA_TYPE; return DEFAULT_MEDIA_TYPE;
} }
} }

View File

@@ -32,10 +32,7 @@ public class RootFaviconFetcher implements FaviconFetcher {
URI uri = URI.create(url.trim()); URI uri = URI.create(url.trim());
String faviconUrl = String faviconUrl =
"%s://%s%s/favicon.ico" "%s://%s%s/favicon.ico"
.formatted( .formatted(uri.getScheme(), uri.getHost(), uri.getPort() > 0 ? ":" + uri.getPort() : "");
uri.getScheme(),
uri.getHost(),
uri.getPort() > 0 ? ":" + uri.getPort() : "");
log.debug("getting root icon at {}", faviconUrl); log.debug("getting root icon at {}", faviconUrl);
HttpResult result = getter.get(faviconUrl); HttpResult result = getter.get(faviconUrl);

View File

@@ -37,8 +37,7 @@ public class YoutubeFaviconFetcher implements FaviconFetcher {
private static final JsonPointer CHANNEL_THUMBNAIL_URL = private static final JsonPointer CHANNEL_THUMBNAIL_URL =
JsonPointer.compile("/items/0/snippet/thumbnails/default/url"); JsonPointer.compile("/items/0/snippet/thumbnails/default/url");
private static final JsonPointer PLAYLIST_CHANNEL_ID = private static final JsonPointer PLAYLIST_CHANNEL_ID = JsonPointer.compile("/items/0/snippet/channelId");
JsonPointer.compile("/items/0/snippet/channelId");
private final HttpGetter getter; private final HttpGetter getter;
private final CommaFeedConfiguration config; private final CommaFeedConfiguration config;
@@ -60,17 +59,11 @@ public class YoutubeFaviconFetcher implements FaviconFetcher {
try { try {
List<NameValuePair> params = new URIBuilder(url).getQueryParams(); List<NameValuePair> params = new URIBuilder(url).getQueryParams();
Optional<NameValuePair> userId = Optional<NameValuePair> userId =
params.stream() params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("user")).findFirst();
.filter(nvp -> nvp.getName().equalsIgnoreCase("user"))
.findFirst();
Optional<NameValuePair> channelId = Optional<NameValuePair> channelId =
params.stream() params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("channel_id")).findFirst();
.filter(nvp -> nvp.getName().equalsIgnoreCase("channel_id"))
.findFirst();
Optional<NameValuePair> playlistId = Optional<NameValuePair> playlistId =
params.stream() params.stream().filter(nvp -> nvp.getName().equalsIgnoreCase("playlist_id")).findFirst();
.filter(nvp -> nvp.getName().equalsIgnoreCase("playlist_id"))
.findFirst();
byte[] response = null; byte[] response = null;
if (userId.isPresent()) { if (userId.isPresent()) {
@@ -103,10 +96,7 @@ public class YoutubeFaviconFetcher implements FaviconFetcher {
} }
private byte[] fetchForUser(String googleAuthKey, String userId) private byte[] fetchForUser(String googleAuthKey, String userId)
throws IOException, throws IOException, NotModifiedException, TooManyRequestsException, SchemeNotAllowedException {
NotModifiedException,
TooManyRequestsException,
SchemeNotAllowedException {
URI uri = URI uri =
UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/channels") UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/channels")
.queryParam("part", PART_SNIPPET) .queryParam("part", PART_SNIPPET)
@@ -117,10 +107,7 @@ public class YoutubeFaviconFetcher implements FaviconFetcher {
} }
private byte[] fetchForChannel(String googleAuthKey, String channelId) private byte[] fetchForChannel(String googleAuthKey, String channelId)
throws IOException, throws IOException, NotModifiedException, TooManyRequestsException, SchemeNotAllowedException {
NotModifiedException,
TooManyRequestsException,
SchemeNotAllowedException {
URI uri = URI uri =
UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/channels") UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/channels")
.queryParam("part", PART_SNIPPET) .queryParam("part", PART_SNIPPET)
@@ -131,10 +118,7 @@ public class YoutubeFaviconFetcher implements FaviconFetcher {
} }
private byte[] fetchForPlaylist(String googleAuthKey, String playlistId) private byte[] fetchForPlaylist(String googleAuthKey, String playlistId)
throws IOException, throws IOException, NotModifiedException, TooManyRequestsException, SchemeNotAllowedException {
NotModifiedException,
TooManyRequestsException,
SchemeNotAllowedException {
URI uri = URI uri =
UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/playlists") UriBuilder.fromUri("https://www.googleapis.com/youtube/v3/playlists")
.queryParam("part", PART_SNIPPET) .queryParam("part", PART_SNIPPET)

View File

@@ -36,8 +36,7 @@ public class FeedFetcher {
private final HttpGetter getter; private final HttpGetter getter;
private final List<FeedURLProvider> urlProviders; private final List<FeedURLProvider> urlProviders;
public FeedFetcher( public FeedFetcher(FeedParser parser, HttpGetter getter, @All List<FeedURLProvider> urlProviders) {
FeedParser parser, HttpGetter getter, @All List<FeedURLProvider> urlProviders) {
this.parser = parser; this.parser = parser;
this.getter = getter; this.getter = getter;
this.urlProviders = urlProviders; this.urlProviders = urlProviders;
@@ -58,9 +57,7 @@ public class FeedFetcher {
NoFeedFoundException { NoFeedFoundException {
log.debug("Fetching feed {}", feedUrl); log.debug("Fetching feed {}", feedUrl);
HttpResult result = HttpResult result = getter.get(HttpRequest.builder(feedUrl).lastModified(lastModified).eTag(eTag).build());
getter.get(
HttpRequest.builder(feedUrl).lastModified(lastModified).eTag(eTag).build());
byte[] content = result.content(); byte[] content = result.content();
FeedParserResult parserResult; FeedParserResult parserResult;
@@ -71,17 +68,13 @@ public class FeedFetcher {
String extractedUrl = String extractedUrl =
extractFeedUrl( extractFeedUrl(
urlProviders, urlProviders,
feedUrl, result.urlAfterRedirect(),
new String(result.content(), StandardCharsets.UTF_8)); new String(result.content(), StandardCharsets.UTF_8));
if (StringUtils.isNotBlank(extractedUrl)) { if (StringUtils.isNotBlank(extractedUrl)) {
feedUrl = extractedUrl; feedUrl = extractedUrl;
result = result =
getter.get( getter.get(HttpRequest.builder(extractedUrl).lastModified(lastModified).eTag(eTag).build());
HttpRequest.builder(extractedUrl)
.lastModified(lastModified)
.eTag(eTag)
.build());
content = result.content(); content = result.content();
parserResult = parser.parse(result.urlAfterRedirect(), content); parserResult = parser.parse(result.urlAfterRedirect(), content);
} else { } else {
@@ -96,8 +89,7 @@ public class FeedFetcher {
throw new IOException("Feed content is empty."); throw new IOException("Feed content is empty.");
} }
boolean lastModifiedHeaderValueChanged = boolean lastModifiedHeaderValueChanged = !Strings.CS.equals(lastModified, result.lastModifiedSince());
!Strings.CS.equals(lastModified, result.lastModifiedSince());
boolean etagHeaderValueChanged = !Strings.CS.equals(eTag, result.eTag()); boolean etagHeaderValueChanged = !Strings.CS.equals(eTag, result.eTag());
String hash = Digests.sha1Hex(content); String hash = Digests.sha1Hex(content);
@@ -109,8 +101,7 @@ public class FeedFetcher {
etagHeaderValueChanged ? result.eTag() : null); etagHeaderValueChanged ? result.eTag() : null);
} }
if (lastPublishedDate != null if (lastPublishedDate != null && lastPublishedDate.equals(parserResult.lastPublishedDate())) {
&& lastPublishedDate.equals(parserResult.lastPublishedDate())) {
log.debug("publishedDate not modified: {}", feedUrl); log.debug("publishedDate not modified: {}", feedUrl);
throw new NotModifiedException( throw new NotModifiedException(
"publishedDate not modified", "publishedDate not modified",
@@ -127,8 +118,7 @@ public class FeedFetcher {
result.validFor()); result.validFor());
} }
private static String extractFeedUrl( private static String extractFeedUrl(List<FeedURLProvider> urlProviders, String url, String urlContent) {
List<FeedURLProvider> urlProviders, String url, String urlContent) {
return urlProviders.stream() return urlProviders.stream()
.flatMap(provider -> provider.get(url, urlContent).stream()) .flatMap(provider -> provider.get(url, urlContent).stream())
.filter(StringUtils::isNotBlank) .filter(StringUtils::isNotBlank)

View File

@@ -67,8 +67,7 @@ public class FeedRefreshEngine {
this.queue = new LinkedBlockingDeque<>(); this.queue = new LinkedBlockingDeque<>();
metrics.register( metrics.register(MetricRegistry.name(getClass(), "queue", "size"), (Gauge<Integer>) queue::size);
MetricRegistry.name(getClass(), "queue", "size"), (Gauge<Integer>) queue::size);
metrics.register( metrics.register(
MetricRegistry.name(getClass(), "worker", "active"), MetricRegistry.name(getClass(), "worker", "active"),
(Gauge<Integer>) () -> workerExecutor.getActiveCount()); (Gauge<Integer>) () -> workerExecutor.getActiveCount());
@@ -88,12 +87,10 @@ public class FeedRefreshEngine {
this.refillLoopExecutor = Executors.newSingleThreadExecutor(); this.refillLoopExecutor = Executors.newSingleThreadExecutor();
this.refillExecutor = newDiscardingSingleThreadExecutorService(); this.refillExecutor = newDiscardingSingleThreadExecutorService();
this.workerExecutor = newBlockingExecutorService(config.feedRefresh().httpThreads()); this.workerExecutor = newBlockingExecutorService(config.feedRefresh().httpThreads());
this.databaseUpdaterExecutor = this.databaseUpdaterExecutor = newBlockingExecutorService(config.feedRefresh().databaseThreads());
newBlockingExecutorService(config.feedRefresh().databaseThreads());
this.notifierExecutor = this.notifierExecutor =
newDiscardingExecutorService( newDiscardingExecutorService(
config.pushNotifications().threads(), config.pushNotifications().threads(), config.pushNotifications().queueCapacity());
config.pushNotifications().queueCapacity());
} }
public void start() { public void start() {
@@ -104,56 +101,52 @@ public class FeedRefreshEngine {
private void startFeedProcessingLoop() { private void startFeedProcessingLoop() {
// take a feed from the queue, process it, rince, repeat // take a feed from the queue, process it, rince, repeat
feedProcessingLoopExecutor.submit( feedProcessingLoopExecutor.submit(() -> {
() -> { while (!feedProcessingLoopExecutor.isShutdown()) {
while (!feedProcessingLoopExecutor.isShutdown()) { try {
try { // take() is blocking until a feed is available from the queue
// take() is blocking until a feed is available from the queue Feed feed = queue.take();
Feed feed = queue.take();
// send the feed to be processed // send the feed to be processed
log.debug( log.debug("got feed {} from the queue, send it for processing", feed.getId());
"got feed {} from the queue, send it for processing", processFeedAsync(feed);
feed.getId());
processFeedAsync(feed);
// we removed a feed from the queue, try to refill it as it may now be // we removed a feed from the queue, try to refill it as it may now be
// empty // empty
if (queue.isEmpty()) { if (queue.isEmpty()) {
log.debug("took the last feed from the queue, try to refill"); log.debug("took the last feed from the queue, try to refill");
refillQueueAsync(); refillQueueAsync();
}
} catch (InterruptedException e) {
log.debug("interrupted while waiting for a feed in the queue");
Thread.currentThread().interrupt();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
} }
}); } catch (InterruptedException e) {
log.debug("interrupted while waiting for a feed in the queue");
Thread.currentThread().interrupt();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
});
} }
private void startRefillLoop() { private void startRefillLoop() {
// refill the queue at regular intervals if it's empty // refill the queue at regular intervals if it's empty
refillLoopExecutor.submit( refillLoopExecutor.submit(() -> {
() -> { while (!refillLoopExecutor.isShutdown()) {
while (!refillLoopExecutor.isShutdown()) { try {
try { if (queue.isEmpty()) {
if (queue.isEmpty()) { log.debug("refilling queue");
log.debug("refilling queue"); refillQueueAsync();
refillQueueAsync();
}
log.debug("sleeping for 15s");
TimeUnit.SECONDS.sleep(15);
} catch (InterruptedException e) {
log.debug("interrupted while sleeping");
Thread.currentThread().interrupt();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
} }
});
log.debug("sleeping for 15s");
TimeUnit.SECONDS.sleep(15);
} catch (InterruptedException e) {
log.debug("interrupted while sleeping");
Thread.currentThread().interrupt();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
});
} }
public void refreshImmediately(Feed feed) { public void refreshImmediately(Feed feed) {
@@ -173,9 +166,7 @@ public class FeedRefreshEngine {
refill.mark(); refill.mark();
List<Feed> nextUpdatableFeeds = getNextUpdatableFeeds(getBatchSize()); List<Feed> nextUpdatableFeeds = getNextUpdatableFeeds(getBatchSize());
log.debug( log.debug("found {} feeds that are up for refresh", nextUpdatableFeeds.size());
"found {} feeds that are up for refresh",
nextUpdatableFeeds.size());
for (Feed feed : nextUpdatableFeeds) { for (Feed feed : nextUpdatableFeeds) {
// add the feed only if it was not already queued // add the feed only if it was not already queued
if (queue.stream().noneMatch(f -> f.getId().equals(feed.getId()))) { if (queue.stream().noneMatch(f -> f.getId().equals(feed.getId()))) {
@@ -184,65 +175,51 @@ public class FeedRefreshEngine {
} }
}, },
refillExecutor) refillExecutor)
.whenComplete( .whenComplete((data, ex) -> {
(data, ex) -> { if (ex != null) {
if (ex != null) { log.error("error while refilling the queue", ex);
log.error("error while refilling the queue", ex); }
} });
});
} }
private void processFeedAsync(Feed feed) { private void processFeedAsync(Feed feed) {
CompletableFuture.supplyAsync(() -> worker.update(feed), workerExecutor) CompletableFuture.supplyAsync(() -> worker.update(feed), workerExecutor)
.thenApplyAsync(r -> updater.update(r.feed(), r.entries()), databaseUpdaterExecutor) .thenApplyAsync(r -> updater.update(r.feed(), r.entries()), databaseUpdaterExecutor)
.thenCompose( .thenCompose(r -> {
r -> { List<CompletableFuture<Void>> futures =
List<CompletableFuture<Void>> futures = r.insertedUnreadEntriesBySubscription().entrySet().stream()
r.insertedUnreadEntriesBySubscription().entrySet().stream() .map(e -> {
.map( FeedSubscription sub = e.getKey();
e -> { List<FeedEntry> entries = e.getValue();
FeedSubscription sub = e.getKey();
List<FeedEntry> entries = e.getValue();
notifier.notifyOverWebsocket(sub, entries); notifier.notifyOverWebsocket(sub, entries);
return CompletableFuture.runAsync( return CompletableFuture.runAsync(
() -> () -> notifier.sendPushNotifications(sub, entries), notifierExecutor);
notifier })
.sendPushNotifications( .toList();
sub, return CompletableFuture.allOf(futures.toArray(CompletableFuture[]::new));
entries), })
notifierExecutor); .exceptionally(ex -> {
}) log.error("error while processing feed {}", feed.getUrl(), ex);
.toList(); return null;
return CompletableFuture.allOf( });
futures.toArray(CompletableFuture[]::new));
})
.exceptionally(
ex -> {
log.error("error while processing feed {}", feed.getUrl(), ex);
return null;
});
} }
private List<Feed> getNextUpdatableFeeds(int max) { private List<Feed> getNextUpdatableFeeds(int max) {
return unitOfWork.call( return unitOfWork.call(() -> {
() -> { Instant lastLoginThreshold =
Instant lastLoginThreshold = config.feedRefresh().userInactivityPeriod().isZero()
config.feedRefresh().userInactivityPeriod().isZero() ? null
? null : Instant.now().minus(config.feedRefresh().userInactivityPeriod());
: Instant.now() List<Feed> feeds = feedDAO.findNextUpdatable(max, lastLoginThreshold);
.minus(config.feedRefresh().userInactivityPeriod()); if (!feeds.isEmpty()) {
List<Feed> feeds = feedDAO.findNextUpdatable(max, lastLoginThreshold); // update disabledUntil to prevent feeds from being returned again by
if (!feeds.isEmpty()) { // feedDAO.findNextUpdatable()
// update disabledUntil to prevent feeds from being returned again by Instant nextUpdateDate = Instant.now().plus(config.feedRefresh().interval());
// feedDAO.findNextUpdatable() feedDAO.setDisabledUntil(feeds.stream().map(AbstractModel::getId).toList(), nextUpdateDate);
Instant nextUpdateDate = }
Instant.now().plus(config.feedRefresh().interval()); return feeds;
feedDAO.setDisabledUntil( });
feeds.stream().map(AbstractModel::getId).toList(), nextUpdateDate);
}
return feeds;
});
} }
private int getBatchSize() { private int getBatchSize() {
@@ -250,26 +227,19 @@ public class FeedRefreshEngine {
} }
public void stop() { public void stop() {
MoreExecutors.shutdownAndAwaitTermination( MoreExecutors.shutdownAndAwaitTermination(this.feedProcessingLoopExecutor, config.shutdownTimeout());
this.feedProcessingLoopExecutor, config.shutdownTimeout()); MoreExecutors.shutdownAndAwaitTermination(this.refillLoopExecutor, config.shutdownTimeout());
MoreExecutors.shutdownAndAwaitTermination(
this.refillLoopExecutor, config.shutdownTimeout());
MoreExecutors.shutdownAndAwaitTermination(this.refillExecutor, config.shutdownTimeout()); MoreExecutors.shutdownAndAwaitTermination(this.refillExecutor, config.shutdownTimeout());
MoreExecutors.shutdownAndAwaitTermination(this.workerExecutor, config.shutdownTimeout()); MoreExecutors.shutdownAndAwaitTermination(this.workerExecutor, config.shutdownTimeout());
MoreExecutors.shutdownAndAwaitTermination( MoreExecutors.shutdownAndAwaitTermination(this.databaseUpdaterExecutor, config.shutdownTimeout());
this.databaseUpdaterExecutor, config.shutdownTimeout());
MoreExecutors.shutdownAndAwaitTermination(this.notifierExecutor, config.shutdownTimeout()); MoreExecutors.shutdownAndAwaitTermination(this.notifierExecutor, config.shutdownTimeout());
queue.clear(); queue.clear();
} }
/** /** returns an ExecutorService with a single thread that discards tasks if a task is already running */
* returns an ExecutorService with a single thread that discards tasks if a task is already
* running
*/
private ThreadPoolExecutor newDiscardingSingleThreadExecutorService() { private ThreadPoolExecutor newDiscardingSingleThreadExecutorService() {
ThreadPoolExecutor pool = ThreadPoolExecutor pool = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new SynchronousQueue<>());
new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new SynchronousQueue<>());
pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy()); pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
return pool; return pool;
} }
@@ -278,11 +248,7 @@ public class FeedRefreshEngine {
private ThreadPoolExecutor newDiscardingExecutorService(int threads, int queueCapacity) { private ThreadPoolExecutor newDiscardingExecutorService(int threads, int queueCapacity) {
ThreadPoolExecutor pool = ThreadPoolExecutor pool =
new ThreadPoolExecutor( new ThreadPoolExecutor(
threads, threads, threads, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(queueCapacity));
threads,
0L,
TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<>(queueCapacity));
pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy()); pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardPolicy());
return pool; return pool;
} }
@@ -290,21 +256,19 @@ public class FeedRefreshEngine {
/** returns an ExecutorService that blocks submissions until a thread is available */ /** returns an ExecutorService that blocks submissions until a thread is available */
private ThreadPoolExecutor newBlockingExecutorService(int threads) { private ThreadPoolExecutor newBlockingExecutorService(int threads) {
ThreadPoolExecutor pool = ThreadPoolExecutor pool =
new ThreadPoolExecutor( new ThreadPoolExecutor(threads, threads, 0L, TimeUnit.MILLISECONDS, new SynchronousQueue<>());
threads, threads, 0L, TimeUnit.MILLISECONDS, new SynchronousQueue<>()); pool.setRejectedExecutionHandler((r, e) -> {
pool.setRejectedExecutionHandler( if (e.isShutdown()) {
(r, e) -> { return;
if (e.isShutdown()) { }
return;
}
try { try {
e.getQueue().put(r); e.getQueue().put(r);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
log.debug("interrupted while waiting for a slot in the queue.", ex); log.debug("interrupted while waiting for a slot in the queue.", ex);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
}); });
return pool; return pool;
} }
} }

View File

@@ -22,8 +22,7 @@ public class FeedRefreshIntervalCalculator {
private final FeedRefreshErrorHandling errorHandling; private final FeedRefreshErrorHandling errorHandling;
private final InstantSource instantSource; private final InstantSource instantSource;
public FeedRefreshIntervalCalculator( public FeedRefreshIntervalCalculator(CommaFeedConfiguration config, InstantSource instantSource) {
CommaFeedConfiguration config, InstantSource instantSource) {
this.interval = config.feedRefresh().interval(); this.interval = config.feedRefresh().interval();
this.maxInterval = config.feedRefresh().maxInterval(); this.maxInterval = config.feedRefresh().maxInterval();
this.empirical = config.feedRefresh().intervalEmpirical(); this.empirical = config.feedRefresh().intervalEmpirical();
@@ -31,8 +30,7 @@ public class FeedRefreshIntervalCalculator {
this.instantSource = instantSource; this.instantSource = instantSource;
} }
public Instant onFetchSuccess( public Instant onFetchSuccess(Instant publishedDate, Long averageEntryInterval, Duration validFor) {
Instant publishedDate, Long averageEntryInterval, Duration validFor) {
Instant instant = Instant instant =
empirical empirical
? computeEmpiricalRefreshInterval(publishedDate, averageEntryInterval) ? computeEmpiricalRefreshInterval(publishedDate, averageEntryInterval)
@@ -54,14 +52,11 @@ public class FeedRefreshIntervalCalculator {
} }
Duration retryInterval = Duration retryInterval =
errorHandling errorHandling.backoffInterval().multipliedBy(errorCount - errorHandling.retriesBeforeBackoff() + 1L);
.backoffInterval()
.multipliedBy(errorCount - errorHandling.retriesBeforeBackoff() + 1L);
return constrainToBounds(instantSource.instant().plus(retryInterval)); return constrainToBounds(instantSource.instant().plus(retryInterval));
} }
private Instant computeEmpiricalRefreshInterval( private Instant computeEmpiricalRefreshInterval(Instant publishedDate, Long averageEntryInterval) {
Instant publishedDate, Long averageEntryInterval) {
Instant now = instantSource.instant(); Instant now = instantSource.instant();
if (publishedDate == null) { if (publishedDate == null) {
@@ -80,9 +75,7 @@ public class FeedRefreshIntervalCalculator {
int factor = 2; int factor = 2;
long millis = long millis =
Longs.constrainToRange( Longs.constrainToRange(
averageEntryInterval / factor, averageEntryInterval / factor, interval.toMillis(), maxInterval.dividedBy(4).toMillis());
interval.toMillis(),
maxInterval.dividedBy(4).toMillis());
return now.plusMillis(millis); return now.plusMillis(millis);
} else { } else {
// unknown case // unknown case

View File

@@ -64,8 +64,7 @@ public class FeedRefreshUpdater {
entryInserted = metrics.meter(MetricRegistry.name(getClass(), "entryInserted")); entryInserted = metrics.meter(MetricRegistry.name(getClass(), "entryInserted"));
} }
private AddEntryResult addEntry( private AddEntryResult addEntry(final Feed feed, final Entry entry, final List<FeedSubscription> subscriptions) {
final Feed feed, final Entry entry, final List<FeedSubscription> subscriptions) {
boolean processed = false; boolean processed = false;
FeedEntry insertedEntry = null; FeedEntry insertedEntry = null;
Set<FeedSubscription> subscriptionsForWhichEntryIsUnread = new HashSet<>(); Set<FeedSubscription> subscriptionsForWhichEntryIsUnread = new HashSet<>();
@@ -91,33 +90,27 @@ public class FeedRefreshUpdater {
if (locked1 && locked2) { if (locked1 && locked2) {
processed = true; processed = true;
insertedEntry = insertedEntry =
unitOfWork.call( unitOfWork.call(() -> {
() -> { if (feedEntryService.find(feed, entry) != null) {
if (feedEntryService.find(feed, entry) != null) { // entry already exists, nothing to do
// entry already exists, nothing to do return null;
return null; }
}
FeedEntry feedEntry = feedEntryService.create(feed, entry); FeedEntry feedEntry = feedEntryService.create(feed, entry);
entryInserted.mark(); entryInserted.mark();
for (FeedSubscription sub : subscriptions) { for (FeedSubscription sub : subscriptions) {
boolean unread = boolean unread = feedEntryService.applyFilter(sub, feedEntry);
feedEntryService.applyFilter(sub, feedEntry); if (unread) {
if (unread) { subscriptionsForWhichEntryIsUnread.add(sub);
subscriptionsForWhichEntryIsUnread.add(sub); }
} }
} return feedEntry;
return feedEntry; });
});
} else { } else {
log.error("lock timeout for {} - {}", feed.getUrl(), key1); log.error("lock timeout for {} - {}", feed.getUrl(), key1);
} }
} catch (InterruptedException e) { } catch (InterruptedException e) {
log.error( log.error("interrupted while waiting for lock for {} : {}", feed.getUrl(), e.getMessage(), e);
"interrupted while waiting for lock for {} : {}",
feed.getUrl(),
e.getMessage(),
e);
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} finally { } finally {
if (locked1) { if (locked1) {
@@ -133,13 +126,11 @@ public class FeedRefreshUpdater {
public FeedRefreshUpdaterResult update(Feed feed, List<Entry> entries) { public FeedRefreshUpdaterResult update(Feed feed, List<Entry> entries) {
boolean processed = true; boolean processed = true;
long inserted = 0; long inserted = 0;
Map<FeedSubscription, List<FeedEntry>> insertedUnreadEntriesBySubscription = Map<FeedSubscription, List<FeedEntry>> insertedUnreadEntriesBySubscription = new HashMap<>();
new HashMap<>();
if (!entries.isEmpty()) { if (!entries.isEmpty()) {
List<FeedSubscription> subscriptions = null; List<FeedSubscription> subscriptions = null;
List<Entry> newEntries = List<Entry> newEntries = unitOfWork.call(() -> feedEntryService.removeExistingEntries(feed, entries));
unitOfWork.call(() -> feedEntryService.removeExistingEntries(feed, entries));
for (Entry entry : newEntries) { for (Entry entry : newEntries) {
if (subscriptions == null) { if (subscriptions == null) {
subscriptions = unitOfWork.call(() -> feedSubscriptionDAO.findByFeed(feed)); subscriptions = unitOfWork.call(() -> feedSubscriptionDAO.findByFeed(feed));
@@ -147,14 +138,13 @@ public class FeedRefreshUpdater {
AddEntryResult addEntryResult = addEntry(feed, entry, subscriptions); AddEntryResult addEntryResult = addEntry(feed, entry, subscriptions);
processed &= addEntryResult.processed; processed &= addEntryResult.processed;
inserted += addEntryResult.insertedEntry != null ? 1 : 0; inserted += addEntryResult.insertedEntry != null ? 1 : 0;
addEntryResult.subscriptionsForWhichEntryIsUnread.forEach( addEntryResult.subscriptionsForWhichEntryIsUnread.forEach(sub -> {
sub -> { if (addEntryResult.insertedEntry != null) {
if (addEntryResult.insertedEntry != null) { insertedUnreadEntriesBySubscription
insertedUnreadEntriesBySubscription .computeIfAbsent(sub, k -> new ArrayList<>())
.computeIfAbsent(sub, k -> new ArrayList<>()) .add(addEntryResult.insertedEntry);
.add(addEntryResult.insertedEntry); }
} });
});
} }
if (inserted == 0) { if (inserted == 0) {
@@ -179,9 +169,7 @@ public class FeedRefreshUpdater {
} }
private record AddEntryResult( private record AddEntryResult(
boolean processed, boolean processed, FeedEntry insertedEntry, Set<FeedSubscription> subscriptionsForWhichEntryIsUnread) {}
FeedEntry insertedEntry,
Set<FeedSubscription> subscriptionsForWhichEntryIsUnread) {}
public record FeedRefreshUpdaterResult( public record FeedRefreshUpdaterResult(
Map<FeedSubscription, List<FeedEntry>> insertedUnreadEntriesBySubscription) {} Map<FeedSubscription, List<FeedEntry>> insertedUnreadEntriesBySubscription) {}

View File

@@ -22,8 +22,8 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
/** /**
* Calls {@link FeedFetcher} and updates the Feed object, but does not update the database, ({@link * Calls {@link FeedFetcher} and updates the Feed object, but does not update the database, ({@link FeedRefreshUpdater}
* FeedRefreshUpdater} does that) * does that)
*/ */
@Slf4j @Slf4j
@Singleton @Singleton
@@ -68,10 +68,7 @@ public class FeedRefreshWorker {
Duration entriesMaxAge = config.database().cleanup().entriesMaxAge(); Duration entriesMaxAge = config.database().cleanup().entriesMaxAge();
if (!entriesMaxAge.isZero()) { if (!entriesMaxAge.isZero()) {
Instant threshold = Instant.now().minus(entriesMaxAge); Instant threshold = Instant.now().minus(entriesMaxAge);
entries = entries = entries.stream().filter(entry -> entry.published().isAfter(threshold)).toList();
entries.stream()
.filter(entry -> entry.published().isAfter(threshold))
.toList();
} }
String urlAfterRedirect = result.urlAfterRedirect(); String urlAfterRedirect = result.urlAfterRedirect();
@@ -121,9 +118,7 @@ public class FeedRefreshWorker {
feed.setErrorCount(feed.getErrorCount() + 1); feed.setErrorCount(feed.getErrorCount() + 1);
feed.setMessage("Server indicated that we are sending too many requests"); feed.setMessage("Server indicated that we are sending too many requests");
feed.setDisabledUntil( feed.setDisabledUntil(refreshIntervalCalculator.onTooManyRequests(e.getRetryAfter(), feed.getErrorCount()));
refreshIntervalCalculator.onTooManyRequests(
e.getRetryAfter(), feed.getErrorCount()));
return new FeedRefreshWorkerResult(feed, Collections.emptyList()); return new FeedRefreshWorkerResult(feed, Collections.emptyList());
} catch (Exception e) { } catch (Exception e) {

View File

@@ -30,15 +30,12 @@ public class FeedUpdateNotifier {
public void notifyOverWebsocket(FeedSubscription sub, List<FeedEntry> entries) { public void notifyOverWebsocket(FeedSubscription sub, List<FeedEntry> entries) {
if (!entries.isEmpty()) { if (!entries.isEmpty()) {
webSocketSessions.sendMessage( webSocketSessions.sendMessage(sub.getUser(), WebSocketMessageBuilder.newFeedEntries(sub, entries.size()));
sub.getUser(), WebSocketMessageBuilder.newFeedEntries(sub, entries.size()));
} }
} }
public void sendPushNotifications(FeedSubscription sub, List<FeedEntry> entries) { public void sendPushNotifications(FeedSubscription sub, List<FeedEntry> entries) {
if (!config.pushNotifications().enabled() if (!config.pushNotifications().enabled() || !sub.isPushNotificationsEnabled() || entries.isEmpty()) {
|| !sub.isPushNotificationsEnabled()
|| entries.isEmpty()) {
return; return;
} }

View File

@@ -40,8 +40,7 @@ public class FeedUtils {
return false; return false;
} }
return TextDirectionDetector.detect(stripped) return TextDirectionDetector.detect(stripped) == TextDirectionDetector.Direction.RIGHT_TO_LEFT;
== TextDirectionDetector.Direction.RIGHT_TO_LEFT;
} }
public static String getFaviconUrl(FeedSubscription subscription) { public static String getFaviconUrl(FeedSubscription subscription) {

View File

@@ -14,8 +14,8 @@ import java.nio.charset.Charset;
public class EncodingDetector { public class EncodingDetector {
/** /**
* Detect feed encoding by using the declared encoding in the xml processing instruction and by * Detect feed encoding by using the declared encoding in the xml processing instruction and by detecting the
* detecting the characters used in the feed * characters used in the feed
*/ */
public Charset getEncoding(byte[] bytes) { public Charset getEncoding(byte[] bytes) {
String extracted = extractDeclaredEncoding(bytes); String extracted = extractDeclaredEncoding(bytes);

View File

@@ -42,14 +42,12 @@ import java.util.stream.Collectors;
@Singleton @Singleton
public class FeedParser { public class FeedParser {
private static final Namespace ATOM_10_NS = private static final Namespace ATOM_10_NS = Namespace.getNamespace("http://www.w3.org/2005/Atom");
Namespace.getNamespace("http://www.w3.org/2005/Atom");
private static final Instant START = Instant.ofEpochMilli(86400000); private static final Instant START = Instant.ofEpochMilli(86400000);
private static final Instant END = Instant.ofEpochMilli(1000L * Integer.MAX_VALUE - 86400000); private static final Instant END = Instant.ofEpochMilli(1000L * Integer.MAX_VALUE - 86400000);
private static final Comparator<Entry> ENTRY_COMPARATOR = private static final Comparator<Entry> ENTRY_COMPARATOR = Comparator.comparing(Entry::published).reversed();
Comparator.comparing(Entry::published).reversed();
private final EncodingDetector encodingDetector; private final EncodingDetector encodingDetector;
private final XMLCleaner xmlCleaner; private final XMLCleaner xmlCleaner;
@@ -78,20 +76,13 @@ public class FeedParser {
List<Entry> entries = buildEntries(feed, feedUrl); List<Entry> entries = buildEntries(feed, feedUrl);
Instant lastEntryDate = entries.stream().findFirst().map(Entry::published).orElse(null); Instant lastEntryDate = entries.stream().findFirst().map(Entry::published).orElse(null);
Instant lastPublishedDate = toValidInstant(feed.getPublishedDate(), false); Instant lastPublishedDate = toValidInstant(feed.getPublishedDate(), false);
if (lastPublishedDate == null if (lastPublishedDate == null || lastEntryDate != null && lastPublishedDate.isBefore(lastEntryDate)) {
|| lastEntryDate != null && lastPublishedDate.isBefore(lastEntryDate)) {
lastPublishedDate = lastEntryDate; lastPublishedDate = lastEntryDate;
} }
Long averageEntryInterval = averageTimeBetweenEntries(entries); Long averageEntryInterval = averageTimeBetweenEntries(entries);
return new FeedParserResult( return new FeedParserResult(
title, title, link, iconUrl, lastPublishedDate, averageEntryInterval, lastEntryDate, entries);
link,
iconUrl,
lastPublishedDate,
averageEntryInterval,
lastEntryDate,
entries);
} catch (FeedParsingException e) { } catch (FeedParsingException e) {
throw e; throw e;
} catch (Exception e) { } catch (Exception e) {
@@ -151,9 +142,7 @@ public class FeedParser {
String author = StringUtils.trimToNull(item.getAuthor()); String author = StringUtils.trimToNull(item.getAuthor());
String categories = String categories =
StringUtils.trimToNull( StringUtils.trimToNull(
item.getCategories().stream() item.getCategories().stream().map(SyndCategory::getName).collect(Collectors.joining(", ")));
.map(SyndCategory::getName)
.collect(Collectors.joining(", ")));
Enclosure enclosure = buildEnclosure(item); Enclosure enclosure = buildEnclosure(item);
Media media = buildMedia(item); Media media = buildMedia(item);
@@ -281,9 +270,7 @@ public class FeedParser {
SummaryStatistics stats = new SummaryStatistics(); SummaryStatistics stats = new SummaryStatistics();
for (int i = 0; i < entries.size() - 1; i++) { for (int i = 0; i < entries.size() - 1; i++) {
long diff = long diff =
Math.abs( Math.abs(entries.get(i).published().toEpochMilli() - entries.get(i + 1).published().toEpochMilli());
entries.get(i).published().toEpochMilli()
- entries.get(i + 1).published().toEpochMilli());
stats.addValue(diff); stats.addValue(diff);
} }
return (long) stats.getMean(); return (long) stats.getMean();

View File

@@ -14,18 +14,9 @@ public record FeedParserResult(
public record Entry(String guid, String url, Instant published, Content content) {} public record Entry(String guid, String url, Instant published, Content content) {}
public record Content( public record Content(
String title, String title, String content, String author, String categories, Enclosure enclosure, Media media) {}
String content,
String author,
String categories,
Enclosure enclosure,
Media media) {}
public record Enclosure(String url, String type) {} public record Enclosure(String url, String type) {}
public record Media( public record Media(String description, String thumbnailUrl, Integer thumbnailWidth, Integer thumbnailHeight) {}
String description,
String thumbnailUrl,
Integer thumbnailWidth,
Integer thumbnailHeight) {}
} }

View File

@@ -8,16 +8,15 @@ import org.apache.commons.lang3.StringUtils;
import org.jdom2.Verifier; import org.jdom2.Verifier;
import java.util.Collection; import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@Singleton @Singleton
public class XMLCleaner { public class XMLCleaner {
private static final Pattern DOCTYPE_PATTERN = private static final Pattern DOCTYPE_START_PATTERN = Pattern.compile("<!DOCTYPE", Pattern.CASE_INSENSITIVE);
Pattern.compile("<!DOCTYPE[^>]*>", Pattern.CASE_INSENSITIVE);
private final Trie trie = private final Trie trie = Trie.builder().ignoreOverlaps().addKeywords(HtmlEntities.HTML_ENTITIES).build();
Trie.builder().ignoreOverlaps().addKeywords(HtmlEntities.HTML_ENTITIES).build();
public String clean(String xml) { public String clean(String xml) {
xml = removeCharactersBeforeFirstXmlTag(xml); xml = removeCharactersBeforeFirstXmlTag(xml);
@@ -78,6 +77,22 @@ public class XMLCleaner {
return null; return null;
} }
return DOCTYPE_PATTERN.matcher(xml).replaceAll(""); // Equivalent to removing all matches of "<!DOCTYPE[^>]*>", without the quadratic cost of that regex when the
// input contains many "<!DOCTYPE" and no closing bracket after them.
Matcher matcher = DOCTYPE_START_PATTERN.matcher(xml);
StringBuilder sb = new StringBuilder(xml.length());
int pos = 0;
while (matcher.find(pos)) {
int end = xml.indexOf('>', matcher.end());
if (end < 0) {
break;
}
sb.append(xml, pos, matcher.start());
pos = end + 1;
}
return sb.append(xml, pos, xml.length()).toString();
} }
} }

View File

@@ -42,6 +42,9 @@ public class User extends AbstractModel {
@Column(nullable = false) @Column(nullable = false)
private boolean disabled; private boolean disabled;
@Column(nullable = false)
private int sessionVersion;
@Column private Instant lastLogin; @Column private Instant lastLogin;
@Column private Instant created; @Column private Instant created;

View File

@@ -155,8 +155,7 @@ public class UserSettings extends AbstractModel {
private boolean instapaper; private boolean instapaper;
private boolean buffer; private boolean buffer;
@Embedded @Embedded private PushNotificationUserSettings pushNotifications = new PushNotificationUserSettings();
private PushNotificationUserSettings pushNotifications = new PushNotificationUserSettings();
@Embeddable @Embeddable
@SuppressWarnings("serial") @SuppressWarnings("serial")

View File

@@ -49,8 +49,7 @@ public class OPMLExporter {
} }
// export root subscriptions // export root subscriptions
for (FeedSubscription sub : for (FeedSubscription sub : subscriptions.stream().filter(s -> s.getCategory() == null).toList()) {
subscriptions.stream().filter(s -> s.getCategory() == null).toList()) {
opml.getOutlines().add(buildSubscriptionOutline(sub)); opml.getOutlines().add(buildSubscriptionOutline(sub));
} }
@@ -65,20 +64,14 @@ public class OPMLExporter {
for (FeedCategory child : for (FeedCategory child :
categories.stream() categories.stream()
.filter( .filter(c -> c.getParent() != null && c.getParent().getId().equals(cat.getId()))
c ->
c.getParent() != null
&& c.getParent().getId().equals(cat.getId()))
.toList()) { .toList()) {
outline.getChildren().add(buildCategoryOutline(child, categories, subscriptions)); outline.getChildren().add(buildCategoryOutline(child, categories, subscriptions));
} }
for (FeedSubscription sub : for (FeedSubscription sub :
subscriptions.stream() subscriptions.stream()
.filter( .filter(s -> s.getCategory() != null && s.getCategory().getId().equals(cat.getId()))
s ->
s.getCategory() != null
&& s.getCategory().getId().equals(cat.getId()))
.toList()) { .toList()) {
outline.getChildren().add(buildSubscriptionOutline(sub)); outline.getChildren().add(buildSubscriptionOutline(sub));
} }

View File

@@ -47,7 +47,11 @@ public class OPMLImporter {
private void handleOutline(User user, Outline outline, FeedCategory parent, int position) { private void handleOutline(User user, Outline outline, FeedCategory parent, int position) {
List<Outline> children = outline.getChildren(); List<Outline> children = outline.getChildren();
if (CollectionUtils.isNotEmpty(children)) { // an outline without children is an empty category, unless it describes a feed or another type of content
boolean isCategory =
CollectionUtils.isNotEmpty(children)
|| StringUtils.isBlank(outline.getXmlUrl()) && StringUtils.isBlank(outline.getType());
if (isCategory) {
String name = FeedUtils.truncate(outline.getText(), 128); String name = FeedUtils.truncate(outline.getText(), 128);
if (name == null) { if (name == null) {
name = FeedUtils.truncate(outline.getTitle(), 128); name = FeedUtils.truncate(outline.getTitle(), 128);
@@ -79,8 +83,7 @@ public class OPMLImporter {
} }
// make sure we continue with the import process even if a feed failed // make sure we continue with the import process even if a feed failed
try { try {
feedSubscriptionService.subscribe( feedSubscriptionService.subscribe(user, outline.getXmlUrl(), name, parent, position);
user, outline.getXmlUrl(), name, parent, position);
} catch (Exception e) { } catch (Exception e) {
log.error("error while importing {}: {}", outline.getXmlUrl(), e.getMessage()); log.error("error while importing {}: {}", outline.getXmlUrl(), e.getMessage());
} }

View File

@@ -33,10 +33,8 @@ import java.util.List;
public class FeedEntryContentCleaningService { public class FeedEntryContentCleaningService {
private static final Safelist HTML_WHITELIST = buildWhiteList(); private static final Safelist HTML_WHITELIST = buildWhiteList();
private static final List<String> ALLOWED_IFRAME_CSS_RULES = private static final List<String> ALLOWED_IFRAME_CSS_RULES = Arrays.asList("height", "width", "border");
Arrays.asList("height", "width", "border"); private static final List<String> ALLOWED_IMG_CSS_RULES = Arrays.asList("display", "width", "height");
private static final List<String> ALLOWED_IMG_CSS_RULES =
Arrays.asList("display", "width", "height");
private static final char[] FORBIDDEN_CSS_RULE_CHARACTERS = new char[] {'(', ')'}; private static final char[] FORBIDDEN_CSS_RULE_CHARACTERS = new char[] {'(', ')'};
public String clean(String content, String baseUri, boolean keepTextOnly) { public String clean(String content, String baseUri, boolean keepTextOnly) {
@@ -59,8 +57,7 @@ public class FeedEntryContentCleaningService {
e.attr("style", escaped); e.attr("style", escaped);
} }
clean.outputSettings( clean.outputSettings(new OutputSettings().escapeMode(EscapeMode.base).prettyPrint(false));
new OutputSettings().escapeMode(EscapeMode.base).prettyPrint(false));
Element body = clean.body(); Element body = clean.body();
if (keepTextOnly) { if (keepTextOnly) {
content = body.text(); content = body.text();
@@ -126,24 +123,13 @@ public class FeedEntryContentCleaningService {
whitelist.addAttributes("blockquote", "cite"); whitelist.addAttributes("blockquote", "cite");
whitelist.addAttributes("col", "span", "width"); whitelist.addAttributes("col", "span", "width");
whitelist.addAttributes("colgroup", "span", "width"); whitelist.addAttributes("colgroup", "span", "width");
whitelist.addAttributes( whitelist.addAttributes("iframe", "src", "height", "width", "allowfullscreen", "frameborder", "style");
"iframe", "src", "height", "width", "allowfullscreen", "frameborder", "style");
whitelist.addAttributes("img", "align", "alt", "height", "src", "title", "width", "style"); whitelist.addAttributes("img", "align", "alt", "height", "src", "title", "width", "style");
whitelist.addAttributes("ol", "start", "type"); whitelist.addAttributes("ol", "start", "type");
whitelist.addAttributes("q", "cite"); whitelist.addAttributes("q", "cite");
whitelist.addAttributes("table", "border", "bordercolor", "summary", "width"); whitelist.addAttributes("table", "border", "bordercolor", "summary", "width");
whitelist.addAttributes( whitelist.addAttributes("td", "border", "bordercolor", "abbr", "axis", "colspan", "rowspan", "width");
"td", "border", "bordercolor", "abbr", "axis", "colspan", "rowspan", "width"); whitelist.addAttributes("th", "border", "bordercolor", "abbr", "axis", "colspan", "rowspan", "scope", "width");
whitelist.addAttributes(
"th",
"border",
"bordercolor",
"abbr",
"axis",
"colspan",
"rowspan",
"scope",
"width");
whitelist.addAttributes("ul", "type"); whitelist.addAttributes("ul", "type");
whitelist.addProtocols("a", "href", "ftp", "http", "https", "magnet", "mailto"); whitelist.addProtocols("a", "href", "ftp", "http", "https", "magnet", "mailto");
@@ -154,6 +140,7 @@ public class FeedEntryContentCleaningService {
whitelist.addEnforcedAttribute("a", "target", "_blank"); whitelist.addEnforcedAttribute("a", "target", "_blank");
whitelist.addEnforcedAttribute("a", "rel", "noreferrer"); whitelist.addEnforcedAttribute("a", "rel", "noreferrer");
whitelist.addEnforcedAttribute("iframe", "referrerpolicy", "strict-origin-when-cross-origin");
return whitelist; return whitelist;
} }
@@ -161,8 +148,7 @@ public class FeedEntryContentCleaningService {
String rule = ""; String rule = "";
try { try {
List<String> rules = new ArrayList<>(); List<String> rules = new ArrayList<>();
CSSStyleDeclaration decl = CSSStyleDeclaration decl = buildCssParser().parseStyleDeclaration(new InputSource(new StringReader(orig)));
buildCssParser().parseStyleDeclaration(new InputSource(new StringReader(orig)));
for (int i = 0; i < decl.getLength(); i++) { for (int i = 0; i < decl.getLength(); i++) {
String property = decl.item(i); String property = decl.item(i);
@@ -187,8 +173,7 @@ public class FeedEntryContentCleaningService {
String rule = ""; String rule = "";
try { try {
List<String> rules = new ArrayList<>(); List<String> rules = new ArrayList<>();
CSSStyleDeclaration decl = CSSStyleDeclaration decl = buildCssParser().parseStyleDeclaration(new InputSource(new StringReader(orig)));
buildCssParser().parseStyleDeclaration(new InputSource(new StringReader(orig)));
for (int i = 0; i < decl.getLength(); i++) { for (int i = 0; i < decl.getLength(); i++) {
String property = decl.item(i); String property = decl.item(i);
@@ -216,8 +201,7 @@ public class FeedEntryContentCleaningService {
new ErrorHandler() { new ErrorHandler() {
@Override @Override
public void warning(CSSParseException exception) throws CSSException { public void warning(CSSParseException exception) throws CSSException {
log.debug( log.debug("warning while parsing css: {}", exception.getMessage(), exception);
"warning while parsing css: {}", exception.getMessage(), exception);
} }
@Override @Override
@@ -227,10 +211,7 @@ public class FeedEntryContentCleaningService {
@Override @Override
public void fatalError(CSSParseException exception) throws CSSException { public void fatalError(CSSParseException exception) throws CSSException {
log.debug( log.debug("fatal error while parsing css: {}", exception.getMessage(), exception);
"fatal error while parsing css: {}",
exception.getMessage(),
exception);
} }
}); });

View File

@@ -27,9 +27,7 @@ public class FeedEntryContentService {
public FeedEntryContent findOrCreate(Content content, String baseUrl) { public FeedEntryContent findOrCreate(Content content, String baseUrl) {
FeedEntryContent entryContent = buildContent(content, baseUrl); FeedEntryContent entryContent = buildContent(content, baseUrl);
Optional<FeedEntryContent> existing = Optional<FeedEntryContent> existing =
feedEntryContentDAO feedEntryContentDAO.findExisting(entryContent.getContentHash(), entryContent.getTitleHash()).stream()
.findExisting(entryContent.getContentHash(), entryContent.getTitleHash())
.stream()
.filter(entryContent::equivalentTo) .filter(entryContent::equivalentTo)
.findFirst(); .findFirst();
if (existing.isPresent()) { if (existing.isPresent()) {
@@ -44,11 +42,9 @@ public class FeedEntryContentService {
FeedEntryContent entryContent = new FeedEntryContent(); FeedEntryContent entryContent = new FeedEntryContent();
entryContent.setTitleHash(Digests.sha1Hex(StringUtils.trimToEmpty(content.title()))); entryContent.setTitleHash(Digests.sha1Hex(StringUtils.trimToEmpty(content.title())));
entryContent.setContentHash(Digests.sha1Hex(StringUtils.trimToEmpty(content.content()))); entryContent.setContentHash(Digests.sha1Hex(StringUtils.trimToEmpty(content.content())));
entryContent.setTitle( entryContent.setTitle(FeedUtils.truncate(cleaningService.clean(content.title(), baseUrl, true), 2048));
FeedUtils.truncate(cleaningService.clean(content.title(), baseUrl, true), 2048));
entryContent.setContent(cleaningService.clean(content.content(), baseUrl, false)); entryContent.setContent(cleaningService.clean(content.content(), baseUrl, false));
entryContent.setAuthor( entryContent.setAuthor(FeedUtils.truncate(cleaningService.clean(content.author(), baseUrl, true), 128));
FeedUtils.truncate(cleaningService.clean(content.author(), baseUrl, true), 128));
entryContent.setCategories(FeedUtils.truncate(content.categories(), 4096)); entryContent.setCategories(FeedUtils.truncate(content.categories(), 4096));
entryContent.setDirection( entryContent.setDirection(
FeedUtils.isRTL(content.title(), content.content()) FeedUtils.isRTL(content.title(), content.content())
@@ -63,8 +59,7 @@ public class FeedEntryContentService {
Media media = content.media(); Media media = content.media();
if (media != null) { if (media != null) {
entryContent.setMediaDescription( entryContent.setMediaDescription(cleaningService.clean(media.description(), baseUrl, false));
cleaningService.clean(media.description(), baseUrl, false));
entryContent.setMediaThumbnailUrl(FeedUtils.truncate(media.thumbnailUrl(), 2048)); entryContent.setMediaThumbnailUrl(FeedUtils.truncate(media.thumbnailUrl(), 2048));
entryContent.setMediaThumbnailWidth(media.thumbnailWidth()); entryContent.setMediaThumbnailWidth(media.thumbnailWidth());
entryContent.setMediaThumbnailHeight(media.thumbnailHeight()); entryContent.setMediaThumbnailHeight(media.thumbnailHeight());

View File

@@ -45,33 +45,22 @@ public class FeedEntryFilteringService {
.addVar("categories", SimpleType.STRING) .addVar("categories", SimpleType.STRING)
.addVar("categoriesLower", SimpleType.STRING) .addVar("categoriesLower", SimpleType.STRING)
.build(); .build();
private static final CelRuntime CEL_RUNTIME = private static final CelRuntime CEL_RUNTIME = CelRuntimeFactory.plannerRuntimeBuilder().build();
CelRuntimeFactory.standardCelRuntimeBuilder().build();
private final ExecutorService executor = Executors.newCachedThreadPool(); private final ExecutorService executor = Executors.newCachedThreadPool();
private final CommaFeedConfiguration config; private final CommaFeedConfiguration config;
public boolean filterMatchesEntry(String filter, FeedEntry entry) public boolean filterMatchesEntry(String filter, FeedEntry entry) throws FeedEntryFilterException {
throws FeedEntryFilterException {
if (StringUtils.isBlank(filter)) { if (StringUtils.isBlank(filter)) {
return true; return true;
} }
String title = String title = entry.getContent().getTitle() == null ? "" : Jsoup.parse(entry.getContent().getTitle()).text();
entry.getContent().getTitle() == null String author = entry.getContent().getAuthor() == null ? "" : entry.getContent().getAuthor();
? ""
: Jsoup.parse(entry.getContent().getTitle()).text();
String author =
entry.getContent().getAuthor() == null ? "" : entry.getContent().getAuthor();
String content = String content =
entry.getContent().getContent() == null entry.getContent().getContent() == null ? "" : Jsoup.parse(entry.getContent().getContent()).text();
? ""
: Jsoup.parse(entry.getContent().getContent()).text();
String url = entry.getUrl() == null ? "" : entry.getUrl(); String url = entry.getUrl() == null ? "" : entry.getUrl();
String categories = String categories = entry.getContent().getCategories() == null ? "" : entry.getContent().getCategories();
entry.getContent().getCategories() == null
? ""
: entry.getContent().getCategories();
Map<String, Object> data = new HashMap<>(); Map<String, Object> data = new HashMap<>();
data.put("title", title); data.put("title", title);
@@ -98,11 +87,9 @@ public class FeedEntryFilteringService {
TimeUnit.MILLISECONDS); TimeUnit.MILLISECONDS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
throw new FeedEntryFilterException( throw new FeedEntryFilterException("interrupted while evaluating expression " + filter, e);
"interrupted while evaluating expression " + filter, e);
} catch (ExecutionException e) { } catch (ExecutionException e) {
throw new FeedEntryFilterException( throw new FeedEntryFilterException("Exception while evaluating expression " + filter, e);
"Exception while evaluating expression " + filter, e);
} catch (TimeoutException e) { } catch (TimeoutException e) {
throw new FeedEntryFilterException("Took too long evaluating expression " + filter, e); throw new FeedEntryFilterException("Took too long evaluating expression " + filter, e);
} }

View File

@@ -55,12 +55,9 @@ public class FeedEntryService {
} }
public List<Entry> removeExistingEntries(Feed feed, List<Entry> entries) { public List<Entry> removeExistingEntries(Feed feed, List<Entry> entries) {
Set<String> guidHashes = Set<String> guidHashes = entries.stream().map(e -> Digests.sha1Hex(e.guid())).collect(Collectors.toSet());
entries.stream().map(e -> Digests.sha1Hex(e.guid())).collect(Collectors.toSet());
Set<String> existingGuidHashes = feedEntryDAO.findExistingGuidHashes(guidHashes, feed); Set<String> existingGuidHashes = feedEntryDAO.findExistingGuidHashes(guidHashes, feed);
return entries.stream() return entries.stream().filter(e -> !existingGuidHashes.contains(Digests.sha1Hex(e.guid()))).toList();
.filter(e -> !existingGuidHashes.contains(Digests.sha1Hex(e.guid())))
.toList();
} }
public boolean applyFilter(FeedSubscription sub, FeedEntry entry) { public boolean applyFilter(FeedSubscription sub, FeedEntry entry) {
@@ -119,55 +116,38 @@ public class FeedEntryService {
List<FeedSubscription> subscriptions, List<FeedSubscription> subscriptions,
Instant olderThan, Instant olderThan,
Instant insertedBefore, Instant insertedBefore,
List<FeedEntryKeyword> keywords) { List<FeedEntryKeyword> keywords,
String tag) {
List<FeedEntryStatus> statuses = List<FeedEntryStatus> statuses =
feedEntryStatusDAO.findBySubscriptions( feedEntryStatusDAO.findBySubscriptions(
user, user, subscriptions, true, keywords, null, -1, -1, null, false, tag, null, null);
subscriptions,
true,
keywords,
null,
-1,
-1,
null,
false,
null,
null,
null);
markList(statuses, olderThan, insertedBefore); markList(statuses, olderThan, insertedBefore);
} }
public void markStarredEntries(User user, Instant olderThan, Instant insertedBefore) { public void markStarredEntries(User user, Instant olderThan, Instant insertedBefore) {
List<FeedEntryStatus> statuses = List<FeedEntryStatus> statuses = feedEntryStatusDAO.findStarred(user, null, null, -1, -1, null, false);
feedEntryStatusDAO.findStarred(user, null, null, -1, -1, null, false);
markList(statuses, olderThan, insertedBefore); markList(statuses, olderThan, insertedBefore);
} }
private void markList( private void markList(List<FeedEntryStatus> statuses, Instant olderThan, Instant insertedBefore) {
List<FeedEntryStatus> statuses, Instant olderThan, Instant insertedBefore) {
List<FeedEntryStatus> statusesToMark = List<FeedEntryStatus> statusesToMark =
statuses.stream() statuses.stream()
.filter(FeedEntryStatus::isMarkable) .filter(FeedEntryStatus::isMarkable)
.filter( .filter(s -> {
s -> { Instant entryDate = s.getEntry().getPublished();
Instant entryDate = s.getEntry().getPublished(); return olderThan == null || entryDate == null || entryDate.isBefore(olderThan);
return olderThan == null })
|| entryDate == null .filter(s -> {
|| entryDate.isBefore(olderThan); Instant insertedDate = s.getEntry().getInserted();
}) return insertedBefore == null
.filter( || insertedDate == null
s -> { || insertedDate.isBefore(insertedBefore);
Instant insertedDate = s.getEntry().getInserted(); })
return insertedBefore == null
|| insertedDate == null
|| insertedDate.isBefore(insertedBefore);
})
.toList(); .toList();
statusesToMark.forEach( statusesToMark.forEach(s -> {
s -> { s.setRead(true);
s.setRead(true); feedEntryStatusDAO.merge(s);
feedEntryStatusDAO.merge(s); });
});
} }
} }

View File

@@ -36,16 +36,14 @@ public class FeedEntryTagService {
} }
List<FeedEntryTag> existingTags = feedEntryTagDAO.findByEntry(user, entry); List<FeedEntryTag> existingTags = feedEntryTagDAO.findByEntry(user, entry);
Set<String> existingTagNames = Set<String> existingTagNames = existingTags.stream().map(FeedEntryTag::getName).collect(Collectors.toSet());
existingTags.stream().map(FeedEntryTag::getName).collect(Collectors.toSet());
List<FeedEntryTag> addList = List<FeedEntryTag> addList =
tagNames.stream() tagNames.stream()
.filter(name -> !existingTagNames.contains(name)) .filter(name -> !existingTagNames.contains(name))
.map(name -> new FeedEntryTag(user, entry, name)) .map(name -> new FeedEntryTag(user, entry, name))
.toList(); .toList();
List<FeedEntryTag> removeList = List<FeedEntryTag> removeList = existingTags.stream().filter(tag -> !tagNames.contains(tag.getName())).toList();
existingTags.stream().filter(tag -> !tagNames.contains(tag.getName())).toList();
addList.forEach(feedEntryTagDAO::persist); addList.forEach(feedEntryTagDAO::persist);
feedEntryTagDAO.delete(removeList); feedEntryTagDAO.delete(removeList);

Some files were not shown because too many files have changed in this diff Show More