diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/api/web/push_subscriptions_controller.rb | 1 | ||||
-rw-r--r-- | app/javascript/mastodon/features/ui/components/columns_area.js | 5 | ||||
-rw-r--r-- | app/javascript/mastodon/features/ui/containers/columns_area_container.js | 1 | ||||
-rw-r--r-- | app/javascript/styles/mastodon/components.scss | 4 | ||||
-rw-r--r-- | app/models/user.rb | 4 | ||||
-rw-r--r-- | app/services/activitypub/fetch_remote_status_service.rb | 2 | ||||
-rw-r--r-- | app/workers/digest_mailer_worker.rb | 6 | ||||
-rw-r--r-- | app/workers/scheduler/email_scheduler.rb | 24 |
8 files changed, 39 insertions, 8 deletions
diff --git a/app/controllers/api/web/push_subscriptions_controller.rb b/app/controllers/api/web/push_subscriptions_controller.rb index 52e250d02..68ccbd5e2 100644 --- a/app/controllers/api/web/push_subscriptions_controller.rb +++ b/app/controllers/api/web/push_subscriptions_controller.rb @@ -4,6 +4,7 @@ class Api::Web::PushSubscriptionsController < Api::BaseController respond_to :json before_action :require_user! + protect_from_forgery with: :exception def create params.require(:subscription).require(:endpoint) diff --git a/app/javascript/mastodon/features/ui/components/columns_area.js b/app/javascript/mastodon/features/ui/components/columns_area.js index f00b74dfd..a01e5a390 100644 --- a/app/javascript/mastodon/features/ui/components/columns_area.js +++ b/app/javascript/mastodon/features/ui/components/columns_area.js @@ -37,6 +37,7 @@ export default class ColumnsArea extends ImmutablePureComponent { static propTypes = { intl: PropTypes.object.isRequired, columns: ImmutablePropTypes.list.isRequired, + isModalOpen: PropTypes.bool.isRequired, singleColumn: PropTypes.bool, children: PropTypes.node, }; @@ -144,7 +145,7 @@ export default class ColumnsArea extends ImmutablePureComponent { } render () { - const { columns, children, singleColumn } = this.props; + const { columns, children, singleColumn, isModalOpen } = this.props; const { shouldAnimate } = this.state; const columnIndex = getIndex(this.context.router.history.location.pathname); @@ -159,7 +160,7 @@ export default class ColumnsArea extends ImmutablePureComponent { } return ( - <div className='columns-area' ref={this.setRef}> + <div className={`columns-area ${ isModalOpen ? 'unscrollable' : '' }`} ref={this.setRef}> {columns.map(column => { const params = column.get('params', null) === null ? null : column.get('params').toJS(); diff --git a/app/javascript/mastodon/features/ui/containers/columns_area_container.js b/app/javascript/mastodon/features/ui/containers/columns_area_container.js index 95f95618b..f3e82a8ac 100644 --- a/app/javascript/mastodon/features/ui/containers/columns_area_container.js +++ b/app/javascript/mastodon/features/ui/containers/columns_area_container.js @@ -3,6 +3,7 @@ import ColumnsArea from '../components/columns_area'; const mapStateToProps = state => ({ columns: state.getIn(['settings', 'columns']), + isModalOpen: !!state.get('modal').modalType, }); export default connect(mapStateToProps, null, null, { withRef: true })(ColumnsArea); diff --git a/app/javascript/styles/mastodon/components.scss b/app/javascript/styles/mastodon/components.scss index a2e908683..71bffdaa6 100644 --- a/app/javascript/styles/mastodon/components.scss +++ b/app/javascript/styles/mastodon/components.scss @@ -1613,6 +1613,10 @@ justify-content: flex-start; overflow-x: auto; position: relative; + + &.unscrollable { + overflow-x: hidden; + } } @media screen and (min-width: 360px) { diff --git a/app/models/user.rb b/app/models/user.rb index 855ae908d..65ecb33cd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -170,6 +170,10 @@ class User < ApplicationRecord settings.default_privacy || (account.locked? ? 'private' : 'public') end + def allows_digest_emails? + settings.notification_emails['digest'] + end + def token_for_app(a) return nil if a.nil? || a.owner != self Doorkeeper::AccessToken diff --git a/app/services/activitypub/fetch_remote_status_service.rb b/app/services/activitypub/fetch_remote_status_service.rb index 7649bceca..503c175d8 100644 --- a/app/services/activitypub/fetch_remote_status_service.rb +++ b/app/services/activitypub/fetch_remote_status_service.rb @@ -30,7 +30,7 @@ class ActivityPub::FetchRemoteStatusService < BaseService end def actor_id - first_of_value(@json['attributedTo']) + value_or_id(first_of_value(@json['attributedTo'])) end def trustworthy_attribution?(uri, attributed_to) diff --git a/app/workers/digest_mailer_worker.rb b/app/workers/digest_mailer_worker.rb index 028db89a9..21f1c357a 100644 --- a/app/workers/digest_mailer_worker.rb +++ b/app/workers/digest_mailer_worker.rb @@ -9,7 +9,7 @@ class DigestMailerWorker def perform(user_id) @user = User.find(user_id) - deliver_digest if user_receives_digest? + deliver_digest if @user.allows_digest_emails? end private @@ -18,8 +18,4 @@ class DigestMailerWorker NotificationMailer.digest(user.account).deliver_now! user.touch(:last_emailed_at) end - - def user_receives_digest? - user.settings.notification_emails['digest'] - end end diff --git a/app/workers/scheduler/email_scheduler.rb b/app/workers/scheduler/email_scheduler.rb new file mode 100644 index 000000000..24d0c0ebe --- /dev/null +++ b/app/workers/scheduler/email_scheduler.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true +require 'sidekiq-scheduler' + +class Scheduler::EmailScheduler + include Sidekiq::Worker + + def perform + eligible_users.find_each do |user| + next unless user.allows_digest_emails? + DigestMailerWorker.perform_async(user.id) + end + end + + private + + def eligible_users + User.confirmed + .joins(:account) + .where(accounts: { silenced: false, suspended: false }) + .where(disabled: false) + .where('current_sign_in_at < ?', 20.days.ago) + .where('last_emailed_at IS NULL OR last_emailed_at < ?', 20.days.ago) + end +end |