Commit Graph

524 Commits (dc7a49ddf6084da43cfed7179a432df102d703f1)

Author SHA1 Message Date
Claire 51a33ce77a
Fix not being able to follow more than one hashtag ()
Fixes regression from 
trwnh 7fdeed5fbc
Make tag following idempotent ()
trwnh e1f819fd78
Fix pagination of followed tags ()
* Fix missing pagination headers on followed tags

* Fix typo
Daniel Axtens 4d85c27d1a
Add 'private' to Cache-Control, match Rails expectations ()
Several controlers set quite intricate Cache-Control headers in order to
hopefully not be cached by any intermediate proxies or local caches. Unfortunately,
these headers are processed by ActionDispatch::HTTP::Cache in a way that squashes
and discards any values set alongside no-store other than private:
8015c2c2cf/actionpack/lib/action_dispatch/http/cache.rb (L207-L209)

We want to preserve no-store on these responses, but we might as well remove
parts that are going to be dropped anyway. As many of the endpoints in these
controllers are private to a particular user, we should also add "private",
which will be preserved alongside no-store.
trwnh b59ce0a60f
Move V2 Filter methods under /api/v2 prefix ()
* Move V2 Filter methods under /api/v2 prefix

* move over the tests too
Eugen Rochko b31afc6294
Fix error when passing unknown filter param in REST API ()
Fix 
Eugen Rochko 167d86d21d
Fix `role_ids` not accepting arrays in admin API ()
Fix 
Claire 86f6631d28
Remove dead code and refactor status threading code ()
* Remove dead code

* Remove unneeded/broken parameters and refactor descendant computation
Claire 1615c3eb6e
Change logged out /api/v1/statuses/:id/context logged out limits ()
James Tucker 78a6b871fe
Improve performance by avoiding regex construction ()
```ruby
10.times { p /#{FOO}/.object_id }
10.times { p FOO_RE.object_id }
```
Eugen Rochko 0cd0786aef
Revert filtering public timelines by locale by default ()
trwnh 89e1974f30
Make account endorsements idempotent (fix ) ()
* Make account endorsements idempotent (fix )

* Accept suggestion to use exists? instead of find_by + nil check

Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh>

* fix logic (unless, not if)

* switch to using `find_or_create_by!`

Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh>
trwnh 68d9dcd425
Fix uncaught 500 error on invalid `replies_policy` (Fix ) ()
Claire 4cb2323458
Fix crash in legacy filter creation controller ()
Eugen Rochko 3a41fccc43
Change `AUTHORIZED_FETCH` to not block unauthenticated REST API access ()
New environment variable `DISALLOW_UNAUTHENTICATED_API_ACCESS`
Claire c2170991c7
Fix reblogs being discarded after the reblogged status ()
Eugen Rochko 15bae3e0e4
Change post-processing to be deferred only for large media types ()
Eugen Rochko 26478f461c
Remove language filtering from hashtag timelines ()
Eugen Rochko 276b85bc91
Fix admin APIs returning deleted object instead of empty object upon delete ()
Fix 
Eugen Rochko 5724da0780
Fix language not being saved when editing status ()
Fix 
Eugen Rochko 3e18e05330
Fix uncaught error when invalid date is supplied to API ()
Fix 
Eugen Rochko 1ae508bf2f
Change unauthenticated search to not support pagination in REST API ()
- Only exact search matches for queries with < 5 characters
- Do not support queries with `offset` (pagination)
- Return HTTP 401 on truthy `resolve` instead of overriding to false
Takeshi Umeda 74ead7d106
Change featured tag updates to add/remove activity ()
* Change featured tag updates to add/remove activity

* Fix to check for the existence of feature tag

* Rename service and worker

* Merge AddHashtagSerializer with AddSerializer

* Undo removal of sidekiq_options
Takeshi Umeda b0e3f0312c
Add synchronization of remote featured tags ()
* Add LIMIT of featured tag to instance API response

* Add featured_tags_collection_url to Account

* Add synchronization of remote featured tags

* Deliver update activity when updating featured tag

* Remove featured_tags_collection_url

* Revert "Add featured_tags_collection_url to Account"

This reverts commit cff349fc27.

* Add hashtag sync from featured collections

* Fix tag name normalize

* Add target option to fetch featured collection

* Refactor fetch_featured_tags_collection_service

* Add LIMIT of featured tag to v1/instance API response
Eugen Rochko 1bd00036c2
Change about page to be mounted in the web UI ()
Eugen Rochko 45ebdb72ca
Add support for language preferences for trending statuses and links ()
Eugen Rochko a2ba011326
Change privacy policy to be rendered in web UI, add REST API ()
Source string no longer localized, Markdown instead of raw HTML
Eugen Rochko 9f65909f42
Change public timelines to be filtered by current locale by default ()
In the absence of an opt-in to multiple specific languages in the
preferences, it makes more sense to filter by the user's presumed
language only (interface language or `lang` override)
Eugen Rochko d2528b26b6
Add server banner to web app, add `GET /api/v2/instance` to REST API ()
Claire cedcece0cc
Fix deleted pinned posts potentially counting towards the pinned posts limit ()
Fixes 
Eugen Rochko 0d6b878808
Add user content translations with configurable backends ()
Eugen Rochko 50948b46aa
Add ability to filter followed accounts' posts by language ()
Claire 2750a7a0e6
Fix REST API sometimes returning HTML on error ()
Fixes 
Eugen Rochko c57907737a
Change search API to be accessible without being logged in ()
But with the resolve option turned off
Eugen Rochko c99c106ef0
Change following and followers API to be accessible without being logged in ()
Eugen Rochko 2a7766dcc9
Add admin API for managing e-mail domain blocks ()
Eugen Rochko c556c3a0d1
Add admin API for managing canonical e-mail blocks ()
Eugen Rochko b399d79545
Add admin API for managing IP blocks ()
Claire 50487db122
Add ability to filter individual posts ()
* Add database table for status-specific filters

* Add REST endpoints, entities and attributes

* Show status filters in /filters interface

* Perform server-side filtering for individual posts filters

* Fix filtering on context mismatch

* Refactor `toServerSideType` by moving it to its own module

* Move loupe and delete icons to their own module

* Add ability to filter individual posts from WebUI

* Replace keyword list by warnings (expired, context mismatch)

* Refactor server-side filtering code

* Add tests
Claire 726931fe4a
Fix /api/v1/tags/:id route constraints ()
The constraint was applied prior to decoding, and rejected anything containing
the '%' character, which would be used for anything with non-ASCII unicode
characters.
Eugen Rochko c3f0621a59
Add ability to follow hashtags ()
Eugen Rochko e7aa2be828
Change how hashtags are normalized ()
* Change how hashtags are normalized

* Fix tests
Eugen Rochko 44b2ee3485
Add customizable user roles ()
* Add customizable user roles

* Various fixes and improvements

* Add migration for old settings and fix tootctl role management
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.
Claire 35588d09e2
Add /api/v1/admin/domain_allows ()
- `GET /api/v1/admin/domain_allows` lists allowed domains
- `GET /api/v1/admin/domain_allows/:id` shows one by ID
- `DELETE /api/v1/admin/domain_allows/:id` deletes a given domain from the list
  of allowed domains
- `POST /api/v1/admin/domain_allows` to allow a new domain:
  if that domain is already allowed, the existing DomainAllow will be returned
tateisu 47f2ff617d
use Notification::TYPES for api push subscription alerts ()
Claire 28329ba62f
Add /api/v1/admin/domain_blocks ()
* Add /api/v1/admin/domain_blocks

Fixes 

- `GET /api/v1/admin/domain_blocks` lists domain blocks
- `GET /api/v1/admin/domain_blocks/:id` shows one by ID
- `DELETE /api/v1/admin/domain_blocks/:id` deletes a given domain block
- `POST /api/v1/admin/domain_blocks` to create a new domain block:
  if it conflicts with an existing one, returns an error with
  an attribute `existing_domain_block` with the rendered domain block

* Simplify conflict handling as suggested in review
Eugen Rochko 9f81b9f29a
Fix suspended users being able to access APIs that don't require a user ()
Claire 440eb71310
Change unapproved and unconfirmed account to not be accessible in the REST API ()
* Change unapproved and unconfirmed account to not be accessible in the REST API

* Change Account#searchable? to reject unconfirmed and unapproved users

* Disable search for unapproved and unconfirmed users in Account.search_for

* Disable search for unapproved and unconfirmed users in Account.advanced_search_for

* Remove unconfirmed and unapproved accounts from Account.searchable scope

* Prevent mentions to unapproved/unconfirmed accounts

* Fix some old tests for Account.advanced_search_for

* Add some Account.advanced_search_for tests for existing behaviors

* Add some tests for Account.search_for

* Add Account.advanced_search_for tests unconfirmed and unapproved accounts

* Add Account.searchable tests

* Fix Account.without_unapproved scope potentially messing with previously-applied scopes

* Allow lookup of unconfirmed/unapproved accounts through /api/v1/accounts/lookup

This is so that the API can still be used to check whether an username is free
to use.
Claire 9a3be0ad68
Fix error when looking handle with surrounding spaces ()