- uses: docker/build-push-action@v2
with:
context: .
- platforms: ${{ matrix.os }}
+ platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
- cache-from: type=registry,ref=tootsuite/mastodon:latest
+ cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/mastodon:latest
cache-to: type=inline
# frozen_string_literal: true
class StatusLengthValidator < ActiveModel::Validator
- MAX_CHARS = 500
+ MAX_CHARS = (ENV['MAX_TOOT_CHARS'] || 500).to_i
URL_PLACEHOLDER_CHARS = 23
- URL_PLACEHOLDER = "\1#{'x' * URL_PLACEHOLDER_CHARS}"
+ URL_PLACEHOLDER = 'x' * 23
def validate(status)
return unless status.local? && !status.reblog?
expect(status.errors).to have_received(:add)
end
+ it 'does not count overly long URLs as 23 characters flat' do
+ text = "http://example.com/valid?#{'#foo?' * 1000}"
+ status = double(spoiler_text: '', text: text, errors: double(add: nil), local?: true, reblog?: false)
+ subject.validate(status)
+ expect(status.errors).to have_received(:add)
+ end
+
it 'counts only the front part of remote usernames' do
- text = ('a' * 475) + " @alice@#{'b' * 30}.com"
+ username = '@alice'
+ chars = StatusLengthValidator::MAX_CHARS - 1 - username.length
+ text = ('a' * 475) + " #{username}@#{'b' * 30}.com"
status = double(spoiler_text: '', text: text, errors: double(add: nil), local?: true, reblog?: false)
subject.validate(status)