Commit Graph

477 Commits (083bc137bcb7626a58e6a68b6a31bb971d46fe53)

Author SHA1 Message Date
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 ()
Claire 66a63d79ea
Fix 500 error when a bookmark or favorite has been reported and deleted ()
0x2019 012537452a
Fix error resposes for `from` search prefix ()
* Fix error responses in `from` search prefix (addresses )

Using unsupported prefixes now reports a 422; searching for posts from an
account the instance is not aware of reports a 404. TODO: The UI for this
on the front end is abysmal.

Searching `from:username@domain` now succeeds when `domain` is the local
domain; searching `from:@username(@domain)?` now works as expected.

* Remove unused methods on new Error classes as they are not being used

Currently when `raise`d there are error messages being supplied, but
this is not actually being used. The associated `raise`s have been
edited accordingly.

* Remove needless comments

* Satisfy rubocop

* Try fixing tests being unable to find AccountFindingConcern methods

* Satisfy rubocop

* Simplify `from` prefix logic

This incorporates @ClearlyClaire's suggestion (see
https://github.com/mastodon/mastodon/pull/17963#pullrequestreview-933986737).

Accepctable account strings in `from:` clauses are more lenient than
before this commit; for example, `from:@user@example.org@asnteo +cat`
will not error, and return posts by @user@example.org containing the
word "cat". This is more consistent with how Mastodon matches mentions
in statuses. In addition, `from` clauses will not be checked for
syntatically invalid usernames or domain names, simply 404ing when
`Account.find_remote!` raises ActiveRecord::NotFound.

New code for this PR that is no longer used has been removed.
Claire 3906dd67ed
Fix extremely rare race condition when deleting a toot or account ()
Eugen Rochko 465ee7792f
Fix pagination header on empty trends responses in REST API ()
Claire 62c6e12fa5
Fix admin API unconditionally requiring CSRF token ()
Fixes 

Since , the admin API has only been available through the web
application because of the unconditional requirement to provide a valid CSRF
token.

This commit changes it back to `null_session`, which should make it work
both with session-based authentication (provided a CSRF token) and with a
bearer token.
Eugen Rochko d116cb7733
Fix `GET /api/v1/trends/tags` missing `offset` param in REST API ()
Claire 894956e20c
Fix /api/v1/admin/accounts ()
* Fix /api/v1/admin/accounts

Compatibility was broken since  which changed the underlying filter class
without changing the controller.

This commits restore support for the old parameters.

* Add /api/v2/admin/accounts with the new parameters

* Add tests

* Add missing filter for `silenced` status

Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>

Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
Eugen Rochko cefa526c6d
Refactor formatter ()
* Refactor formatter

* Move custom emoji pre-rendering logic to view helpers

* Move more methods out of Formatter

* Fix code style issues

* Remove Formatter

* Add inline poll options to RSS feeds

* Remove unused helper method

* Fix code style issues

* Various fixes and improvements

* Fix test
Eugen Rochko e3a2203061
Add offset pagination to trends in REST API ()
Eugen Rochko 67d550830b
Fix locale not being set in REST API ()
Eugen Rochko e6ffbfb5e7
Add `types` param to `GET /api/v1/notifications` in REST API ()
* Add `types` param to `GET /api/v1/notifications` in REST API

* Improve tests
Eugen Rochko bc320d6cec
Fix `POST /api/v1/emails/confirmations` not being available after sign-up ()
Eugen Rochko b2cd34474b
Add rate limit for editing ()
Eugen Rochko 8f6c67bfde
Fix performance of account timelines ()
* Fix performance of account timelines

* Various fixes and improvements

* Fix duplicate results being returned

Co-authored-by: Claire <claire.github-309c@sitedethib.com>

* Fix grouping for pinned statuses scope

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Eugen Rochko edf09ec747
Add `/api/v1/accounts/familiar_followers` to REST API ()
* Add `/api/v1/accounts/familiar_followers` to REST API

* Change hide network preference to be stored consistently for local and remote accounts

* Add dummy classes to migration

* Apply suggestions from code review

Co-authored-by: Claire <claire.github-309c@sitedethib.com>

Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Eugen Rochko 2ea754b861
Fix duplicate notifications being possible after poll expiration ()
Claire ff43e54a49
Allow editing media attachments for scheduled toots ()
Fixes 
Eugen Rochko 631e495a79
Change `follow` scope to be covered by `read` and `write` scopes in REST API ()
Deprecate `follow` scope
Eugen Rochko e24b14cc74
Fix leak of existence of otherwise inaccessible statuses in REST API ()
Eugen Rochko 02b8d63fce
Fix report category not being saved in REST API ()
Eugen Rochko 50ea54b3ed
Change authorized applications page ()
* Change authorized applications page

* Hide revoke button for superapps and suspended accounts

* Clean up db/schema.rb
Eugen Rochko 27965ce5ed
Add trending statuses ()
* Add trending statuses

* Fix dangling items with stale scores in localized sets

* Various fixes and improvements

- Change approve_all/reject_all to approve_accounts/reject_accounts
- Change Trends::Query methods to not mutate the original query
- Change Trends::Query#skip to offset
- Change follow recommendations to be refreshed in a transaction

* Add tests for trending statuses filtering behaviour

* Fix not applying filtering scope in controller
Eugen Rochko 7b816eb5ae
Add notifications for new sign-ups ()
Eugen Rochko 8f03b7a2fb
Add notifications when a reblogged status has been updated ()
* Add notifications when a reblogged status has been updated

* Change wording to say "edit" instead of "update" and add missing controls

* Replace previous update notifications with the most up-to-date one
Eugen Rochko 63002cde03
Add editing for published statuses ()
* Add editing for published statuses

* Fix change of multiple-choice boolean in poll not resetting votes

* Remove the ability to update existing media attachments for now
Eugen Rochko 2f8159baad
Add `category` and `rule_ids` params to `POST /api/v1/reports` ()
Eugen Rochko fd3a45e348
Add edit history to web UI ()
* Add edit history to web UI

* Change history reducer to store items per status

* Fix missing loading prop
Claire 03d59340da
Fix Sidekiq warnings about JSON serialization ()
* Fix Sidekiq warnings about JSON serialization

This occurs on every symbol argument we pass, and every symbol key in hashes,
because Sidekiq expects strings instead.

See https://github.com/mperham/sidekiq/pull/5071

We do not need to change how workers parse their arguments because this has
not changed and we were already converting to symbols adequately or using
`with_indifferent_access`.

* Set Sidekiq to raise on unsafe arguments in test mode

In order to more easily catch issues that would produce warnings in production
code.
Claire bddd9ba36d
Add OMNIAUTH_ONLY environment variable to enforce externa log-in ()
* Remove support for OAUTH_REDIRECT_AT_SIGN_IN

Fixes 

Introduced in , OAUTH_REDIRECT_AT_SIGN_IN allowed skipping the log-in form
to instead redirect to the external OmniAuth login provider.

However, it did not prevent the log-in form on /about introduced by  from
appearing, and completely broke with the introduction of .

As I restoring that previous log-in flow without introducing a security
vulnerability may require extensive care and knowledge of how OmniAuth works,
this commit removes support for OAUTH_REDIRECT_AT_SIGN_IN instead for the time
being.

* Add OMNIAUTH_ONLY environment variable to enforce external log-in only

* Disable user registration when OMNIAUTH_ONLY is set to true

* Replace log-in links When OMNIAUTH_ONLY is set with exactly one OmniAuth provider
Eugen Rochko 1060666c58
Add support for editing for published statuses ()
* Add support for editing for published statuses

* Fix references to stripped-out code

* Various fixes and improvements

* Further fixes and improvements

* Fix updates being potentially sent to unauthorized recipients

* Various fixes and improvements

* Fix wrong words in test

* Fix notifying accounts that were tagged but were not in the audience

* Fix mistake
Eugen Rochko 14f436c457
Add notifications for statuses deleted by moderators ()
Claire d5c9feb7b7
Add support for private pinned posts ()
* Add support for private pinned toots

* Allow local user to pin private toots

* Change wording to avoid "direct message"
Eugen Rochko 8e84ebf0cb
Remove IP tracking columns from users table ()
Eugen Rochko 7de0ee7aba
Remove Keybase integration ()
Eugen Rochko 6e50134a42
Add trending links ()
* Add trending links

* Add overriding specific links trendability

* Add link type to preview cards and only trend articles

Change trends review notifications from being sent every 5 minutes to being sent every 2 hours

Change threshold from 5 unique accounts to 15 unique accounts

* Fix tests
Takeshi Umeda 17f4e457b3
Add remove from followers api ()
* Add followed_by? to account_interactions

* Add RemoveFromFollowersService

* Fix AccountBatch to use RemoveFromFollowersService

* Add remove from followers API
Eugen Rochko 07341e7aa6
Add graphs and retention metrics to admin dashboard ()
Claire d8629e7b86
Add logging of S3-related errors ()
Eugen Rochko 1410dffdf4
Fix e-mail confirmations API not working correctly ()
* Fix e-mail confirmations API not working correctly

* Fix typo
Claire 566fc90913
Add Ruby 3.0 support ()
* Fix issues with POSIX::Spawn, Terrapin and Ruby 3.0

Also improve the Terrapin monkey-patch for the stderr/stdout issue.

* Fix keyword argument handling throughout the codebase

* Monkey-patch Paperclip to fix keyword arguments handling in validators

* Change validation_extensions to please CodeClimate

* Bump microformats from 4.2.1 to 4.3.1

* Allow Ruby 3.0

* Add Ruby 3.0 test target to CircleCI

* Add test for admin dashboard warnings

* Fix admin dashboard warnings on Ruby 3.0
abcang d0fc69d721
Further improve the media attached status query for accounts ()
abcang 1f47511023
Improve media attached status query ()
Eugen Rochko daccc07dc1
Change auto-following admin-selected accounts, show in recommendations ()
Eugen Rochko ce2148c571
Add `policy` param to `POST /api/v1/push/subscriptions` ()
With possible values `all`, `followed`, `follower`, and `none`,
control from whom notifications will generate a Web Push alert
Eugen Rochko f7117646af
Add cold-start follow recommendations ()
Eugen Rochko dd1eb9918a
Add `email` param to `POST /api/v1/emails/confirmations` ()
Allow changing e-mail as long as the account is unconfirmed
Eugen Rochko ee1119208c
Add `POST /api/v1/emails/confirmations` to REST API ()
Only available to the application the user originally signed-up with