Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge upstream #234

Merged
merged 41 commits into from
Oct 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
9114b84
Bump babel-jest from 26.3.0 to 26.5.2 (#14945)
dependabot[bot] Oct 7, 2020
0b03ee3
Bump @github/webauthn-json from 0.5.5 to 0.5.6 (#14946)
dependabot[bot] Oct 7, 2020
e2d20be
Bump sass from 1.26.11 to 1.26.12 (#14947)
dependabot[bot] Oct 7, 2020
dcaff7d
Bump eslint-plugin-react from 7.21.2 to 7.21.3 (#14950)
dependabot[bot] Oct 7, 2020
d175a3b
Bump mini-css-extract-plugin from 0.11.0 to 0.11.3 (#14949)
dependabot[bot] Oct 7, 2020
3f6ab34
Bump jest from 26.4.2 to 26.5.2 (#14951)
dependabot[bot] Oct 7, 2020
a37732e
Bump eslint from 7.6.0 to 7.10.0 (#14948)
dependabot[bot] Oct 7, 2020
d9f8890
update themes
mashirozx Oct 7, 2020
7d985f2
Remove dependency on goldfinger gem (#14919)
Gargron Oct 7, 2020
dac3e36
Fix unread notification marker not updating when mounting column (#14…
ClearlyClaire Oct 7, 2020
dc52a77
Fix issue checking for last unread notification when there are gaps (…
ClearlyClaire Oct 9, 2020
c1d9995
add & fix themes
mashirozx Oct 9, 2020
aeccdb6
Merge branch 'master' into dev
mashirozx Oct 9, 2020
6271102
update theme
mashirozx Oct 9, 2020
f3f410b
Merge branch 'dev' of github.com:mashirozx/mastodon into dev
mashirozx Oct 9, 2020
4926488
fix theme
mashirozx Oct 9, 2020
e024c43
fix theme
mashirozx Oct 9, 2020
5e1364c
Add IP-based rules (#14963)
Gargron Oct 12, 2020
f54ca3d
Fix browser notification permission request logic (#13543)
ClearlyClaire Oct 12, 2020
9676175
Add duration parameter to muting. (#13831)
aquarla Oct 12, 2020
53b22d2
helm: add optional cron job to run `tootctl remove media` (#14396)
dunn Oct 12, 2020
4c45b43
Change how CDN_HOST is passed down to make assets build reproducible …
ClearlyClaire Oct 12, 2020
3e5636b
handle conflict
mashirozx Oct 13, 2020
3547009
Bump compression-webpack-plugin from 6.0.2 to 6.0.3 (#14979)
dependabot[bot] Oct 13, 2020
fc87b15
Bump sass-loader from 10.0.2 to 10.0.3 (#14977)
dependabot[bot] Oct 13, 2020
658dbd7
Bump imports-loader from 1.1.0 to 1.2.0 (#14976)
dependabot[bot] Oct 13, 2020
5b131f0
Bump tzinfo-data from 1.2020.1 to 1.2020.2 (#14966)
dependabot[bot] Oct 13, 2020
06c3d36
Bump rubocop from 0.92.0 to 0.93.0 (#14967)
dependabot[bot] Oct 13, 2020
5de8665
Bump file-loader from 6.1.0 to 6.1.1 (#14974)
dependabot[bot] Oct 13, 2020
a8e8ee2
Bump eslint-plugin-react from 7.21.3 to 7.21.4 (#14968)
dependabot[bot] Oct 13, 2020
df8cbbf
Bump terser-webpack-plugin from 4.2.2 to 4.2.3 (#14971)
dependabot[bot] Oct 13, 2020
37295d5
Bump eslint from 7.10.0 to 7.11.0 (#14975)
dependabot[bot] Oct 13, 2020
ec1d8b7
Bump sass from 1.26.12 to 1.27.0 (#14973)
dependabot[bot] Oct 13, 2020
bb18092
Bump jest from 26.5.2 to 26.5.3 (#14969)
dependabot[bot] Oct 13, 2020
b4c4af1
Fix a bear check when the activity object is nil (#14981)
noellabo Oct 13, 2020
a69ca29
Change how missing desktop notifications permission is displayed (#14…
Gargron Oct 15, 2020
fb5f3be
Fix strings that could not be translated (#14980)
mayaeh Oct 15, 2020
4130aef
Fix translation string (#14986)
mayaeh Oct 16, 2020
abae994
update theme
mashirozx Oct 16, 2020
9e55cba
handle conflict
mashirozx Oct 16, 2020
fe5f6d3
Merge branch 'master' into dev
mashirozx Oct 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ gem 'doorkeeper', '~> 5.4'
gem 'ed25519', '~> 1.2'
gem 'fast_blank', '~> 1.0'
gem 'fastimage'
gem 'goldfinger', '~> 2.1'
gem 'hiredis', '~> 0.6'
gem 'redis-namespace', '~> 1.8'
gem 'health_check', git: 'https://github.com/ianheggie/health_check', ref: '0b799ead604f900ed50685e9b2d469cd2befba5b'
Expand Down Expand Up @@ -143,7 +142,7 @@ group :development do
gem 'letter_opener', '~> 1.7'
gem 'letter_opener_web', '~> 1.4'
gem 'memory_profiler'
gem 'rubocop', '~> 0.92', require: false
gem 'rubocop', '~> 0.93', require: false
gem 'rubocop-rails', '~> 2.8', require: false
gem 'brakeman', '~> 4.10', require: false
gem 'bundler-audit', '~> 0.7', require: false
Expand Down
20 changes: 7 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ GEM
ruby-progressbar (~> 1.4)
globalid (0.4.2)
activesupport (>= 4.2.0)
goldfinger (2.1.1)
addressable (~> 2.5)
http (~> 4.0)
nokogiri (~> 1.8)
oj (~> 3.0)
hamlit (2.13.0)
temple (>= 0.8.2)
thor
Expand Down Expand Up @@ -403,7 +398,7 @@ GEM
parallel (1.19.2)
parallel_tests (3.3.0)
parallel
parser (2.7.1.5)
parser (2.7.2.0)
ast (~> 2.4.1)
parslet (2.0.0)
pastel (0.8.0)
Expand Down Expand Up @@ -503,7 +498,7 @@ GEM
redis-store (>= 1.2, < 2)
redis-store (1.9.0)
redis (>= 4, < 5)
regexp_parser (1.8.1)
regexp_parser (1.8.2)
request_store (1.5.0)
rack (>= 1.4)
responders (3.0.1)
Expand Down Expand Up @@ -539,13 +534,13 @@ GEM
rspec-support (3.9.3)
rspec_junit_formatter (0.4.1)
rspec-core (>= 2, < 4, != 2.12.0)
rubocop (0.92.0)
rubocop (0.93.0)
parallel (~> 1.10)
parser (>= 2.7.1.5)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.7)
regexp_parser (>= 1.8)
rexml
rubocop-ast (>= 0.5.0)
rubocop-ast (>= 0.6.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 1.4.0, < 2.0)
rubocop-ast (0.7.1)
Expand Down Expand Up @@ -640,7 +635,7 @@ GEM
unf (~> 0.1.0)
tzinfo (1.2.7)
thread_safe (~> 0.1)
tzinfo-data (1.2020.1)
tzinfo-data (1.2020.2)
tzinfo (>= 1.0.0)
unf (0.1.4)
unf_ext
Expand Down Expand Up @@ -722,7 +717,6 @@ DEPENDENCIES
fog-core (<= 2.1.0)
fog-openstack (~> 0.3)
fuubar (~> 2.5)
goldfinger (~> 2.1)
hamlit-rails (~> 0.2)
health_check!
hiredis (~> 0.6)
Expand Down Expand Up @@ -787,7 +781,7 @@ DEPENDENCIES
rspec-rails (~> 4.0)
rspec-sidekiq (~> 3.1)
rspec_junit_formatter (~> 0.4)
rubocop (~> 0.92)
rubocop (~> 0.93)
rubocop-rails (~> 2.8)
ruby-progressbar (~> 1.10)
sanitize (~> 5.2)
Expand Down
56 changes: 56 additions & 0 deletions app/controllers/admin/ip_blocks_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# frozen_string_literal: true

module Admin
class IpBlocksController < BaseController
def index
authorize :ip_block, :index?

@ip_blocks = IpBlock.page(params[:page])
@form = Form::IpBlockBatch.new
end

def new
authorize :ip_block, :create?

@ip_block = IpBlock.new(ip: '', severity: :no_access, expires_in: 1.year)
end

def create
authorize :ip_block, :create?

@ip_block = IpBlock.new(resource_params)

if @ip_block.save
log_action :create, @ip_block
redirect_to admin_ip_blocks_path, notice: I18n.t('admin.ip_blocks.created_msg')
else
render :new
end
end

def batch
@form = Form::IpBlockBatch.new(form_ip_block_batch_params.merge(current_account: current_account, action: action_from_button))
@form.save
rescue ActionController::ParameterMissing
flash[:alert] = I18n.t('admin.ip_blocks.no_ip_block_selected')
rescue Mastodon::NotPermittedError
flash[:alert] = I18n.t('admin.custom_emojis.not_permitted')
ensure
redirect_to admin_ip_blocks_path
end

private

def resource_params
params.require(:ip_block).permit(:ip, :severity, :comment, :expires_in)
end

def action_from_button
'delete' if params[:delete]
end

def form_ip_block_batch_params
params.require(:form_ip_block_batch).permit(ip_block_ids: [])
end
end
end
4 changes: 2 additions & 2 deletions app/controllers/api/v1/accounts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def show
end

def create
token = AppSignUpService.new.call(doorkeeper_token.application, account_params)
token = AppSignUpService.new.call(doorkeeper_token.application, request.remote_ip, account_params)
response = Doorkeeper::OAuth::TokenResponse.new(token)

headers.merge!(response.headers)
Expand All @@ -42,7 +42,7 @@ def block
end

def mute
MuteService.new.call(current_user.account, @account, notifications: truthy_param?(:notifications))
MuteService.new.call(current_user.account, @account, notifications: truthy_param?(:notifications), duration: (params[:duration] || 0))
render json: @account, serializer: REST::RelationshipSerializer, relationships: relationships
end

Expand Down
2 changes: 1 addition & 1 deletion app/controllers/api/v1/mutes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Api::V1::MutesController < Api::BaseController

def index
@accounts = load_accounts
render json: @accounts, each_serializer: REST::AccountSerializer
render json: @accounts, each_serializer: REST::MutedAccountSerializer
end

private
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/auth/registrations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def update_resource(resource, params)
def build_resource(hash = nil)
super(hash)

resource.locale = I18n.locale
resource.invite_code = params[:invite_code] if resource.invite_code.blank?
resource.current_sign_in_ip = request.remote_ip
resource.locale = I18n.locale
resource.invite_code = params[:invite_code] if resource.invite_code.blank?
resource.sign_up_ip = request.remote_ip

resource.build_account if resource.account.nil?
end
Expand Down
4 changes: 4 additions & 0 deletions app/helpers/admin/action_logs_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ def linkable_log_target(record)
link_to record.target_account.acct, admin_account_path(record.target_account_id)
when 'Announcement'
link_to truncate(record.text), edit_admin_announcement_path(record.id)
when 'IpBlock'
"#{record.ip}/#{record.ip.prefix} (#{I18n.t("simple_form.labels.ip_block.severities.#{record.severity}")})"
end
end

Expand All @@ -48,6 +50,8 @@ def log_target_from_history(type, attributes)
end
when 'Announcement'
truncate(attributes['text'].is_a?(Array) ? attributes['text'].last : attributes['text'])
when 'IpBlock'
"#{attributes['ip']}/#{attributes['ip'].prefix} (#{I18n.t("simple_form.labels.ip_block.severities.#{attributes['severity']}")})"
end
end
end
33 changes: 1 addition & 32 deletions app/helpers/webfinger_helper.rb
Original file line number Diff line number Diff line change
@@ -1,38 +1,7 @@
# frozen_string_literal: true

# Monkey-patch on monkey-patch.
# Because it conflicts with the request.rb patch.
class HTTP::Timeout::PerOperationOriginal < HTTP::Timeout::PerOperation
def connect(socket_class, host, port, nodelay = false)
::Timeout.timeout(@connect_timeout, HTTP::TimeoutError) do
@socket = socket_class.open(host, port)
@socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) if nodelay
end
end
end

module WebfingerHelper
def webfinger!(uri)
hidden_service_uri = /\.(onion|i2p)(:\d+)?$/.match(uri)

raise Mastodon::HostValidationError, 'Instance does not support hidden service connections' if !Rails.configuration.x.access_to_hidden_service && hidden_service_uri

opts = {
ssl: !hidden_service_uri,

headers: {
'User-Agent': Mastodon::Version.user_agent,
},

timeout_class: HTTP::Timeout::PerOperationOriginal,

timeout_options: {
write_timeout: 10,
connect_timeout: 5,
read_timeout: 10,
},
}

Goldfinger::Client.new(uri, opts.merge(Rails.configuration.x.http_client_proxy)).finger
Webfinger.new(uri).perform
end
end
4 changes: 2 additions & 2 deletions app/javascript/mastodon/actions/accounts.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,11 @@ export function unblockAccountFail(error) {
};


export function muteAccount(id, notifications) {
export function muteAccount(id, notifications, duration=0) {
return (dispatch, getState) => {
dispatch(muteAccountRequest(id));

api(getState).post(`/api/v1/accounts/${id}/mute`, { notifications }).then(response => {
api(getState).post(`/api/v1/accounts/${id}/mute`, { notifications, duration }).then(response => {
// Pass in entire statuses map so we can use it to filter stuff in different parts of the reducers
dispatch(muteAccountSuccess(response.data, getState().get('statuses')));
}).catch(error => {
Expand Down
10 changes: 10 additions & 0 deletions app/javascript/mastodon/actions/mutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const MUTES_EXPAND_FAIL = 'MUTES_EXPAND_FAIL';

export const MUTES_INIT_MODAL = 'MUTES_INIT_MODAL';
export const MUTES_TOGGLE_HIDE_NOTIFICATIONS = 'MUTES_TOGGLE_HIDE_NOTIFICATIONS';
export const MUTES_CHANGE_DURATION = 'MUTES_CHANGE_DURATION';

export function fetchMutes() {
return (dispatch, getState) => {
Expand Down Expand Up @@ -104,3 +105,12 @@ export function toggleHideNotifications() {
dispatch({ type: MUTES_TOGGLE_HIDE_NOTIFICATIONS });
};
}

export function changeMuteDuration(duration) {
return dispatch => {
dispatch({
type: MUTES_CHANGE_DURATION,
duration,
});
};
}
45 changes: 45 additions & 0 deletions app/javascript/mastodon/actions/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { getFiltersRegex } from '../selectors';
import { usePendingItems as preferPendingItems } from 'mastodon/initial_state';
import compareId from 'mastodon/compare_id';
import { searchTextFromRawStatus } from 'mastodon/actions/importer/normalizer';
import { requestNotificationPermission } from '../utils/notifications';

export const NOTIFICATIONS_UPDATE = 'NOTIFICATIONS_UPDATE';
export const NOTIFICATIONS_UPDATE_NOOP = 'NOTIFICATIONS_UPDATE_NOOP';
Expand All @@ -33,8 +34,12 @@ export const NOTIFICATIONS_LOAD_PENDING = 'NOTIFICATIONS_LOAD_PENDING';
export const NOTIFICATIONS_MOUNT = 'NOTIFICATIONS_MOUNT';
export const NOTIFICATIONS_UNMOUNT = 'NOTIFICATIONS_UNMOUNT';


export const NOTIFICATIONS_MARK_AS_READ = 'NOTIFICATIONS_MARK_AS_READ';

export const NOTIFICATIONS_SET_BROWSER_SUPPORT = 'NOTIFICATIONS_SET_BROWSER_SUPPORT';
export const NOTIFICATIONS_SET_BROWSER_PERMISSION = 'NOTIFICATIONS_SET_BROWSER_PERMISSION';

defineMessages({
mention: { id: 'notification.mention', defaultMessage: '{name} mentioned you' },
group: { id: 'notifications.group', defaultMessage: '{count} notifications' },
Expand Down Expand Up @@ -235,6 +240,46 @@ export const unmountNotifications = () => ({
type: NOTIFICATIONS_UNMOUNT,
});


export const markNotificationsAsRead = () => ({
type: NOTIFICATIONS_MARK_AS_READ,
});

// Browser support
export function setupBrowserNotifications() {
return dispatch => {
dispatch(setBrowserSupport('Notification' in window));
if ('Notification' in window) {
dispatch(setBrowserPermission(Notification.permission));
}

if ('Notification' in window && 'permissions' in navigator) {
navigator.permissions.query({ name: 'notifications' }).then((status) => {
status.onchange = () => dispatch(setBrowserPermission(Notification.permission));
});
}
};
}

export function requestBrowserPermission(callback = noOp) {
return dispatch => {
requestNotificationPermission((permission) => {
dispatch(setBrowserPermission(permission));
callback(permission);
});
};
};

export function setBrowserSupport (value) {
return {
type: NOTIFICATIONS_SET_BROWSER_SUPPORT,
value,
};
}

export function setBrowserPermission (value) {
return {
type: NOTIFICATIONS_SET_BROWSER_PERMISSION,
value,
};
}
13 changes: 13 additions & 0 deletions app/javascript/mastodon/actions/onboarding.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
import { changeSetting, saveSettings } from './settings';
import { requestBrowserPermission } from './notifications';

export const INTRODUCTION_VERSION = 20181216044202;

export const closeOnboarding = () => dispatch => {
dispatch(changeSetting(['introductionVersion'], INTRODUCTION_VERSION));
dispatch(saveSettings());

dispatch(requestBrowserPermission((permission) => {
if (permission === 'granted') {
dispatch(changeSetting(['notifications', 'alerts', 'follow'], true));
dispatch(changeSetting(['notifications', 'alerts', 'favourite'], true));
dispatch(changeSetting(['notifications', 'alerts', 'reblog'], true));
dispatch(changeSetting(['notifications', 'alerts', 'mention'], true));
dispatch(changeSetting(['notifications', 'alerts', 'poll'], true));
dispatch(changeSetting(['notifications', 'alerts', 'status'], true));
dispatch(saveSettings());
}
}));
};
7 changes: 7 additions & 0 deletions app/javascript/mastodon/components/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import IconButton from './icon_button';
import { defineMessages, injectIntl } from 'react-intl';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { me } from '../initial_state';
import RelativeTimestamp from './relative_timestamp';

const messages = defineMessages({
follow: { id: 'account.follow', defaultMessage: 'Follow' },
Expand Down Expand Up @@ -107,11 +108,17 @@ class Account extends ImmutablePureComponent {
}
}

let mute_expires_at;
if (account.get('mute_expires_at')) {
mute_expires_at = <div><RelativeTimestamp timestamp={account.get('mute_expires_at')} futureDate /></div>;
}

return (
<div className='account'>
<div className='account__wrapper'>
<Permalink key={account.get('id')} className='account__display-name' title={account.get('acct')} href={account.get('url')} to={`/accounts/${account.get('id')}`}>
<div className='account__avatar-wrapper'><Avatar account={account} size={36} /></div>
{mute_expires_at}
<DisplayName account={account} />
</Permalink>

Expand Down
Loading