Commit graph

8420 commits

Author SHA1 Message Date
Eugen Rochko
5e1364c448
Add IP-based rules (#14963) 2020-10-12 16:33:49 +02:00
ThibG
dc52a778e1
Fix issue checking for last unread notification when there are gaps (#14960) 2020-10-09 17:12:52 +02:00
Thibaut Girka
cd861c051c Fix issue checking for last unread notification when there are gaps 2020-10-08 22:44:30 +02:00
ThibG
dac3e362fd
Fix unread notification marker not updating when mounting column (#14954) 2020-10-08 00:35:27 +02:00
Eugen Rochko
7d985f2aac
Remove dependency on goldfinger gem (#14919)
There are edge cases where requests to certain hosts timeout when
using the vanilla HTTP.rb gem, which the goldfinger gem uses. Now
that we no longer need to support OStatus servers, webfinger logic
is so simple that there is no point encapsulating it in a gem, so
we can just use our own Request class. With that, we benefit from
more robust timeout code and IPv4/IPv6 resolution.

Fix #14091
2020-10-08 00:34:57 +02:00
ThibG
63770d3aac
Ignore alt-key hotkeys in text fields (#14942)
Fixes #14862

This used to be the case until #13987, which introduced a hotkey to toggle
the Content Warning field.

Unfortunately, MacOS relies on the “alt” key for many things, including
composing text (see #14862), therefore, even if that makes the CW toggle
hotkey significantly less useful, it makes sense to not interfere with
composing toots.
2020-10-05 22:04:06 +02:00
mayaeh
5a9ad221bf
Update translation files (#14920) 2020-10-05 02:57:38 +02:00
Eugen Rochko
a549415868
Fix regressions in icon buttons in web UI (#14915) 2020-10-04 15:02:36 +02:00
Takeshi Umeda
bec8b12bb5
Fix mark as read in notifications to be saved immediately (#14907)
* Fix mark as read in notifications to be saved immediately

* fix code style
2020-10-01 04:17:46 +02:00
ThibG
65136600e3
Fix logging out on mobile (#14901)
Fixes #14900
2020-09-30 19:31:17 +02:00
ThibG
78e45a5285
Add option to disable swiping motions across the WebUI (#13885)
Fixes #13882
2020-09-30 19:31:03 +02:00
Takeshi Umeda
f5d08f2417
Fix unread notification markers (#14897) 2020-09-29 15:30:56 +02:00
Thibaut Girka
b5edf30160 Fix boost icon not being displayed in boost notifications 2020-09-29 11:05:05 +02:00
ThibG
82951920f7
Fix bell button causing a brief “Cancel follow request” on locked accounts (#14896) 2020-09-28 21:44:29 +02:00
Thibaut Girka
ccfc2b6dce Make explicit in glitch-soc's WebUI when an account is suspended 2020-09-28 18:00:49 +02:00
Thibaut Girka
e3f822ac1b Do not filter out temporarily-suspended accounts from relationships API 2020-09-28 17:56:16 +02:00
Eugen Rochko
dadec533ce [Glitch] Fix unreadable placeholder text color in high contrast theme in web UI (#14803)
Port bbcbf12215 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-28 17:56:16 +02:00
Thibaut Girka
6dde075425 Fix actions being performed before the redux state is set up 2020-09-28 17:49:55 +02:00
ThibG
f8205b7b4a [Glitch] Add paragraph about browser add-ons when encountering some errors
Port b67caf9be4 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-28 17:49:55 +02:00
Eugen Rochko
14869ee656 [Glitch] Add option to be notified when a followed user posts
Port 974b1b79ce to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-28 17:49:55 +02:00
Eugen Rochko
0a069bffd9 [Glitch] Optimize the process of following someone
Port front-end changes from 6d59dfa15d to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-28 17:49:55 +02:00
Eugen Rochko
6775de3fc9 [Glitch] Change web UI to show empty profile for suspended accounts
Port fcb9350ff8 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-28 17:49:55 +02:00
ThibG
572d1a1bf8 [Glitch] Fix home TL marker code mishandling gaps
Port eaea2311aa to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-28 15:00:19 +02:00
ThibG
4586202448 [Glitch] Fix notification filter bar incorrectly filtering gaps
Port aab867b0e8 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-28 14:59:10 +02:00
ThibG
d31792a2a6 [Glitch] Add border around 🕺 emoji
Port 91eecd1b3c to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-28 14:58:25 +02:00
Thibaut Girka
a7aedebc31 Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `Gemfile.lock`:
  Not a real conflict, upstream updated dependencies that were too close to
  glitch-soc-only ones in the file.
- `app/controllers/oauth/authorized_applications_controller.rb`:
  Upstream changed the logic surrounding suspended accounts.
  Minor conflict due to glitch-soc's theming system.
  Ported upstream changes.
- `app/controllers/settings/base_controller.rb`:
  Upstream refactored and changed the logic surrounding suspended accounts.
  Minor conflict due to glitch-soc's theming system.
  Ported upstream changes.
- `app/controllers/settings/sessions_controller.rb`:
  Upstream refactored and changed the logic surrounding suspended accounts.
  Minor conflict due to glitch-soc's theming system.
  Ported upstream changes.
- `app/models/user.rb`:
  Upstream refactored and changed the logic surrounding suspended accounts.
  Minor conflict due to glitch-soc not preventing moved accounts from logging
  in.
  Ported upstream changes while keeping the ability for moved accounts to log
  in.
- `app/policies/status_policy.rb`:
  Upstream refactored and changed the logic surrounding suspended accounts.
  Minor conflict due to glitch-soc's local-only toots.
  Ported upstream changes.
- `app/serializers/rest/account_serializer.rb`:
  Upstream refactored and changed the logic surrounding suspended accounts.
  Minor conflict due to glitch-soc's ability  to hide followers count.
  Ported upstream changes.
- `app/services/process_mentions_service.rb`:
  Upstream refactored and changed the logic surrounding suspended accounts.
  Minor conflict due to glitch-soc's local-only toots.
  Ported upstream changes.
- `package.json`:
  Not a real conflict, upstream updated dependencies that were too close to
  glitch-soc-only ones in the file.
2020-09-28 14:13:30 +02:00
Eugen Rochko
d88a79b456
Add pop-out player for audio/video in web UI (#14870)
Fix #11160
2020-09-28 13:29:43 +02:00
ThibG
d60290044e
Add environment variable to allow requests to some private addresses (#14722) 2020-09-26 20:57:39 +02:00
ThibG
ff89025979
Add unread notification markers (#14818)
* Add unread notification markers

Fixes #14804

* Allow IntersectionObserverArticle's children to be updated
2020-09-26 20:57:07 +02:00
Jeremy Rose
03b6b034b9
add og:published_time to opengraph meta tags (#14865) 2020-09-24 23:32:13 +02:00
Takeshi Umeda
b655a7f88f
Fix a slow query for TagFeed (#14861)
* Fix a slow query for TagFeed

* rename tags to tag_ids
2020-09-23 16:01:54 +02:00
Takeshi Umeda
070026e634
Fix method of the DELETE DATA button (#14855) 2020-09-21 20:37:19 +02:00
Eugen Rochko
8c8bf0289f
Fix not being able to enable status notifications in Web Push API (#14822) 2020-09-21 17:48:55 +02:00
Thibaut Girka
787d5d7289 Fix minor bugs 2020-09-19 15:01:46 +02:00
Thibaut Girka
312c936d51 Minor refactoring and fixups 2020-09-19 14:15:28 +02:00
Thibaut Girka
85b9086e6b Filter out mounted lists from “getting started” column 2020-09-18 20:07:25 +02:00
Eugen Rochko
974b1b79ce
Add option to be notified when a followed user posts (#13546)
* Add bell button

Fix #4890

* Remove duplicate type from post-deployment migration

* Fix legacy class type mappings

* Improve query performance with better index

* Fix validation

* Remove redundant index from notifications
2020-09-18 17:26:45 +02:00
Thibaut Girka
a681980307 Submit timeline markers closer to the moment they change 2020-09-17 15:22:56 +02:00
Thibaut Girka
60eebc6cc4 Fix crashes when connection drops 2020-09-17 15:22:56 +02:00
Thibaut Girka
f1c0cf9806 Add button to manually mark all notifications as read 2020-09-17 15:22:56 +02:00
Thibaut Girka
94c290d7d2 Only update read marker when giving focus/mounting column 2020-09-17 15:22:56 +02:00
Thibaut Girka
145ed37978 Refactor and change logic to only update marker if we reached the last
read notification.
2020-09-17 15:22:56 +02:00
Thibaut Girka
66e9a77e36 Display unread marker for notifications 2020-09-17 15:22:56 +02:00
Thibaut Girka
ae698469d0 Clean up leftover from DM conversation view redesign 2020-09-17 15:22:56 +02:00
ThibG
eaea2311aa
Fix home TL marker code mishandling gaps (#14809) 2020-09-16 20:17:40 +02:00
ThibG
aab867b0e8
Fix notification filter bar incorrectly filtering gaps (#14808) 2020-09-16 20:17:16 +02:00
kawaguchi
5d3c8baa9a
Fix validates :sign_count of WebauthnCredential (#14806) 2020-09-16 20:16:46 +02:00
Eugen Rochko
ed099d8bdc
Change account suspensions to be reversible by default (#14726) 2020-09-15 14:37:58 +02:00
Eugen Rochko
bbcbf12215
Fix unreadable placeholder text color in high contrast theme in web UI (#14803)
Fix #14717
2020-09-15 09:24:24 +02:00
ThibG
b67caf9be4
Add paragraph about browser add-ons when encountering some errors (#14801)
* Add paragraph about browser add-ons when encountering some errors

When a crash is caused by a NotFoundError exception, add a paragraph
to the error page mentioning browser add-ons.

Indeed, crashes with NotFoundError are often caused by browser extensions
messing with the DOM in ways React.JS can't recover from (e.g. issues #13325
and #14731).

* Reword error messages
2020-09-14 15:05:22 +02:00
ThibG
cd4ec7cd74
Do not serve account actors at all in limited federation mode (#14800)
* Do not serve account actors at all in limited federation mode

When an account is fetched without a signature from an allowed instance,
return an error.

This isn't really an improvement in security, as the only information that was
previously returned was required protocol-level info, and the only personal bit
was the existence of the account. The existence of the account can still be
checked by issuing a webfinger query, as those are accepted without signatures.

However, this change makes it so that unallowed instances won't create account
records on their end when they find a reference to an unknown account.

The previous behavior of rendering a limited list of fields, instead of not
rendering the actor at all, was in order to prevent situations in which two
instances in Authorized Fetch mode or Limited Federation mode would fail to
reach each other because resolving an account would require a signed query…
from an account which can only be fetched with a signed query itself. However,
this should now be fine as fetching accounts is done by signing on behalf of
the special instance actor, which does not require any kind of valid signature
to be fetched.

* Fix tests
2020-09-14 13:04:29 +02:00
Eugen Rochko
42c4322ce7
Fix reported statuses not being included in warning e-mail (#14778) 2020-09-13 12:52:17 +02:00
tateisu
fa0c71f0d9
allow pagination by min_id and max_id (#14776)
* allow pagination by min_id and max_id

* also AccountConversation allows min_id,max_id pair

* also home,list TL allows min_id,max_id pair
2020-09-12 17:09:49 +02:00
Eugen Rochko
4e4b3a0c8e
Refactor settings controllers (#14767)
- Disallow suspended accounts from revoking sessions and apps
- Allow suspended accounts to access exports
2020-09-11 20:56:35 +02:00
Eugen Rochko
e6b272e5c9
Change REST API to return empty data for suspended accounts (#14765) 2020-09-11 15:16:29 +02:00
ThibG
91eecd1b3c
Add border around 🕺 emoji (#14769)
Fixes #14768
2020-09-10 19:08:03 +02:00
kedama
afa753a890 [Glitch] Set z-index of dropdown to 9999.
Port 678f5ed296 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-10 17:44:38 +02:00
Eugen Rochko
fcb9350ff8
Change web UI to show empty profile for suspended accounts (#14766) 2020-09-10 00:07:19 +02:00
Thibaut Girka
9748f074a3 Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/controllers/api/v1/timelines/public_controller.rb
- app/lib/feed_manager.rb
- app/models/status.rb
- app/services/precompute_feed_service.rb
- app/workers/feed_insert_worker.rb
- spec/models/status_spec.rb

All conflicts are due to upstream refactoring feed management and us having
local-only toots on top of that. Rewrote local-only toots management for
upstream's changes.
2020-09-08 16:26:47 +02:00
Eugen Rochko
65760f59df
Refactor feed manager (#14761) 2020-09-08 03:41:16 +02:00
ThibG
517af45e32
Fix multiple boosts of a same toot erroneously appearing in TL (#14759)
* Check for and record reblog info atomically

Instead of using ZREVRANK to determine whether a reblog is a new reblog or not,
use ZADD's NX option to perform the check/addition option atomically.

* Replace ZREVRANK call with ZSCORE key which is more efficient

* Make tests a bit stricter

* Fix off-by-one
2020-09-07 18:00:15 +02:00
abcang
e79d719e92
Changed tag most_used to recently_used (#14760) 2020-09-07 17:47:41 +02:00
Eugen Rochko
e8bc187845
Refactor how public and tag timelines are queried (#14728) 2020-09-07 11:02:04 +02:00
Thibaut Girka
e5f934ddf0 Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/activitypub/collections_controller.rb`:
  Conflict caused because we have additional code to make sure pinned
  local-only toots don't get rendered on the ActivityPub endpoints.
  Ported upstream changes.
2020-09-07 09:21:38 +02:00
Eugen Rochko
a6121a159c
Remove obsolete IndexedDB operations from web UI (#14730)
Storing objects in IndexedDB was disabled in #7932, but we were
still trying to read objects from it before making an API call
2020-09-04 20:22:40 +02:00
Takeshi Umeda
272aa4a109
Fix direct visibility style for light theme (#14727) 2020-09-04 08:49:56 +02:00
ThibG
abee40b232
Add outbox attribute to instance actor (#14721)
It's not useful for now, but it's required by ActivityPub
2020-09-02 18:42:50 +02:00
Takeshi Umeda
33ad850c98
Added account featured tags API (#11817) 2020-09-02 02:13:10 +02:00
Eugen Rochko
17340365bb
Add featured hashtags as an ActivityPub collection (#11595) 2020-09-02 02:11:12 +02:00
ThibG
787a629b8f [Glitch] Update Tesseract.js
Port 5fc5a9f9f1 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-01 17:10:20 +02:00
ThibG
a2d66a90e6 [Glitch] Add border around 🐞 emoji
Port JS change from f0b6ddd979 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-01 17:08:09 +02:00
Thibaut Girka
3fefb7909b Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `config/webpack/shared.js`:
  Upstream has changed how Tesseract.js gets included and dropped a dependency.
  The conflict is caused by glitch-soc having different code due to its
  theming system.
  Ported upstream changes.
- `lib/mastodon/version.rb`:
  Upstream refactor/code style change in a place we replaced upstream's
  repo URL with ours.
  Ported upstram changes, keeping our repo URL.
- `yarn.lock`:
  Upstream dropped dependencies, one of which was textually too close to
  a glitch-soc-specific dependency. Not a real conflict.
2020-09-01 17:02:18 +02:00
Thibaut Girka
d95dd3883e Change radio button design to be consistent with that of the directory explorer
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-01 14:09:35 +02:00
Thibaut Girka
70e64206be Capitalize replies_policy strings
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-09-01 14:09:35 +02:00
ThibG
79305428a7
Add configuration option to filter replies in lists (#9205)
* Add database support for list show-reply preferences

* Add backend support to read and update list-specific show_replies settings

* Add basic UI to set list replies setting

* Add specs for list replies policy

* Switch "cycling" reply policy link to a set of radio inputs

* Capitalize replies_policy strings

* Change radio button design to be consistent with that of the directory explorer
2020-09-01 13:31:28 +02:00
Eugen Rochko
1c308af84c
Change own direct-visibility statuses to be in the home feed again (#14711)
And remove highlighting in web UI

Full circle from #8940
2020-09-01 13:30:42 +02:00
Thibaut Girka
e02f375d22 Fix threaded mode
Fixes #1414
2020-09-01 09:37:17 +02:00
dependabot[bot]
8972e5f7f6
Bump rubocop from 0.86.0 to 0.88.0 (#14412)
* Bump rubocop from 0.86.0 to 0.88.0

Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.86.0 to 0.88.0.
- [Release notes](https://github.com/rubocop-hq/rubocop/releases)
- [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.86.0...v0.88.0)

Signed-off-by: dependabot[bot] <support@github.com>

* Fix for latest RuboCop

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Yamagishi Kazutoshi <ykzts@desire.sh>
2020-09-01 03:04:00 +02:00
ThibG
5fc5a9f9f1
Update Tesseract.js (#14708)
* [WiP] Update Tesseract.js

- Update Tesseract.js to 2.2.1
- Use versioned file names
- differentiate two progression states: preparing OCR and detecting picture

* Get rid of copy-webpack-plugin
2020-09-01 00:26:10 +02:00
Thibaut Girka
38182fceb3 Fix crash when opening detailed view of a status you boosted 2020-08-31 23:48:16 +02:00
ThibG
f0b6ddd979
Add border around 🐞 emoji (#14712) 2020-08-31 23:30:27 +02:00
ThibG
7febf19296
Add back “Home” link to the “Getting Started” column when the “Home” column isn't mounted (#14707)
* Add back "Home" link to "Getting started" when Home column isn't mounted

* Fix keys in getting_started

It should not matter much in practice as the list of items will only
change extremely rarely, but having a `key` that corresponds to the actual
item makes much more sense than having it be the index of the item within
the list.
2020-08-31 18:11:37 +02:00
Takeshi Umeda
b1bb1906be
Fix limited follower id in fan-out-on-write service (#14709) 2020-08-31 18:11:27 +02:00
Akihiko Odaki
ae871c4d46
Make Array-creation behavior of Paginable more predictable (#14687)
* Make Array-creation behavior of Paginable more predictable

Paginable.paginate_by_id usually returns ActiveRecord::Relation, but it
returns an Array if min_id option is present. The behavior caused problems
fixed with the following commits:
- 552e886b64
- b63ede5005
- 64ef37b89d

To prevent from recurring similar problems, this commit introduces two
changes:
- The scope now always returns an Array whether min_id option is present
  or not.
- The scope is renamed to to_a_paginated_by_id to clarify it returns an
  Array.

* Transform Paginable.to_a_paginated_by_id from a scope to a class method

https://api.rubyonrails.org/classes/ActiveRecord/Scoping/Named/ClassMethods.html#method-i-scope
> The method is intended to return an ActiveRecord::Relation object, which
> is composable with other scopes.

Paginable.to_a_paginated_by_id returns an Array and is not appropriate
as a scope.
2020-08-31 12:47:09 +02:00
Thibaut Girka
a68ec50e4e Adapt 2FA changes to glitch-soc's theming system 2020-08-30 17:26:18 +02:00
santiagorodriguez96
a340e653df [Glitch] Add WebAuthn as an alternative 2FA method
Port CSS changes from e8d41bc2fe

Co-authored-by: Facundo Padula <facundo.padula@cedarcode.com>
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-08-30 17:21:16 +02:00
Tdxdxoz
bf55b5463a [Glitch] Fix: also use custom private boost icon for detailed status
Port a3ec9af9b0 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-08-30 16:51:16 +02:00
Daigo 3 Dango
72b1d5fdc5 [Glitch] Better manage subscriptionCounters
Port 9669557be1 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-08-30 16:35:33 +02:00
proxy
3bbf6b1519 [Glitch] reword "boost to original audience" as per tootsuite#14596
Port 46210a65d1 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-08-30 16:34:38 +02:00
Takeshi Umeda
cd806663af [Glitch] Fix click range discrepancies in gifv
Port debf6ae316 to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-08-30 16:31:41 +02:00
ThibG
45d1f34a30 [Glitch] Fix scrolling issues when closing some dropdown menus
Port c7cfd4e67a to glitch-soc

Signed-off-by: Thibaut Girka <thib@sitedethib.com>
2020-08-30 16:31:02 +02:00
Thibaut Girka
8c3c27bf06 Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- `app/controllers/accounts_controller.rb`:
  Upstream change too close to a glitch-soc change related to
  instance-local toots. Merged upstream changes.
- `app/services/fan_out_on_write_service.rb`:
  Minor conflict due to glitch-soc's handling of Direct Messages,
  merged upstream changes.
- `yarn.lock`:
  Not really a conflict, caused by glitch-soc-only dependencies
  being textually too close to updated upstream dependencies.
  Merged upstream changes.
2020-08-30 16:13:08 +02:00
Eugen Rochko
52157fdcba
Add support for dereferencing objects through bearcaps (#14683) 2020-08-30 12:34:20 +02:00
Eugen Rochko
ce8f33dd2f
Fix inefficiencies in fan-out-on-write service (#14682) 2020-08-30 12:33:59 +02:00
Eugen Rochko
bf477cee9f
Fix videos with near-60 fps being rejected (#14684)
Fix #14668
2020-08-30 01:54:30 +02:00
Thibaut Girka
30632adf9e Fix replying to some remote toots switching to local-only 2020-08-29 19:57:32 +02:00
Akihiko Odaki
64ef37b89d
Introduce ApplicationController#cache_collection_paginated_by_id (#14677)
* Replace incorrect use of distinct with group

Some uses of ActiveRecord::QueryMethods#distinct pass field names but they
are incorrect for the current version of Rails.

ActiveRecord::QueryMethods#group provides the expected behavior and
benefits performance. See commit 6da24aad4cafdef8d8a2c92bac2002a5fc2fe9c8.

* Introduce ApplicationController#cache_collection_paginated_by_id

ApplicationController#cache_collection_paginated_by_id fuses
ApplicationController#cache_collection and Paginable.paginate_by_id.

An advantage of this method is that it prevents from modifying scope which
Paginable.paginate_by_id may provide.
ApplicationController#cache_collection always return an array and there
is no possibility of the scope modification. It is also clear for a
programmer, considering the implication of "cache".

This method can also emit more efficient queries by using
Cacheable.cache_ids before calling Paginable.paginate_by_id.
2020-08-28 12:31:56 +02:00
Akihiko Odaki
b63ede5005
Eagerly load statuses with the main query in Api::V1::BookmarksController (#14674)
This is same with commit 552e886b64 except
that it was for Api::V1::FavouritesController while this is for
Api::V1::BookmarksController.
2020-08-28 12:30:23 +02:00
Akihiko Odaki
e26e7a1cb5
Replace incorrect use of distinct with group (#14675)
Some uses of ActiveRecord::QueryMethods#distinct pass field names but they
are incorrect for the current version of Rails.

ActiveRecord::QueryMethods#group provides the expected behavior and
benefits performance. See commit 6da24aad4cafdef8d8a2c92bac2002a5fc2fe9c8.
2020-08-28 12:29:59 +02:00
Akihiko Odaki
552e886b64
Eagerly load statuses with the main query in Api::V1::FavouritesController (#14673)
The old implementation had two queries:
1. The query constructed in Api::V1::FavouritesController#results
2. The query constructed in #cached_favourites, which is merged with 1.

Both of them are issued againt PostgreSQL. The combination of the two
queries caused the following problems:
- The small window between the two queries involves race conditions.
- Minor performance inefficiency.

Moreover, the construction of query 2, which involves merging with query
1 has a bug. Query 1 is finalized with paginate_by_id, but paginate_by_id
returns an array when min_id parameter is specified. The behavior prevents
from merging the query, and in the real world, ActiveRecord simply ignores
the merge (!), which results in querying the entire scan of statuses and
favourites table.

This change fixes these issues by simply letting query 1 get all the works
done.
2020-08-28 09:27:33 +02:00