Compare commits
11 Commits
main
...
main-rebas
Author | SHA1 | Date |
---|---|---|
kouhai | 4e52502719 | |
kouhai | a126a2733f | |
kouhai | 41adbcaa80 | |
kouhai | 2f61b9a11e | |
kouhai | c3cfa23eff | |
kouhai | 8ce73ff257 | |
kouhai | 0f4eee9c94 | |
kouhai | 097880191e | |
kouhai | da813d46db | |
Ariadne Conill | 86d566af3e | |
Ariadne Conill | 61feb28111 |
|
@ -1,22 +1,41 @@
|
|||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# Order-independent
|
||||
*.sw*
|
||||
*.swp
|
||||
*~
|
||||
.DS_Store
|
||||
.bundle
|
||||
.env
|
||||
.env.*
|
||||
.git
|
||||
.gitattributes
|
||||
.gitignore
|
||||
.github
|
||||
public/system
|
||||
.gitignore
|
||||
.woodpecker.yml
|
||||
/*.md
|
||||
build
|
||||
chart
|
||||
coverage
|
||||
data
|
||||
elasticsearch
|
||||
log
|
||||
neo4j
|
||||
node_modules
|
||||
postgres
|
||||
postgres*
|
||||
postgres14
|
||||
public/assets
|
||||
public/packs
|
||||
public/packs-test
|
||||
node_modules
|
||||
neo4j
|
||||
vendor/bundle
|
||||
.DS_Store
|
||||
*.swp
|
||||
*~
|
||||
postgres
|
||||
postgres14
|
||||
public/system
|
||||
redis
|
||||
elasticsearch
|
||||
chart
|
||||
sorbet
|
||||
tmp
|
||||
vendor/bundle
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
LOCAL_DOMAIN=localhost
|
||||
ALTERNATE_DOMAINS=mastodon.internal
|
||||
STREAMING_API_BASE_URL=https://streaming.mastodon.internal
|
||||
|
||||
DB_HOST=$PWD/data/postgres
|
||||
DB_USER=mastodon
|
||||
DB_NAME=mastodon_dev
|
||||
REDIS_URL=unix://$PWD/data/redis/redis-dev.sock
|
||||
TH_MENTION_SPAM_HEURISTIC_AUTO_LIMIT_ACTIVE=can-spam
|
||||
TH_MENTION_SPAM_THRESHOLD=2
|
||||
TH_STAFF_ACCOUNT=staff
|
||||
|
||||
TH_USE_INVITE_QUOTA=1
|
||||
|
||||
# Required by ActiveRecord encryption feature
|
||||
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=fkSxKD2bF396kdQbrP1EJ7WbU7ZgNokR
|
||||
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT=r0hvVmzBVsjxC7AMlwhOzmtc36ZCOS1E
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
# ----------
|
||||
# This identifies your server and cannot be changed safely later
|
||||
# ----------
|
||||
LOCAL_DOMAIN=example.com
|
||||
LOCAL_DOMAIN=localhost
|
||||
|
||||
# Use this only if you need to run mastodon on a different domain than the one used for federation.
|
||||
# You can read more about this option on https://docs.joinmastodon.org/admin/config/#web-domain
|
||||
|
@ -25,6 +25,7 @@ LOCAL_DOMAIN=example.com
|
|||
# handler@example2.com etc. for the same user. LOCAL_DOMAIN should not
|
||||
# be added. Comma separated values
|
||||
# ALTERNATE_DOMAINS=example1.com,example2.com
|
||||
ALTERNATE_DOMAINS=mastodon.internal
|
||||
|
||||
# Use HTTP proxy for outgoing request (optional)
|
||||
# http_proxy=http://gateway.local:8118
|
||||
|
@ -43,13 +44,13 @@ LOCAL_DOMAIN=example.com
|
|||
|
||||
# Redis
|
||||
# -----
|
||||
REDIS_HOST=localhost
|
||||
REDIS_HOST=redis
|
||||
REDIS_PORT=6379
|
||||
|
||||
|
||||
# PostgreSQL
|
||||
# ----------
|
||||
DB_HOST=/var/run/postgresql
|
||||
DB_HOST=db
|
||||
DB_USER=mastodon
|
||||
DB_NAME=mastodon_production
|
||||
DB_PASS=
|
||||
|
|
|
@ -4,6 +4,11 @@ NODE_ENV=production
|
|||
LOCAL_DOMAIN=cb6e6126.ngrok.io
|
||||
LOCAL_HTTPS=true
|
||||
|
||||
DB_HOST=$(pwd)/data/postgres
|
||||
DB_USER=mastodon
|
||||
DB_NAME=mastodon_dev
|
||||
REDIS_URL=unix://./data/redis/redis-dev.sock
|
||||
|
||||
# Secret values required by ActiveRecord encryption feature
|
||||
# Use `bin/rails db:encryption:init` to generate fresh secrets
|
||||
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY=test_determinist_key_DO_NOT_USE_IN_PRODUCTION
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
# or operating system, you probably want to add a global ignore instead:
|
||||
# git config --global core.excludesfile '~/.gitignore_global'
|
||||
|
||||
# Ignore local dotenv overrides
|
||||
.env.*.local
|
||||
|
||||
# Ignore bundler config and downloaded libraries.
|
||||
/.bundle
|
||||
/vendor/bundle
|
||||
|
@ -12,6 +15,9 @@
|
|||
/db/*.sqlite3
|
||||
/db/*.sqlite3-journal
|
||||
|
||||
# Ignore local data directory
|
||||
/data
|
||||
|
||||
# Ignore all logfiles and tempfiles.
|
||||
.eslintcache
|
||||
/log/*
|
||||
|
@ -69,5 +75,14 @@ yarn-debug.log
|
|||
# Ignore Docker option files
|
||||
docker-compose.override.yml
|
||||
|
||||
# Yarn Berry
|
||||
.pnp.*
|
||||
.yarn/*
|
||||
!.yarn/patches
|
||||
!.yarn/plugins
|
||||
!.yarn/releases
|
||||
!.yarn/sdks
|
||||
!.yarn/versions
|
||||
|
||||
# Ignore dotenv .local files
|
||||
.env*.local
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
variables:
|
||||
environment: &docker-environment
|
||||
SERVER_IMAGE: gitea.treehouse.systems/treehouse/mastodon
|
||||
STREAMING_IMAGE: gitea.treehouse.systems/treehouse/mastodon-streaming
|
||||
DATE_COMMAND: export COMMIT_DATE=$(date -u -Idate -d @$(git show -s --format=%ct))
|
||||
docker-step: &docker-step
|
||||
image: docker:rc-git
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
environment:
|
||||
<<: *docker-environment
|
||||
|
||||
clone:
|
||||
git:
|
||||
image: woodpeckerci/plugin-git
|
||||
settings:
|
||||
partial: false
|
||||
depth: 10
|
||||
|
||||
pipeline:
|
||||
output:
|
||||
<<: *docker-step
|
||||
commands:
|
||||
- eval $DATE_COMMAND
|
||||
- export TAG=$${COMMIT_DATE}.$CI_COMMIT_SHA && echo $${TAG}
|
||||
- docker image build -f Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $SERVER_IMAGE:$${TAG}
|
||||
- docker image build -f streaming/Dockerfile --build-arg SOURCE_TAG=$CI_COMMIT_SHA . -t $STREAMING_IMAGE:$${TAG}
|
||||
- docker tag $SERVER_IMAGE:$${TAG} $SERVER_IMAGE:latest
|
||||
- docker tag $STREAMING_IMAGE:$${TAG} $STREAMING_IMAGE:latest
|
||||
- echo -n > tags.txt
|
||||
- echo $${TAG} | tee -a tags.txt
|
||||
- echo latest | tee -a tags.txt
|
||||
|
||||
# maybe we can use tags someday,,,
|
||||
# tag-tag:
|
||||
# image: *docker-git
|
||||
# volumes:
|
||||
# - /var/run/docker.sock:/var/run/docker.sock
|
||||
# commands:
|
||||
# - docker tag $SERVER_IMAGE:latest $SERVER_IMAGE:$CI_COMMIT_TAG
|
||||
# when:
|
||||
# event: tag
|
||||
|
||||
push:
|
||||
<<: *docker-step
|
||||
commands:
|
||||
- echo $REGISTRY_SECRET | docker login -u $REGISTRY_USER --password-stdin gitea.treehouse.systems
|
||||
- cat tags.txt | xargs -n 1 -I% echo docker image push $SERVER_IMAGE:%
|
||||
- cat tags.txt | xargs -n 1 -I% docker image push $SERVER_IMAGE:%
|
||||
- cat tags.txt | xargs -n 1 -I% echo docker image push $STREAMING_IMAGE:%
|
||||
- cat tags.txt | xargs -n 1 -I% docker image push $STREAMING_IMAGE:%
|
||||
when:
|
||||
event: [push, tag]
|
||||
branch: main
|
||||
secrets: [REGISTRY_SECRET]
|
||||
environment:
|
||||
<<: *docker-environment
|
||||
REGISTRY_USER: ariadne
|
10
.yarnrc.yml
|
@ -1 +1,11 @@
|
|||
compressionLevel: mixed
|
||||
|
||||
enableGlobalCache: true
|
||||
|
||||
logFilters:
|
||||
- code: YN0013
|
||||
level: "${YARN_NOISE_LOG_CODE_LEVEL:-info}"
|
||||
|
||||
nodeLinker: node-modules
|
||||
|
||||
yarnPath: .yarn/releases/yarn-4.1.0.cjs
|
||||
|
|
|
@ -1,11 +1,29 @@
|
|||
# Contributing to Mastodon Glitch Edition
|
||||
# Contributing to Mastodon Glitch+Treehouse Edition
|
||||
|
||||
Thank you for your interest in contributing to the `glitch-soc` project!
|
||||
Thank you for your interest in contributing to the **Treehouse Mastodon** project!
|
||||
Here are some guidelines, and ways you can help.
|
||||
|
||||
> (This document is a bit of a work-in-progress, so please bear with us.
|
||||
> If you don't see what you're looking for here, please don't hesitate to reach out!)
|
||||
|
||||
## Merging
|
||||
|
||||
If your username is kouhai, or you're otherwise merging from upstream glitch-soc
|
||||
for some reason, the following snippets may be useful:
|
||||
|
||||
```sh
|
||||
git fetch glitch && git merge glitch/main && git checkout glitch/main -- yarn.lock
|
||||
```
|
||||
|
||||
```sh
|
||||
export RAILS_ENV=production NODE_ENV=production
|
||||
export OTP_SECRET=precompile_placeholder SECRET_KEY_BASE=precompile_placeholder
|
||||
bundle install \
|
||||
&& yarn install \
|
||||
&& bundle exec rake assets:clobber \
|
||||
&& bundle exec rake webpacker:compile | tee /tmp/out.log
|
||||
```
|
||||
|
||||
## Translations
|
||||
|
||||
You can submit glitch-soc-specific translations via [Crowdin](https://crowdin.com/project/glitch-soc). They are periodically merged into the codebase.
|
||||
|
@ -14,14 +32,19 @@ You can submit glitch-soc-specific translations via [Crowdin](https://crowdin.co
|
|||
|
||||
## Planning
|
||||
|
||||
Right now a lot of the planning for this project takes place in our development Discord, or through GitHub Issues and Projects.
|
||||
Right now a lot of the planning for this project takes place in the `#fediverse`
|
||||
channel of the Treehouse Discord, or through Gitea Issues.
|
||||
|
||||
We're working on ways to improve the planning structure and better solicit feedback, and if you feel like you can help in this respect, feel free to give us a holler.
|
||||
|
||||
## Documentation
|
||||
|
||||
The documentation for this repository is available at [`glitch-soc/docs`](https://github.com/glitch-soc/docs) (online at [glitch-soc.github.io/docs/](https://glitch-soc.github.io/docs/)).
|
||||
Right now, we've mostly focused on the features that make this fork different from upstream in some manner.
|
||||
Adding screenshots, improving descriptions, and so forth are all ways to help contribute to the project even if you don't know any code.
|
||||
The upstream Glitch documentation for this repository is available at [`glitch-soc/docs`](https://github.com/glitch-soc/docs) (online at [glitch-soc.github.io/docs/](https://glitch-soc.github.io/docs/)).
|
||||
|
||||
## Setup
|
||||
|
||||
For a some-batteries-required guide to setting up a development environment for this repository, read Rin's excellent
|
||||
[SETUP.md](https://gitea.treehouse.systems/treehouse/mastodon/src/branch/main/SETUP.md).
|
||||
|
||||
## Frontend Development
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# Divergences
|
||||
|
||||
## Major Features
|
||||
|
||||
- quote posting
|
||||
- Treehouse::Automod (experimental feature flagged)
|
||||
|
||||
## Other Changes
|
||||
|
||||
- various build system changes
|
||||
- a better dockerfile
|
||||
- yarn v2 (a mistake, tbh)
|
||||
- various dev env changes
|
||||
- various css/style changes
|
|
@ -30,6 +30,8 @@ ARG MASTODON_VERSION_PRERELEASE=""
|
|||
# Append build metadata or fork information to version.rb [--build-arg MASTODON_VERSION_METADATA="pr-123456"]
|
||||
ARG MASTODON_VERSION_METADATA=""
|
||||
|
||||
ARG SOURCE_TAG=""
|
||||
|
||||
# Allow Ruby on Rails to serve static files
|
||||
# See: https://docs.joinmastodon.org/admin/config/#rails_serve_static_files
|
||||
ARG RAILS_SERVE_STATIC_FILES="true"
|
||||
|
@ -119,13 +121,13 @@ RUN \
|
|||
# Create temporary build layer from base image
|
||||
FROM ruby AS build
|
||||
|
||||
COPY --from=node /usr/local/bin /usr/local/bin
|
||||
COPY --from=node /usr/local/lib /usr/local/lib
|
||||
|
||||
# Copy Node package configuration files into working directory
|
||||
COPY package.json yarn.lock .yarnrc.yml /opt/mastodon/
|
||||
COPY .yarn /opt/mastodon/.yarn
|
||||
|
||||
COPY --from=node /usr/local/bin /usr/local/bin
|
||||
COPY --from=node /usr/local/lib /usr/local/lib
|
||||
|
||||
ARG TARGETPLATFORM
|
||||
|
||||
# hadolint ignore=DL3008
|
||||
|
|
3
Gemfile
|
@ -212,6 +212,9 @@ group :development, :test do
|
|||
|
||||
# RSpec runner for rails
|
||||
gem 'rspec-rails', '~> 6.0'
|
||||
|
||||
# foreman
|
||||
gem 'foreman'
|
||||
end
|
||||
|
||||
group :production do
|
||||
|
|
|
@ -280,6 +280,7 @@ GEM
|
|||
fog-openstack (1.1.3)
|
||||
fog-core (~> 2.1)
|
||||
fog-json (>= 1.0)
|
||||
foreman (0.87.2)
|
||||
formatador (1.1.0)
|
||||
fugit (1.10.1)
|
||||
et-orbi (~> 1, >= 1.2.7)
|
||||
|
@ -944,6 +945,7 @@ DEPENDENCIES
|
|||
flatware-rspec
|
||||
fog-core (<= 2.4.0)
|
||||
fog-openstack (~> 1.0)
|
||||
foreman
|
||||
fuubar (~> 2.5)
|
||||
haml-rails (~> 2.0)
|
||||
haml_lint
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
web: env PORT=3000 RAILS_ENV=development bundle exec puma -C config/puma.rb
|
||||
sidekiq: env PORT=3000 RAILS_ENV=development bundle exec sidekiq
|
||||
stream: env PORT=4000 yarn workspace @mastodon/streaming start
|
||||
stream: env PORT=4000 NODE_ENV=development yarn workspace @mastodon/streaming start | npx pino-pretty
|
||||
webpack: bin/webpack-dev-server
|
||||
|
|
9
Rakefile
|
@ -6,3 +6,12 @@
|
|||
require File.expand_path('config/application', __dir__)
|
||||
|
||||
Rails.application.load_tasks
|
||||
|
||||
# please don't do this
|
||||
if Rake::Task.task_defined?('assets:precompile') && ENV.include?('RAKE_NO_YARN_INSTALL_HACK')
|
||||
task = Rake::Task['assets:precompile']
|
||||
puts task.prerequisites
|
||||
task.prerequisites.delete('webpacker:yarn_install')
|
||||
task.prerequisites.delete('yarn:install')
|
||||
puts task.prerequisites
|
||||
end
|
||||
|
|
|
@ -0,0 +1,143 @@
|
|||
# Setting up a dev environment
|
||||
|
||||
## Prerequisites
|
||||
|
||||
Mastodon development requires the following:
|
||||
|
||||
- Ruby 3.0
|
||||
- Ruby gems:
|
||||
- `bundler`
|
||||
- `irb`
|
||||
- `foreman`
|
||||
- NodeJS v18 (LTS)
|
||||
- NPM packages:
|
||||
- `yarn`
|
||||
- Postgres
|
||||
- Redis
|
||||
|
||||
### macOS
|
||||
|
||||
First, make sure you have Homebrew installed. Follow the instructions at [brew.sh](https://brew.sh).
|
||||
|
||||
Run the following to install all necessary packages:
|
||||
```
|
||||
brew install ruby@3.0 foreman node yarn postgresql redis
|
||||
```
|
||||
|
||||
Ruby 3.0 is **keg-only** by default. Follow the instructions in the **Caveat** to add it to your path.
|
||||
|
||||
### Linux
|
||||
|
||||
We will assume that you know how to locate the correct packages for your distro. That said, some distros package `bundler` and `irb` separately. Make sure that you also install these.
|
||||
|
||||
On Arch, you will need:
|
||||
- `ruby`
|
||||
- `ruby-bundler`
|
||||
- `ruby-irb`
|
||||
- `ruby-foreman`
|
||||
- `redis`
|
||||
- `postgresql`
|
||||
- `yarn`
|
||||
- `gmp`
|
||||
- `libidn`
|
||||
|
||||
### Windows
|
||||
|
||||
Unfortunately, none of the authors use Windows. Contributions welcome!
|
||||
|
||||
## Database
|
||||
|
||||
In the root of this repository, go through the following script:
|
||||
```sh
|
||||
# Create a folder for local data
|
||||
mkdir -p data
|
||||
|
||||
# Set up a local database
|
||||
pg_ctl -D data/postgres initdb -o '-U mastodon --auth-host=trust'
|
||||
|
||||
# Use the data/postgres folder for the DB connection unix socket
|
||||
#
|
||||
# If you don't know what that means, it's just a way for Mastodon to communicate
|
||||
# with a database on the same machine efficiently.
|
||||
#
|
||||
# See: https://manpages.ubuntu.com/manpages/jammy/man7/unix.7.html
|
||||
echo 'unix_socket_directories = .' >> data/postgres/postgresql.conf
|
||||
|
||||
# Start the database
|
||||
pg_ctl -D data/postgres start --silent
|
||||
```
|
||||
|
||||
## Redis
|
||||
|
||||
In the root of this repository, run the following:
|
||||
```sh
|
||||
# Create a folder for redis data
|
||||
mkdir -p data/redis
|
||||
|
||||
# Start Redis
|
||||
redis-server ./redis-dev.conf
|
||||
|
||||
# [Optional] Stop Redis
|
||||
# kill "$(cat ./data/redis/redis-dev.pid)"
|
||||
```
|
||||
|
||||
## Ruby
|
||||
|
||||
```sh
|
||||
export RAILS_ENV=development
|
||||
|
||||
# Bundle installs all Ruby gems globally by default, which might cause problems.
|
||||
bundle config set --local path 'vendor/bundle'
|
||||
|
||||
# [Apple Silicon] If using macOS on Apple Silicon, run the following:
|
||||
# bundle config build.idn-ruby -- --with-idn-dir="$(brew --prefix libidn)"
|
||||
|
||||
# Install dependencies using bundle (Ruby) and yarn (JS)
|
||||
bundle install
|
||||
yarn install
|
||||
|
||||
# Setup the database using the pre-defined Rake task
|
||||
#
|
||||
# Rake is a command runner for Ruby projects. The `bundle exec` ensures that
|
||||
# we use the version of Rake that this project requires.
|
||||
bundle exec rake db:setup
|
||||
|
||||
# [Optional] If that fails, run the following and try again:
|
||||
# bundle exec rake db:reset
|
||||
```
|
||||
|
||||
## Running Mastodon
|
||||
|
||||
1. Run `export RAILS_ENV=development NODE_ENV=development`.
|
||||
- Put these in your shell's .rc, or a script you can source if you want to skip this step in the future.
|
||||
2. Run `bundle exec rake assets:precompile`.
|
||||
- If this explodes, complaining about `Hash`, you'll need to `export NODE_OPTIONS=--openssl-legacy-provider`.
|
||||
- After doing this, you will need to run `bundle exec rake assets:clobber` and then re-run `bundle exec rake assets:precompile`.
|
||||
3. Run `foreman start`
|
||||
|
||||
# Updates/Troubleshooting
|
||||
|
||||
## RubyVM/DebugInspector Issues
|
||||
|
||||
Still unable to fix. Circumvent by removing `better_errors` and `binding_of_caller` from Gemfile.
|
||||
|
||||
Happy to troubleshoot with someone better with Ruby than us >_<'/.
|
||||
|
||||
## Webpack Issues
|
||||
|
||||
If Webpack compalins about being unable to find some assets or locales:
|
||||
|
||||
Try:
|
||||
1. `rm -rf node_modules`
|
||||
2. `yarn install`
|
||||
|
||||
If this doesn't help, try:
|
||||
1. `yarn add webpack`
|
||||
2. `git restore package.json yarn.lock`
|
||||
3. `yarn install`
|
||||
|
||||
Then re-run `foreman start`. No. We have no idea why this worked.
|
||||
|
||||
# Need Help?
|
||||
|
||||
If the above instructions don't work, please contact @Rin here, or @tammy@social.treehouse.systems.
|
|
@ -76,7 +76,8 @@ class Api::V1::StatusesController < Api::BaseController
|
|||
content_type: status_params[:content_type],
|
||||
allowed_mentions: status_params[:allowed_mentions],
|
||||
idempotency: request.headers['Idempotency-Key'],
|
||||
with_rate_limit: true
|
||||
with_rate_limit: true,
|
||||
quote_id: status_params[:quote_id].presence
|
||||
)
|
||||
|
||||
render json: @status, serializer: serializer_for_status
|
||||
|
@ -159,6 +160,7 @@ class Api::V1::StatusesController < Api::BaseController
|
|||
:visibility,
|
||||
:language,
|
||||
:scheduled_at,
|
||||
:quote_id,
|
||||
:content_type,
|
||||
allowed_mentions: [],
|
||||
media_ids: [],
|
||||
|
|
|
@ -14,6 +14,8 @@ class InvitesController < ApplicationController
|
|||
|
||||
@invites = invites
|
||||
@invite = Invite.new
|
||||
@invite.max_uses ||= 1
|
||||
@invite.expires_in ||= 1.day.in_seconds
|
||||
end
|
||||
|
||||
def create
|
||||
|
|
|
@ -42,6 +42,7 @@ module ContextHelper
|
|||
'cipherText' => 'toot:cipherText',
|
||||
},
|
||||
suspended: { 'toot' => 'http://joinmastodon.org/ns#', 'suspended' => 'toot:suspended' },
|
||||
quote_uri: { 'fedibird' => 'http://fedibird.com/ns#', 'quoteUri' => 'fedibird:quoteUri' },
|
||||
}.freeze
|
||||
|
||||
def full_context
|
||||
|
|
|
@ -19,7 +19,17 @@ module FormattingHelper
|
|||
module_function :extract_status_plain_text
|
||||
|
||||
def status_content_format(status)
|
||||
html_aware_format(status.text, status.local?, preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : []), content_type: status.content_type)
|
||||
base = html_aware_format(status.text, status.local?, preloaded_accounts: [status.account] + (status.respond_to?(:active_mentions) ? status.active_mentions.map(&:account) : []), content_type: status.content_type)
|
||||
|
||||
if status.quote? && status.local?
|
||||
after_html = begin
|
||||
"<span class=\"quote-inline\"><a href=\"#{status.quote.to_log_permalink}\" class=\"status-link unhandled-link\" target=\"_blank\">#{status.quote.to_log_permalink}</a></span>"
|
||||
end.html_safe # rubocop:disable Rails/OutputSafety
|
||||
|
||||
base + after_html
|
||||
else
|
||||
base
|
||||
end
|
||||
end
|
||||
|
||||
def rss_status_content_format(status)
|
||||
|
|
|
@ -86,6 +86,9 @@ export const COMPOSE_CHANGE_MEDIA_ORDER = 'COMPOSE_CHANGE_MEDIA_ORDER';
|
|||
export const COMPOSE_SET_STATUS = 'COMPOSE_SET_STATUS';
|
||||
export const COMPOSE_FOCUS = 'COMPOSE_FOCUS';
|
||||
|
||||
export const COMPOSE_QUOTE = 'COMPOSE_QUOTE';
|
||||
export const COMPOSE_QUOTE_CANCEL = 'COMPOSE_QUOTE_CANCEL';
|
||||
|
||||
const messages = defineMessages({
|
||||
uploadErrorLimit: { id: 'upload_error.limit', defaultMessage: 'File upload limit exceeded.' },
|
||||
uploadErrorPoll: { id: 'upload_error.poll', defaultMessage: 'File upload not allowed with polls.' },
|
||||
|
@ -136,6 +139,25 @@ export function cancelReplyCompose() {
|
|||
};
|
||||
}
|
||||
|
||||
export function quoteCompose(status, router) {
|
||||
return (dispatch, getState) => {
|
||||
dispatch({
|
||||
type: COMPOSE_QUOTE,
|
||||
status: status,
|
||||
});
|
||||
|
||||
if (!getState().getIn(['compose', 'mounted'])) {
|
||||
router.push('/publish');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function cancelQuoteCompose() {
|
||||
return {
|
||||
type: COMPOSE_QUOTE_CANCEL,
|
||||
};
|
||||
};
|
||||
|
||||
export function resetCompose() {
|
||||
return {
|
||||
type: COMPOSE_RESET,
|
||||
|
@ -218,6 +240,7 @@ export function submitCompose(routerHistory, overridePrivacy = null) {
|
|||
status,
|
||||
content_type: getState().getIn(['compose', 'content_type']),
|
||||
in_reply_to_id: getState().getIn(['compose', 'in_reply_to'], null),
|
||||
quote_id: getState().getIn(['compose', 'quote_id'], null),
|
||||
media_ids: media.map(item => item.get('id')),
|
||||
media_attributes,
|
||||
sensitive: getState().getIn(['compose', 'sensitive']) || (spoilerText.length > 0 && media.size !== 0),
|
||||
|
|
|
@ -59,6 +59,8 @@ export function normalizeStatus(status, normalOldStatus, settings) {
|
|||
normalStatus.contentHtml = normalOldStatus.get('contentHtml');
|
||||
normalStatus.spoilerHtml = normalOldStatus.get('spoilerHtml');
|
||||
normalStatus.hidden = normalOldStatus.get('hidden');
|
||||
normalStatus.quote = normalOldStatus.get('quote');
|
||||
normalStatus.quote_hidden = normalOldStatus.get('quote_hidden');
|
||||
|
||||
if (normalOldStatus.get('translation')) {
|
||||
normalStatus.translation = normalOldStatus.get('translation');
|
||||
|
@ -72,6 +74,35 @@ export function normalizeStatus(status, normalOldStatus, settings) {
|
|||
normalStatus.contentHtml = emojify(normalStatus.content, emojiMap);
|
||||
normalStatus.spoilerHtml = emojify(escapeTextContentForBrowser(spoilerText), emojiMap);
|
||||
normalStatus.hidden = (spoilerText.length > 0 || normalStatus.sensitive) && autoHideCW(settings, spoilerText);
|
||||
|
||||
if (status.quote && status.quote.id) {
|
||||
const quote_spoilerText = status.quote.spoiler_text || '';
|
||||
const quote_searchContent = [quote_spoilerText, status.quote.content].join('\n\n').replace(/<br\s*\/?>/g, '\n').replace(/<\/p><p>/g, '\n\n');
|
||||
|
||||
const quote_emojiMap = makeEmojiMap(normalStatus.quote.emojis);
|
||||
|
||||
const quote_account_emojiMap = makeEmojiMap(status.quote.account.emojis);
|
||||
const displayName = normalStatus.quote.account.display_name.length === 0 ? normalStatus.quote.account.username : normalStatus.quote.account.display_name;
|
||||
normalStatus.quote.account.display_name_html = emojify(escapeTextContentForBrowser(displayName), quote_account_emojiMap);
|
||||
normalStatus.quote.search_index = domParser.parseFromString(quote_searchContent, 'text/html').documentElement.textContent;
|
||||
let docElem = domParser.parseFromString(normalStatus.quote.content, 'text/html').documentElement;
|
||||
Array.from(docElem.querySelectorAll('span.quote-inline'), span => span.remove());
|
||||
Array.from(docElem.querySelectorAll('p,br'), line => {
|
||||
let parentNode = line.parentNode;
|
||||
if (line.nextSibling) {
|
||||
parentNode.insertBefore(document.createTextNode(' '), line.nextSibling);
|
||||
}
|
||||
});
|
||||
let _contentHtml = docElem.textContent;
|
||||
normalStatus.quote.contentHtml = '<p>'+emojify(_contentHtml.substr(0, 150), quote_emojiMap) + (_contentHtml.substr(150) ? '...' : '')+'</p>';
|
||||
normalStatus.quote.spoilerHtml = emojify(escapeTextContentForBrowser(quote_spoilerText), quote_emojiMap);
|
||||
normalStatus.quote_hidden = (quote_spoilerText.length > 0 || normalStatus.quote.sensitive) && autoHideCW(settings, quote_spoilerText);
|
||||
|
||||
// delete the quote link!!!!
|
||||
let parentDocElem = domParser.parseFromString(normalStatus.contentHtml, 'text/html').documentElement;
|
||||
Array.from(parentDocElem.querySelectorAll('span.quote-inline'), span => span.remove());
|
||||
normalStatus.contentHtml = parentDocElem.children[1].innerHTML;
|
||||
}
|
||||
}
|
||||
|
||||
if (normalOldStatus) {
|
||||
|
|
|
@ -85,6 +85,7 @@ class Status extends ImmutablePureComponent {
|
|||
rootId: PropTypes.string,
|
||||
onClick: PropTypes.func,
|
||||
onReply: PropTypes.func,
|
||||
onQuote: PropTypes.func,
|
||||
onFavourite: PropTypes.func,
|
||||
onReblog: PropTypes.func,
|
||||
onBookmark: PropTypes.func,
|
||||
|
@ -732,7 +733,7 @@ class Status extends ImmutablePureComponent {
|
|||
if (!status.get('sensitive') && !(status.get('spoiler_text').length > 0) && settings.getIn(['collapsed', 'backgrounds', 'preview_images'])) {
|
||||
background = attachments.getIn([0, 'preview_url']);
|
||||
}
|
||||
} else if (status.get('card') && settings.get('inline_preview_cards') && !this.props.muted) {
|
||||
} else if (!status.get('quote') && status.get('card') && settings.get('inline_preview_cards') && !this.props.muted) {
|
||||
media.push(
|
||||
<Card
|
||||
onOpenMedia={this.handleOpenMedia}
|
||||
|
|
|
@ -10,6 +10,7 @@ import ImmutablePureComponent from 'react-immutable-pure-component';
|
|||
|
||||
import BookmarkIcon from '@/material-icons/400-24px/bookmark-fill.svg?react';
|
||||
import BookmarkBorderIcon from '@/material-icons/400-24px/bookmark.svg?react';
|
||||
import FormatQuoteIcon from '@/material-icons/400-24px/format_quote-fill.svg?react';
|
||||
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
|
||||
import RepeatIcon from '@/material-icons/400-24px/repeat.svg?react';
|
||||
import ReplyIcon from '@/material-icons/400-24px/reply.svg?react';
|
||||
|
@ -46,6 +47,7 @@ const messages = defineMessages({
|
|||
replyAll: { id: 'status.replyAll', defaultMessage: 'Reply to thread' },
|
||||
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
|
||||
reblog_private: { id: 'status.reblog_private', defaultMessage: 'Boost with original visibility' },
|
||||
quote: { id: 'status.quote', defaultMessage: 'Quote' },
|
||||
cancel_reblog_private: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost' },
|
||||
cannot_reblog: { id: 'status.cannot_reblog', defaultMessage: 'This post cannot be boosted' },
|
||||
favourite: { id: 'status.favourite', defaultMessage: 'Favorite' },
|
||||
|
@ -74,6 +76,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
onReply: PropTypes.func,
|
||||
onFavourite: PropTypes.func,
|
||||
onReblog: PropTypes.func,
|
||||
onQuote: PropTypes.func,
|
||||
onDelete: PropTypes.func,
|
||||
onDirect: PropTypes.func,
|
||||
onMention: PropTypes.func,
|
||||
|
@ -114,6 +117,17 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
handleQuoteClick = () => {
|
||||
const { signedIn } = this.context.identity;
|
||||
|
||||
if (signedIn) {
|
||||
this.props.onQuote(this.props.status, this.props.history);
|
||||
} else {
|
||||
// TODO(ariadne): Add an interaction modal for quoting specifically.
|
||||
this.props.onInteractionModal('reply', this.props.status);
|
||||
}
|
||||
};
|
||||
|
||||
handleShareClick = () => {
|
||||
navigator.share({
|
||||
url: this.props.status.get('url'),
|
||||
|
@ -217,6 +231,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
|
||||
let menu = [];
|
||||
let reblogIcon = 'retweet';
|
||||
let quoteIcon = 'quote-right';
|
||||
let replyIcon;
|
||||
let replyIconComponent;
|
||||
let replyTitle;
|
||||
|
@ -299,6 +314,7 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
const reblogPrivate = status.getIn(['account', 'id']) === me && status.get('visibility') === 'private';
|
||||
|
||||
let reblogTitle, reblogIconComponent;
|
||||
let quoteTitle, quoteIconComponent;
|
||||
|
||||
if (status.get('reblogged')) {
|
||||
reblogTitle = intl.formatMessage(messages.cancel_reblog_private);
|
||||
|
@ -314,6 +330,19 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
reblogIconComponent = RepeatDisabledIcon;
|
||||
}
|
||||
|
||||
// quotes
|
||||
if (publicStatus) {
|
||||
quoteTitle = intl.formatMessage(messages.quote);
|
||||
quoteIconComponent = FormatQuoteIcon;
|
||||
} else if (reblogPrivate) {
|
||||
quoteTitle = intl.formatMessage(messages.reblog_private);
|
||||
quoteIconComponent = FormatQuoteIcon;
|
||||
} else {
|
||||
quoteTitle = intl.formatMessage(messages.cannot_reblog);
|
||||
quoteIconComponent = FormatQuoteIcon;
|
||||
}
|
||||
|
||||
|
||||
const filterButton = this.props.onFilter && (
|
||||
<IconButton className='status__action-bar-button' title={intl.formatMessage(messages.hide)} icon='eye' iconComponent={VisibilityIcon} onClick={this.handleHideClick} />
|
||||
);
|
||||
|
@ -329,7 +358,10 @@ class StatusActionBar extends ImmutablePureComponent {
|
|||
counter={showReplyCount ? status.get('replies_count') : undefined}
|
||||
obfuscateCount
|
||||
/>
|
||||
|
||||
<IconButton className={classNames('status__action-bar-button', { reblogPrivate })} disabled={!publicStatus && !reblogPrivate} active={status.get('reblogged')} title={reblogTitle} icon={reblogIcon} iconComponent={reblogIconComponent} onClick={this.handleReblogClick} counter={withCounters ? status.get('reblogs_count') : undefined} />
|
||||
<IconButton className={classNames('status__action-bar-button', { reblogPrivate })} disabled={!publicStatus && !reblogPrivate} /* active={status.get('reblogged')} */ title={quoteTitle} icon={quoteIcon} iconComponent={quoteIconComponent} onClick={this.handleQuoteClick} />
|
||||
|
||||
<IconButton className='status__action-bar-button star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' iconComponent={status.get('favourited') ? StarIcon : StarBorderIcon} onClick={this.handleFavouriteClick} counter={withCounters ? status.get('favourites_count') : undefined} />
|
||||
<IconButton className='status__action-bar-button bookmark-icon' disabled={!signedIn} active={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' iconComponent={status.get('bookmarked') ? BookmarkIcon : BookmarkBorderIcon} onClick={this.handleBookmarkClick} />
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import InsertChartIcon from '@/material-icons/400-24px/insert_chart.svg?react';
|
|||
import LinkIcon from '@/material-icons/400-24px/link.svg?react';
|
||||
import MovieIcon from '@/material-icons/400-24px/movie.svg?react';
|
||||
import MusicNoteIcon from '@/material-icons/400-24px/music_note.svg?react';
|
||||
import QuoteIcon from '@/material-icons/400-24px/format_quote-fill.svg?react';
|
||||
import { Icon } from 'flavours/glitch/components/icon';
|
||||
import { identityContextPropShape, withIdentity } from 'flavours/glitch/identity_context';
|
||||
import { autoPlayGif, languages as preloadedLanguages } from 'flavours/glitch/initial_state';
|
||||
|
@ -361,6 +362,37 @@ class StatusContent extends PureComponent {
|
|||
<TranslateButton onClick={this.handleTranslate} translation={status.get('translation')} />
|
||||
);
|
||||
|
||||
let quote = '';
|
||||
|
||||
if (status.get('quote', null) !== null) {
|
||||
let quoteStatus = status.get('quote');
|
||||
let quoteStatusContent = { __html: quoteStatus.get('contentHtml') };
|
||||
let quoteStatusAccount = quoteStatus.get('account');
|
||||
let quoteStatusDisplayName = { __html: quoteStatusAccount.get('display_name_html') };
|
||||
|
||||
quote = (
|
||||
<div className='status__quote'>
|
||||
<blockquote>
|
||||
<bdi>
|
||||
<span className='quote-display-name'>
|
||||
<Icon
|
||||
fixedWidth
|
||||
aria-hidden='true'
|
||||
key='icon-quote-right'
|
||||
icon={QuoteIcon} />
|
||||
<strong className='display-name__html'>
|
||||
<a onClick={this.handleAccountClick} href={quoteStatus.getIn(['account', 'url'])} dangerouslySetInnerHTML={quoteStatusDisplayName} />
|
||||
</strong>
|
||||
</span>
|
||||
</bdi>
|
||||
<div>
|
||||
<a href={quoteStatus.get('url')} target='_blank' rel='noopener noreferrer' dangerouslySetInnerHTML={quoteStatusContent} />
|
||||
</div>
|
||||
</blockquote>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (status.get('spoiler_text').length > 0) {
|
||||
let mentionsPlaceholder = '';
|
||||
|
||||
|
@ -435,6 +467,7 @@ class StatusContent extends PureComponent {
|
|||
{mentionsPlaceholder}
|
||||
|
||||
<div className={`status__content__spoiler ${!hidden ? 'status__content__spoiler--visible' : ''}`}>
|
||||
{quote}
|
||||
<div
|
||||
ref={this.setContentsRef}
|
||||
key={`contents-${tagLinks}`}
|
||||
|
@ -460,6 +493,7 @@ class StatusContent extends PureComponent {
|
|||
onMouseUp={this.handleMouseUp}
|
||||
tabIndex={0}
|
||||
>
|
||||
{quote}
|
||||
<div
|
||||
ref={this.setContentsRef}
|
||||
key={`contents-${tagLinks}-${rewriteMentions}`}
|
||||
|
@ -481,6 +515,7 @@ class StatusContent extends PureComponent {
|
|||
className='status__content'
|
||||
tabIndex={0}
|
||||
>
|
||||
{quote}
|
||||
<div
|
||||
ref={this.setContentsRef}
|
||||
key={`contents-${tagLinks}`}
|
||||
|
|
|
@ -5,6 +5,7 @@ import { connect } from 'react-redux';
|
|||
import { initBlockModal } from 'flavours/glitch/actions/blocks';
|
||||
import {
|
||||
replyCompose,
|
||||
quoteCompose,
|
||||
mentionCompose,
|
||||
directCompose,
|
||||
} from 'flavours/glitch/actions/compose';
|
||||
|
@ -51,6 +52,8 @@ const messages = defineMessages({
|
|||
replyMessage: { id: 'confirmations.reply.message', defaultMessage: 'Replying now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
|
||||
editConfirm: { id: 'confirmations.edit.confirm', defaultMessage: 'Edit' },
|
||||
editMessage: { id: 'confirmations.edit.message', defaultMessage: 'Editing now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
|
||||
quoteConfirm: { id: 'confirmations.quote.confirm', defaultMessage: 'Quote' },
|
||||
quoteMessage: { id: 'confirmations.quote.message', defaultMessage: 'Quoting now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
|
||||
unfilterConfirm: { id: 'confirmations.unfilter.confirm', defaultMessage: 'Show' },
|
||||
author: { id: 'confirmations.unfilter.author', defaultMessage: 'Author' },
|
||||
matchingFilters: { id: 'confirmations.unfilter.filters', defaultMessage: 'Matching {count, plural, one {filter} other {filters}}' },
|
||||
|
@ -113,6 +116,26 @@ const mapDispatchToProps = (dispatch, { intl, contextType }) => ({
|
|||
});
|
||||
},
|
||||
|
||||
onQuote (status, router) {
|
||||
dispatch((_, getState) => {
|
||||
let state = getState();
|
||||
|
||||
if (state.getIn(['local_settings', 'confirm_before_clearing_draft']) && state.getIn(['compose', 'text']).trim().length !== 0) {
|
||||
dispatch(openModal({
|
||||
modalType: 'CONFIRM',
|
||||
modalProps: {
|
||||
message: intl.formatMessage(messages.quoteMessage),
|
||||
confirm: intl.formatMessage(messages.quoteConfirm),
|
||||
onDoNotAsk: () => dispatch(changeLocalSetting(['confirm_before_clearing_draft'], false)),
|
||||
onConfirm: () => dispatch(quoteCompose(status, router)),
|
||||
},
|
||||
}));
|
||||
} else {
|
||||
dispatch(quoteCompose(status, router));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onModalReblog (status, privacy) {
|
||||
if (status.get('reblogged')) {
|
||||
dispatch(unreblog({ statusId: status.get('id') }));
|
||||
|
|
|
@ -257,6 +257,7 @@ class ComposeForm extends ImmutablePureComponent {
|
|||
return (
|
||||
<form className='compose-form' onSubmit={this.handleSubmit}>
|
||||
<ReplyIndicator />
|
||||
{/* <QuoteIndicatorContainer /> */}
|
||||
{!withoutNavigation && <NavigationBar />}
|
||||
<WarningContainer />
|
||||
|
||||
|
|
|
@ -0,0 +1,85 @@
|
|||
// Package imports.
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||
import ImmutablePureComponent from 'react-immutable-pure-component';
|
||||
|
||||
|
||||
import CloseIcon from '@/material-icons/400-24px/close.svg?react';
|
||||
import AttachmentList from 'flavours/glitch/components/attachment_list';
|
||||
import { WithOptionalRouterPropTypes, withOptionalRouter } from 'flavours/glitch/utils/react_router';
|
||||
|
||||
import { Avatar } from '../../../components/avatar';
|
||||
import { DisplayName } from '../../../components/display_name';
|
||||
import { Icon } from '../../../components/icon';
|
||||
import { IconButton } from '../../../components/icon_button';
|
||||
|
||||
// Messages.
|
||||
const messages = defineMessages({
|
||||
cancel: {
|
||||
defaultMessage: 'Cancel',
|
||||
id: 'quote_indicator.cancel',
|
||||
},
|
||||
});
|
||||
|
||||
class QuoteIndicator extends ImmutablePureComponent {
|
||||
|
||||
static propTypes = {
|
||||
status: ImmutablePropTypes.map,
|
||||
onCancel: PropTypes.func,
|
||||
intl: PropTypes.object.isRequired,
|
||||
...WithOptionalRouterPropTypes,
|
||||
};
|
||||
|
||||
handleClick = () => {
|
||||
this.props.onCancel();
|
||||
};
|
||||
|
||||
handleAccountClick = (e) => {
|
||||
if (e.button === 0 && !(e.ctrlKey || e.metaKey)) {
|
||||
e.preventDefault();
|
||||
this.props.history?.push(`/@${this.props.status.getIn(['account', 'acct'])}`);
|
||||
}
|
||||
}
|
||||
|
||||
// Rendering.
|
||||
render () {
|
||||
const { status, intl } = this.props;
|
||||
|
||||
if (!status) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const content = { __html: status.get('contentHtml') };
|
||||
|
||||
// The result.
|
||||
return (
|
||||
<article className='quote-indicator'>
|
||||
<header className='quote-indicator__header'>
|
||||
<div className='quote-indicator__cancel'>
|
||||
<IconButton title={intl.formatMessage(messages.cancel)} icon='times' iconComponent={CloseIcon} onClick={this.handleClick} inverted />
|
||||
</div>
|
||||
|
||||
<a href={status.getIn(['account', 'url'])} onClick={this.handleAccountClick} className='quote-indicator__display-name' target='_blank' rel='noopener noreferrer'>
|
||||
<div className='quote-indicator__display-avatar'><Avatar account={status.get('account')} size={24} /></div>
|
||||
<DisplayName account={status.get('account')} inline />
|
||||
</a>
|
||||
</header>
|
||||
|
||||
<div className='quote-indicator__content translate' dangerouslySetInnerHTML={content} />
|
||||
|
||||
{status.get('media_attachments').size > 0 && (
|
||||
<AttachmentList
|
||||
compact
|
||||
media={status.get('media_attachments')}
|
||||
/>
|
||||
)}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default withOptionalRouter(injectIntl(QuoteIndicator));
|
|
@ -0,0 +1,31 @@
|
|||
import { connect } from 'react-redux';
|
||||
|
||||
import { cancelQuoteCompose } from 'flavours/glitch/actions/compose';
|
||||
import { makeGetStatus } from '../../../selectors';
|
||||
import QuoteIndicator from '../components/quote_indicator';
|
||||
|
||||
const makeMapStateToProps = () => {
|
||||
const getStatus = makeGetStatus();
|
||||
|
||||
const mapStateToProps = state => {
|
||||
const statusId = state.getIn(['compose', 'quote_id'], null);
|
||||
const editing = false;
|
||||
|
||||
return {
|
||||
status: getStatus(state, { id: statusId }),
|
||||
editing,
|
||||
};
|
||||
};
|
||||
|
||||
return mapStateToProps;
|
||||
};
|
||||
|
||||
const mapDispatchToProps = dispatch => ({
|
||||
|
||||
onCancel () {
|
||||
dispatch(cancelQuoteCompose());
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
export default connect(makeMapStateToProps, mapDispatchToProps)(QuoteIndicator);
|
|
@ -11,6 +11,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes';
|
|||
import BookmarkIcon from '@/material-icons/400-24px/bookmark-fill.svg?react';
|
||||
import BookmarkBorderIcon from '@/material-icons/400-24px/bookmark.svg?react';
|
||||
import MoreHorizIcon from '@/material-icons/400-24px/more_horiz.svg?react';
|
||||
import QuoteIcon from '@/material-icons/400-24px/format_quote-fill.svg?react';
|
||||
import RepeatIcon from '@/material-icons/400-24px/repeat.svg?react';
|
||||
import ReplyIcon from '@/material-icons/400-24px/reply.svg?react';
|
||||
import ReplyAllIcon from '@/material-icons/400-24px/reply_all.svg?react';
|
||||
|
@ -38,6 +39,7 @@ const messages = defineMessages({
|
|||
reply: { id: 'status.reply', defaultMessage: 'Reply' },
|
||||
reblog: { id: 'status.reblog', defaultMessage: 'Boost' },
|
||||
reblog_private: { id: 'status.reblog_private', defaultMessage: 'Boost with original visibility' },
|
||||
quote: { id: 'status.quote', defaultMessage: 'Quote' },
|
||||
cancel_reblog_private: { id: 'status.cancel_reblog_private', defaultMessage: 'Unboost' },
|
||||
cannot_reblog: { id: 'status.cannot_reblog', defaultMessage: 'This post cannot be boosted' },
|
||||
favourite: { id: 'status.favourite', defaultMessage: 'Favorite' },
|
||||
|
@ -71,6 +73,7 @@ class ActionBar extends PureComponent {
|
|||
onEdit: PropTypes.func.isRequired,
|
||||
onDirect: PropTypes.func.isRequired,
|
||||
onMention: PropTypes.func.isRequired,
|
||||
onQuote: PropTypes.func.isRequired,
|
||||
onMute: PropTypes.func,
|
||||
onBlock: PropTypes.func,
|
||||
onMuteConversation: PropTypes.func,
|
||||
|
@ -97,6 +100,10 @@ class ActionBar extends PureComponent {
|
|||
this.props.onBookmark(this.props.status, e);
|
||||
};
|
||||
|
||||
handleQuoteClick = () => {
|
||||
this.props.onQuote(this.props.status);
|
||||
}
|
||||
|
||||
handleDeleteClick = () => {
|
||||
this.props.onDelete(this.props.status, this.props.history);
|
||||
};
|
||||
|
@ -250,6 +257,7 @@ class ActionBar extends PureComponent {
|
|||
<div className='detailed-status__action-bar'>
|
||||
<div className='detailed-status__button'><IconButton title={intl.formatMessage(messages.reply)} icon={replyIcon} iconComponent={replyIconComponent} onClick={this.handleReplyClick} /></div>
|
||||
<div className='detailed-status__button'><IconButton className={classNames({ reblogPrivate })} disabled={!publicStatus && !reblogPrivate} active={status.get('reblogged')} title={reblogTitle} icon='retweet' iconComponent={reblogIconComponent} onClick={this.handleReblogClick} /></div>
|
||||
<div className='detailed-status__button'><IconButton className='quote-right-icon' disabled={!publicStatus} title={intl.formatMessage(messages.quote)} icon='quote-right' iconComponent={QuoteIcon} onClick={this.handleQuoteClick} /></div>
|
||||
<div className='detailed-status__button'><IconButton className='star-icon' animate active={status.get('favourited')} title={intl.formatMessage(messages.favourite)} icon='star' iconComponent={status.get('favourited') ? StarIcon : StarBorderIcon} onClick={this.handleFavouriteClick} /></div>
|
||||
<div className='detailed-status__button'><IconButton className='bookmark-icon' disabled={!signedIn} active={status.get('bookmarked')} title={intl.formatMessage(messages.bookmark)} icon='bookmark' iconComponent={status.get('bookmarked') ? BookmarkIcon : BookmarkBorderIcon} onClick={this.handleBookmarkClick} /></div>
|
||||
|
||||
|
|
|
@ -221,7 +221,7 @@ class DetailedStatus extends ImmutablePureComponent {
|
|||
);
|
||||
mediaIcons.push('picture-o');
|
||||
}
|
||||
} else if (status.get('card')) {
|
||||
} else if (!status.get('quote') && status.get('card')) {
|
||||
media.push(<Card sensitive={status.get('sensitive')} onOpenMedia={this.props.onOpenMedia} card={status.get('card')} />);
|
||||
mediaIcons.push('link');
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { showAlertForError } from '../../../actions/alerts';
|
|||
import { initBlockModal } from '../../../actions/blocks';
|
||||
import {
|
||||
replyCompose,
|
||||
quoteCompose,
|
||||
mentionCompose,
|
||||
directCompose,
|
||||
} from '../../../actions/compose';
|
||||
|
@ -32,6 +33,8 @@ import DetailedStatus from '../components/detailed_status';
|
|||
const messages = defineMessages({
|
||||
deleteConfirm: { id: 'confirmations.delete.confirm', defaultMessage: 'Delete' },
|
||||
deleteMessage: { id: 'confirmations.delete.message', defaultMessage: 'Are you sure you want to delete this status?' },
|
||||
quoteConfirm: { id: 'confirmations.quote.confirm', defaultMessage: 'Quote' },
|
||||
quoteMessage: { id: 'confirmations.quote.message', defaultMessage: 'Quoting now will overwrite the message you are currently composing. Are you sure you want to proceed?' },
|
||||
redraftConfirm: { id: 'confirmations.redraft.confirm', defaultMessage: 'Delete & redraft' },
|
||||
redraftMessage: { id: 'confirmations.redraft.message', defaultMessage: 'Are you sure you want to delete this status and re-draft it? Favorites and boosts will be lost, and replies to the original post will be orphaned.' },
|
||||
replyConfirm: { id: 'confirmations.reply.confirm', defaultMessage: 'Reply' },
|
||||
|
@ -70,6 +73,21 @@ const mapDispatchToProps = (dispatch, { intl }) => ({
|
|||
});
|
||||
},
|
||||
|
||||
onQuote (status, router) {
|
||||
dispatch((_, getState) => {
|
||||
let state = getState();
|
||||
if (state.getIn(['compose', 'text']).trim().length !== 0) {
|
||||
dispatch(openModal('CONFIRM', {
|
||||
message: intl.formatMessage(messages.quoteMessage),
|
||||
confirm: intl.formatMessage(messages.quoteConfirm),
|
||||
onConfirm: () => dispatch(quoteCompose(status, router)),
|
||||
}));
|
||||
} else {
|
||||
dispatch(quoteCompose(status, router));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
onModalReblog (status, privacy) {
|
||||
dispatch(reblog({ statusId: status.get('id'), visibility: privacy }));
|
||||
},
|
||||
|
|
|
@ -28,6 +28,7 @@ import { WithRouterPropTypes } from 'flavours/glitch/utils/react_router';
|
|||
import { initBlockModal } from '../../actions/blocks';
|
||||
import {
|
||||
replyCompose,
|
||||
quoteCompose,
|
||||
mentionCompose,
|
||||
directCompose,
|
||||
} from '../../actions/compose';
|
||||
|
@ -342,6 +343,21 @@ class Status extends ImmutablePureComponent {
|
|||
}
|
||||
};
|
||||
|
||||
handleQuoteClick = (status) => {
|
||||
const { dispatch } = this.props;
|
||||
const { signedIn } = this.context.identity;
|
||||
|
||||
if (signedIn) {
|
||||
dispatch(quoteCompose(status, this.context.router.history));
|
||||
} else {
|
||||
dispatch(openModal('INTERACTION', {
|
||||
type: 'reply',
|
||||
accountId: status.getIn(['account', 'id']),
|
||||
url: status.get('url'),
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
handleModalReblog = (status, privacy) => {
|
||||
const { dispatch } = this.props;
|
||||
|
||||
|
@ -760,6 +776,7 @@ class Status extends ImmutablePureComponent {
|
|||
onFavourite={this.handleFavouriteClick}
|
||||
onReblog={this.handleReblogClick}
|
||||
onBookmark={this.handleBookmarkClick}
|
||||
onQuote={this.handleQuoteClick}
|
||||
onDelete={this.handleDeleteClick}
|
||||
onEdit={this.handleEditClick}
|
||||
onDirect={this.handleDirectClick}
|
||||
|
|
|
@ -9,6 +9,8 @@ import {
|
|||
COMPOSE_REPLY,
|
||||
COMPOSE_REPLY_CANCEL,
|
||||
COMPOSE_DIRECT,
|
||||
COMPOSE_QUOTE,
|
||||
COMPOSE_QUOTE_CANCEL,
|
||||
COMPOSE_MENTION,
|
||||
COMPOSE_SUBMIT_REQUEST,
|
||||
COMPOSE_SUBMIT_SUCCESS,
|
||||
|
@ -80,6 +82,7 @@ const initialState = ImmutableMap({
|
|||
caretPosition: null,
|
||||
preselectDate: null,
|
||||
in_reply_to: null,
|
||||
quote_id: null,
|
||||
is_composing: false,
|
||||
is_submitting: false,
|
||||
is_changing_upload: false,
|
||||
|
@ -169,6 +172,7 @@ function clearAll(state) {
|
|||
map.set('is_submitting', false);
|
||||
map.set('is_changing_upload', false);
|
||||
map.set('in_reply_to', null);
|
||||
map.set('quote_id', null);
|
||||
map.update(
|
||||
'advanced_options',
|
||||
map => map.mergeWith(overwrite, state.get('default_advanced_options')),
|
||||
|
@ -358,6 +362,51 @@ const updateSuggestionTags = (state, token) => {
|
|||
});
|
||||
};
|
||||
|
||||
const updateWithReply = (state, action) => {
|
||||
// doesn't support QT&reply
|
||||
const isQuote = action.type === COMPOSE_QUOTE;
|
||||
const parentStatusId = action.status.get('id');
|
||||
|
||||
return state.withMutations(map => {
|
||||
map.set('id', null);
|
||||
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
|
||||
map.update(
|
||||
'advanced_options',
|
||||
map => map.merge(new ImmutableMap({ do_not_federate: !!action.status.get('local_only') })),
|
||||
);
|
||||
map.set('focusDate', new Date());
|
||||
map.set('caretPosition', null);
|
||||
map.set('preselectDate', new Date());
|
||||
map.set('idempotencyKey', uuid());
|
||||
|
||||
if (action.status.get('spoiler_text').length > 0) {
|
||||
let spoilerText = action.status.get('spoiler_text');
|
||||
if (action.prependCWRe && !spoilerText.match(/^(re|qt)[: ]/i)) {
|
||||
spoilerText = isQuote ? `QT: ${spoilerText}` : `re: ${spoilerText}`;
|
||||
}
|
||||
map.set('spoiler', true);
|
||||
map.set('spoiler_text', spoilerText);
|
||||
} else {
|
||||
map.set('spoiler', false);
|
||||
map.set('spoiler_text', '');
|
||||
}
|
||||
|
||||
if (isQuote) {
|
||||
map.set('in_reply_to', null);
|
||||
map.set('quote_id', parentStatusId);
|
||||
map.set('text', '');
|
||||
} else {
|
||||
map.set('in_reply_to', parentStatusId);
|
||||
map.set('quote_id', null);
|
||||
map.set('text', statusToTextMentions(state, action.status));
|
||||
|
||||
if (action.status.get('language')) {
|
||||
map.set('language', action.status.get('language'));
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const updatePoll = (state, index, value, maxOptions) => state.updateIn(['poll', 'options'], options => {
|
||||
const tmp = options.set(index, value).filterNot(x => x.trim().length === 0);
|
||||
|
||||
|
@ -420,46 +469,17 @@ export default function compose(state = initialState, action) {
|
|||
case COMPOSE_COMPOSING_CHANGE:
|
||||
return state.set('is_composing', action.value);
|
||||
case COMPOSE_REPLY:
|
||||
return state.withMutations(map => {
|
||||
map.set('id', null);
|
||||
map.set('in_reply_to', action.status.get('id'));
|
||||
map.set('text', statusToTextMentions(state, action.status));
|
||||
map.set('privacy', privacyPreference(action.status.get('visibility'), state.get('default_privacy')));
|
||||
map.update(
|
||||
'advanced_options',
|
||||
map => map.merge(new ImmutableMap({ do_not_federate: !!action.status.get('local_only') })),
|
||||
);
|
||||
map.set('focusDate', new Date());
|
||||
map.set('caretPosition', null);
|
||||
map.set('preselectDate', new Date());
|
||||
map.set('idempotencyKey', uuid());
|
||||
|
||||
map.update('media_attachments', list => list.filter(media => media.get('unattached')));
|
||||
|
||||
if (action.status.get('language') && !action.status.has('translation')) {
|
||||
map.set('language', action.status.get('language'));
|
||||
} else {
|
||||
map.set('language', state.get('default_language'));
|
||||
}
|
||||
|
||||
if (action.status.get('spoiler_text').length > 0) {
|
||||
let spoiler_text = action.status.get('spoiler_text');
|
||||
if (action.prependCWRe && !spoiler_text.match(/^re[: ]/i)) {
|
||||
spoiler_text = 're: '.concat(spoiler_text);
|
||||
}
|
||||
map.set('spoiler', true);
|
||||
map.set('spoiler_text', spoiler_text);
|
||||
} else {
|
||||
map.set('spoiler', false);
|
||||
map.set('spoiler_text', '');
|
||||
}
|
||||
});
|
||||
case COMPOSE_QUOTE:
|
||||
return updateWithReply(state, action);
|
||||
case COMPOSE_REPLY_CANCEL:
|
||||
state = state.setIn(['advanced_options', 'threaded_mode'], false);
|
||||
// eslint-disable-next-line no-fallthrough -- fall-through to `COMPOSE_RESET` is intended
|
||||
case COMPOSE_QUOTE_CANCEL:
|
||||
// eslint-disable-next-line no-fallthrough -- fall-through to `COMPOSE_RESET` is intended
|
||||
case COMPOSE_RESET:
|
||||
return state.withMutations(map => {
|
||||
map.set('in_reply_to', null);
|
||||
map.set('quote_id', null);
|
||||
if (defaultContentType) map.set('content_type', defaultContentType);
|
||||
map.set('text', '');
|
||||
map.set('spoiler', false);
|
||||
|
|
|
@ -1009,6 +1009,50 @@ body > [data-popper-placement] {
|
|||
}
|
||||
}
|
||||
|
||||
.quote-indicator,
|
||||
.reply-indicator {
|
||||
border-radius: 4px;
|
||||
margin-bottom: 10px;
|
||||
background: $ui-primary-color;
|
||||
padding: 10px;
|
||||
min-height: 23px;
|
||||
overflow-y: auto;
|
||||
flex: 0 2 auto;
|
||||
}
|
||||
|
||||
.quote-indicator__header,
|
||||
.reply-indicator__header {
|
||||
margin-bottom: 5px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.quote-indicator__cancel,
|
||||
.reply-indicator__cancel {
|
||||
float: right;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.quote-indicator__display-name,
|
||||
.reply-indicator__display-name {
|
||||
color: $inverted-text-color;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
line-height: 24px;
|
||||
overflow: hidden;
|
||||
text-decoration: none;
|
||||
|
||||
& > .display-name {
|
||||
line-height: unset;
|
||||
height: unset;
|
||||
}
|
||||
}
|
||||
|
||||
.quote-indicator__display-avatar,
|
||||
.reply-indicator__display-avatar {
|
||||
float: left;
|
||||
margin-inline-end: 5px;
|
||||
}
|
||||
|
||||
.status__content--with-action {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -1019,6 +1063,7 @@ body > [data-popper-placement] {
|
|||
|
||||
.status__content,
|
||||
.edit-indicator__content,
|
||||
.quote-indicator__content,
|
||||
.reply-indicator__content {
|
||||
position: relative;
|
||||
word-wrap: break-word;
|
||||
|
@ -1041,7 +1086,8 @@ body > [data-popper-placement] {
|
|||
}
|
||||
|
||||
p,
|
||||
pre {
|
||||
pre,
|
||||
blockquote {
|
||||
margin-bottom: 20px;
|
||||
white-space: pre-wrap;
|
||||
unicode-bidi: plaintext;
|
||||
|
@ -1419,6 +1465,7 @@ body > [data-popper-placement] {
|
|||
}
|
||||
|
||||
.focusable {
|
||||
&:hover,
|
||||
&:focus {
|
||||
outline: 0;
|
||||
background: rgba($ui-highlight-color, 0.05);
|
||||
|
@ -2279,7 +2326,9 @@ a .account__avatar {
|
|||
}
|
||||
}
|
||||
|
||||
.status__display-name,
|
||||
a.status__display-name,
|
||||
.quote-indicator__display-name,
|
||||
.reply-indicator__display-name,
|
||||
.detailed-status__display-name,
|
||||
a.account__display-name {
|
||||
&:hover .display-name strong {
|
||||
|
|
|
@ -1,7 +1,21 @@
|
|||
.compose-form {
|
||||
.compose-form__modifiers {
|
||||
.compose-form__upload {
|
||||
&-description {
|
||||
input {
|
||||
&::placeholder {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.status__content a,
|
||||
.reply-indicator__content a,
|
||||
.edit-indicator__content a,
|
||||
.link-footer a,
|
||||
.quote-indicator__content a,
|
||||
.reply-indicator__content a,
|
||||
.status__content__read-more-button,
|
||||
.status__content__translate-button {
|
||||
text-decoration: underline;
|
||||
|
@ -29,9 +43,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
.status__content a,
|
||||
.reply-indicator__content a,
|
||||
.edit-indicator__content a {
|
||||
.status__content a {
|
||||
color: $highlight-text-color;
|
||||
}
|
||||
|
||||
|
@ -39,10 +51,24 @@
|
|||
color: $darker-text-color;
|
||||
}
|
||||
|
||||
.report-dialog-modal__textarea::placeholder {
|
||||
.compose-form__poll-wrapper .button.button-secondary,
|
||||
.compose-form .autosuggest-textarea__textarea::placeholder,
|
||||
.compose-form .spoiler-input__input::placeholder,
|
||||
.report-dialog-modal__textarea::placeholder,
|
||||
.language-dropdown__dropdown__results__item__common-name,
|
||||
.compose-form .icon-button {
|
||||
color: $inverted-text-color;
|
||||
}
|
||||
|
||||
.text-icon-button.active {
|
||||
color: $ui-highlight-color;
|
||||
}
|
||||
|
||||
.language-dropdown__dropdown__results__item.active {
|
||||
background: $ui-highlight-color;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.link-button:disabled {
|
||||
cursor: not-allowed;
|
||||
|
||||
|
|
|
@ -21,6 +21,25 @@ html {
|
|||
}
|
||||
|
||||
// Change default background colors of columns
|
||||
.column > .scrollable,
|
||||
.getting-started,
|
||||
.column-inline-form,
|
||||
.regeneration-indicator {
|
||||
background: $white;
|
||||
border: 1px solid lighten($ui-base-color, 8%);
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.error-column {
|
||||
border: 1px solid lighten($ui-base-color, 8%);
|
||||
}
|
||||
|
||||
.column > .scrollable.about {
|
||||
border-top: 1px solid lighten($ui-base-color, 8%);
|
||||
}
|
||||
|
||||
.about__meta,
|
||||
.about__section__title,
|
||||
.interaction-modal {
|
||||
background: $white;
|
||||
border: 1px solid lighten($ui-base-color, 8%);
|
||||
|
@ -34,6 +53,29 @@ html {
|
|||
background: lighten($ui-base-color, 12%);
|
||||
}
|
||||
|
||||
.filter-form {
|
||||
background: $white;
|
||||
border-bottom: 1px solid lighten($ui-base-color, 8%);
|
||||
}
|
||||
|
||||
.column-back-button,
|
||||
.column-header {
|
||||
background: $white;
|
||||
border: 1px solid lighten($ui-base-color, 8%);
|
||||
|
||||
@media screen and (max-width: $no-gap-breakpoint) {
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
&--slim-button {
|
||||
top: -50px;
|
||||
right: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.column-header__back-button,
|
||||
.column-header__button,
|
||||
.column-header__button.active,
|
||||
.account__header {
|
||||
background: $white;
|
||||
}
|
||||
|
@ -45,6 +87,7 @@ html {
|
|||
&:active,
|
||||
&:focus {
|
||||
color: $ui-highlight-color;
|
||||
background: $white;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +113,25 @@ html {
|
|||
}
|
||||
}
|
||||
|
||||
.column-subheading {
|
||||
background: darken($ui-base-color, 4%);
|
||||
border-bottom: 1px solid lighten($ui-base-color, 8%);
|
||||
}
|
||||
|
||||
.getting-started,
|
||||
.scrollable {
|
||||
.column-link {
|
||||
background: $white;
|
||||
border-bottom: 1px solid lighten($ui-base-color, 8%);
|
||||
|
||||
&:hover,
|
||||
&:active,
|
||||
&:focus {
|
||||
background: $ui-base-color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.getting-started .navigation-bar {
|
||||
border-top: 1px solid lighten($ui-base-color, 8%);
|
||||
border-bottom: 1px solid lighten($ui-base-color, 8%);
|
||||
|
@ -79,8 +141,11 @@ html {
|
|||
}
|
||||
}
|
||||
|
||||
.compose-form__autosuggest-wrapper,
|
||||
.poll__option input[type='text'],
|
||||
.compose-form .spoiler-input__input,
|
||||
.compose-form__poll-wrapper select,
|
||||
.search__input,
|
||||
.search__popout,
|
||||
.setting-text,
|
||||
.report-dialog-modal__textarea,
|
||||
.audio-player {
|
||||
|
@ -103,6 +168,86 @@ html {
|
|||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.compose-form__poll-wrapper select {
|
||||
background: $simple-background-color
|
||||
url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14.933 18.467' height='19.698' width='15.929'><path d='M3.467 14.967l-3.393-3.5H14.86l-3.392 3.5c-1.866 1.925-3.666 3.5-4 3.5-.335 0-2.135-1.575-4-3.5zm.266-11.234L7.467 0 11.2 3.733l3.733 3.734H0l3.733-3.734z' fill='#{hex-color(lighten($ui-base-color, 8%))}'/></svg>")
|
||||
no-repeat right 8px center / auto 16px;
|
||||
}
|
||||
|
||||
.compose-form__poll-wrapper,
|
||||
.compose-form__poll-wrapper .poll__footer {
|
||||
border-top-color: lighten($ui-base-color, 8%);
|
||||
}
|
||||
|
||||
.notification__filter-bar {
|
||||
border: 1px solid lighten($ui-base-color, 8%);
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.compose-form .compose-form__buttons-wrapper {
|
||||
background: $ui-base-color;
|
||||
border: 1px solid lighten($ui-base-color, 8%);
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.drawer__header,
|
||||
.drawer__inner {
|
||||
background: $white;
|
||||
border: 1px solid lighten($ui-base-color, 8%);
|
||||
}
|
||||
|
||||
.drawer__inner__mastodon {
|
||||
background: $white
|
||||
url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 234.80078 31.757813" width="234.80078" height="31.757812"><path d="M19.599609 0c-1.05 0-2.10039.375-2.90039 1.125L0 16.925781v14.832031h234.80078V17.025391l-16.5-15.900391c-1.6-1.5-4.20078-1.5-5.80078 0l-13.80078 13.099609c-1.6 1.5-4.19883 1.5-5.79883 0L179.09961 1.125c-1.6-1.5-4.19883-1.5-5.79883 0L159.5 14.224609c-1.6 1.5-4.20078 1.5-5.80078 0L139.90039 1.125c-1.6-1.5-4.20078-1.5-5.80078 0l-13.79883 13.099609c-1.6 1.5-4.20078 1.5-5.80078 0L100.69922 1.125c-1.600001-1.5-4.198829-1.5-5.798829 0l-13.59961 13.099609c-1.6 1.5-4.200781 1.5-5.800781 0L61.699219 1.125c-1.6-1.5-4.198828-1.5-5.798828 0L42.099609 14.224609c-1.6 1.5-4.198828 1.5-5.798828 0L22.5 1.125C21.7.375 20.649609 0 19.599609 0z" fill="#{hex-color($ui-base-color)}"/></svg>')
|
||||
no-repeat bottom / 100% auto;
|
||||
}
|
||||
|
||||
// Change the colors used in compose-form
|
||||
.compose-form {
|
||||
.compose-form__modifiers {
|
||||
.compose-form__upload__actions .icon-button,
|
||||
.compose-form__upload__warning .icon-button {
|
||||
color: lighten($white, 7%);
|
||||
|
||||
&:active,
|
||||
&:focus,
|
||||
&:hover {
|
||||
color: $white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.compose-form__buttons-wrapper {
|
||||
background: darken($ui-base-color, 6%);
|
||||
}
|
||||
|
||||
.autosuggest-textarea__suggestions {
|
||||
background: darken($ui-base-color, 6%);
|
||||
}
|
||||
|
||||
.autosuggest-textarea__suggestions__item {
|
||||
&:hover,
|
||||
&:focus,
|
||||
&:active,
|
||||
&.selected {
|
||||
background: lighten($ui-base-color, 4%);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.emoji-mart-bar {
|
||||
border-color: lighten($ui-base-color, 4%);
|
||||
|
||||
&:first-child {
|
||||
background: darken($ui-base-color, 6%);
|
||||
}
|
||||
}
|
||||
|
||||
.emoji-mart-search input {
|
||||
background: rgba($ui-base-color, 0.3);
|
||||
border-color: $ui-base-color;
|
||||
}
|
||||
|
||||
.upload-progress__backdrop {
|
||||
background: $ui-base-color;
|
||||
}
|
||||
|
@ -112,7 +257,13 @@ html {
|
|||
background: lighten($white, 4%);
|
||||
}
|
||||
|
||||
.detailed-status,
|
||||
.detailed-status__action-bar {
|
||||
background: $white;
|
||||
}
|
||||
|
||||
// Change the background colors of status__content__spoiler-link
|
||||
.quote-indicator__content .status__content__spoiler-link,
|
||||
.reply-indicator__content .status__content__spoiler-link,
|
||||
.status__content .status__content__spoiler-link {
|
||||
background: $ui-base-color;
|
||||
|
@ -123,11 +274,52 @@ html {
|
|||
}
|
||||
}
|
||||
|
||||
// Change the background colors of media and video spoilers
|
||||
.media-spoiler,
|
||||
.video-player__spoiler {
|
||||
background: $ui-base-color;
|
||||
}
|
||||
|
||||
.privacy-dropdown.active .privacy-dropdown__value.active .icon-button {
|
||||
color: $white;
|
||||
}
|
||||
|
||||
.account-gallery__item a {
|
||||
background-color: $ui-base-color;
|
||||
}
|
||||
|
||||
// Change the colors used in the dropdown menu
|
||||
.dropdown-menu {
|
||||
background: $white;
|
||||
|
||||
&__arrow::before {
|
||||
background-color: $white;
|
||||
}
|
||||
|
||||
&__item {
|
||||
color: $darker-text-color;
|
||||
|
||||
&--dangerous {
|
||||
color: $error-value-color;
|
||||
}
|
||||
|
||||
a,
|
||||
button {
|
||||
background: $white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Change the text colors on inverted background
|
||||
.privacy-dropdown__option.active,
|
||||
.privacy-dropdown__option:hover,
|
||||
.privacy-dropdown__option.active .privacy-dropdown__option__content,
|
||||
.privacy-dropdown__option.active .privacy-dropdown__option__content strong,
|
||||
.privacy-dropdown__option:hover .privacy-dropdown__option__content,
|
||||
.privacy-dropdown__option:hover .privacy-dropdown__option__content strong,
|
||||
.dropdown-menu__item:not(.dropdown-menu__item--dangerous) a:active,
|
||||
.dropdown-menu__item:not(.dropdown-menu__item--dangerous) a:focus,
|
||||
.dropdown-menu__item:not(.dropdown-menu__item--dangerous) a:hover,
|
||||
.actions-modal ul li:not(:empty) a.active,
|
||||
.actions-modal ul li:not(:empty) a.active button,
|
||||
.actions-modal ul li:not(:empty) a:active,
|
||||
|
@ -136,6 +328,7 @@ html {
|
|||
.actions-modal ul li:not(:empty) a:focus button,
|
||||
.actions-modal ul li:not(:empty) a:hover,
|
||||
.actions-modal ul li:not(:empty) a:hover button,
|
||||
.language-dropdown__dropdown__results__item.active,
|
||||
.admin-wrapper .sidebar ul .simple-navigation-active-leaf a,
|
||||
.simple_form .block-button,
|
||||
.simple_form .button,
|
||||
|
@ -143,6 +336,19 @@ html {
|
|||
color: $white;
|
||||
}
|
||||
|
||||
.language-dropdown__dropdown__results__item
|
||||
.language-dropdown__dropdown__results__item__common-name {
|
||||
color: lighten($ui-base-color, 8%);
|
||||
}
|
||||
|
||||
.language-dropdown__dropdown__results__item.active
|
||||
.language-dropdown__dropdown__results__item__common-name {
|
||||
color: darken($ui-base-color, 12%);
|
||||
}
|
||||
|
||||
.dropdown-menu__separator,
|
||||
.dropdown-menu__item.edited-timestamp__history__item,
|
||||
.dropdown-menu__container__header,
|
||||
.compare-history-modal .report-modal__target,
|
||||
.report-dialog-modal .poll__option.dialog-option {
|
||||
border-bottom-color: lighten($ui-base-color, 4%);
|
||||
|
@ -176,7 +382,10 @@ html {
|
|||
|
||||
.reactions-bar__item:hover,
|
||||
.reactions-bar__item:focus,
|
||||
.reactions-bar__item:active {
|
||||
.reactions-bar__item:active,
|
||||
.language-dropdown__dropdown__results__item:hover,
|
||||
.language-dropdown__dropdown__results__item:focus,
|
||||
.language-dropdown__dropdown__results__item:active {
|
||||
background-color: $ui-base-color;
|
||||
}
|
||||
|
||||
|
@ -214,7 +423,7 @@ html {
|
|||
.column-header__collapsible-inner {
|
||||
background: darken($ui-base-color, 4%);
|
||||
border: 1px solid lighten($ui-base-color, 8%);
|
||||
border-bottom: 0;
|
||||
border-top: 0;
|
||||
}
|
||||
|
||||
.column-settings__hashtags .column-select__option {
|
||||
|
@ -264,11 +473,11 @@ html {
|
|||
}
|
||||
|
||||
.react-toggle-track {
|
||||
background: $ui-primary-color;
|
||||
background: $ui-secondary-color;
|
||||
}
|
||||
|
||||
.react-toggle:hover:not(.react-toggle--disabled) .react-toggle-track {
|
||||
background: lighten($ui-primary-color, 10%);
|
||||
background: darken($ui-secondary-color, 10%);
|
||||
}
|
||||
|
||||
.react-toggle.react-toggle--checked:hover:not(.react-toggle--disabled)
|
||||
|
@ -419,7 +628,14 @@ html {
|
|||
}
|
||||
}
|
||||
|
||||
.quote-indicator,
|
||||
.reply-indicator {
|
||||
background: transparent;
|
||||
border: 1px solid lighten($ui-base-color, 8%);
|
||||
}
|
||||
|
||||
.status__content,
|
||||
.quote-indicator__content,
|
||||
.reply-indicator__content {
|
||||
a {
|
||||
color: $highlight-text-color;
|
||||
|
@ -440,8 +656,7 @@ html {
|
|||
.directory__tag > div,
|
||||
.card > a,
|
||||
.page-header,
|
||||
.compose-form,
|
||||
.compose-form__warning {
|
||||
.compose-form .compose-form__warning {
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
|
@ -513,6 +728,13 @@ html {
|
|||
}
|
||||
}
|
||||
|
||||
.status.collapsed .status__content::after {
|
||||
background: linear-gradient(
|
||||
rgba(darken($ui-base-color, 13%), 0),
|
||||
rgba(darken($ui-base-color, 13%), 1)
|
||||
);
|
||||
}
|
||||
|
||||
.drawer__inner__mastodon {
|
||||
background: $white
|
||||
url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 234.80078 31.757813" width="234.80078" height="31.757812"><path d="M19.599609 0c-1.05 0-2.10039.375-2.90039 1.125L0 16.925781v14.832031h234.80078V17.025391l-16.5-15.900391c-1.6-1.5-4.20078-1.5-5.80078 0l-13.80078 13.099609c-1.6 1.5-4.19883 1.5-5.79883 0L179.09961 1.125c-1.6-1.5-4.19883-1.5-5.79883 0L159.5 14.224609c-1.6 1.5-4.20078 1.5-5.80078 0L139.90039 1.125c-1.6-1.5-4.20078-1.5-5.80078 0l-13.79883 13.099609c-1.6 1.5-4.20078 1.5-5.80078 0L100.69922 1.125c-1.600001-1.5-4.198829-1.5-5.798829 0l-13.59961 13.099609c-1.6 1.5-4.200781 1.5-5.800781 0L61.699219 1.125c-1.6-1.5-4.198828-1.5-5.798828 0L42.099609 14.224609c-1.6 1.5-4.198828 1.5-5.798828 0L22.5 1.125C21.7.375 20.649609 0 19.599609 0z" fill="#{hex-color($ui-base-color)}"/></svg>')
|
||||
|
@ -522,47 +744,3 @@ html {
|
|||
filter: contrast(75%) brightness(75%) !important;
|
||||
}
|
||||
}
|
||||
|
||||
.compose-form__actions .icon-button.active,
|
||||
.dropdown-button.active,
|
||||
.privacy-dropdown__option.active,
|
||||
.privacy-dropdown__option:focus,
|
||||
.language-dropdown__dropdown__results__item:focus,
|
||||
.language-dropdown__dropdown__results__item.active,
|
||||
.privacy-dropdown__option:focus .privacy-dropdown__option__content,
|
||||
.privacy-dropdown__option:focus .privacy-dropdown__option__content strong,
|
||||
.privacy-dropdown__option.active .privacy-dropdown__option__content,
|
||||
.privacy-dropdown__option.active .privacy-dropdown__option__content strong,
|
||||
.language-dropdown__dropdown__results__item:focus
|
||||
.language-dropdown__dropdown__results__item__common-name,
|
||||
.language-dropdown__dropdown__results__item.active
|
||||
.language-dropdown__dropdown__results__item__common-name {
|
||||
color: $white;
|
||||
}
|
||||
|
||||
.compose-form .spoiler-input__input {
|
||||
color: lighten($ui-highlight-color, 8%);
|
||||
}
|
||||
|
||||
.compose-form .autosuggest-textarea__textarea,
|
||||
.compose-form__highlightable,
|
||||
.search__input,
|
||||
.search__popout,
|
||||
.emoji-mart-search input,
|
||||
.language-dropdown__dropdown .emoji-mart-search input,
|
||||
.poll__option input[type='text'] {
|
||||
background: darken($ui-base-color, 10%);
|
||||
}
|
||||
|
||||
.inline-follow-suggestions {
|
||||
background-color: rgba($ui-highlight-color, 0.1);
|
||||
border-bottom-color: rgba($ui-highlight-color, 0.3);
|
||||
}
|
||||
|
||||
.inline-follow-suggestions__body__scrollable__card {
|
||||
background: $white;
|
||||
}
|
||||
|
||||
.inline-follow-suggestions__body__scroll-button__icon {
|
||||
color: $white;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
.status__quote,
|
||||
.status__content__text,
|
||||
.e-content,
|
||||
.edit-indicator__content,
|
||||
.quote-indicator__content,
|
||||
.reply-indicator__content {
|
||||
pre,
|
||||
blockquote {
|
||||
|
@ -91,3 +93,11 @@
|
|||
list-style-type: decimal;
|
||||
}
|
||||
}
|
||||
|
||||
.quote-indicator__content,
|
||||
.reply-indicator__content {
|
||||
blockquote {
|
||||
border-inline-start-color: $inverted-text-color;
|
||||
color: $inverted-text-color;
|
||||
}
|
||||
}
|
||||
|
|
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 8.5 KiB After Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 950 B After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 2.0 KiB |
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 66 KiB |
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 6.3 KiB |
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 5.7 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 8.6 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 9.5 KiB |
Before Width: | Height: | Size: 7.5 KiB After Width: | Height: | Size: 10 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 588 B After Width: | Height: | Size: 641 B |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 2.0 KiB |
|
@ -1,2 +1,138 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="79" height="79" viewBox="0 0 79 75"><symbol id="logo-symbol-icon"><path d="M74.7135 16.6043C73.6199 8.54587 66.5351 2.19527 58.1366 0.964691C56.7196 0.756754 51.351 0 38.9148 0H38.822C26.3824 0 23.7135 0.756754 22.2966 0.964691C14.1319 2.16118 6.67571 7.86752 4.86669 16.0214C3.99657 20.0369 3.90371 24.4888 4.06535 28.5726C4.29578 34.4289 4.34049 40.275 4.877 46.1075C5.24791 49.9817 5.89495 53.8251 6.81328 57.6088C8.53288 64.5968 15.4938 70.4122 22.3138 72.7848C29.6155 75.259 37.468 75.6697 44.9919 73.971C45.8196 73.7801 46.6381 73.5586 47.4475 73.3063C49.2737 72.7302 51.4164 72.086 52.9915 70.9542C53.0131 70.9384 53.0308 70.9178 53.0433 70.8942C53.0558 70.8706 53.0628 70.8445 53.0637 70.8179V65.1661C53.0634 65.1412 53.0574 65.1167 53.0462 65.0944C53.035 65.0721 53.0189 65.0525 52.9992 65.0371C52.9794 65.0218 52.9564 65.011 52.9318 65.0056C52.9073 65.0002 52.8819 65.0003 52.8574 65.0059C48.0369 66.1472 43.0971 66.7193 38.141 66.7103C29.6118 66.7103 27.3178 62.6981 26.6609 61.0278C26.1329 59.5842 25.7976 58.0784 25.6636 56.5486C25.6622 56.5229 25.667 56.4973 25.6775 56.4738C25.688 56.4502 25.7039 56.4295 25.724 56.4132C25.7441 56.397 25.7678 56.3856 25.7931 56.3801C25.8185 56.3746 25.8448 56.3751 25.8699 56.3816C30.6101 57.5151 35.4693 58.0873 40.3455 58.086C41.5183 58.086 42.6876 58.086 43.8604 58.0553C48.7647 57.919 53.9339 57.6701 58.7591 56.7361C58.8794 56.7123 58.9998 56.6918 59.103 56.6611C66.7139 55.2124 73.9569 50.665 74.6929 39.1501C74.7204 38.6967 74.7892 34.4016 74.7892 33.9312C74.7926 32.3325 75.3085 22.5901 74.7135 16.6043ZM62.9996 45.3371H54.9966V25.9069C54.9966 21.8163 53.277 19.7302 49.7793 19.7302C45.9343 19.7302 44.0083 22.1981 44.0083 27.0727V37.7082H36.0534V27.0727C36.0534 22.1981 34.124 19.7302 30.279 19.7302C26.8019 19.7302 25.0651 21.8163 25.0617 25.9069V45.3371H17.0656V25.3172C17.0656 21.2266 18.1191 17.9769 20.2262 15.568C22.3998 13.1648 25.2509 11.9308 28.7898 11.9308C32.8859 11.9308 35.9812 13.492 38.0447 16.6111L40.036 19.9245L42.0308 16.6111C44.0943 13.492 47.1896 11.9308 51.2788 11.9308C54.8143 11.9308 57.6654 13.1648 59.8459 15.568C61.9529 17.9746 63.0065 21.2243 63.0065 25.3172L62.9996 45.3371Z" fill="currentColor"/></symbol><use xlink:href="#logo-symbol-icon"/></svg>
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
<svg
|
||||
width="100mm"
|
||||
height="100mm"
|
||||
viewBox="0 0 100 100"
|
||||
version="1.1"
|
||||
id="svg299"
|
||||
inkscape:version="1.2.1 (9c6d41e410, 2022-07-14, custom)"
|
||||
sodipodi:docname="treehouse-icon-wordmark.svg"
|
||||
xml:space="preserve"
|
||||
inkscape:export-filename="safari-1024x1024.png"
|
||||
inkscape:export-xdpi="260.10001"
|
||||
inkscape:export-ydpi="260.10001"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"><sodipodi:namedview
|
||||
id="namedview301"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#000000"
|
||||
borderopacity="0.25"
|
||||
inkscape:showpageshadow="2"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pagecheckerboard="0"
|
||||
inkscape:deskcolor="#d1d1d1"
|
||||
inkscape:document-units="mm"
|
||||
showgrid="false"
|
||||
inkscape:zoom="2.1739703"
|
||||
inkscape:cx="171.11549"
|
||||
inkscape:cy="141.21628"
|
||||
inkscape:window-width="1623"
|
||||
inkscape:window-height="1371"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="layer1" /><defs
|
||||
id="defs296"><linearGradient
|
||||
id="linearGradient34140"
|
||||
inkscape:swatch="solid"><stop
|
||||
style="stop-color:#ffffff;stop-opacity:1;"
|
||||
offset="0"
|
||||
id="stop34138" /></linearGradient><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath266"><rect
|
||||
style="fill:#000000;stroke-width:0.75"
|
||||
id="rect268"
|
||||
width="300"
|
||||
height="300"
|
||||
x="0.89256281"
|
||||
y="-298.39465"
|
||||
transform="scale(1,-1)" /></clipPath><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath262"><rect
|
||||
style="fill:#000000;stroke-width:0.75"
|
||||
id="rect264"
|
||||
width="300"
|
||||
height="300"
|
||||
x="0.89256281"
|
||||
y="-298.39465"
|
||||
transform="scale(1,-1)" /></clipPath><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath258"><rect
|
||||
style="fill:#000000;stroke-width:0.75"
|
||||
id="rect260"
|
||||
width="300"
|
||||
height="300"
|
||||
x="0.89256281"
|
||||
y="-298.39465"
|
||||
transform="scale(1,-1)" /></clipPath><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath254"><rect
|
||||
style="fill:#000000;stroke-width:0.75"
|
||||
id="rect256"
|
||||
width="300"
|
||||
height="300"
|
||||
x="0.89256281"
|
||||
y="-298.39465"
|
||||
transform="scale(1,-1)" /></clipPath><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath250"><rect
|
||||
style="fill:#000000;stroke-width:0.75"
|
||||
id="rect252"
|
||||
width="300"
|
||||
height="300"
|
||||
x="0.89256281"
|
||||
y="-298.39465"
|
||||
transform="scale(1,-1)" /></clipPath><clipPath
|
||||
clipPathUnits="userSpaceOnUse"
|
||||
id="clipPath246"><rect
|
||||
style="fill:#000000;stroke-width:0.75"
|
||||
id="rect248"
|
||||
width="300"
|
||||
height="300"
|
||||
x="0.89256281"
|
||||
y="-298.39465"
|
||||
transform="scale(1,-1)" /></clipPath><mask
|
||||
maskUnits="userSpaceOnUse"
|
||||
id="mask1677"><image
|
||||
width="100"
|
||||
height="100"
|
||||
preserveAspectRatio="none"
|
||||
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAM4AAADOCAYAAAB2Hz3EAAAABHNCSVQICAgIfAhkiAAACLpJREFU eJzt3W2MXFUdx/Hv3rZS2l3a2tqUllZiaMFqAtQUiBIfXqClaEKiMRoFDFgjhJg0xhgVE40afaGS gBHxkQokRmLUGLQqvjBqlIoIAY2lVdSU1kK7LWX73DK+ODPs7HZ2985/7sydu/v9JDf7NHPu/8X+ 8j9799xzB2q1Gn1uKbCifiwHXgEsrB8LgEFgDnAOMKv+npcB83OOP1AfqwhzgbMLGqtoh4ETBY01 ApzM+drjwJGmrw8CL9Y/Hq5/PAAMA7uAvcB/gd1A3/5yDvRRcM4GLgEuA9YBFwFrKO6XWtVyFHgK 2AE8BmyrH8+XWVRDmcEZIAVlA3A1cAWpc0gTqQFPAlvrx+/I3/kKVUZwLgLeD1wHrOr1yTWtDAMP AFuAP/byxL0KTgZcC2wGruzFCTXj/AO4Hfg+cKzbJ+t2cGYDNwAfAy7s5omkur3AHfVjpFsn6WZw NgBfAdZ26wTSJPYAtwH3kK7iFaobwVkJ3AVcU/TAUsCjwE2kK3OFyQoca4BU4BMYGvWPdaTL2J+h wKu2RXWcxaSW+PYiBpO65BHg3cDTnQ5URHAuBn4CnN/pQFIPHATeA/yyk0E6naptAH6PoVF1LAQe BG7tZJBOgvNe4KektWJSlcwC7gQ+Hx0gGpxNwH2kxZRSVX0K+GrkjZHgvI90ubnIK3JSWTYDn273 Te1eHNgI/Bg7jaafW0gNIZd2gvMa4GHy3+ciVclp0r9TtuZ5cd7gLAD+DKyO1yX1vWFgPfCvqV6Y 5++UAeBeDI2mv5cDPyLdyTupPMG5EXhHpxVJFXEJ8NmpXjTVVG0Vae3ZOQUVJVXBadJ9Y3+a6AVT dZy7MTSaeWYB32WSRaGTBedq0pIaaSZ6NXDzRD+caKo2G3gcb0LTzLYfuIC0MHSMiTrODRgaaTHw iVY/aNVxMmA7KWnSTDdCWv2/v/mbrTrOtRgaqWGQFn/rtOo4fwBe34uKpIrYDbwSONX4xviOcyGG RhpvOfDW5m+MD871vatFqpQx2Wieqg0A/yFt7yRprGPAMuqbvjd3nPUYGmkic4GrGl80B2dj72uR KuVtjU+ag3NVixdKGvVSc2n8jTOXNHfzlmhpcquBnY2OczGGRspjPYxO1a4osRCpSi6H0eBcWmIh UpWsg9HgrCmxEKlKVsPoxYFhYFGp5UjVsSgDlmBopHZckAEryq5CqpiVGWnlp6T8zjU4UvuWZaT7 qiXltyTDB0NJ7RrKgKGyq5AqZtCOI7XPjiMF2HGkgKGM9NAoSfkN+gBcqX1ZRo6nT0kaYygDziq7 CqlqnKpJAQZHat/sDJhXdhVSxczPmOQ5h5Jac6omBWSkJ+xKaoNLbqQAp2pSgMGRAgZqtdppDJDU lgxDI7XN0EgBBkcKMDhSgMGRAgyOFGBwpACDIwUYHCnA4EgBBkcKMDhSgMGRAgyOFGBwpACDIwUY HCnA4EgBBkcKMDhSgMGRAgyOFGBwpACDIwUYHCnA4EgBBkcKMDhSgMGRAgyOFGBwpACDIwUYHCnA 4EgBBkcKMDhSgMGRAgyOFGBwpACDIwUYHCnA4EgBBkcKMDhSgMGRAgyOFGBwpACDIwUYHCnA4EgB BkcKMDhSgMGRAgyOFGBwpACDIwVkwOGyi5CqJgNOlV2EVDVO1aQAgyMFGBwpwOBIAQZHCjA4UoDB kQIMjhRgcKQAgyMFGBwpIAOOlF2EVDUZcLLsIqSqcaomBRgcKcDgSAEGRwowOFKAwZECDI4UYHCk AIMjBRgcKcDgSAEGRwowOFKAwZECvK1ACvBGNql9h52qSe07ZXCkgAw4UXYRUtVkwNGyi5AqZsSp mtS+0xlwqOwqpIoZyYAXyq5CqpiRDBgpuwqpYuw4UsALdhypfXYcKeBQBuwvuwqpYoYz4H9lVyFV zJ4M2F12FVLF7MmAXWVXIVXMMwO1Wg3S6oGhkouRqmJxY63azlLLkKrjOeoXBwD+VmYlUoU8BaOb dTxeYiFSlTwGo8F5tMRCpCp5GEaDsw04VV4tUmVsg9HgjAB/Ka8WqRKeZdzfOAC/KacWqTJ+AdRg bHAeLKcWqTK2Nj5p/AMUUoieAZaVUZHU506QsnEAxnacF4H7yqhIqoCfUw8NnLnp+r29rUWqjC3N XzRP1RoeAV7Xs3Kk/rcPWEHT5p2t9lW7vWflSNVwB+N2vG3VcWYD/wRW9agoqZ8dBs4ndZ2XtOo4 p4Av96AgqQq+w7jQQOuOA3AW8HfgVV0uSupnh4DVpBUDY0y0d/Rx4OPdrEiqgC/SIjQwccdp+C3w xm5UJPW5p4G1wLFWP5zqaQUfxMeAaOapAZuYIDQwdXB2ALcVWZFUAXczxaLnqaZqkML1EPCWgoqS +tlO4FKm2Bo6T3AAlpLu1zmv87qkvnUUeAPw16lemPeJbM8C78LnhWp620SO0ED+4EC61/pG0ipq abr5EnB/3hfnnao1uxn4ertvkvrYt4EPUb+7M4/Iw3PvAj4ZeJ/Uj7YAH6aN0ECs4zTcSlo1OhAd QCrZN4FbgNPtvrGTx7V/DbgOONnBGFJZPkfqNG2HBjrrOA1XAj8Ezu10IKkHRkhXz37QySBFBAdS aB4gXQOX+tUO4J3AE50O1MlUrdke4M2k5Tn+r0f9pgZ8g7QlQMehgeI6TrPXAvfgvgXqD/8mTc0e KnLQojpOsyeBy4CbSJ1IKsMIaQa0loJDA93pOM0GgY8Am4El3TyRVHcE+BbwBdJDoLqi28FpmAd8 APgo3o6t7tgH3Ela1XLGHgFF61VwGjLgTcD1pEWjg708uaadk6QdNr9H2tf5eK9O3OvgNJtHuhJ3 DbCRtAWPNJXngF8BPwN+DQyXUUSZwRlvJemiwuXAOmBN/XuaufYB20mPD9xWP7bT5rqybuin4LQy n7Q9z3nA8vqxFFhYPxYBc4AFpGngEGlDxYY5OB0syzHO3K+isWn586T9+w7WjwOkTrIX2AXsJv2z spRuksf/AQGJjDhvlYqLAAAAAElFTkSuQmCC "
|
||||
id="image1679"
|
||||
x="-142.08125"
|
||||
y="-68.527077"
|
||||
style="fill:#000000;fill-opacity:1" /></mask></defs><g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"><g
|
||||
id="g9734"
|
||||
transform="translate(-0.56747079,-0.60319788)"
|
||||
style="fill:#000000;fill-opacity:1"><path
|
||||
id="path9722"
|
||||
clip-path="url(#clipPath266)"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.04672"
|
||||
d="m 148.10952,261.04452 c -2.06649,0.0422 -4.13783,0.0165 -6.20654,-0.082 -9.03297,-0.43028 -17.4723,-1.69278 -25.21582,-3.6709 1.95723,-3.04579 3.62861,-6.19047 4.86181,-9.41895 1.0933,-2.86169 2.06819,-6.06832 2.93702,-9.39404 5.97882,1.41185 12.41455,2.26761 19.3374,2.43164 7.8224,0.18531 15.14923,-0.68835 21.97412,-2.31592 0.86115,3.28373 1.82434,6.45027 2.90479,9.27832 1.23038,3.22113 2.88552,6.3635 4.83691,9.40284 -7.87565,2.15196 -16.58364,3.58862 -25.42969,3.76904 z M 86.219871,243.54843 C 79.135999,238.83894 72.903758,233.56337 67.024558,227.68417 49.557998,210.21762 36.413306,184.82735 36.943991,150.03133 37.322903,125.20846 46.732098,105.05671 57.637839,90.085532 61.45103,84.852994 65.425291,79.543181 70.00991,75.366781 c 19.181088,-17.465513 42.57142,-30.269605 77.8667,-30.079102 15.91534,0.08478 31.16013,4.698278 43.30518,10.453125 12.23927,5.799859 22.86841,13.510545 31.35937,22.612794 8.56947,9.187033 15.97962,19.660028 21.33252,32.425782 5.2315,12.47583 9.54041,27.78413 8.74805,45.22559 -0.73166,16.10163 -4.59718,31.20723 -10.45459,43.30517 -8.99238,18.57589 -21.58401,33.19172 -38.1958,44.06397 -2.31466,-6.63911 -4.61328,-13.17798 -6.85254,-19.50586 3.44267,-2.57487 6.59968,-5.30936 9.42187,-8.13135 14.29397,-14.29395 25.48515,-34.26814 26.02735,-61.65234 0.54115,-27.4062 -11.35774,-48.68927 -25.17334,-62.504888 -14.30339,-14.304424 -34.60695,-26.239746 -61.43848,-26.239746 -27.74113,0 -48.035409,10.491046 -62.718751,25.17334 -13.699435,13.699434 -26.239746,34.165224 -26.239746,61.438474 0,27.79034 10.744976,48.07693 25.171875,62.50489 3.314031,3.31403 6.965461,6.49069 10.954102,9.43213 -2.257102,6.37839 -4.571641,12.9692 -6.903809,19.65967 z"
|
||||
transform="matrix(0.35277777,0,0,-0.35277777,-0.52260784,108.57872)" /><g
|
||||
id="g9726"
|
||||
clip-path="url(#clipPath262)"
|
||||
transform="matrix(0.35277777,0,0,-0.35277777,-0.52260784,108.57872)"
|
||||
style="fill:#000000;fill-opacity:1"><path
|
||||
id="path9724"
|
||||
style="color:#000000;fill:#000000;stroke-width:7.79528;-inkscape-stroke:none;fill-opacity:1"
|
||||
d="m 75.314109,288.61142 c 0.792777,-2.69314 1.634814,-5.51875 2.904786,-9.4292 3.288523,-10.12592 7.91432,-23.60109 12.613769,-37.04883 8.510354,-24.35287 15.714366,-44.24376 17.293946,-48.61524 l 17.83447,13.95117 c -0.34406,3.20433 -2.77605,25.20128 -8.05224,39.01172 v 0.001 c -2.69383,7.05234 -7.75838,14.01594 -13.73438,20.22656 -7.323043,7.61056 -15.978751,14.09202 -22.936522,18.52002 -2.358994,1.50129 -4.088107,2.38872 -5.923829,3.38233 z" /></g><g
|
||||
id="g9730"
|
||||
clip-path="url(#clipPath258)"
|
||||
transform="matrix(0.35277777,0,0,-0.35277777,-0.52260784,108.57872)"
|
||||
style="fill:#000000;fill-opacity:1"><path
|
||||
id="path9728"
|
||||
style="color:#000000;fill:#000000;stroke-width:7.79528;-inkscape-stroke:none;fill-opacity:1"
|
||||
d="m 214.98257,288.76376 c -0.13295,-0.0727 -0.19067,-0.0887 -0.32666,-0.16406 -3.98394,-2.20699 -9.28528,-5.56377 -14.80371,-9.75147 -11.03686,-8.37541 -22.86033,-20.19752 -27.5083,-32.36572 v -0.001 c -5.27619,-13.81042 -7.70819,-35.80734 -8.05225,-39.01172 l 17.83301,-13.95117 c 1.5796,4.37153 8.7836,24.2624 17.29394,48.61524 4.69945,13.44774 9.32378,26.92291 12.61231,37.04883 1.29043,3.97344 2.15527,6.86878 2.95166,9.58154 z" /></g><path
|
||||
d="m 173.4755,165.60476 c -0.4773,6.26252 -0.12456,18.21709 -3.41335,22.39978 -2.90046,3.68864 -10.18248,3.58187 -17.06675,3.83936 -6.86752,0.2575 -12.48631,0.65316 -17.91878,0 -5.70462,-0.6856 -11.77872,-0.0314 -14.93354,-3.41335 -3.47091,-3.72108 -3.30135,-14.73047 -3.83936,-21.97272 -1.10533,-14.86654 -0.58616,-29.35627 -13.86693,-31.14616 0.12247,-1.65486 -0.25749,-3.8132 0.21353,-5.1195 27.39054,-0.17271 56.5605,-0.48045 84.47858,0 0.3203,1.41097 0.3203,3.70852 0,5.1195 -13.07247,1.98981 -12.54074,15.70601 -13.6534,30.29309 m -40.53209,59.51852 h 24.31946 c 0.49301,-3.98695 0.0743,-8.8856 0.21249,-13.22634 12.614,-1.12731 25.68962,-0.0429 31.35969,-7.8933 4.38052,-6.06469 4.12303,-17.83295 4.90702,-28.15988 1.35027,-17.79945 0.3496,-34.36692 18.34584,-35.41154 -0.2397,-9.97523 0.50661,-21.91934 -0.42706,-30.50662 h -54.39798 c -0.62908,-4.70396 0.20307,-10.87018 -0.42706,-15.57308 -8.03671,0.1413 -16.63864,-0.28262 -24.31946,0.21353 -0.49405,4.62545 -0.0733,10.16573 -0.21353,15.14602 -18.17209,0.56523 -38.38841,-0.10153 -54.825041,0.42706 v 30.50662 c 5.375951,0.63012 10.631521,2.43153 13.438821,6.39964 3.98172,5.62506 4.12408,16.23356 4.90702,25.81208 1.21629,14.87806 0.30041,30.53069 10.66607,35.62612 6.43104,3.16109 15.7573,2.71624 25.81313,3.19982 0.75259,3.9409 -0.45951,9.84648 0.64059,13.43987"
|
||||
style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.75;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
||||
id="path9732"
|
||||
clip-path="url(#clipPath254)"
|
||||
transform="matrix(0.35277777,0,0,-0.35277777,-0.52260784,108.57872)" /></g></g></svg>
|
||||
|
|
Before Width: | Height: | Size: 2.3 KiB After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92Z"/></svg>
|
After Width: | Height: | Size: 322 B |
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 -960 960 960" width="24"><path d="m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM320-500q25 0 42.5-17.5T380-560q0-25-17.5-42.5T320-620q-25 0-42.5 17.5T260-560q0 25 17.5 42.5T320-500Zm360 0q25 0 42.5-17.5T740-560q0-25-17.5-42.5T680-620q-25 0-42.5 17.5T620-560q0 25 17.5 42.5T680-500Zm0-60Zm-360 0Z"/></svg>
|
After Width: | Height: | Size: 538 B |
|
@ -86,6 +86,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
@status = Status.create!(@params)
|
||||
attach_tags(@status)
|
||||
end
|
||||
return if Treehouse::Automod.process_status!(@status)
|
||||
|
||||
resolve_thread(@status)
|
||||
fetch_replies(@status)
|
||||
|
@ -130,6 +131,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
media_attachment_ids: attachment_ids,
|
||||
ordered_media_attachment_ids: attachment_ids,
|
||||
poll: process_poll,
|
||||
quote: process_quote,
|
||||
}
|
||||
end
|
||||
|
||||
|
@ -430,4 +432,28 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
|||
poll.reload
|
||||
retry
|
||||
end
|
||||
|
||||
def guess_quote_url
|
||||
if @object["quoteUri"] && !@object["quoteUri"].empty?
|
||||
@object["quoteUri"]
|
||||
elsif @object["quoteUrl"] && !@object["quoteUrl"].empty?
|
||||
@object["quoteUrl"]
|
||||
elsif @object["quoteURL"] && !@object["quoteURL"].empty?
|
||||
@object["quoteURL"]
|
||||
elsif @object["_misskey_quote"] && !@object["_misskey_quote"].empty?
|
||||
@object["_misskey_quote"]
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def process_quote
|
||||
url = guess_quote_url
|
||||
return nil if url.nil?
|
||||
|
||||
quote = ResolveURLService.new.call(url)
|
||||
status_from_uri(quote.uri) if quote
|
||||
rescue
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -83,11 +83,15 @@ class ActivityPub::TagManager
|
|||
# Unlisted and private statuses go out primarily to the followers collection
|
||||
# Others go out only to the people they mention
|
||||
def to(status)
|
||||
to = []
|
||||
|
||||
to << uri_for(status.quote.account) if status.quote?
|
||||
|
||||
case status.visibility
|
||||
when 'public'
|
||||
[COLLECTIONS[:public]]
|
||||
to << COLLECTIONS[:public]
|
||||
when 'unlisted', 'private'
|
||||
[account_followers_url(status.account)]
|
||||
to << account_followers_url(status.account)
|
||||
when 'direct', 'limited'
|
||||
if status.account.silenced?
|
||||
# Only notify followers if the account is locally silenced
|
||||
|
|
|
@ -21,6 +21,11 @@ class Invite < ApplicationRecord
|
|||
|
||||
COMMENT_SIZE_LIMIT = 420
|
||||
|
||||
# FIXME: make this a rails cfg key or whatev?
|
||||
TH_USE_INVITE_QUOTA = !!ENV['TH_USE_INVITE_QUOTA']
|
||||
TH_INVITE_MAX_USES = ENV.fetch('TH_INVITE_MAX_USES', 25).to_i
|
||||
TH_ACTIVE_INVITE_SLOT_QUOTA = ENV.fetch('TH_ACTIVE_INVITE_SLOT_QUOTA', 40).to_i
|
||||
|
||||
belongs_to :user, inverse_of: :invites
|
||||
has_many :users, inverse_of: :invite, dependent: nil
|
||||
|
||||
|
@ -28,6 +33,15 @@ class Invite < ApplicationRecord
|
|||
|
||||
validates :comment, length: { maximum: COMMENT_SIZE_LIMIT }
|
||||
|
||||
with_options if: :th_use_invite_quota?, unless: :created_by_moderator? do |invite|
|
||||
invite.validates :expires_at, presence: true
|
||||
invite.validate :expires_in_at_most_one_week?
|
||||
invite.validates :max_uses, presence: true
|
||||
# In Rails 6.1, numericality doesn't support :in
|
||||
invite.validates :max_uses, numericality: { only_integer: true, greater_than: 0, less_than_or_equal_to: TH_INVITE_MAX_USES }
|
||||
invite.validate :reasonable_outstanding_invite_count?
|
||||
end
|
||||
|
||||
before_validation :set_code
|
||||
|
||||
def valid_for_use?
|
||||
|
@ -42,4 +56,31 @@ class Invite < ApplicationRecord
|
|||
break if Invite.find_by(code: code).nil?
|
||||
end
|
||||
end
|
||||
|
||||
def created_by_moderator?
|
||||
self.user.can?(:manage_invites)
|
||||
end
|
||||
|
||||
def th_use_invite_quota?
|
||||
TH_USE_INVITE_QUOTA
|
||||
end
|
||||
|
||||
def expires_in_at_most_one_week?
|
||||
return if self.expires_in.to_i.seconds <= 1.week
|
||||
# FIXME: Localize this
|
||||
errors.add(:expires_in, 'must expire within one week')
|
||||
end
|
||||
|
||||
def reasonable_outstanding_invite_count?
|
||||
valid_invites = self.user.invites.filter { |i| i.valid_for_use? }
|
||||
count = valid_invites.sum do |i|
|
||||
next i.max_uses unless i.max_uses.nil?
|
||||
|
||||
errors.add(:max_uses, 'must not have any active unlimited-use invites')
|
||||
return
|
||||
end
|
||||
|
||||
return if count + max_uses <= TH_ACTIVE_INVITE_SLOT_QUOTA
|
||||
errors.add(:max_uses, "must not exceed active invite slot quota of #{TH_ACTIVE_INVITE_SLOT_QUOTA}")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
# edited_at :datetime
|
||||
# trendable :boolean
|
||||
# ordered_media_attachment_ids :bigint(8) is an Array
|
||||
# quote_id :bigint(8)
|
||||
#
|
||||
|
||||
class Status < ApplicationRecord
|
||||
|
@ -66,6 +67,7 @@ class Status < ApplicationRecord
|
|||
with_options class_name: 'Status', optional: true do
|
||||
belongs_to :thread, foreign_key: 'in_reply_to_id', inverse_of: :replies
|
||||
belongs_to :reblog, foreign_key: 'reblog_of_id', inverse_of: :reblogs
|
||||
belongs_to :quote, foreign_key: 'quote_id', inverse_of: :quoted
|
||||
end
|
||||
|
||||
has_many :favourites, inverse_of: :status, dependent: :destroy
|
||||
|
@ -76,6 +78,7 @@ class Status < ApplicationRecord
|
|||
has_many :mentions, dependent: :destroy, inverse_of: :status
|
||||
has_many :mentioned_accounts, through: :mentions, source: :account, class_name: 'Account'
|
||||
has_many :media_attachments, dependent: :nullify
|
||||
has_many :quoted, foreign_key: 'quote_id', class_name: 'Status', inverse_of: :quote, dependent: :nullify
|
||||
|
||||
# The `dependent` option is enabled by the initial `mentions` association declaration
|
||||
has_many :active_mentions, -> { active }, class_name: 'Mention', inverse_of: :status # rubocop:disable Rails/HasManyOrHasOneDependent
|
||||
|
@ -102,6 +105,7 @@ class Status < ApplicationRecord
|
|||
validates :reblog, uniqueness: { scope: :account }, if: :reblog?
|
||||
validates :visibility, exclusion: { in: %w(direct limited) }, if: :reblog?
|
||||
validates :content_type, inclusion: { in: %w(text/plain text/markdown text/html) }, allow_nil: true
|
||||
validates :quote_visibility, inclusion: { in: %w(public unlisted) }, if: :quote?
|
||||
|
||||
accepts_nested_attributes_for :poll
|
||||
|
||||
|
@ -178,6 +182,17 @@ class Status < ApplicationRecord
|
|||
account: [:account_stat, user: :role],
|
||||
active_mentions: :account,
|
||||
],
|
||||
quote: [
|
||||
:application,
|
||||
:tags,
|
||||
:media_attachments,
|
||||
:conversation,
|
||||
:status_stat,
|
||||
:preloadable_poll,
|
||||
preview_cards_status: [:preview_card],
|
||||
account: [:account_stat, :user],
|
||||
active_mentions: { account: :account_stat },
|
||||
],
|
||||
thread: :account
|
||||
|
||||
delegate :domain, to: :account, prefix: true
|
||||
|
@ -212,6 +227,14 @@ class Status < ApplicationRecord
|
|||
!reblog_of_id.nil?
|
||||
end
|
||||
|
||||
def quote?
|
||||
!quote_id.nil? && quote
|
||||
end
|
||||
|
||||
def quote_visibility
|
||||
quote&.visibility
|
||||
end
|
||||
|
||||
def within_realtime_window?
|
||||
created_at >= REAL_TIME_WINDOW.ago
|
||||
end
|
||||
|
@ -284,7 +307,7 @@ class Status < ApplicationRecord
|
|||
fields = [spoiler_text, text]
|
||||
fields += preloadable_poll.options unless preloadable_poll.nil?
|
||||
|
||||
@emojis = CustomEmoji.from_text(fields.join(' '), account.domain)
|
||||
@emojis = CustomEmoji.from_text(fields.join(' '), account.domain) + (quote? ? CustomEmoji.from_text([quote.spoiler_text, quote.text].join(' '), quote.account.domain) : [])
|
||||
end
|
||||
|
||||
def ordered_media_attachments
|
||||
|
|
|
@ -62,6 +62,10 @@ class StatusEdit < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
def quote?
|
||||
status.quote?
|
||||
end
|
||||
|
||||
def proper
|
||||
self
|
||||
end
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
||||
include FormattingHelper
|
||||
|
||||
context_extensions :atom_uri, :conversation, :sensitive, :voters_count, :direct_message
|
||||
context_extensions :atom_uri, :conversation, :sensitive, :voters_count, :direct_message, :quote_uri
|
||||
|
||||
attributes :id, :type, :summary,
|
||||
:in_reply_to, :published, :url,
|
||||
|
@ -11,6 +11,8 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
|||
:atom_uri, :in_reply_to_atom_uri,
|
||||
:conversation
|
||||
|
||||
attribute :quote_uri, if: -> { object.quote? }
|
||||
|
||||
attribute :content
|
||||
attribute :content_map, if: :language?
|
||||
attribute :updated, if: :edited?
|
||||
|
@ -150,6 +152,10 @@ class ActivityPub::NoteSerializer < ActivityPub::Serializer
|
|||
end
|
||||
end
|
||||
|
||||
def quote_uri
|
||||
ActivityPub::TagManager.instance.uri_for(object.quote) if object.quote?
|
||||
end
|
||||
|
||||
def local?
|
||||
object.account.local?
|
||||
end
|
||||
|
|
|
@ -202,3 +202,13 @@ class REST::StatusSerializer < ActiveModel::Serializer
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
class REST::QuoteStatusSerializer < REST::StatusSerializer
|
||||
attribute :quote do
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
class REST::StatusSerializer < ActiveModel::Serializer
|
||||
belongs_to :quote, serializer: REST::QuoteStatusSerializer
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'digest'
|
||||
|
||||
class ActivityPub::ProcessAccountService < BaseService
|
||||
include JsonLdHelper
|
||||
include DomainControlHelper
|
||||
|
@ -90,6 +92,9 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
set_immediate_protocol_attributes!
|
||||
set_fetchable_key! unless @account.suspended? && @account.suspension_origin_local?
|
||||
set_immediate_attributes! unless @account.suspended?
|
||||
|
||||
Treehouse::Automod.process_account!(@account)
|
||||
|
||||
set_fetchable_attributes! unless @options[:only_key] || @account.suspended?
|
||||
|
||||
@account.save_with_optional_media!
|
||||
|
|
|
@ -78,7 +78,7 @@ class FetchLinkCardService < BaseService
|
|||
@status.text.scan(URL_PATTERN).map { |array| Addressable::URI.parse(array[1]).normalize }
|
||||
else
|
||||
document = Nokogiri::HTML(@status.text)
|
||||
links = document.css('a')
|
||||
links = document.css(':not(.quote-inline) > a')
|
||||
|
||||
links.filter_map { |a| Addressable::URI.parse(a['href']) unless skip_link?(a) }.filter_map(&:normalize)
|
||||
end
|
||||
|
|
|
@ -31,6 +31,7 @@ class PostStatusService < BaseService
|
|||
# @option [String] :idempotency Optional idempotency key
|
||||
# @option [Boolean] :with_rate_limit
|
||||
# @option [Enumerable] :allowed_mentions Optional array of expected mentioned account IDs, raises `UnexpectedMentionsError` if unexpected accounts end up in mentions
|
||||
# @option [String] :quote_id
|
||||
# @return [Status]
|
||||
def call(account, options = {})
|
||||
@account = account
|
||||
|
@ -210,6 +211,7 @@ class PostStatusService < BaseService
|
|||
application: @options[:application],
|
||||
content_type: @options[:content_type] || @account.user&.setting_default_content_type,
|
||||
rate_limit: @options[:with_rate_limit],
|
||||
quote_id: @options[:quote_id],
|
||||
}.compact
|
||||
end
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ class ReportService < BaseService
|
|||
end
|
||||
|
||||
def notify_staff!
|
||||
return if @options[:th_skip_notify_staff]
|
||||
return if @report.unresolved_siblings?
|
||||
|
||||
User.those_who_can(:manage_reports).includes(:account).find_each do |u|
|
||||
|
@ -65,6 +66,7 @@ class ReportService < BaseService
|
|||
end
|
||||
|
||||
def forward?
|
||||
return false if @options[:th_skip_forward]
|
||||
!@target_account.local? && ActiveModel::Type::Boolean.new.cast(@options[:forward])
|
||||
end
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
|
||||
.fields-row
|
||||
.fields-row__column.fields-row__column-6.fields-group
|
||||
= form.input :max_uses, wrapper: :with_label, collection: invites_max_uses_options, label_method: ->(num) { I18n.t('invites.max_uses', count: num) }, prompt: I18n.t('invites.max_uses_prompt')
|
||||
= form.input :max_uses, wrapper: :with_label, collection: invites_max_uses_options, label_method: ->(num) { I18n.t('invites.max_uses', count: num) }, prompt: I18n.t('invites.max_uses_prompt'), include_blank: false, include_hidden: false
|
||||
.fields-row__column.fields-row__column-6.fields-group
|
||||
= form.input :expires_in, wrapper: :with_label, collection: invites_expires_options.map(&:to_i), label_method: ->(i) { I18n.t("invites.expires_in.#{i}") }, prompt: I18n.t('invites.expires_in_prompt')
|
||||
= form.input :expires_in, wrapper: :with_label, collection: invites_expires_options.map(&:to_i), label_method: ->(i) { I18n.t("invites.expires_in.#{i}") }, prompt: I18n.t('invites.expires_in_prompt'), include_blank: false, include_hidden: false
|
||||
|
||||
.fields-group
|
||||
= form.input :autofollow, wrapper: :with_label
|
||||
|
|
|
@ -15,7 +15,11 @@
|
|||
|
||||
= account_action_button(status.account)
|
||||
|
||||
- if status.quote?
|
||||
= render partial: "statuses/quote_status", locals: {status: status.quote}
|
||||
|
||||
.status__content.emojify{ data: ({ spoiler: current_account&.user&.setting_expand_spoilers ? 'expanded' : 'folded' } if status.spoiler_text?) }<
|
||||
|
||||
- if status.spoiler_text?
|
||||
%p<
|
||||
%span.p-summary> #{prerender_custom_emojis(h(status.spoiler_text), status.emojis)}
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
.status.quote-status{ dataurl: ActivityPub::TagManager.instance.url_for(status) }
|
||||
= link_to ActivityPub::TagManager.instance.url_for(status.account), class: 'status__display-name u-url', target: stream_link_target, rel: 'noopener noreferrer' do
|
||||
.status__avatar
|
||||
%div
|
||||
- if prefers_autoplay?
|
||||
= image_tag status.account.avatar_original_url, alt: '', class: 'u-photo account__avatar'
|
||||
- else
|
||||
= image_tag status.account.avatar_static_url, alt: '', class: 'u-photo account__avatar'
|
||||
%span.display-name
|
||||
%bdi
|
||||
%strong.display-name__html.p-name.emojify= display_name(status.account, custom_emojify: true, autoplay: prefers_autoplay?)
|
||||
|
||||
%span.display-name__account
|
||||
= acct(status.account)
|
||||
= fa_icon('lock') if status.account.locked?
|
||||
|
||||
.status__content.emojify{ data: ({ spoiler: current_account&.user&.setting_expand_spoilers ? 'expanded' : 'folded' } if status.spoiler_text?) }<
|
||||
|
||||
- if status.spoiler_text?
|
||||
%p<
|
||||
%span.p-summary> #{prerender_custom_emojis(h(status.spoiler_text), status.emojis)}
|
||||
%button.status__content__spoiler-link= t('statuses.show_more')
|
||||
.e-content{ lang: status.language }<
|
||||
= prerender_custom_emojis(status_content_format(status), status.emojis)
|
||||
|
||||
- if status.preloadable_poll
|
||||
= render_poll_component(status)
|
||||
|
||||
- if !status.ordered_media_attachments.empty?
|
||||
- if status.ordered_media_attachments.first.video?
|
||||
= render_video_component(status, width: 610, height: 343)
|
||||
- elsif status.ordered_media_attachments.first.audio?
|
||||
= render_audio_component(status, width: 610, height: 343)
|
||||
- else
|
||||
= render_media_gallery_component(status, height: 343)
|
||||
- elsif status.preview_card
|
||||
= render_card_component(status)
|
||||
|
|
@ -27,7 +27,12 @@
|
|||
%span.display-name__account
|
||||
= acct(status.account)
|
||||
= fa_icon('lock') if status.account.locked?
|
||||
|
||||
- if status.quote?
|
||||
= render partial: "statuses/quote_status", locals: {status: status.quote}
|
||||
|
||||
.status__content.emojify{ data: ({ spoiler: current_account&.user&.setting_expand_spoilers ? 'expanded' : 'folded' } if status.spoiler_text?) }<
|
||||
|
||||
- if status.spoiler_text?
|
||||
%p<
|
||||
%span.p-summary> #{prerender_custom_emojis(h(status.spoiler_text), status.emojis)}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eux
|
||||
|
||||
export NODE_ENV=production
|
||||
export RAILS_ENV=production
|
||||
|
||||
bundle exec rake assets:clobber
|
||||
bundle exec rake assets:precompile
|
||||
|
||||
export RAILS_ENV=test
|
||||
bundle exec rake spec
|
|
@ -56,6 +56,10 @@ require_relative '../lib/active_record/with_recursive'
|
|||
require_relative '../lib/arel/union_parenthesizing'
|
||||
require_relative '../lib/simple_navigation/item_extensions'
|
||||
|
||||
require_relative '../lib/treehouse/automod'
|
||||
|
||||
Dotenv::Railtie.load
|
||||
|
||||
Bundler.require(:pam_authentication) if ENV['PAM_ENABLED'] == 'true'
|
||||
|
||||
module Mastodon
|
||||
|
@ -121,5 +125,15 @@ module Mastodon
|
|||
Devise::FailureApp.include AbstractController::Callbacks
|
||||
Devise::FailureApp.include Localized
|
||||
end
|
||||
|
||||
config.x.th_automod.automod_account_username = ENV['TH_STAFF_ACCOUNT']
|
||||
config.x.th_automod.account_service_heuristic_auto_suspend_active = ENV.fetch('TH_ACCOUNT_SERVICE_HEURISTIC_AUTO_SUSPEND', '') == 'that-one-spammer'
|
||||
config.x.th_automod.mention_spam_heuristic_auto_limit_active = ENV.fetch('TH_MENTION_SPAM_HEURISTIC_AUTO_LIMIT_ACTIVE', '') == 'can-spam'
|
||||
config.x.th_automod.mention_spam_threshold =
|
||||
begin
|
||||
value = ENV.fetch('TH_MENTION_SPAM_THRESHOLD', '0').to_i
|
||||
value == 0 ? Float::INFINITY : value
|
||||
end
|
||||
config.x.th_automod.min_account_age_threshold = ENV.fetch('TH_MIN_ACCOUNT_AGE_THRESHOLD', '2').to_i.days
|
||||
end
|
||||
end
|
||||
|
|
|
@ -36,7 +36,7 @@ Rails.application.config.content_security_policy do |p|
|
|||
p.frame_ancestors :none
|
||||
p.font_src :self, assets_host
|
||||
p.img_src :self, :data, :blob, *media_hosts
|
||||
p.style_src :self, assets_host
|
||||
p.style_src :self, :unsafe_inline, assets_host
|
||||
p.media_src :self, :data, *media_hosts
|
||||
p.frame_src :self, :https
|
||||
p.manifest_src :self, assets_host
|
||||
|
@ -58,7 +58,7 @@ Rails.application.config.content_security_policy do |p|
|
|||
p.script_src :self, :unsafe_inline, :unsafe_eval, assets_host
|
||||
else
|
||||
p.connect_src :self, :data, :blob, *media_hosts, Rails.configuration.x.streaming_api_base_url
|
||||
p.script_src :self, assets_host, "'wasm-unsafe-eval'"
|
||||
p.script_src :self, assets_host, "'wasm-unsafe-eval'", :unsafe_eval
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
require 'doorkeeper/grape/authorization_decorator'
|
||||
|
||||
class Rack::Attack
|
||||
TH_DEACTIVATE_THROTTLES = !!ENV['TH_DEACTIVATE_THROTTLES']
|
||||
TH_DEACTIVATE_DANGEROUS_THROTTLES = !!ENV['TH_DEACTIVATE_DANGEROUS_THROTTLES']
|
||||
|
||||
class Request
|
||||
def authenticated_token
|
||||
return @authenticated_token if defined?(@authenticated_token)
|
||||
|
@ -76,7 +79,7 @@ class Rack::Attack
|
|||
|
||||
throttle('throttle_unauthenticated_api', limit: 300, period: 5.minutes) do |req|
|
||||
req.throttleable_remote_ip if req.api_request? && req.unauthenticated?
|
||||
end
|
||||
end unless TH_DEACTIVATE_THROTTLES
|
||||
|
||||
throttle('throttle_api_media', limit: 30, period: 30.minutes) do |req|
|
||||
req.authenticated_user_id if req.post? && req.path.match?(%r{\A/api/v\d+/media\z}i)
|
||||
|
@ -84,7 +87,7 @@ class Rack::Attack
|
|||
|
||||
throttle('throttle_media_proxy', limit: 30, period: 10.minutes) do |req|
|
||||
req.throttleable_remote_ip if req.path.start_with?('/media_proxy')
|
||||
end
|
||||
end unless TH_DEACTIVATE_THROTTLES
|
||||
|
||||
throttle('throttle_api_sign_up', limit: 5, period: 30.minutes) do |req|
|
||||
req.throttleable_remote_ip if req.post? && req.path == '/api/v1/accounts'
|
||||
|
@ -96,7 +99,7 @@ class Rack::Attack
|
|||
|
||||
throttle('throttle_unauthenticated_paging', limit: 300, period: 15.minutes) do |req|
|
||||
req.throttleable_remote_ip if req.paging_request? && req.unauthenticated?
|
||||
end
|
||||
end unless TH_DEACTIVATE_THROTTLES
|
||||
|
||||
API_DELETE_REBLOG_REGEX = %r{\A/api/v1/statuses/\d+/unreblog\z}
|
||||
API_DELETE_STATUS_REGEX = %r{\A/api/v1/statuses/\d+\z}
|
||||
|
@ -115,7 +118,7 @@ class Rack::Attack
|
|||
|
||||
throttle('throttle_password_resets/ip', limit: 25, period: 5.minutes) do |req|
|
||||
req.throttleable_remote_ip if req.post? && req.path_matches?('/auth/password')
|
||||
end
|
||||
end unless TH_DEACTIVATE_DANGEROUS_THROTTLES
|
||||
|
||||
throttle('throttle_password_resets/email', limit: 5, period: 30.minutes) do |req|
|
||||
req.params.dig('user', 'email').presence if req.post? && req.path_matches?('/auth/password')
|
||||
|
@ -135,7 +138,7 @@ class Rack::Attack
|
|||
|
||||
throttle('throttle_login_attempts/ip', limit: 25, period: 5.minutes) do |req|
|
||||
req.throttleable_remote_ip if req.post? && req.path_matches?('/auth/sign_in')
|
||||
end
|
||||
end unless TH_DEACTIVATE_DANGEROUS_THROTTLES
|
||||
|
||||
throttle('throttle_login_attempts/email', limit: 25, period: 1.hour) do |req|
|
||||
req.session[:attempt_user_id] || req.params.dig('user', 'email').presence if req.post? && req.path_matches?('/auth/sign_in')
|
||||
|
|
|
@ -107,7 +107,7 @@ en:
|
|||
imports:
|
||||
data: CSV file exported from another Mastodon server
|
||||
invite_request:
|
||||
text: This will help us review your application
|
||||
text: "Be sure to provide at least one link to an established account on another social website: GitHub, Twitter, or a personal blog or website. This will help us review your request in a timely manner."
|
||||
ip_block:
|
||||
comment: Optional. Remember why you added this rule.
|
||||
expires_in: IP addresses are a finite resource, they are sometimes shared and often change hands. For this reason, indefinite IP blocks are not recommended.
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddQuoteIdToStatuses < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :statuses, :quote_id, :bigint, null: true, default: nil
|
||||
end
|
||||
end
|
|
@ -0,0 +1,7 @@
|
|||
class AddIndexToStatusesQuoteId < ActiveRecord::Migration[6.1]
|
||||
disable_ddl_transaction!
|
||||
|
||||
def change
|
||||
add_index :statuses, :quote_id, algorithm: :concurrently
|
||||
end
|
||||
end
|
|
@ -1087,6 +1087,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_07_094856) do
|
|||
t.datetime "edited_at", precision: nil
|
||||
t.boolean "trendable"
|
||||
t.bigint "ordered_media_attachment_ids", array: true
|
||||
t.bigint "quote_id"
|
||||
t.index ["account_id", "id", "visibility", "updated_at"], name: "index_statuses_20190820", order: { id: :desc }, where: "(deleted_at IS NULL)"
|
||||
t.index ["account_id"], name: "index_statuses_on_account_id"
|
||||
t.index ["deleted_at"], name: "index_statuses_on_deleted_at", where: "(deleted_at IS NOT NULL)"
|
||||
|
@ -1094,6 +1095,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_07_094856) do
|
|||
t.index ["id", "account_id"], name: "index_statuses_public_20200119", order: { id: :desc }, where: "((deleted_at IS NULL) AND (visibility = 0) AND (reblog_of_id IS NULL) AND ((NOT reply) OR (in_reply_to_account_id = account_id)))"
|
||||
t.index ["in_reply_to_account_id"], name: "index_statuses_on_in_reply_to_account_id", where: "(in_reply_to_account_id IS NOT NULL)"
|
||||
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id", where: "(in_reply_to_id IS NOT NULL)"
|
||||
t.index ["quote_id"], name: "index_statuses_on_quote_id"
|
||||
t.index ["reblog_of_id", "account_id"], name: "index_statuses_on_reblog_of_id_and_account_id"
|
||||
t.index ["uri"], name: "index_statuses_on_uri", unique: true, opclass: :text_pattern_ops, where: "(uri IS NOT NULL)"
|
||||
end
|
||||
|
|
|
@ -1,10 +1,29 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'pathname'
|
||||
|
||||
def setup_redis_env_url(prefix = nil, defaults = true)
|
||||
prefix = "#{prefix.to_s.upcase}_" unless prefix.nil?
|
||||
prefix = '' if prefix.nil?
|
||||
redis_url_key = "#{prefix}REDIS_URL"
|
||||
|
||||
return if ENV["#{prefix}REDIS_URL"].present?
|
||||
if ENV[redis_url_key].present?
|
||||
conn = +ENV["#{prefix}REDIS_URL"].sub(/redis:\/\//i, '')
|
||||
|
||||
# Strip any prefixing `unix://`
|
||||
unix = !conn.sub!(/^unix:\/\//i, '').nil?
|
||||
# Strip any prefixing `./`
|
||||
unix |= conn.sub!(/^(\.\/)+/, '')
|
||||
unix |= conn.start_with?('/')
|
||||
|
||||
if unix
|
||||
pn = Pathname.new(conn)
|
||||
pn = Pathname.getwd / pn if pn.relative?
|
||||
ENV[redis_url_key] = "unix://#{pn}"
|
||||
end
|
||||
|
||||
return
|
||||
end
|
||||
|
||||
password = ENV.fetch("#{prefix}REDIS_PASSWORD") { '' if defaults }
|
||||
host = ENV.fetch("#{prefix}REDIS_HOST") { 'localhost' if defaults }
|
||||
|
|
|
@ -25,7 +25,7 @@ module Mastodon
|
|||
end
|
||||
|
||||
def build_metadata
|
||||
['glitch', ENV.fetch('MASTODON_VERSION_METADATA', nil)].compact_blank.join('.')
|
||||
['glitch.th', ENV.fetch('MASTODON_VERSION_METADATA', nil)].compact_blank.join('.')
|
||||
end
|
||||
|
||||
def to_a
|
||||
|
@ -44,25 +44,42 @@ module Mastodon
|
|||
end
|
||||
|
||||
def repository
|
||||
ENV.fetch('GITHUB_REPOSITORY', 'glitch-soc/mastodon')
|
||||
@repository ||= ENV.fetch('GIT_REPOSITORY', false) || ENV.fetch('GITHUB_REPOSITORY', false) || 'treehouse/mastodon'
|
||||
end
|
||||
|
||||
def source_base_url
|
||||
ENV.fetch('SOURCE_BASE_URL', "https://github.com/#{repository}")
|
||||
@source_base_url ||=
|
||||
begin
|
||||
base = ENV['GITHUB_REPOSITORY'] ? 'https://github.com' : 'https://gitea.treehouse.systems'
|
||||
ENV.fetch('SOURCE_BASE_URL', "#{base}/#{repository}")
|
||||
end
|
||||
end
|
||||
|
||||
# specify git tag or commit hash here
|
||||
def source_tag
|
||||
ENV.fetch('SOURCE_TAG', nil)
|
||||
@source_tag ||=
|
||||
begin
|
||||
tag = ENV.fetch('SOURCE_TAG', nil)
|
||||
return if tag.nil? || tag.empty?
|
||||
tag
|
||||
end
|
||||
end
|
||||
|
||||
def source_url
|
||||
if source_tag
|
||||
"#{source_base_url}/tree/#{source_tag}"
|
||||
@source_url ||=
|
||||
begin
|
||||
if source_tag && source_base_url =~ /gitea/
|
||||
suffix = if !tag[/\H/]
|
||||
"commit/#{source_tag}"
|
||||
else
|
||||
"branch/#{source_tag}"
|
||||
end
|
||||
"#{source_base_url}/#{suffix}"
|
||||
else
|
||||
source_base_url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def user_agent
|
||||
@user_agent ||= "#{HTTP::Request::USER_AGENT} (Mastodon/#{Version}; +http#{Rails.configuration.x.use_https ? 's' : ''}://#{Rails.configuration.x.web_domain}/)"
|
||||
|
|
|
@ -31,6 +31,7 @@ class Sanitize
|
|||
next true if /^(h|p|u|dt|e)-/.match?(e) # microformats classes
|
||||
next true if /^(mention|hashtag)$/.match?(e) # semantic classes
|
||||
next true if /^(ellipsis|invisible)$/.match?(e) # link formatting classes
|
||||
next true if /^quote-inline$/.match?(e) # quote inline classes
|
||||
end
|
||||
|
||||
node['class'] = class_list.join(' ')
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'pathname'
|
||||
|
||||
DATA_DIR = Pathname.new('data')
|
||||
POSTGRES_DIR = DATA_DIR / 'postgres'
|
||||
POSTGRES_CONF_FILE = POSTGRES_DIR / 'postgresql.conf'
|
||||
POSTGRES_SOCKET_FILE = POSTGRES_DIR / '.s.PGSQL.5432'
|
||||
POSTGRES_PID_FILE = POSTGRES_DIR / 'postmaster.pid'
|
||||
REDIS_DIR = DATA_DIR / 'redis'
|
||||
REDIS_PID_FILE = REDIS_DIR / 'redis-dev.pid'
|
||||
|
||||
def divider
|
||||
puts '=========='
|
||||
end
|
||||
|
||||
def get_pid(pid_file)
|
||||
return false unless File.file?(pid_file)
|
||||
pid = File.read(pid_file).to_i
|
||||
|
||||
Process.kill(0, pid)
|
||||
pid
|
||||
rescue Errno::ESRCH
|
||||
nil
|
||||
end
|
||||
|
||||
def postgres_running?
|
||||
get_pid POSTGRES_PID_FILE
|
||||
end
|
||||
|
||||
directory REDIS_DIR.to_s
|
||||
|
||||
namespace :deps do
|
||||
task start: ['postgres:start', 'redis:start']
|
||||
task stop: ['postgres:stop', 'redis:stop']
|
||||
|
||||
namespace :postgres do
|
||||
namespace :setup do
|
||||
task all: [POSTGRES_DIR.to_s]
|
||||
|
||||
file POSTGRES_DIR.to_s do
|
||||
if POSTGRES_CONF_FILE.exist?
|
||||
puts 'Postgres conf exists, skipping initdb'
|
||||
next
|
||||
end
|
||||
sh %(printf '%s\\n' pg_ctl -D data/postgres initdb -o '-U mastodon --auth-host=trust')
|
||||
end
|
||||
|
||||
task configure: [POSTGRES_DIR.to_s] do
|
||||
next if File.foreach(POSTGRES_CONF_FILE).detect? { |line| line == /^unix_socket_directories = \.\s*$/ }
|
||||
|
||||
POSTGRES_CONF_FILE.open('at') do |f|
|
||||
f.write("\n", PG_SOCKET_DIRECTORIES_LINE, "\n")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
task start: ['setup:all'] do
|
||||
if (pid = get_pid POSTGRES_PID_FILE)
|
||||
puts "Postgres is running (pid #{pid})!"
|
||||
next
|
||||
end
|
||||
|
||||
puts 'Starting postgres...'
|
||||
divider
|
||||
sh %(pg_ctl -D ./data/postgres start)
|
||||
divider
|
||||
end
|
||||
|
||||
task :stop do
|
||||
unless (pid = get_pid POSTGRES_PID_FILE)
|
||||
puts "Postgres isn't running!"
|
||||
next
|
||||
end
|
||||
|
||||
puts "Stopping Postgres (pid #{pid})..."
|
||||
sh %(pg_ctl -D ./data/postgres stop)
|
||||
divider
|
||||
end
|
||||
end
|
||||
|
||||
namespace :redis do
|
||||
task init: [REDIS_DIR.to_s] do
|
||||
end
|
||||
|
||||
task start: [:init] do
|
||||
if (pid = get_pid REDIS_PID_FILE)
|
||||
puts "Redis is running (pid #{pid})!"
|
||||
next
|
||||
end
|
||||
|
||||
puts 'Starting redis...'
|
||||
divider
|
||||
sh %(redis-server redis-dev.conf)
|
||||
divider
|
||||
end
|
||||
|
||||
task :stop do
|
||||
unless (pid = get_pid REDIS_PID_FILE)
|
||||
puts "Redis isn't running!"
|
||||
next
|
||||
end
|
||||
|
||||
puts "Stopping Redis (pid #{pid})..."
|
||||
divider
|
||||
Process.kill(:TERM, pid)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,151 @@
|
|||
module Treehouse
|
||||
module Automod
|
||||
COMMENT_HEADER = <<~EOS
|
||||
Tracking Report - automatically created by TreehouseAutomod
|
||||
EOS
|
||||
|
||||
WARNING_TEXT = <<~EOS
|
||||
Tracking Infraction - automatically created by TreehouseAutomod
|
||||
EOS
|
||||
|
||||
def self.silence_with_tracking_report!(account, status_ids: [], explanation: "")
|
||||
account.save!
|
||||
|
||||
self.file_tracking_report!(account, status_ids: status_ids, type: 'silence') unless account.suspension_origin == "local"
|
||||
end
|
||||
|
||||
def self.suspend_with_tracking_report!(account, status_ids: [], explanation: "")
|
||||
account.save!
|
||||
|
||||
self.file_tracking_report!(account, status_ids: status_ids, type: 'suspend') unless account.suspension_origin == "local"
|
||||
end
|
||||
|
||||
def self.file_tracking_report!(target_account, status_ids: [], explanation: "", type: 'suspend')
|
||||
reporter = self.staff_account
|
||||
return if reporter.nil?
|
||||
|
||||
# status_ids is broken because of validation
|
||||
report = ReportService.new.call(
|
||||
reporter,
|
||||
target_account,
|
||||
{
|
||||
status_ids: status_ids,
|
||||
comment: explanation.blank? ? COMMENT_HEADER : "#{COMMENT_HEADER}\n\n#{EXPLANATION}",
|
||||
th_skip_notify_staff: true,
|
||||
th_skip_forward: true,
|
||||
}
|
||||
)
|
||||
report.save!
|
||||
report.assign_to_self!(reporter)
|
||||
|
||||
account_action = Admin::AccountAction.new(
|
||||
type: type,
|
||||
report_id: report.id,
|
||||
target_account: target_account,
|
||||
current_account: reporter,
|
||||
send_email_notification: false,
|
||||
text: WARNING_TEXT,
|
||||
)
|
||||
account_action.save!
|
||||
|
||||
Admin::ActionLog.create(
|
||||
account: reporter,
|
||||
action: account_action,
|
||||
target: target_account,
|
||||
)
|
||||
|
||||
report.resolve!(reporter)
|
||||
end
|
||||
|
||||
def self.staff_account
|
||||
username = Rails.configuration.x.th_automod.automod_account_username
|
||||
Account.find_local(username) unless username.blank?
|
||||
end
|
||||
|
||||
def self.process_status!(status)
|
||||
ActivityPubActivityCreateExt.process!(status)
|
||||
end
|
||||
|
||||
def self.process_account!(account)
|
||||
AccountServiceExt.process!(account)
|
||||
end
|
||||
|
||||
module ActivityPubActivityCreateExt
|
||||
EXPLANATION = <<~EOS
|
||||
This account was automatically suspended by TreehouseAutomod, an unsupported feature.
|
||||
|
||||
Currently, the account-only heuristic should only automatically suspend accounts with one specific username and display name.
|
||||
|
||||
If this action is unexpected, please unset TH_MENTION_SPAM_HEURISTIC_AUTO_LIMIT_ACTIVE.
|
||||
EOS
|
||||
|
||||
def self.is_spam?(status)
|
||||
return false unless Rails.configuration.x.th_automod.mention_spam_heuristic_auto_limit_active
|
||||
account = status.account
|
||||
minimal_effort = account.note.blank? && account.avatar_remote_url.blank? && account.header_remote_url.blank?
|
||||
return false if (account.local? ||
|
||||
account.local_followers_count > 0 ||
|
||||
!minimal_effort)
|
||||
|
||||
# minimal effort account, check mentions and account-known age
|
||||
has_mention_spam = status.mentions.size >= Rails.configuration.x.th_automod.mention_spam_threshold
|
||||
is_new_account = account.created_at > (Time.now - Rails.configuration.x.th_automod.min_account_age_threshold)
|
||||
|
||||
has_mention_spam && is_new_account
|
||||
end
|
||||
|
||||
# check if the status should be considered spam
|
||||
# @return true if the status was reported and the account was infracted
|
||||
def self.process!(status)
|
||||
return false unless self.is_spam?(status)
|
||||
return true if status.account.silenced?
|
||||
|
||||
Automod.silence_with_tracking_report!(status.account, explanation: EXPLANATION)
|
||||
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
module AccountServiceExt
|
||||
# hardcoded for now
|
||||
# md5 because they don't deserve more mentions
|
||||
HEURISTIC_NAMES = {
|
||||
"0116a9deace3289b7092e945ef5ca0a5" => Set["57d3d0b932cc9cd01be6b2f4e82c1a4a"],
|
||||
}
|
||||
# probably mathematically impossible to collide, but just in case...
|
||||
HEURISTIC_MAX_LEN = 16
|
||||
|
||||
EXPLANATION = <<~EOS
|
||||
This account was automatically suspended by TreehouseAutomod, an unsupported feature.
|
||||
|
||||
Currently, the account-only heuristic should only automatically suspend accounts with one specific username and display name.
|
||||
|
||||
If this action is unexpected, please unset TH_HEURISTIC_AUTO_SUSPEND.
|
||||
EOS
|
||||
|
||||
# @return true if the account was infracted
|
||||
def self.process!(account)
|
||||
return false unless heuristic_auto_suspend?(account)
|
||||
|
||||
Automod.suspend_with_tracking_report!(account, explanation: EXPLANATION) unless account.suspension_origin == "local"
|
||||
|
||||
true
|
||||
end
|
||||
|
||||
def self.matches_evil_hash?(account)
|
||||
username_md5 = Digest::MD5.hexdigest(account.username)
|
||||
display_name_md5 = Digest::MD5.hexdigest(account.display_name)
|
||||
|
||||
HEURISTIC_NAMES[username_md5].include?(display_name_md5)
|
||||
end
|
||||
|
||||
def self.heuristic_auto_suspend?(account)
|
||||
return false unless Rails.configuration.x.th_automod.account_service_heuristic_auto_suspend_active
|
||||
|
||||
return unless account.username.length < HEURISTIC_MAX_LEN && account.display_name.length < HEURISTIC_MAX_LEN
|
||||
|
||||
self.matches_evil_hash?(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -55,7 +55,7 @@
|
|||
"axios": "^1.4.0",
|
||||
"babel-loader": "^8.3.0",
|
||||
"babel-plugin-formatjs": "^10.5.1",
|
||||
"babel-plugin-lodash": "patch:babel-plugin-lodash@npm%3A3.3.4#~/.yarn/patches/babel-plugin-lodash-npm-3.3.4-c7161075b6.patch",
|
||||
"babel-plugin-lodash": "patch:babel-plugin-lodash@npm%3A3.3.4#.yarn/patches/babel-plugin-lodash-npm-3.3.4-c7161075b6.patch",
|
||||
"babel-plugin-preval": "^5.1.0",
|
||||
"babel-plugin-transform-react-remove-prop-types": "^0.4.24",
|
||||
"blurhash": "^2.0.5",
|
||||
|
|
After Width: | Height: | Size: 2.6 KiB |
|
@ -0,0 +1,12 @@
|
|||
# This redis configuration is for development only
|
||||
|
||||
daemonize yes
|
||||
|
||||
dir ./data/redis
|
||||
pidfile ./redis-dev.pid
|
||||
|
||||
unixsocket ./redis-dev.sock
|
||||
unixsocketperm 700
|
||||
|
||||
# Disable TCP
|
||||
port 0
|
|
@ -56,6 +56,50 @@ describe InvitesController do
|
|||
expect(subject).to redirect_to invites_path
|
||||
expect(Invite.last).to have_attributes(user_id: user.id, max_uses: 10)
|
||||
end
|
||||
|
||||
# context 'when th_invite_limits_active?' do
|
||||
# let(:max_uses) { 25 }
|
||||
# let(:expires_in) { 86400 }
|
||||
|
||||
# subject { post :create, params: { invite: { max_uses: "#{max_uses}", expires_in: expires_in } } }
|
||||
|
||||
# before do
|
||||
# # expect_any_instance_of(Invite).to receive(:th_invite_limits_active?).and_return true
|
||||
# allow_any_instance_of(Invite).to receive(:th_invite_limits_active?).and_return true
|
||||
# # expect_any_instance_of(Invite).to receive(:created_by_moderator?).and_return false
|
||||
# allow_any_instance_of(Invite).to receive(:created_by_moderator?).and_return false
|
||||
# end
|
||||
|
||||
# it do
|
||||
# expect(user.moderator).to be_falsy
|
||||
# end
|
||||
|
||||
# shared_examples 'fails to create an invite' do
|
||||
# it 'fails to create an invite' do
|
||||
# expect { subject }.not_to change { Invite.count }
|
||||
# end
|
||||
# end
|
||||
|
||||
# it 'succeeds to create a invite' do
|
||||
# expect { subject }.to change { Invite.count }.by(1)
|
||||
# expect(subject).to redirect_to invites_path
|
||||
# expect(Invite.last).to have_attributes(user_id: user.id, max_uses: max_uses)
|
||||
# end
|
||||
|
||||
# context 'when the request is over the limits' do
|
||||
# context do
|
||||
# let(:max_uses) { 26 }
|
||||
|
||||
# include_examples 'fails to create an invite'
|
||||
# end
|
||||
|
||||
# context do
|
||||
# let(:expires_in) { 86401 }
|
||||
|
||||
# include_examples 'fails to create an invite'
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
end
|
||||
|
||||
context 'when not everyone can invite' do
|
||||
|
|
|
@ -13,3 +13,7 @@ Fabricator(:user) do
|
|||
current_sign_in_at { Time.zone.now }
|
||||
agreement true
|
||||
end
|
||||
|
||||
Fabricator(:moderator_user, :from => :user) do
|
||||
role { Fabricate(:moderator_role) }
|
||||
end
|
||||
|
|
|
@ -5,3 +5,11 @@ Fabricator(:user_role) do
|
|||
color ''
|
||||
permissions 0
|
||||
end
|
||||
|
||||
Fabricator(:moderator_role, :from => :user_role) do
|
||||
name 'fake moderator'
|
||||
permissions UserRole::Flags::DEFAULT |
|
||||
UserRole::Flags::CATEGORIES[:moderation]
|
||||
.map { |p| UserRole::FLAGS[p] }
|
||||
.reduce(&:|)
|
||||
end
|
||||
|
|
|
@ -1158,5 +1158,89 @@ RSpec.describe ActivityPub::Activity::Create do
|
|||
expect(sender.statuses.count).to eq 0
|
||||
end
|
||||
end
|
||||
|
||||
context 'with automod active' do
|
||||
subject { described_class.new(json, sender, delivery: true) }
|
||||
|
||||
let(:sender) { Fabricate(:account, followers_url: 'http://example.com/followers', domain: 'example.com', uri: 'https://example.com/actor', created_at: created_at) }
|
||||
let(:created_at) { Time.now }
|
||||
let(:min_account_age_threshold) { 1.day }
|
||||
|
||||
let(:recipient_a) { Fabricate(:account) }
|
||||
let(:recipient_b) { Fabricate(:account) }
|
||||
let(:staff_user) { Fabricate(:moderator_user) }
|
||||
|
||||
let(:object_json) do
|
||||
{
|
||||
id: [ActivityPub::TagManager.instance.uri_for(sender), '#bar'].join,
|
||||
type: 'Note',
|
||||
content: 'Lorem ipsum',
|
||||
cc: ActivityPub::TagManager.instance.uri_for(recipient_a),
|
||||
tag: recipients.map do |recipient|
|
||||
{
|
||||
type: 'Mention',
|
||||
href: ActivityPub::TagManager.instance.uri_for(recipient),
|
||||
}
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
||||
before do
|
||||
allow(Rails.configuration.x.th_automod).to receive(:automod_account_username).and_return(staff_user.account.username)
|
||||
allow(Rails.configuration.x.th_automod).to receive(:mention_spam_heuristic_auto_limit_active).and_return(true)
|
||||
allow(Rails.configuration.x.th_automod).to receive(:mention_spam_threshold).and_return(2)
|
||||
allow(Rails.configuration.x.th_automod).to receive(:min_account_age_threshold).and_return(min_account_age_threshold)
|
||||
allow(subject).to receive(:distribute)
|
||||
allow(sender).to receive(:silence!).and_call_original
|
||||
subject.perform
|
||||
end
|
||||
|
||||
shared_examples 'automod activates' do
|
||||
it 'silences the sender' do
|
||||
expect(sender).to have_received(:silence!)
|
||||
expect(sender.silenced?).to be_truthy
|
||||
end
|
||||
|
||||
it 'skips distribution' do
|
||||
expect(subject).not_to have_received(:distribute)
|
||||
end
|
||||
|
||||
it 'files a tracking report' do
|
||||
expect(sender.previous_strikes_count).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples 'automod does not activate' do
|
||||
it 'does not silence the sender' do
|
||||
expect(sender.silenced?).to be_falsy
|
||||
end
|
||||
|
||||
it 'does not file a tracking report' do
|
||||
expect(sender.reports.empty?).to be_truthy
|
||||
end
|
||||
end
|
||||
|
||||
context 'and spammy message' do
|
||||
let(:recipients) { [recipient_a, recipient_b] }
|
||||
|
||||
context 'and old account' do
|
||||
let(:created_at) { Time.now - min_account_age_threshold - 1.hour }
|
||||
|
||||
include_examples 'automod does not activate'
|
||||
end
|
||||
|
||||
context 'and new account' do
|
||||
let(:created_at) { Time.now - min_account_age_threshold + 1.hour }
|
||||
|
||||
include_examples 'automod activates'
|
||||
end
|
||||
end
|
||||
|
||||
context 'and hammy message' do
|
||||
let(:recipients) { [recipient_a] }
|
||||
|
||||
include_examples 'automod does not activate'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,4 +35,67 @@ RSpec.describe Invite do
|
|||
expect(invite.valid_for_use?).to be false
|
||||
end
|
||||
end
|
||||
|
||||
context 'when th_use_invite_quota?' do
|
||||
let(:max_uses) { 25 }
|
||||
let(:expires_in) { 1.week.in_seconds }
|
||||
let(:regular_user) { Fabricate(:user) }
|
||||
let(:moderator_user) { Fabricate(:moderator_user) }
|
||||
let(:user) { regular_user }
|
||||
let(:created_at) { Time.at(0) }
|
||||
let(:expires_at) { Time.at(0) + expires_in }
|
||||
|
||||
subject { Fabricate.build(:invite, user: user, max_uses: max_uses, created_at: created_at, expires_at: expires_at ) }
|
||||
|
||||
before do
|
||||
stub_const('Invite::TH_USE_INVITE_QUOTA', true)
|
||||
stub_const('Invite::TH_INVITE_MAX_USES', 25)
|
||||
stub_const('Invite::TH_ACTIVE_INVITE_SLOT_QUOTA', 30)
|
||||
end
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
|
||||
context 'and' do
|
||||
context 'max_uses exceeds quota' do
|
||||
let(:max_uses) { 26 }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'expires_in exceeds quota' do
|
||||
let(:expires_in) { 1.week.in_seconds + 1 }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'multiple values exceed quota' do
|
||||
let(:max_uses) { 26 }
|
||||
let(:expires_in) { 86401 }
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'an unlimited use invite' do
|
||||
before do
|
||||
Fabricate.build(:invite, user: user).save(validate: false)
|
||||
end
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'too many outstanding invites' do
|
||||
before do
|
||||
Fabricate.build(:invite, user: user, max_uses: 6).save(validate: false)
|
||||
end
|
||||
|
||||
it { is_expected.not_to be_valid }
|
||||
end
|
||||
|
||||
context 'a moderator created the invite' do
|
||||
let(:user) { moderator_user }
|
||||
|
||||
it { is_expected.to be_valid }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|