Compare commits

..

21 Commits

Author SHA1 Message Date
Rin 4a18d8e642 Fix non-rendering on certain engines
ci/woodpecker/pr/woodpecker Pipeline was successful Details
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-11-13 02:12:17 +00:00
Rin c048f832c1 Change Safari bookmark colour to match treehouse 2022-11-13 02:12:17 +00:00
Rin bd6a63ebed Add small icon assets 2022-11-13 02:12:17 +00:00
Ariadne Conill b0dc619c56 woodpecker: add registry secret
ci/woodpecker/push/woodpecker Pipeline was successful Details
2022-11-12 14:08:48 +00:00
Ariadne Conill d51636a24d woodpecker: remove separate login step
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-11-12 11:18:48 +00:00
Ariadne Conill 5650b7a785 woodpecker: expose host docker socket for now until i have time to make docker-in-docker work
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-11-12 10:55:53 +00:00
Ariadne Conill 1678011556 add woodpecker CI
ci/woodpecker/push/woodpecker Pipeline failed Details
2022-11-12 10:50:24 +00:00
Ariadne Conill 946388f02e Merge gitea.treehouse.systems:mirrors/mastodon-glitch 2022-11-10 07:11:03 +00:00
Ariadne Conill c515158c09 Revert "Add prefers-color-scheme based theme"
This reverts commit 652882a81b.
2022-11-10 07:05:56 +00:00
Claire b2a25d446a
Merge pull request #1905 from ClearlyClaire/glitch-soc/merge-upstream
Merge upstream changes
2022-11-08 16:42:24 +01:00
Claire 9b6d6a919f [Glitch] Fix redrafting a currently-editing post not leaving edit mode
Port 782b6835f7 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2022-11-08 16:26:25 +01:00
Claire fe1b694128 [Glitch] Fix opening the language picker scrolling the single-column view to the top
Port 608343c135 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2022-11-08 15:49:09 +01:00
Zach Flanders 6eac1cfccd [Glitch] Fix spoiler buttons css not rendering correct color in light theme
Port 0beb095a4b to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
2022-11-08 15:47:48 +01:00
Claire a8c854b3ea Merge branch 'main' into glitch-soc/merge-upstream 2022-11-08 15:44:57 +01:00
Claire 782b6835f7
Fix redrafting a currently-editing post not leaving edit mode (#20023) 2022-11-08 04:06:54 +01:00
James Tucker 833d9c2f1c
Improve performance by avoiding method cache busts (#19957)
Switch to monkey-patching http.rb rather than a runtime extend of each
response, so as to avoid busting the global method cache. A guard is
included that will provide developer feedback in development and test
environments should the monkey patch ever collide.
2022-11-08 04:00:27 +01:00
Claire 9f4930ec11
Add password autocomplete hints (#20071)
Fixes #20067

Our password autocomplete hints were “off” but that does not prevent current
browsers from trying to autocomplete them anyway, so use `current-password` and
`new-password` so they don't put a newly-generated password in a password
confirmation prompt, or the old password for a password renewal prompt.
2022-11-08 03:53:06 +01:00
Claire 608343c135
Fix opening the language picker scrolling the single-column view to the top (#19983)
Fixes #19915
2022-11-08 03:52:52 +01:00
Postmodern ca80beb653
Micro-optimization: use `if`/`else` instead of `Array#compact` and `Array#min` (#19906)
* Technically `if`/`else` is faster than using `[value1, value2].compact.min` to find the lesser of two values, one of which may be `nil`.
2022-11-08 03:50:47 +01:00
Zach Flanders 0beb095a4b
Fix spoiler buttons css not rendering correct color in light theme (#19960)
* Updating status__content__spoiler-link css for mastodon-light theme to ensure correct rendering precedence

* Adding focus css selector to status__content__spoiler-link mastodon-light theme

* reformatting code to match convention of having css selectors on separate lines

* fixing code format for  scss linting issue
2022-11-07 22:37:36 +01:00
Claire bbf74498f5
Fix validation error in SynchronizeFeaturedTagsCollectionWorker (#20018)
* Fix followers count not being updated when migrating follows

Fixes #19900

* Fix validation error in SynchronizeFeaturedTagsCollectionWorker

Also saves remote user's chosen case for hashtags

* Limit remote featured tags before validation
2022-11-07 22:35:53 +01:00
24 changed files with 174 additions and 46 deletions

18
.woodpecker.yml Normal file
View File

@ -0,0 +1,18 @@
pipeline:
build:
image: docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- docker image build -f Dockerfile . -t gitea.treehouse.systems/treehouse/mastodon:latest
push:
image: docker
volumes:
- /var/run/docker.sock:/var/run/docker.sock
commands:
- echo $REGISTRY_SECRET | docker login -u ariadne --password-stdin gitea.treehouse.systems
- docker image push --all-tags gitea.treehouse.systems/treehouse/mastodon
when:
event: [push, tag]
secrets: [REGISTRY_SECRET]

View File

@ -51,6 +51,15 @@ class LanguageDropdownMenu extends React.PureComponent {
document.addEventListener('click', this.handleDocumentClick, false);
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
this.setState({ mounted: true });
// Because of https://github.com/react-bootstrap/react-bootstrap/issues/2614 we need
// to wait for a frame before focusing
requestAnimationFrame(() => {
if (this.node) {
const element = this.node.querySelector('input[type="search"]');
if (element) element.focus();
}
});
}
componentWillUnmount () {
@ -226,7 +235,7 @@ class LanguageDropdownMenu extends React.PureComponent {
// react-overlays
<div className={`language-dropdown__dropdown ${placement}`} style={{ ...style, opacity: opacity, transform: mounted ? `scale(${scaleX}, ${scaleY})` : null }} ref={this.setRef}>
<div className='emoji-mart-search'>
<input type='search' value={searchValue} onChange={this.handleSearchChange} onKeyDown={this.handleSearchKeyDown} placeholder={intl.formatMessage(messages.search)} autoFocus />
<input type='search' value={searchValue} onChange={this.handleSearchChange} onKeyDown={this.handleSearchKeyDown} placeholder={intl.formatMessage(messages.search)} />
<button className='emoji-mart-search-icon' disabled={!isSearching} aria-label={intl.formatMessage(messages.clear)} onClick={this.handleClear}>{!isSearching ? loupeIcon : deleteIcon}</button>
</div>

View File

@ -573,6 +573,7 @@ export default function compose(state = initialState, action) {
'advanced_options',
map => map.merge(new ImmutableMap({ do_not_federate }))
);
map.set('id', null);
if (action.status.get('spoiler_text').length > 0) {
map.set('spoiler', true);

View File

@ -268,7 +268,8 @@ html {
.status__content .status__content__spoiler-link {
background: $ui-base-color;
&:hover {
&:hover,
&:focus {
background: lighten($ui-base-color, 4%);
}
}

View File

@ -51,6 +51,15 @@ class LanguageDropdownMenu extends React.PureComponent {
document.addEventListener('click', this.handleDocumentClick, false);
document.addEventListener('touchend', this.handleDocumentClick, listenerOptions);
this.setState({ mounted: true });
// Because of https://github.com/react-bootstrap/react-bootstrap/issues/2614 we need
// to wait for a frame before focusing
requestAnimationFrame(() => {
if (this.node) {
const element = this.node.querySelector('input[type="search"]');
if (element) element.focus();
}
});
}
componentWillUnmount () {
@ -226,7 +235,7 @@ class LanguageDropdownMenu extends React.PureComponent {
// react-overlays
<div className={`language-dropdown__dropdown ${placement}`} style={{ ...style, opacity: opacity, transform: mounted ? `scale(${scaleX}, ${scaleY})` : null }} ref={this.setRef}>
<div className='emoji-mart-search'>
<input type='search' value={searchValue} onChange={this.handleSearchChange} onKeyDown={this.handleSearchKeyDown} placeholder={intl.formatMessage(messages.search)} autoFocus />
<input type='search' value={searchValue} onChange={this.handleSearchChange} onKeyDown={this.handleSearchKeyDown} placeholder={intl.formatMessage(messages.search)} />
<button type='button' className='emoji-mart-search-icon' disabled={!isSearching} aria-label={intl.formatMessage(messages.clear)} onClick={this.handleClear}>{!isSearching ? loupeIcon : deleteIcon}</button>
</div>

View File

@ -452,6 +452,7 @@ export default function compose(state = initialState, action) {
map.set('idempotencyKey', uuid());
map.set('sensitive', action.status.get('sensitive'));
map.set('language', action.status.get('language'));
map.set('id', null);
if (action.status.get('spoiler_text').length > 0) {
map.set('spoiler', true);

View File

@ -1,4 +0,0 @@
@import 'flavours/glitch/styles/application';
@media (prefers-color-scheme: light) {
@import 'flavours/glitch/styles/mastodon-light';
}

View File

@ -1,4 +0,0 @@
en:
skins:
glitch:
mastodon-system: Mastodon (system-preferred)

View File

@ -4,5 +4,5 @@ en:
mastodon-light: Mastodon (light)
es:
skins:
vanilla:
glitch:
mastodon-light: Mastodon (claro)

View File

@ -1,4 +0,0 @@
@import 'styles/application';
@media (prefers-color-scheme: light) {
@import 'styles/mastodon-light';
}

View File

@ -1,4 +0,0 @@
en:
skins:
vanilla:
mastodon-system: Mastodon (system-preferred)

View File

@ -268,7 +268,8 @@ html {
.status__content .status__content__spoiler-link {
background: $ui-base-color;
&:hover {
&:hover,
&:focus {
background: lighten($ui-base-color, 4%);
}
}

View File

@ -62,8 +62,6 @@ class Request
end
begin
response = response.extend(ClientLimit)
# If we are using a persistent connection, we have to
# read every response to be able to move forward at all.
# However, simply calling #to_s or #flush may not be safe,
@ -181,6 +179,14 @@ class Request
end
end
if ::HTTP::Response.methods.include?(:body_with_limit) && !Rails.env.production?
abort 'HTTP::Response#body_with_limit is already defined, the monkey patch will not be applied'
else
class ::HTTP::Response
include Request::ClientLimit
end
end
class Socket < TCPSocket
class << self
def open(host, *args)

View File

@ -139,7 +139,12 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
# Filtering on `id` rather than `min_status_age` ago will treat
# non-snowflake statuses as older than they really are, but Mastodon
# has switched to snowflake IDs significantly over 2 years ago anyway.
max_id = [max_id, Mastodon::Snowflake.id_at(min_status_age.seconds.ago, with_random: false)].compact.min
snowflake_id = Mastodon::Snowflake.id_at(min_status_age.seconds.ago, with_random: false)
if max_id.nil? || snowflake_id < max_id
max_id = snowflake_id
end
Status.where(Status.arel_table[:id].lteq(max_id))
end

View File

@ -63,6 +63,8 @@ class FeaturedTag < ApplicationRecord
end
def validate_featured_tags_limit
return unless account.local?
errors.add(:base, I18n.t('featured_tags.errors.limit')) if account.featured_tags.count >= LIMIT
end

View File

@ -51,21 +51,17 @@ class ActivityPub::FetchFeaturedTagsCollectionService < BaseService
end
def process_items(items)
names = items.filter_map { |item| item['type'] == 'Hashtag' && item['name']&.delete_prefix('#') }.map { |name| HashtagNormalizer.new.normalize(name) }
to_remove = []
to_add = names
names = items.filter_map { |item| item['type'] == 'Hashtag' && item['name']&.delete_prefix('#') }.take(FeaturedTag::LIMIT)
tags = names.index_by { |name| HashtagNormalizer.new.normalize(name) }
normalized_names = tags.keys
FeaturedTag.where(account: @account).map(&:name).each do |name|
if names.include?(name)
to_add.delete(name)
else
to_remove << name
end
FeaturedTag.includes(:tag).references(:tag).where(account: @account).where.not(tag: { name: normalized_names }).delete_all
FeaturedTag.includes(:tag).references(:tag).where(account: @account, tag: { name: normalized_names }).each do |featured_tag|
featured_tag.update(name: tags.delete(featured_tag.tag.name))
end
FeaturedTag.includes(:tag).where(account: @account, tags: { name: to_remove }).delete_all unless to_remove.empty?
to_add.each do |name|
tags.each_value do |name|
FeaturedTag.create!(account: @account, name: name)
end
end

View File

@ -5,7 +5,7 @@
= f.input :return_to, as: :hidden
.field-group
= f.input :current_password, wrapper: :with_block_label, input_html: { :autocomplete => 'off', :autofocus => true }, label: t('challenge.prompt'), required: true
= f.input :current_password, wrapper: :with_block_label, input_html: { :autocomplete => 'current-password', :autofocus => true }, label: t('challenge.prompt'), required: true
.actions
= f.button :button, t('challenge.confirm'), type: :submit

View File

@ -8,9 +8,9 @@
= f.input :reset_password_token, as: :hidden
.fields-group
= f.input :password, wrapper: :with_label, autofocus: true, label: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.new_password'), :autocomplete => 'off', :minlength => User.password_length.first, :maxlength => User.password_length.last }, required: true
= f.input :password, wrapper: :with_label, autofocus: true, label: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.new_password'), :autocomplete => 'new-password', :minlength => User.password_length.first, :maxlength => User.password_length.last }, required: true
.fields-group
= f.input :password_confirmation, wrapper: :with_label, label: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_new_password'), :autocomplete => 'off' }, required: true
= f.input :password_confirmation, wrapper: :with_label, label: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_new_password'), :autocomplete => 'new-password' }, required: true
.actions
= f.button :button, t('auth.set_new_password'), type: :submit

View File

@ -13,13 +13,13 @@
.fields-row__column.fields-group.fields-row__column-6
= f.input :email, wrapper: :with_label, input_html: { 'aria-label' => t('simple_form.labels.defaults.email') }, required: true, disabled: current_account.suspended?
.fields-row__column.fields-group.fields-row__column-6
= f.input :current_password, wrapper: :with_label, input_html: { 'aria-label' => t('simple_form.labels.defaults.current_password'), :autocomplete => 'off' }, required: true, disabled: current_account.suspended?, hint: false
= f.input :current_password, wrapper: :with_label, input_html: { 'aria-label' => t('simple_form.labels.defaults.current_password'), :autocomplete => 'current-password' }, required: true, disabled: current_account.suspended?, hint: false
.fields-row
.fields-row__column.fields-group.fields-row__column-6
= f.input :password, wrapper: :with_label, label: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.new_password'), :autocomplete => 'off', :minlength => User.password_length.first, :maxlength => User.password_length.last }, hint: t('simple_form.hints.defaults.password'), disabled: current_account.suspended?
= f.input :password, wrapper: :with_label, label: t('simple_form.labels.defaults.new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.new_password'), :autocomplete => 'new-password', :minlength => User.password_length.first, :maxlength => User.password_length.last }, hint: t('simple_form.hints.defaults.password'), disabled: current_account.suspended?
.fields-row__column.fields-group.fields-row__column-6
= f.input :password_confirmation, wrapper: :with_label, label: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_new_password'), :autocomplete => 'off' }, disabled: current_account.suspended?
= f.input :password_confirmation, wrapper: :with_label, label: t('simple_form.labels.defaults.confirm_new_password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.confirm_new_password'), :autocomplete => 'new-password' }, disabled: current_account.suspended?
.actions
= f.button :button, t('generic.save_changes'), type: :submit, class: 'button', disabled: current_account.suspended?

View File

@ -12,7 +12,7 @@
- else
= f.input :email, autofocus: true, wrapper: :with_label, label: t('simple_form.labels.defaults.email'), input_html: { 'aria-label' => t('simple_form.labels.defaults.email') }, hint: false
.fields-group
= f.input :password, wrapper: :with_label, label: t('simple_form.labels.defaults.password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.password'), :autocomplete => 'off' }, hint: false
= f.input :password, wrapper: :with_label, label: t('simple_form.labels.defaults.password'), input_html: { 'aria-label' => t('simple_form.labels.defaults.password'), :autocomplete => 'current-password' }, hint: false
.actions
= f.button :button, t('auth.login'), type: :submit

View File

@ -21,7 +21,7 @@
%hr.spacer/
- if current_user.encrypted_password.present?
= f.input :password, wrapper: :with_block_label, input_html: { :autocomplete => 'off' }, hint: t('deletes.confirm_password')
= f.input :password, wrapper: :with_block_label, input_html: { :autocomplete => 'current-password' }, hint: t('deletes.confirm_password')
- else
= f.input :username, wrapper: :with_block_label, input_html: { :autocomplete => 'off' }, hint: t('deletes.confirm_username')

View File

@ -19,7 +19,7 @@
.fields-row__column.fields-group.fields-row__column-6
- if current_user.encrypted_password.present?
= f.input :current_password, wrapper: :with_block_label, input_html: { :autocomplete => 'off' }, required: true
= f.input :current_password, wrapper: :with_block_label, input_html: { :autocomplete => 'current-password' }, required: true
- else
= f.input :current_username, wrapper: :with_block_label, input_html: { :autocomplete => 'off' }, required: true

View File

@ -48,7 +48,7 @@
.fields-row__column.fields-group.fields-row__column-6
- if current_user.encrypted_password.present?
= f.input :current_password, wrapper: :with_block_label, input_html: { :autocomplete => 'off' }, required: true, disabled: on_cooldown?
= f.input :current_password, wrapper: :with_block_label, input_html: { :autocomplete => 'current-password' }, required: true, disabled: on_cooldown?
- else
= f.input :current_username, wrapper: :with_block_label, input_html: { :autocomplete => 'off' }, required: true, disabled: on_cooldown?

View File

@ -0,0 +1,95 @@
require 'rails_helper'
RSpec.describe ActivityPub::FetchFeaturedTagsCollectionService, type: :service do
let(:collection_url) { 'https://example.com/account/tags' }
let(:actor) { Fabricate(:account, domain: 'example.com', uri: 'https://example.com/account') }
let(:items) do
[
{ type: 'Hashtag', href: 'https://example.com/account/tagged/foo', name: 'Foo' },
{ type: 'Hashtag', href: 'https://example.com/account/tagged/bar', name: 'bar' },
{ type: 'Hashtag', href: 'https://example.com/account/tagged/baz', name: 'baZ' },
]
end
let(:payload) do
{
'@context': 'https://www.w3.org/ns/activitystreams',
type: 'Collection',
id: collection_url,
items: items,
}.with_indifferent_access
end
subject { described_class.new }
shared_examples 'sets featured tags' do
before do
subject.call(actor, collection_url)
end
it 'sets expected tags as pinned tags' do
expect(actor.featured_tags.map(&:display_name)).to match_array ['Foo', 'bar', 'baZ']
end
end
describe '#call' do
context 'when the endpoint is a Collection' do
before do
stub_request(:get, collection_url).to_return(status: 200, body: Oj.dump(payload))
end
it_behaves_like 'sets featured tags'
end
context 'when the account already has featured tags' do
before do
stub_request(:get, collection_url).to_return(status: 200, body: Oj.dump(payload))
actor.featured_tags.create!(name: 'FoO')
actor.featured_tags.create!(name: 'baz')
actor.featured_tags.create!(name: 'oh').update(name: nil)
end
it_behaves_like 'sets featured tags'
end
context 'when the endpoint is an OrderedCollection' do
let(:payload) do
{
'@context': 'https://www.w3.org/ns/activitystreams',
type: 'OrderedCollection',
id: collection_url,
orderedItems: items,
}.with_indifferent_access
end
before do
stub_request(:get, collection_url).to_return(status: 200, body: Oj.dump(payload))
end
it_behaves_like 'sets featured tags'
end
context 'when the endpoint is a paginated Collection' do
let(:payload) do
{
'@context': 'https://www.w3.org/ns/activitystreams',
type: 'Collection',
id: collection_url,
first: {
type: 'CollectionPage',
partOf: collection_url,
items: items,
}
}.with_indifferent_access
end
before do
stub_request(:get, collection_url).to_return(status: 200, body: Oj.dump(payload))
end
it_behaves_like 'sets featured tags'
end
end
end