Skip to content

Commit

Permalink
Merge remote tracking branch 'glitch-soc/main' (#75)
Browse files Browse the repository at this point in the history
* Fix wrong color on active icons with counters in web UI (mastodon#26767)

* Update dependency typescript to v5.2.2 (mastodon#26786)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Fix `before:`, `after:` and `during:` failing when time zone not set (mastodon#26782)

* Update DefinitelyTyped types (non-major) (mastodon#26785)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Fix invalid Content-Type header for WebP images (mastodon#26773)

* Fix light mode colors for advanced interface banner (mastodon#26759)

* Fix `#hashtag` matching non-hashtagged posts in search (mastodon#26781)

* Update dependency rubocop to v1.56.2 (mastodon#26568)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Update dependency stylelint-config-standard-scss to v11 (mastodon#26780)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* Remove kmr from language selection (mastodon#26014)

* Add `in:library` syntax to search (mastodon#26760)

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

* Fix language settings for users having selected the `kmr` language (mastodon#26787)

* Update babel monorepo to v7.22.15 (mastodon#26790)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* [Glitch] Fix light mode colors for advanced interface banner

Port a106c46 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>

* Bump version to v4.2.0-beta3 (mastodon#26753)

* Fix “Scoped order is ignored, it's forced to be batch order.” warnings (mastodon#26793)

* Migrate Dockerfile to Bookworm (mastodon#26802)

* Fix video player not being displayed in reports interface (mastodon#26801)

---------

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Christian Schmidt <github@chsc.dk>
Co-authored-by: Stanislas Signoud <signez@stanisoft.net>
Co-authored-by: gunchleoc <fios@foramnagaidhlig.net>
Co-authored-by: Claire <claire.github-309c@sitedethib.com>
Co-authored-by: Michael Stanclift <mx@vmstan.com>
  • Loading branch information
8 people authored Sep 9, 2023
1 parent 68cd776 commit 4df9ee6
Show file tree
Hide file tree
Showing 37 changed files with 567 additions and 371 deletions.
54 changes: 43 additions & 11 deletions CHANGELOG.md

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.4
# This needs to be bullseye-slim because the Ruby image is built on bullseye-slim
ARG NODE_VERSION="16.20-bullseye-slim"
# This needs to be bookworm-slim because the Ruby image is built on bookworm-slim
ARG NODE_VERSION="16.20-bookworm-slim"

FROM ghcr.io/moritzheiber/ruby-jemalloc:3.2.2-slim as ruby
FROM node:${NODE_VERSION} as build
Expand All @@ -20,7 +20,7 @@ RUN apt-get update && \
apt-get install -y --no-install-recommends build-essential \
git \
libicu-dev \
libidn11-dev \
libidn-dev \
libpq-dev \
libjemalloc-dev \
zlib1g-dev \
Expand Down Expand Up @@ -64,13 +64,13 @@ RUN apt-get update && \
apt-get -y --no-install-recommends install whois \
wget \
procps \
libssl1.1 \
libssl3 \
libpq5 \
imagemagick \
ffmpeg \
libjemalloc2 \
libicu67 \
libidn11 \
libicu72 \
libidn12 \
libyaml-0-2 \
file \
ca-certificates \
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ GEM
sidekiq (>= 5, < 8)
rspec-support (3.12.1)
rspec_chunked (0.6)
rubocop (1.56.1)
rubocop (1.56.2)
base64 (~> 0.1.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
Expand Down
13 changes: 12 additions & 1 deletion app/chewy/public_statuses_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,29 @@ class PublicStatusesIndex < Chewy::Index
english_stemmer
),
},

hashtag: {
tokenizer: 'keyword',
filter: %w(
word_delimiter_graph
lowercase
asciifolding
cjk_width
),
},
},
}

index_scope ::Status.unscoped
.kept
.indexable
.includes(:media_attachments, :preloadable_poll, :preview_cards)
.includes(:media_attachments, :preloadable_poll, :preview_cards, :tags)

root date_detection: false do
field(:id, type: 'long')
field(:account_id, type: 'long')
field(:text, type: 'text', analyzer: 'verbatim', value: ->(status) { status.searchable_text }) { field(:stemmed, type: 'text', analyzer: 'content') }
field(:tags, type: 'text', analyzer: 'hashtag', value: ->(status) { status.tags.map(&:display_name) })
field(:language, type: 'keyword')
field(:properties, type: 'keyword', value: ->(status) { status.searchable_properties })
field(:created_at, type: 'date')
Expand Down
13 changes: 12 additions & 1 deletion app/chewy/statuses_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,26 @@ class StatusesIndex < Chewy::Index
english_stemmer
),
},

hashtag: {
tokenizer: 'keyword',
filter: %w(
word_delimiter_graph
lowercase
asciifolding
cjk_width
),
},
},
}

index_scope ::Status.unscoped.kept.without_reblogs.includes(:media_attachments, :preview_cards, :local_mentioned, :local_favorited, :local_reblogged, :local_bookmarked, preloadable_poll: :local_voters), delete_if: ->(status) { status.searchable_by.empty? }
index_scope ::Status.unscoped.kept.without_reblogs.includes(:media_attachments, :preview_cards, :local_mentioned, :local_favorited, :local_reblogged, :local_bookmarked, :tags, preloadable_poll: :local_voters), delete_if: ->(status) { status.searchable_by.empty? }

root date_detection: false do
field(:id, type: 'long')
field(:account_id, type: 'long')
field(:text, type: 'text', analyzer: 'verbatim', value: ->(status) { status.searchable_text }) { field(:stemmed, type: 'text', analyzer: 'content') }
field(:tags, type: 'text', analyzer: 'hashtag', value: ->(status) { status.tags.map(&:display_name) })
field(:searchable_by, type: 'long', value: ->(status) { status.searchable_by })
field(:language, type: 'keyword')
field(:properties, type: 'keyword', value: ->(status) { status.searchable_properties })
Expand Down
24 changes: 15 additions & 9 deletions app/chewy/tags_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ class TagsIndex < Chewy::Index
analyzer: {
content: {
tokenizer: 'keyword',
filter: %w(lowercase asciifolding cjk_width),
filter: %w(
word_delimiter_graph
lowercase
asciifolding
cjk_width
),
},

edge_ngram: {
tokenizer: 'edge_ngram',
filter: %w(lowercase asciifolding cjk_width),
filter: %w(
lowercase
asciifolding
cjk_width
),
},
},

Expand All @@ -30,12 +39,9 @@ class TagsIndex < Chewy::Index
end

root date_detection: false do
field :name, type: 'text', analyzer: 'content' do
field :edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'content'
end

field :reviewed, type: 'boolean', value: ->(tag) { tag.reviewed? }
field :usage, type: 'long', value: ->(tag, crutches) { tag.history.aggregate(crutches.time_period).accounts }
field :last_status_at, type: 'date', value: ->(tag) { tag.last_status_at || tag.created_at }
field(:name, type: 'text', analyzer: 'content', value: :display_name) { field(:edge_ngram, type: 'text', analyzer: 'edge_ngram', search_analyzer: 'content') }
field(:reviewed, type: 'boolean', value: ->(tag) { tag.reviewed? })
field(:usage, type: 'long', value: ->(tag, crutches) { tag.history.aggregate(crutches.time_period).accounts })
field(:last_status_at, type: 'date', value: ->(tag) { tag.last_status_at || tag.created_at })
end
end
1 change: 0 additions & 1 deletion app/helpers/languages_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ module LanguagesHelper
cnr: ['Montenegrin', 'crnogorski'].freeze,
jbo: ['Lojban', 'la .lojban.'].freeze,
kab: ['Kabyle', 'Taqbaylit'].freeze,
kmr: ['Kurmanji (Kurdish)', 'Kurmancî'].freeze,
ldn: ['Láadan', 'Láadan'].freeze,
lfn: ['Lingua Franca Nova', 'lingua franca nova'].freeze,
sco: ['Scots', 'Scots'].freeze,
Expand Down
1 change: 1 addition & 0 deletions app/helpers/media_component_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def render_video_component(status, **options)
blurhash: video.blurhash,
frameRate: meta.dig('original', 'frame_rate'),
inline: true,
aspectRatio: "#{meta.dig('original', 'width')} / #{meta.dig('original', 'height')}",
media: [
serialize_media_attachment(video),
].as_json,
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/flavours/glitch/styles/components/columns.scss
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ $ui-header-height: 55px;
}

.switch-to-advanced {
color: $classic-primary-color;
background-color: $classic-base-color;
color: $light-text-color;
background-color: $ui-base-color;
padding: 15px;
border-radius: 4px;
margin-top: 4px;
Expand Down
26 changes: 13 additions & 13 deletions app/javascript/styles/mastodon/components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -228,20 +228,20 @@
color: lighten($lighter-text-color, 7%);
background-color: transparent;
}
}

&.active {
color: $highlight-text-color;
&.active {
color: $highlight-text-color;

&:hover,
&:active,
&:focus {
color: $highlight-text-color;
background-color: transparent;
}
&:hover,
&:active,
&:focus {
color: $highlight-text-color;
background-color: transparent;
}

&.disabled {
color: lighten($highlight-text-color, 13%);
}
&.disabled {
color: lighten($highlight-text-color, 13%);
}
}

Expand Down Expand Up @@ -3291,8 +3291,8 @@ $ui-header-height: 55px;
}

.switch-to-advanced {
color: $classic-primary-color;
background-color: $classic-base-color;
color: $light-text-color;
background-color: $ui-base-color;
padding: 15px;
border-radius: 4px;
margin-top: 4px;
Expand Down
2 changes: 1 addition & 1 deletion app/lib/feed_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def populate_home(account)
add_to_feed(:home, account.id, status, aggregate_reblogs: aggregate)
end

account.following.includes(:account_stat).find_each do |target_account|
account.following.includes(:account_stat).reorder(nil).find_each do |target_account|
if redis.zcard(timeline_key) >= limit
oldest_home_score = redis.zrange(timeline_key, 0, 0, with_scores: true).first.last.to_i
last_status_score = Mastodon::Snowflake.id_at(target_account.last_status_at)
Expand Down
2 changes: 1 addition & 1 deletion app/lib/importer/public_statuses_index_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ def index
end

def scope
Status.indexable
Status.indexable.reorder(nil)
end
end
2 changes: 1 addition & 1 deletion app/lib/importer/statuses_index_importer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def import!
# from a different scope to avoid indexing them multiple times, but that
# could end up being a very large array

scope.find_in_batches(batch_size: @batch_size) do |tmp|
scope.reorder(nil).find_in_batches(batch_size: @batch_size) do |tmp|
in_work_unit(tmp.map(&:status_id)) do |status_ids|
deleted = 0

Expand Down
100 changes: 87 additions & 13 deletions app/lib/search_query_transformer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,90 @@ class SearchQueryTransformer < Parslet::Transform
before
after
during
in
).freeze

class Query
attr_reader :must_not_clauses, :must_clauses, :filter_clauses
def initialize(clauses, options = {})
raise ArgumentError if options[:current_account].nil?

def initialize(clauses)
grouped = clauses.compact.chunk(&:operator).to_h
@must_not_clauses = grouped.fetch(:must_not, [])
@must_clauses = grouped.fetch(:must, [])
@filter_clauses = grouped.fetch(:filter, [])
@clauses = clauses
@options = options

flags_from_clauses!
end

def apply(search)
def request
search = Chewy::Search::Request.new(*indexes).filter(default_filter)

must_clauses.each { |clause| search = search.query.must(clause.to_query) }
must_not_clauses.each { |clause| search = search.query.must_not(clause.to_query) }
filter_clauses.each { |clause| search = search.filter(**clause.to_query) }
search.query.minimum_should_match(1)

search
end

private

def clauses_by_operator
@clauses_by_operator ||= @clauses.compact.chunk(&:operator).to_h
end

def flags_from_clauses!
@flags = clauses_by_operator.fetch(:flag, []).to_h { |clause| [clause.prefix, clause.term] }
end

def must_clauses
clauses_by_operator.fetch(:must, [])
end

def must_not_clauses
clauses_by_operator.fetch(:must_not, [])
end

def filter_clauses
clauses_by_operator.fetch(:filter, [])
end

def indexes
case @flags['in']
when 'library'
[StatusesIndex]
else
[PublicStatusesIndex, StatusesIndex]
end
end

def default_filter
{
bool: {
should: [
{
term: {
_index: PublicStatusesIndex.index_name,
},
},
{
bool: {
must: [
{
term: {
_index: StatusesIndex.index_name,
},
},
{
term: {
searchable_by: @options[:current_account].id,
},
},
],
},
},
],

minimum_should_match: 1,
},
}
end
end

Expand Down Expand Up @@ -53,7 +120,11 @@ def initialize(operator, term)
end

def to_query
{ multi_match: { type: 'most_fields', query: @term, fields: ['text', 'text.stemmed'], operator: 'and' } }
if @term.start_with?('#')
{ match: { tags: { query: @term } } }
else
{ multi_match: { type: 'most_fields', query: @term, fields: ['text', 'text.stemmed'], operator: 'and' } }
end
end
end

Expand Down Expand Up @@ -95,15 +166,18 @@ def initialize(prefix, operator, term, options = {})
when 'before'
@filter = :created_at
@type = :range
@term = { lt: term, time_zone: @options[:current_account]&.user_time_zone || 'UTC' }
@term = { lt: term, time_zone: @options[:current_account]&.user_time_zone.presence || 'UTC' }
when 'after'
@filter = :created_at
@type = :range
@term = { gt: term, time_zone: @options[:current_account]&.user_time_zone || 'UTC' }
@term = { gt: term, time_zone: @options[:current_account]&.user_time_zone.presence || 'UTC' }
when 'during'
@filter = :created_at
@type = :range
@term = { gte: term, lte: term, time_zone: @options[:current_account]&.user_time_zone || 'UTC' }
@term = { gte: term, lte: term, time_zone: @options[:current_account]&.user_time_zone.presence || 'UTC' }
when 'in'
@operator = :flag
@term = term
else
raise "Unknown prefix: #{prefix}"
end
Expand Down Expand Up @@ -172,6 +246,6 @@ def language_code_from_term(term)
end

rule(query: sequence(:clauses)) do
Query.new(clauses)
Query.new(clauses, current_account: current_account)
end
end
2 changes: 1 addition & 1 deletion app/models/admin/status_batch_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def save!
private

def statuses
Status.with_discarded.where(id: status_ids)
Status.with_discarded.where(id: status_ids).reorder(nil)
end

def process_action!
Expand Down
Loading

0 comments on commit 4df9ee6

Please # to comment.