Commit Graph

147 Commits (917a799c673ea617beb9452c5fddbaaca6f406f1)

Author SHA1 Message Date
Emelia Smith b23ff050ac
Fix missing or incorrect cache-control headers for Streaming server ()
Matt Jankowski 5405bdd344
Remove unused E2EE messaging code ()
Emelia Smith 9ba81eae3e
Streaming: Improve Redis connection options handling ()
Emelia Smith f6fb9b75db
Streaming: Fix BIND IPv6 handling ()
Emelia Smith 4118688fba
Streaming: Refactor move database and redis logic into separate files ()
Emelia Smith c245a2044e
Streaming: Refactor to use metrics.$name instead of destructuring ()
Emelia Smith 7490019535
Fix support for IPv6 redis connections in streaming ()
Emelia Smith c953dca1de
Streaming: use pgPool.query instead of manually acquiring & releasing a connection ()
Emelia Smith d436696f46
Streaming: Fix incorrect type definitions ()
Essem 54cc204473
Use WebSocketServer instead of WebSocket.Server in streaming ()
Renaud Chaput 899eac1a92
Use modern ES syntax rather than `.call` ()
Renaud Chaput 036f5a05e3
Convert the streaming server to ESM ()
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Emelia Smith 491dd97642
Streaming: refactor to custom Error classes ()
Co-authored-by: Renaud Chaput <renchap@gmail.com>
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Emelia Smith 881e8c113c
Refactor: fix streaming postgresql and redis typing issues ()
Emelia Smith 3fbf01918f
Streaming: Move more methods to the utils from the main file ()
Emelia Smith 1335083bed
Streaming: replace npmlog with pino & pino-http ()
Emelia Smith 58830be943
Streaming: Rework websocket server initialisation & authentication code ()
Emelia Smith 9826b7780a
Streaming: use standard cors package instead of custom implementation ()
Emelia Smith a4de0e364b
Refactor streaming to simplify for logging change ()
Emelia Smith 15b2d7eec5
Split streaming server from web server ()
Renaud Chaput 774e1189d2
Change `eslint` config to autofix missing comma and indentation in JS files ()
Emelia Smith f68d540271
Fix websocket connections being incorrectly decremented twice on errors ()
Emelia Smith fbfceb9c77
Add additional metrics for streaming ()
Gabriel Simmer be991f1d18
Move to ioredis for streaming ()
Co-authored-by: Emelia Smith <ThisIsMissEm@users.noreply.github.com>
Emelia Smith 6375e390af
Fix: support both DATABASE_URL and DB_PASS ()
Emelia Smith 65096c1ccd
Change streaming `/metrics` to include additional metrics ()
Renaud Chaput 3554c52795
Fix missing return values in streaming ()
Claire 446821a0dc
Swap debug statements in streaming server ()
Emelia Smith 81cdc0f972
Fix: Streaming server memory leak in HTTP EventSource cleanup ()
Emelia Smith ddaf200c78
Refactor streaming's filtering logic & improve documentation ()
Claire 1814990a3d
Fix wrong filters sometimes applying in streaming ()
Emelia Smith 215081240f
Add logging of websocket send errors ()
Emelia Smith c81f59583c
Fix logging of messages that are binary before closing their connection ()
Emelia Smith 16dd3f08c1
Fix performance of streaming by parsing message JSON once ()
Renaud Chaput d27216dc46
Enforce import order with ESLint ()
Nick Schonning f22b4e556c
Add eslint-plugin-jsdoc ()
Emelia Smith 301e03eb8c
Remove clustering from streaming API ()
Claire 174352716a
Disable anonymous access to the streaming API ()
Eugen Rochko be1792e1d4
Fix streaming API not being usable without `DATABASE_URL` ()
Ramūns Usovs 0872f3e3d7
Allow streaming to connect to postgress with self-signed certs ()
emilweth 7c45145430
fix metrics format ()
emilweth c1b823368c
dot is not allowed ()
Eugen Rochko c5a4d8c82d
Add information about database pool to metrics endpoint in streaming API ()
Eugen Rochko 4cb7647516
Add database pool configuration over `DB_POOL` to streaming API ()
Add connection timeout of 15s
Eugen Rochko 01584f03e8
Add metrics endpoint to streaming API ()
Nick Schonning 06b68490d1
Enable eslint:recommended ruleset ()
* Enable ESLint recommended ruleset

* Disable failing ESLint recommended rules

* Remove rules shadowed by eslint:recommended
Claire 8c3c6dcae9
Fix filters from other users being used in the streaming service ()
Claire cd5e98dbdb
Fix public/local timeline posts not being properly filtered ()
* Fix streaming server using wrong property name for matching filters

Late in the PR, the `filter_results` property has been renamed to `filtered`,
but the change has not been reflected in the streaming server code.

* Fix filter_action attribute being an integer instead of a string
Eugen Rochko e7aa2be828
Change how hashtags are normalized ()
* Change how hashtags are normalized

* Fix tests
Claire 02851848e9
Revamp post filtering system ()
* Add model for custom filter keywords

* Use CustomFilterKeyword internally

Does not change the API

* Fix /filters/edit and /filters/new

* Add migration tests

* Remove whole_word column from custom_filters (covered by custom_filter_keywords)

* Redesign /filters

Instead of a list, present a card that displays more information and handles
multiple keywords per filter.

* Redesign /filters/new and /filters/edit to add and remove keywords

This adds a new gem dependency: cocoon, as well as a npm dependency:
cocoon-js-vanilla. Those are used to easily populate and remove form fields
from the user interface when manipulating multiple keyword filters at once.

* Add /api/v2/filters to edit filter with multiple keywords

Entities:
- `Filter`: `id`, `title`, `filter_action` (either `hide` or `warn`), `context`
  `keywords`
- `FilterKeyword`: `id`, `keyword`, `whole_word`

API endpoits:
- `GET /api/v2/filters` to list filters (including keywords)
- `POST /api/v2/filters` to create a new filter
  `keywords_attributes` can also be passed to create keywords in one request
- `GET /api/v2/filters/:id` to read a particular filter
- `PUT /api/v2/filters/:id` to update a new filter
  `keywords_attributes` can also be passed to edit, delete or add keywords in
   one request
- `DELETE /api/v2/filters/:id` to delete a particular filter
- `GET /api/v2/filters/:id/keywords` to list keywords for a filter
- `POST /api/v2/filters/:filter_id/keywords/:id` to add a new keyword to a
   filter
- `GET /api/v2/filter_keywords/:id` to read a particular keyword
- `PUT /api/v2/filter_keywords/:id` to edit a particular keyword
- `DELETE /api/v2/filter_keywords/:id` to delete a particular keyword

* Change from `irreversible` boolean to `action` enum

* Remove irrelevent `irreversible_must_be_within_context` check

* Fix /filters/new and /filters/edit with update for filter_action

* Fix Rubocop/Codeclimate complaining about task names

* Refactor FeedManager#phrase_filtered?

This moves regexp building and filter caching to the `CustomFilter` class.

This does not change the functional behavior yet, but this changes how the
cache is built, doing per-custom_filter regexps so that filters can be matched
independently, while still offering caching.

* Perform server-side filtering and output result in REST API

* Fix numerous filters_changed events being sent when editing multiple keywords at once

* Add some tests

* Use the new API in the WebUI

- use client-side logic for filters we have fetched rules for.
  This is so that filter changes can be retroactively applied without
  reloading the UI.
- use server-side logic for filters we haven't fetched rules for yet
  (e.g. network error, or initial timeline loading)

* Minor optimizations and refactoring

* Perform server-side filtering on the streaming server

* Change the wording of filter action labels

* Fix issues pointed out by linter

* Change design of “Show anyway” link in accordence to review comments

* Drop “irreversible” filtering behavior

* Move /api/v2/filter_keywords to /api/v1/filters/keywords

* Rename `filter_results` attribute to `filtered`

* Rename REST::LegacyFilterSerializer to REST::V1::FilterSerializer

* Fix systemChannelId value in streaming server

* Simplify code by removing client-side filtering code

The simplifcation comes at a cost though: filters aren't retroactively
applied anymore.