Skip to content

Commit

Permalink
merge upstream & update theme (#234)
Browse files Browse the repository at this point in the history
* Bump babel-jest from 26.3.0 to 26.5.2 (mastodon#14945)

Bumps [babel-jest](https://github.com/facebook/jest/tree/HEAD/packages/babel-jest) from 26.3.0 to 26.5.2.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md)
- [Commits](https://github.com/facebook/jest/commits/v26.5.2/packages/babel-jest)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump @github/webauthn-json from 0.5.5 to 0.5.6 (mastodon#14946)

Bumps [@github/webauthn-json](https://github.com/github/webauthn-json) from 0.5.5 to 0.5.6.
- [Release notes](https://github.com/github/webauthn-json/releases)
- [Commits](github/webauthn-json@v0.5.5...v0.5.6)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump sass from 1.26.11 to 1.26.12 (mastodon#14947)

Bumps [sass](https://github.com/sass/dart-sass) from 1.26.11 to 1.26.12.
- [Release notes](https://github.com/sass/dart-sass/releases)
- [Changelog](https://github.com/sass/dart-sass/blob/master/CHANGELOG.md)
- [Commits](sass/dart-sass@1.26.11...1.26.12)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump eslint-plugin-react from 7.21.2 to 7.21.3 (mastodon#14950)

Bumps [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) from 7.21.2 to 7.21.3.
- [Release notes](https://github.com/yannickcr/eslint-plugin-react/releases)
- [Changelog](https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](jsx-eslint/eslint-plugin-react@v7.21.2...v7.21.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump mini-css-extract-plugin from 0.11.0 to 0.11.3 (mastodon#14949)

Bumps [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) from 0.11.0 to 0.11.3.
- [Release notes](https://github.com/webpack-contrib/mini-css-extract-plugin/releases)
- [Changelog](https://github.com/webpack-contrib/mini-css-extract-plugin/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/mini-css-extract-plugin@v0.11.0...v0.11.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump jest from 26.4.2 to 26.5.2 (mastodon#14951)

Bumps [jest](https://github.com/facebook/jest) from 26.4.2 to 26.5.2.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md)
- [Commits](jestjs/jest@v26.4.2...v26.5.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump eslint from 7.6.0 to 7.10.0 (mastodon#14948)

Bumps [eslint](https://github.com/eslint/eslint) from 7.6.0 to 7.10.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.6.0...v7.10.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* update themes

* Remove dependency on goldfinger gem (mastodon#14919)

There are edge cases where requests to certain hosts timeout when
using the vanilla HTTP.rb gem, which the goldfinger gem uses. Now
that we no longer need to support OStatus servers, webfinger logic
is so simple that there is no point encapsulating it in a gem, so
we can just use our own Request class. With that, we benefit from
more robust timeout code and IPv4/IPv6 resolution.

Fix mastodon#14091

* Fix unread notification marker not updating when mounting column (mastodon#14954)

* Fix issue checking for last unread notification when there are gaps (mastodon#14960)

* add & fix themes

* update theme

* fix theme

* fix theme

* Add IP-based rules (mastodon#14963)

* Fix browser notification permission request logic (mastodon#13543)

* Add notification permission handling code

* Request notification permission when enabling any notification setting

* Add badge to notification settings when permissions insufficient

* Disable alerts by default, requesting permission and enable them on onboarding

* Add duration parameter to muting. (mastodon#13831)

* Adding duration to muting.

* Remove useless checks

* helm: add optional cron job to run `tootctl remove media` (mastodon#14396)

* Change how CDN_HOST is passed down to make assets build reproducible (mastodon#14381)

* Change how CDN_HOST is passed down to make assets build reproducible

* Change webpacker/webpack configuration to dynamically load publicPath based on meta header

* Fix embedded layout missing the cdn-host meta header

* Bump compression-webpack-plugin from 6.0.2 to 6.0.3 (mastodon#14979)

Bumps [compression-webpack-plugin](https://github.com/webpack-contrib/compression-webpack-plugin) from 6.0.2 to 6.0.3.
- [Release notes](https://github.com/webpack-contrib/compression-webpack-plugin/releases)
- [Changelog](https://github.com/webpack-contrib/compression-webpack-plugin/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/compression-webpack-plugin@v6.0.2...v6.0.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump sass-loader from 10.0.2 to 10.0.3 (mastodon#14977)

Bumps [sass-loader](https://github.com/webpack-contrib/sass-loader) from 10.0.2 to 10.0.3.
- [Release notes](https://github.com/webpack-contrib/sass-loader/releases)
- [Changelog](https://github.com/webpack-contrib/sass-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/sass-loader@v10.0.2...v10.0.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump imports-loader from 1.1.0 to 1.2.0 (mastodon#14976)

Bumps [imports-loader](https://github.com/webpack-contrib/imports-loader) from 1.1.0 to 1.2.0.
- [Release notes](https://github.com/webpack-contrib/imports-loader/releases)
- [Changelog](https://github.com/webpack-contrib/imports-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/imports-loader@v1.1.0...v1.2.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump tzinfo-data from 1.2020.1 to 1.2020.2 (mastodon#14966)

Bumps [tzinfo-data](https://github.com/tzinfo/tzinfo-data) from 1.2020.1 to 1.2020.2.
- [Release notes](https://github.com/tzinfo/tzinfo-data/releases)
- [Commits](tzinfo/tzinfo-data@v1.2020.1...v1.2020.2)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump rubocop from 0.92.0 to 0.93.0 (mastodon#14967)

Bumps [rubocop](https://github.com/rubocop-hq/rubocop) from 0.92.0 to 0.93.0.
- [Release notes](https://github.com/rubocop-hq/rubocop/releases)
- [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md)
- [Commits](rubocop/rubocop@v0.92.0...v0.93.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump file-loader from 6.1.0 to 6.1.1 (mastodon#14974)

Bumps [file-loader](https://github.com/webpack-contrib/file-loader) from 6.1.0 to 6.1.1.
- [Release notes](https://github.com/webpack-contrib/file-loader/releases)
- [Changelog](https://github.com/webpack-contrib/file-loader/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/file-loader@v6.1.0...v6.1.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump eslint-plugin-react from 7.21.3 to 7.21.4 (mastodon#14968)

Bumps [eslint-plugin-react](https://github.com/yannickcr/eslint-plugin-react) from 7.21.3 to 7.21.4.
- [Release notes](https://github.com/yannickcr/eslint-plugin-react/releases)
- [Changelog](https://github.com/yannickcr/eslint-plugin-react/blob/master/CHANGELOG.md)
- [Commits](jsx-eslint/eslint-plugin-react@v7.21.3...v7.21.4)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump terser-webpack-plugin from 4.2.2 to 4.2.3 (mastodon#14971)

Bumps [terser-webpack-plugin](https://github.com/webpack-contrib/terser-webpack-plugin) from 4.2.2 to 4.2.3.
- [Release notes](https://github.com/webpack-contrib/terser-webpack-plugin/releases)
- [Changelog](https://github.com/webpack-contrib/terser-webpack-plugin/blob/master/CHANGELOG.md)
- [Commits](webpack-contrib/terser-webpack-plugin@v4.2.2...v4.2.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump eslint from 7.10.0 to 7.11.0 (mastodon#14975)

Bumps [eslint](https://github.com/eslint/eslint) from 7.10.0 to 7.11.0.
- [Release notes](https://github.com/eslint/eslint/releases)
- [Changelog](https://github.com/eslint/eslint/blob/master/CHANGELOG.md)
- [Commits](eslint/eslint@v7.10.0...v7.11.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump sass from 1.26.12 to 1.27.0 (mastodon#14973)

Bumps [sass](https://github.com/sass/dart-sass) from 1.26.12 to 1.27.0.
- [Release notes](https://github.com/sass/dart-sass/releases)
- [Changelog](https://github.com/sass/dart-sass/blob/master/CHANGELOG.md)
- [Commits](sass/dart-sass@1.26.12...1.27.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump jest from 26.5.2 to 26.5.3 (mastodon#14969)

Bumps [jest](https://github.com/facebook/jest) from 26.5.2 to 26.5.3.
- [Release notes](https://github.com/facebook/jest/releases)
- [Changelog](https://github.com/facebook/jest/blob/master/CHANGELOG.md)
- [Commits](jestjs/jest@v26.5.2...v26.5.3)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Fix a bear check when the activity object is nil (mastodon#14981)

* Change how missing desktop notifications permission is displayed (mastodon#14985)

Add missing controls for new notification type

* Fix strings that could not be translated (mastodon#14980)

* Fix translation string (mastodon#14986)

* update theme

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eugen Rochko <eugen@zeonfederated.com>
Co-authored-by: ThibG <thib@sitedethib.com>
Co-authored-by: OSAMU SATO <satosamu@gmail.com>
Co-authored-by: Alex Dunn <dunn.alex@gmail.com>
Co-authored-by: Takeshi Umeda <noel.yoshiba@gmail.com>
Co-authored-by: mayaeh <mayaeh@marimo-net.org>
  • Loading branch information
8 people authored Oct 16, 2020
1 parent 6c485bf commit f9afbd0
Show file tree
Hide file tree
Showing 99 changed files with 1,523 additions and 399 deletions.
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

0 comments on commit f9afbd0

Please sign in to comment.