Skip to content

Commit

Permalink
Merge remote-tracking branch 'parent/main' into kb_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
kmycode committed Sep 10, 2023
2 parents e9de561 + 91040da commit 979292d
Show file tree
Hide file tree
Showing 56 changed files with 775 additions and 278 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/test-ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,116 @@ jobs:
with:
name: e2e-screenshots
path: tmp/screenshots/

test-search:
name: Testing search
runs-on: ubuntu-latest

needs:
- build

services:
postgres:
image: postgres:14-alpine
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.17.9
env:
discovery.type: single-node
xpack.security.enabled: false
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 9200:9200

env:
DB_HOST: localhost
DB_USER: postgres
DB_PASS: postgres
DISABLE_SIMPLECOV: true
RAILS_ENV: test
BUNDLE_WITH: test
ES_ENABLED: true
ES_HOST: localhost
ES_PORT: 9200

strategy:
fail-fast: false
matrix:
ruby-version:
- '3.0'
- '3.1'
- '.ruby-version'

steps:
- uses: actions/checkout@v3

- uses: actions/download-artifact@v3
with:
path: './public'
name: ${{ github.sha }}

- name: Update package index
run: sudo apt-get update

- name: Set up Node.js
uses: actions/setup-node@v3
with:
cache: yarn
node-version-file: '.nvmrc'

- name: Install native Ruby dependencies
run: sudo apt-get install -y libicu-dev libidn11-dev

- name: Install additional system dependencies
run: sudo apt-get install -y ffmpeg imagemagick

- name: Set up bundler cache
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version}}
bundler-cache: true

- run: yarn --frozen-lockfile

- name: Load database schema
run: './bin/rails db:create db:schema:load db:seed'

- run: bundle exec rake spec:search

- name: Archive logs
uses: actions/upload-artifact@v3
if: failure()
with:
name: test-search-logs-${{ matrix.ruby-version }}
path: log/

- name: Archive test screenshots
uses: actions/upload-artifact@v3
if: failure()
with:
name: test-search-screenshots
path: tmp/screenshots/
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
16.20
20.6
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1.4
# This needs to be bookworm-slim because the Ruby image is built on bookworm-slim
ARG NODE_VERSION="16.20-bookworm-slim"
ARG NODE_VERSION="20.6-bookworm-slim"

FROM ghcr.io/moritzheiber/ruby-jemalloc:3.2.2-slim as ruby
FROM node:${NODE_VERSION} as build
Expand Down
3 changes: 2 additions & 1 deletion FEDERATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ More information on HTTP Signatures, as well as examples, can be found here: htt

- Linked-Data Signatures: https://docs.joinmastodon.org/spec/security/#ld
- Bearcaps: https://docs.joinmastodon.org/spec/bearcaps/
- Followers collection synchronization: https://git.activitypub.dev/ActivityPubDev/Fediverse-Enhancement-Proposals/src/branch/main/feps/fep-8fcf.md
- Followers collection synchronization: https://codeberg.org/fediverse/fep/src/branch/main/fep/8fcf/fep-8fcf.md
- Search indexing consent for actors: https://codeberg.org/fediverse/fep/src/branch/main/fep/5feb/fep-5feb.md
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ GEM
pastel (0.8.0)
tty-color (~> 0.5)
pg (1.5.4)
pghero (3.3.3)
pghero (3.3.4)
activerecord (>= 6)
posix-spawn (0.3.15)
premailer (1.21.0)
Expand Down
12 changes: 6 additions & 6 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ A "vulnerability in Mastodon" is a vulnerability in the code distributed through

## Supported Versions

| Version | Supported |
| ------- | --------- |
| 4.1.x | Yes |
| 4.0.x | Yes |
| 3.5.x | Yes |
| < 3.5 | No |
| Version | Supported |
| ------- | ---------------- |
| 4.1.x | Yes |
| 4.0.x | Until 2023-10-31 |
| 3.5.x | Until 2023-12-31 |
| < 3.5 | No |
3 changes: 2 additions & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ path.logs: /var/log/elasticsearch
network.host: 0.0.0.0
http.port: 9200
discovery.seed_hosts: ["localhost"]
cluster.initial_master_nodes: ["node-1"]' > /etc/elasticsearch/elasticsearch.yml
cluster.initial_master_nodes: ["node-1"]
xpack.security.enabled: false' > /etc/elasticsearch/elasticsearch.yml
sudo systemctl restart elasticsearch
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/api/v1/directories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ def require_enabled!
end

def set_accounts
@accounts = accounts_scope.offset(params[:offset]).limit(limit_param(DEFAULT_ACCOUNTS_LIMIT))
with_read_replica do
@accounts = accounts_scope.offset(params[:offset]).limit(limit_param(DEFAULT_ACCOUNTS_LIMIT))
end
end

def accounts_scope
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/signature_verification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def request_body
private

def fail_with!(message, **options)
Rails.logger.warn { "Signature verification failed: #{message}" }
Rails.logger.debug { "Signature verification failed: #{message}" }

@signature_verification_failure_reason = { error: message }.merge(options)
@signed_request_actor = nil
Expand Down
45 changes: 33 additions & 12 deletions app/javascript/mastodon/actions/search.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import { fromJS } from 'immutable';

import { searchHistory } from 'mastodon/settings';

import api from '../api';

import { fetchRelationships } from './accounts';
Expand All @@ -15,8 +19,7 @@ export const SEARCH_EXPAND_REQUEST = 'SEARCH_EXPAND_REQUEST';
export const SEARCH_EXPAND_SUCCESS = 'SEARCH_EXPAND_SUCCESS';
export const SEARCH_EXPAND_FAIL = 'SEARCH_EXPAND_FAIL';

export const SEARCH_RESULT_CLICK = 'SEARCH_RESULT_CLICK';
export const SEARCH_RESULT_FORGET = 'SEARCH_RESULT_FORGET';
export const SEARCH_HISTORY_UPDATE = 'SEARCH_HISTORY_UPDATE';

export function changeSearch(value) {
return {
Expand Down Expand Up @@ -170,16 +173,34 @@ export const openURL = (value, history, onFailure) => (dispatch, getState) => {
});
};

export const clickSearchResult = (q, type) => ({
type: SEARCH_RESULT_CLICK,
export const clickSearchResult = (q, type) => (dispatch, getState) => {
const previous = getState().getIn(['search', 'recent']);
const me = getState().getIn(['meta', 'me']);
const current = previous.add(fromJS({ type, q })).takeLast(4);

result: {
type,
q,
},
});
searchHistory.set(me, current.toJS());
dispatch(updateSearchHistory(current));
};

export const forgetSearchResult = q => (dispatch, getState) => {
const previous = getState().getIn(['search', 'recent']);
const me = getState().getIn(['meta', 'me']);
const current = previous.filterNot(result => result.get('q') === q);

export const forgetSearchResult = q => ({
type: SEARCH_RESULT_FORGET,
q,
searchHistory.set(me, current.toJS());
dispatch(updateSearchHistory(current));
};

export const updateSearchHistory = recent => ({
type: SEARCH_HISTORY_UPDATE,
recent,
});

export const hydrateSearch = () => (dispatch, getState) => {
const me = getState().getIn(['meta', 'me']);
const history = searchHistory.get(me);

if (history !== null) {
dispatch(updateSearchHistory(history));
}
};
2 changes: 2 additions & 0 deletions app/javascript/mastodon/actions/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Iterable, fromJS } from 'immutable';

import { hydrateCompose } from './compose';
import { importFetchedAccounts } from './importer';
import { hydrateSearch } from './search';

export const STORE_HYDRATE = 'STORE_HYDRATE';
export const STORE_HYDRATE_LAZY = 'STORE_HYDRATE_LAZY';
Expand All @@ -20,6 +21,7 @@ export function hydrateStore(rawState) {
});

dispatch(hydrateCompose());
dispatch(hydrateSearch());
dispatch(importFetchedAccounts(Object.values(rawState.accounts)));
};
}
15 changes: 8 additions & 7 deletions app/javascript/mastodon/features/audio/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ class Audio extends PureComponent {
};

toggleMute = () => {
const muted = !this.state.muted;
const muted = !(this.state.muted || this.state.volume === 0);

this.setState({ muted }, () => {
this.setState((state) => ({ muted, volume: Math.max(state.volume || 0.5, 0.05) }), () => {
if (this.gainNode) {
this.gainNode.gain.value = muted ? 0 : this.state.volume;
this.gainNode.gain.value = this.state.muted ? 0 : this.state.volume;
}
});
};
Expand Down Expand Up @@ -287,7 +287,7 @@ class Audio extends PureComponent {
const { x } = getPointerPosition(this.volume, e);

if(!isNaN(x)) {
this.setState({ volume: x }, () => {
this.setState((state) => ({ volume: x, muted: state.muted && x === 0 }), () => {
if (this.gainNode) {
this.gainNode.gain.value = this.state.muted ? 0 : x;
}
Expand Down Expand Up @@ -466,8 +466,9 @@ class Audio extends PureComponent {

render () {
const { src, intl, alt, lang, editable, autoPlay, sensitive, blurhash } = this.props;
const { paused, muted, volume, currentTime, duration, buffer, dragging, revealed } = this.state;
const { paused, volume, currentTime, duration, buffer, dragging, revealed } = this.state;
const progress = Math.min((currentTime / duration) * 100, 100);
const muted = this.state.muted || volume === 0;

let warning;

Expand Down Expand Up @@ -557,12 +558,12 @@ class Audio extends PureComponent {
<button type='button' title={intl.formatMessage(muted ? messages.unmute : messages.mute)} aria-label={intl.formatMessage(muted ? messages.unmute : messages.mute)} className='player-button' onClick={this.toggleMute}><Icon id={muted ? 'volume-off' : 'volume-up'} fixedWidth /></button>

<div className={classNames('video-player__volume', { active: this.state.hovered })} ref={this.setVolumeRef} onMouseDown={this.handleVolumeMouseDown}>
<div className='video-player__volume__current' style={{ width: `${volume * 100}%`, backgroundColor: this._getAccentColor() }} />
<div className='video-player__volume__current' style={{ width: `${muted ? 0 : volume * 100}%`, backgroundColor: this._getAccentColor() }} />

<span
className='video-player__volume__handle'
tabIndex={0}
style={{ left: `${volume * 100}%`, backgroundColor: this._getAccentColor() }}
style={{ left: `${muted ? 0 : volume * 100}%`, backgroundColor: this._getAccentColor() }}
/>
</div>

Expand Down
Loading

0 comments on commit 979292d

Please sign in to comment.