Merge branch 'master' into french-translation

This commit is contained in:
nicolas 2016-11-25 13:33:00 +01:00 committed by GitHub
commit 959e4b8198
12 changed files with 38 additions and 21 deletions

View file

@ -128,6 +128,6 @@ class Api::V1::AccountsController < ApiController
end end
end end
raw.map { |status| cached_keys_with_value[status.cache_key] || uncached[status.id] } raw.map { |status| cached_keys_with_value[status.cache_key] || uncached[status.id] }.compact
end end
end end

View file

@ -39,6 +39,6 @@ class Api::V1::NotificationsController < ApiController
end end
end end
raw.map { |notification| cached_keys_with_value[notification.cache_key] || uncached[notification.id] } raw.map { |notification| cached_keys_with_value[notification.cache_key] || uncached[notification.id] }.compact
end end
end end

View file

@ -87,6 +87,6 @@ class Api::V1::TimelinesController < ApiController
end end
end end
raw.map { |status| cached_keys_with_value[status.cache_key] || uncached[status.id] } raw.map { |status| cached_keys_with_value[status.cache_key] || uncached[status.id] }.compact
end end
end end

View file

@ -14,7 +14,10 @@ class Settings::PreferencesController < ApplicationController
current_user.settings(:notification_emails).favourite = user_params[:notification_emails][:favourite] == '1' current_user.settings(:notification_emails).favourite = user_params[:notification_emails][:favourite] == '1'
current_user.settings(:notification_emails).mention = user_params[:notification_emails][:mention] == '1' current_user.settings(:notification_emails).mention = user_params[:notification_emails][:mention] == '1'
if current_user.update(user_params.except(:notification_emails)) current_user.settings(:interactions).must_be_follower = user_params[:interactions][:must_be_follower] == '1'
current_user.settings(:interactions).must_be_following = user_params[:interactions][:must_be_following] == '1'
if current_user.update(user_params.except(:notification_emails, :interactions))
redirect_to settings_preferences_path, notice: I18n.t('generic.changes_saved_msg') redirect_to settings_preferences_path, notice: I18n.t('generic.changes_saved_msg')
else else
render action: :show render action: :show
@ -24,6 +27,6 @@ class Settings::PreferencesController < ApplicationController
private private
def user_params def user_params
params.require(:user).permit(:locale, notification_emails: [:follow, :reblog, :favourite, :mention]) params.require(:user).permit(:locale, notification_emails: [:follow, :reblog, :favourite, :mention], interactions: [:must_be_follower, :must_be_following])
end end
end end

View file

@ -68,30 +68,34 @@ class FeedManager
def filter_from_home?(status, receiver) def filter_from_home?(status, receiver)
should_filter = false should_filter = false
if status.reply? && !status.thread.account.nil? # Filter out if it's a reply if status.reply? && !status.thread.account.nil? # Filter out if it's a reply
should_filter = !receiver.following?(status.thread.account) # and I'm not following the person it's a reply to should_filter = !receiver.following?(status.thread.account) # and I'm not following the person it's a reply to
should_filter &&= !(receiver.id == status.thread.account_id) # and it's not a reply to me should_filter &&= !(receiver.id == status.thread.account_id) # and it's not a reply to me
should_filter &&= !(status.account_id == status.thread.account_id) # and it's not a self-reply should_filter &&= !(status.account_id == status.thread.account_id) # and it's not a self-reply
elsif status.reblog? # Filter out a reblog elsif status.reblog? # Filter out a reblog
should_filter = receiver.blocking?(status.reblog.account) # if I'm blocking the reblogged person should_filter = receiver.blocking?(status.reblog.account) # if I'm blocking the reblogged person
end end
should_filter ||= receiver.blocking?(status.mentions.map(&:account_id)) # or if it mentions someone I blocked
should_filter should_filter
end end
def filter_from_mentions?(status, receiver) def filter_from_mentions?(status, receiver)
should_filter = receiver.id == status.account_id # Filter if I'm mentioning myself should_filter = receiver.id == status.account_id # Filter if I'm mentioning myself
should_filter ||= receiver.blocking?(status.account) # or it's from someone I blocked should_filter ||= receiver.blocking?(status.account) # or it's from someone I blocked
should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account)) # or if it mentions someone I blocked
if status.reply? && !status.thread.account.nil? # or it's a reply if status.reply? && !status.thread.account.nil? # or it's a reply
should_filter ||= receiver.blocking?(status.thread.account) # to a user I blocked should_filter ||= receiver.blocking?(status.thread.account) # to a user I blocked
end end
should_filter should_filter
end end
def filter_from_public?(status, receiver) def filter_from_public?(status, receiver)
should_filter = receiver.blocking?(status.account) should_filter = receiver.blocking?(status.account)
should_filter ||= receiver.blocking?(status.mentions.includes(:account).map(&:account))
if status.reply? && !status.thread.account.nil? if status.reply? && !status.thread.account.nil?
should_filter ||= receiver.blocking?(status.thread.account) should_filter ||= receiver.blocking?(status.thread.account)

View file

@ -66,12 +66,12 @@ class Account < ApplicationRecord
def unfollow!(other_account) def unfollow!(other_account)
follow = active_relationships.find_by(target_account: other_account) follow = active_relationships.find_by(target_account: other_account)
follow.destroy unless follow.nil? follow&.destroy
end end
def unblock!(other_account) def unblock!(other_account)
block = block_relationships.find_by(target_account: other_account) block = block_relationships.find_by(target_account: other_account)
block.destroy unless block.nil? block&.destroy
end end
def following?(other_account) def following?(other_account)

View file

@ -15,6 +15,7 @@ class User < ApplicationRecord
has_settings do |s| has_settings do |s|
s.key :notification_emails, defaults: { follow: false, reblog: false, favourite: false, mention: false } s.key :notification_emails, defaults: { follow: false, reblog: false, favourite: false, mention: false }
s.key :interactions, defaults: { must_be_follower: false, must_be_following: false }
end end
def send_devise_notification(notification, *args) def send_devise_notification(notification, *args)

View file

@ -36,6 +36,8 @@ class NotifyService < BaseService
blocked = false blocked = false
blocked ||= @recipient.id == @notification.from_account.id blocked ||= @recipient.id == @notification.from_account.id
blocked ||= @recipient.blocking?(@notification.from_account) blocked ||= @recipient.blocking?(@notification.from_account)
blocked ||= (@recipient.user.settings(:interactions).must_be_follower && !@notification.from_account.following?(@recipient))
blocked ||= (@recipient.user.settings(:interactions).must_be_following && !@recipient.following?(@notification.from_account))
blocked ||= send("blocked_#{@notification.type}?") blocked ||= send("blocked_#{@notification.type}?")
blocked blocked
end end

View file

@ -12,6 +12,10 @@
= ff.input :favourite, as: :boolean, wrapper: :with_label = ff.input :favourite, as: :boolean, wrapper: :with_label
= ff.input :mention, as: :boolean, wrapper: :with_label = ff.input :mention, as: :boolean, wrapper: :with_label
= f.simple_fields_for :interactions, current_user.settings(:interactions) do |ff|
= ff.input :must_be_follower, as: :boolean, wrapper: :with_label
= ff.input :must_be_following, as: :boolean, wrapper: :with_label
.actions .actions
= f.button :button, t('generic.save_changes'), type: :submit = f.button :button, t('generic.save_changes'), type: :submit

View file

@ -30,9 +30,6 @@ search:
- app/assets/fonts - app/assets/fonts
- app/assets/videos - app/assets/videos
ignore_missing:
- '{devise,simple_form}.*'
ignore_unused: ignore_unused:
- 'activerecord.attributes.*' - 'activerecord.attributes.*'
- '{devise,will_paginate,doorkeeper}.*' - '{devise,will_paginate,doorkeeper}.*'

View file

@ -16,6 +16,9 @@ de:
password: Passwort password: Passwort
silenced: Öffentliche Beiträge nicht auflisten silenced: Öffentliche Beiträge nicht auflisten
username: Nutzername username: Nutzername
interactions:
must_be_follower: Benachrichtigungen von nicht-Folgern blockieren
must_be_following: Benachrichtigungen von Nutzern blockieren, denen ich nicht folge
notification_emails: notification_emails:
favourite: E-mail senden, wenn jemand meinen Beitrag favorisiert favourite: E-mail senden, wenn jemand meinen Beitrag favorisiert
follow: E-mail senden, wenn mir jemand folgt follow: E-mail senden, wenn mir jemand folgt

View file

@ -16,6 +16,9 @@ en:
password: Password password: Password
silenced: Unlisted mode silenced: Unlisted mode
username: Username username: Username
interactions:
must_be_follower: Block notifications from non-followers
must_be_following: Block notifications from people you don't follow
notification_emails: notification_emails:
favourite: Send e-mail when someone favourites your status favourite: Send e-mail when someone favourites your status
follow: Send e-mail when someone follows you follow: Send e-mail when someone follows you