about summary refs log tree commit diff
path: root/app/lib
AgeCommit message (Collapse)Author
2023-02-25Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `.prettierignore`: Upstream added a line at the end of the file, while glitch-soc had its own extra lines. Took upstream's change. - `CONTRIBUTING.md`: We have our custom CONTRIBUTING.md quoting upstream. Upstream made changes. Ported upstream changes. - `app/controllers/application_controller.rb`: Upstream made code style changes in a method that is entirely replaced in glitch-soc. Ignored the change. - `app/models/account.rb`: Code style changes textually close to glitch-soc-specific changes. Ported upstream changes. - `lib/sanitize_ext/sanitize_config.rb`: Upstream code style changes. Ignored them.
2023-02-22Enable Rubocop Style/StringConcatenation defaults (#23792)Nick Schonning
2023-02-20Autofix Rubocop Style/RescueStandardError (#23745)Nick Schonning
2023-02-20Autofix Rubocop remaining Layout rules (#23679)Nick Schonning
2023-02-20Autofix Rubocop Rails/Pluck (#23730)Nick Schonning
2023-02-19Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `.github/dependabot.yml`: Upstream made changes while we have dropped this file. Keep the file deleted. - `.prettierignore`: Upstream made changes at the end of the file, where we had our extra lines. Just moved our extra lines back at the end. - `app/serializers/initial_state_serializer.rb`: Upstream code style changes. Applied them. - `app/services/backup_service.rb`: Upstream code style changes. Applied them.
2023-02-19Autofix Rubocop Style/StringLiterals (#23695)Nick Schonning
2023-02-19Autofix Rubocop Style/RedundantBegin (#23703)Nick Schonning
2023-02-18Autofix Rubocop Style/IfUnlessModifier (#23697)Nick Schonning
2023-02-18Autofix Rubocop Style/PerlBackrefs (#23649)Nick Schonning
2023-02-18Autofix Rubocop Lint/AmbiguousOperatorPrecedence (#23681)Nick Schonning
2023-02-18Autofix Rubocop Lint/SymbolConversion (#23683)Nick Schonning
2023-02-18Run rubocop formatting except line length (#23632)Nick Schonning
2023-02-10Merge branch 'main' into glitch-soc/merge-upstreamClaire
2023-02-10Fix unbounded recursion in post discovery (#23506)Claire
* Add a limit to how many posts can get fetched as a result of a single request * Add tests * Always pass `request_id` when processing `Announce` activities --------- Co-authored-by: nametoolong <nametoolong@users.noreply.github.com>
2023-02-09Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `README.md`: Minor upstream change, our README is completely different. Kept ours. - `lib/tasks/assets.rake`: glitch-soc has extra code to deal with its theming system, upstream changed a line that exists in glitch-soc. Applied upstream changes.
2023-02-08Apply Rubocop Rails/WhereNot (#23448)Nick Schonning
* Apply Rubocop Rails/WhereNot * Update spec for where.not
2023-02-08Apply Rubocop Performance/BlockGivenWithExplicitBlock (#23441)Nick Schonning
* Apply Rubocop Performance/BlockGivenWithExplicitBlock * Unprefix used block parameter
2023-02-08Apply Rubocop Performance/StringIdentifierArgument (#23444)Nick Schonning
2023-02-08Apply Rubocop Performance/DoubleStartEndWith (#23442)Nick Schonning
2023-02-07Autofix Rails/EagerEvaluationLogMessage (#23429)Nick Schonning
* Autofix Rails/EagerEvaluationLogMessage * Update spec for debug block syntax
2023-02-03Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `.github/workflows/build-image.yml`: Upstream updated `docker/build-push-action`, and we a different config for `docker/metadata-action` so the lines directly above were different, but it's not a real conflict. Upgraded `docker/build-push-action` as upstream did. - `app/javascript/mastodon/features/compose/components/compose_form.js`: Upstream changed the codestyle near a line we had modified to accommodate configurable character count. Kept our change.
2023-02-01Change number of stored items in home feed from 400 to 800 (#23349)Eugen Rochko
2023-01-20Advertise supported MIME types for statuses (#2090)Vyr Cossont
2023-01-18Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `config/i18n-tasks.yml`: Upstream added new ignored strings, glitch-soc has extra ignored strings because of the theming system. Added upstream's changes.
2023-01-18Fix spurious admin dashboard warning when using ElasticSearch 7.x (#23064)Claire
Some 7.x ElasticSearch versions support some 6.x nodes, thus the version check is inadequate. I am not sure there is a good way to check if a server implements all the 7.x APIs, so check server version and minimum wire version instead.
2023-01-12Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `app/models/status.rb`: Minor upstream refactor moved hook definitions around, and glitch-soc has an extra `before_create`. Moved the `before_create` accordingly. - `app/services/batched_remove_status_service.rb`: Minor upstream refactor changed a block in which glitch-soc had one extra call to handle direct timelines. Adapted changes to keep glitch-soc's extra call.
2023-01-11fix: allow verification when page size exceeds 1MB (using HTML5 parser) (#22879)Markus Unterwaditzer
* fix: allow verification when page size exceeds 1MB Truncates the page after 1MB instead Closes #15316 * switch to HTML5 parser, fix rubocop errors * undo rubocop fixes Co-authored-by: Chris Zubak-Skees <chriszs@gmail.com>
2023-01-11Fix/remove calling private method with send in model (#22951)Kaspar V
* fix(status): remove send usage for private unlink_from_conversations - make unlink_from_conversations public method - rename unlink_from_conversations to unlink_from_conversations! - fix send call on private method in statuses_vacuum and batched_remove_status_service * fix(feeds_vacuum): replace find_in_batches with in_batches because active record query results should be a little more efficient than itterating with map and each. Postgres can grasp such lists of ids much quicker than ruby can. Will probably make allmost no difference, but cannot hurt either.
2023-01-05Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `README.md`: Upstream updated its README, while we have a completely different one. Kept our README. - `app/controllers/concerns/web_app_controller_concern.rb`: Conflict because of glitch-soc's theming system. Additionally, glitch-soc has different behavior regarding moved accounts. Ported some of the changes, but kept our overall behavior. - `app/javascript/packs/admin.js`: Code changes actually applied to `app/javascript/core/admin.js`
2023-01-05Check OpenSearch compatibility version instead of regular version (#22422)Vyr Cossont
Fixes #18535.
2023-01-05Fix home TL could contain post from who blocked me (#22849)Jeong Arm
* Fix home tl contains post from who blocked me * Add test * Fix feed_manager's build_crutches blocked_by was not includes status' owner * Add test for status from I blocked * Fix typo
2022-12-15Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `README.md`: Discarded upstream changes: we have our own README - `app/controllers/follower_accounts_controller.rb`: Port upstream's minor refactoring
2022-12-15Fix status cache hydration discrepancy (#19879)Claire
2022-12-15Fix inability to use local LibreTranslate without setting ↵Claire
ALLOWED_PRIVATE_ADDRESSES (#21926) Fixes #20029
2022-12-15Fix crash in elasticsearch_check.rb (#21006)s0
Nil unwrap causes the admin dashboard to crash/500 when the Chewy client info version number value is nil. This occurs when running another ES-compatible backend such as MeiliSearch. Obviously it would be good for chewy to recognise upstream but at least avoiding the crash would be fine.
2022-12-15Don't delivery a reply to domains which are blocked by author (#22117)Jeong Arm
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2022-12-07Fix unbounded recursion in account discovery (#22025)Claire
* Fix trying to fetch posts from other users when fetching featured posts * Rate-limit discovery of new subdomains * Put a limit on recursively discovering new accounts
2022-12-04Fix unbounded recursion in account discovery (#1994)Claire
* Fix trying to fetch posts from other users when fetching featured posts * Rate-limit discovery of new subdomains * Put a limit on recursively discovering new accounts
2022-12-02Use a tree‐based approach for advanced text formatting (#1907)kibigo!
* Use a tree‐based approach for adv. text formatting Sanitizing HTML/Markdown means parsing the content into an HTML tree under‐the‐hood anyway, and it is more accurate to do mention/hashtag replacement on the text nodes in that tree than it is to try to hack it in with regexes et cetera. This undoes the overrides of `#entities` and `#rewrite` on `AdvancedTextFormatter` but also stops using them, instead keeping track of the parsed Nokogiri tree itself and using that in the `#to_s` method. Internally, this tree uses `<mastodon-entity>` nodes to keep track of hashtags, links, and mentions. Sanitization is moved to the beginning, so it should be known that these do not appear in the input. * Also disallow entities inside of `<code>` I think this is generally expected behaviour, and people are annoyed when their code gets turned into links/hashtags/mentions. * Minor cleanup to AdvancedTextFormatter * Change AdvancedTextFormatter to rewrite entities in one pass and sanitize at the end Also, minor refactoring to better match how other formatters are organized. * Add some tests Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2022-12-01Merge branch 'main' into glitch-soc/merge-upstreamClaire
2022-12-01Fix some performance issues with /admin/instances (#21907)Claire
/admin/instances?availability=failing remains wholly unefficient
2022-11-28Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `README.md`: Our README is completely different. Discarded upstream changes.
2022-11-27refactor(vacuum statuses): reduce amount of db queries and load for each ↵Kaspar V
query - improve performance (#21487) * refactor(statuses_vacuum): remove dead code - unused Method is not called inside class and private. Clean up dead code. * refactor(statuses_vacuum): make retention_period present test explicit This private method only hides functionality. It is best practice to be as explicit as possible. * refactor(statuses_vacuum): improve query performance - fix statuses_scope having sub-select for Account.remote scope by `joins(:account).merge(Account.remote)` - fix statuses_scope unnecessary use of `Status.arel_table[:id].lt` because it is inexplicit, bad practice and even slower than normal `.where('statuses.id < ?'` - fix statuses_scope remove select(:id, :visibility) for having reusable active record query batches (no re queries) - fix vacuum_statuses! to use in_batches instead of find_in_batches, because in_batches delivers a full blown active record query result, in stead of an array - no requeries necessary - send(:unlink_from_conversations) not to perform another db query, but reuse the in_batches result instead. - remove now obsolete remove_from_account_conversations method - remove_from_search_index uses array of ids, instead of mapping the ids from an array - this should be more efficient - use the in_batches scope to call delete_all, instead of running another db query for this - because it is again more efficient - add TODO comment for calling models private method with send * refactor(status): simplify unlink_from_conversations - add `has_many through:` relation mentioned_accounts - use model scope local instead of method call `Status#local?` - more readable add account to inbox_owners when account.local? * refactor(status): searchable_by way less sub selects These queries all included a sub-select. Doing the same with a joins should be more efficient. Since this method does 5 such queries, this should be significant, since it technically halves the query count. This is how it was: ```ruby [3] pry(main)> Status.first.mentions.where(account: Account.local, silent: false).explain Status Load (1.6ms) SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL ORDER BY "statuses"."id" DESC LIMIT $1 [["LIMIT", 1]] Mention Load (1.5ms) SELECT "mentions".* FROM "mentions" WHERE "mentions"."status_id" = $1 AND "mentions"."account_id" IN (SELECT "accounts"."id" FROM "accounts" WHERE "accounts"."domain" IS NULL) AND "mentions"."silent" = $2 [["status_id", 109382923142288414], ["silent", false]] => EXPLAIN for: SELECT "mentions".* FROM "mentions" WHERE "mentions"."status_id" = $1 AND "mentions"."account_id" IN (SELECT "accounts"."id" FROM "accounts" WHERE "accounts"."domain" IS NULL) AND "mentions"."silent" = $2 [["status_id", 109382923142288414], ["silent", false]] QUERY PLAN ------------------------------------------------------------------------------------------------------------------ Nested Loop (cost=0.15..23.08 rows=1 width=41) -> Seq Scan on accounts (cost=0.00..10.90 rows=1 width=8) Filter: (domain IS NULL) -> Index Scan using index_mentions_on_account_id_and_status_id on mentions (cost=0.15..8.17 rows=1 width=41) Index Cond: ((account_id = accounts.id) AND (status_id = '109382923142288414'::bigint)) Filter: (NOT silent) (6 rows) ``` This is how it is with this change: ```ruby [4] pry(main)> Status.first.mentions.joins(:account).merge(Account.local).active.explain Status Load (1.7ms) SELECT "statuses".* FROM "statuses" WHERE "statuses"."deleted_at" IS NULL ORDER BY "statuses"."id" DESC LIMIT $1 [["LIMIT", 1]] Mention Load (0.7ms) SELECT "mentions".* FROM "mentions" INNER JOIN "accounts" ON "accounts"."id" = "mentions"."account_id" WHERE "mentions"."status_id" = $1 AND "accounts"."domain" IS NULL AND "mentions"."silent" = $2 [["status_id", 109382923142288414], ["silent", false]] => EXPLAIN for: SELECT "mentions".* FROM "mentions" INNER JOIN "accounts" ON "accounts"."id" = "mentions"."account_id" WHERE "mentions"."status_id" = $1 AND "accounts"."domain" IS NULL AND "mentions"."silent" = $2 [["status_id", 109382923142288414], ["silent", false]] QUERY PLAN ------------------------------------------------------------------------------------------------------------------ Nested Loop (cost=0.15..23.08 rows=1 width=41) -> Seq Scan on accounts (cost=0.00..10.90 rows=1 width=8) Filter: (domain IS NULL) -> Index Scan using index_mentions_on_account_id_and_status_id on mentions (cost=0.15..8.17 rows=1 width=41) Index Cond: ((account_id = accounts.id) AND (status_id = '109382923142288414'::bigint)) Filter: (NOT silent) (6 rows) ```
2022-11-14Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `Gemfile`: Upstream removed blank lines.
2022-11-14Fix emoji substitution not applying only to text nodes in backend code (#20641)Claire
Signed-off-by: Claire <claire.github-309c@sitedethib.com> Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2022-11-12Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `app/models/account.rb`: Conflict because we (glitch-soc) have disabled trending of posts without review. Discarded that upstream change. - `app/views/admin/settings/discovery/show.html.haml`: Just an extra setting in glitch-soc. Kept that extra setting.
2022-11-11fixes ArgumentError when proxy is used (#20420)Bearice Ren
* fixes ArgumentError when proxy is used * Update app/lib/request.rb Co-authored-by: Claire <claire.github-309c@sitedethib.com> Co-authored-by: Eugen Rochko <eugen@zeonfederated.com> Co-authored-by: Claire <claire.github-309c@sitedethib.com>
2022-11-10Change incoming activity processing to happen in `ingress` queue (#20264)Eugen Rochko
2022-11-10Merge branch 'main' into glitch-soc/merge-upstreamClaire
Conflicts: - `app/models/custom_emoji.rb`: Not a real conflict, just upstream changing a line too close to a glitch-soc-specific validation. Applied upstream changes. - `app/models/public_feed.rb`: Not a real conflict, just upstream changing a line too close to a glitch-soc-specific parameter documentation. Applied upstream changes.