about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2018-10-30 17:52:08 +0100
committerThibaut Girka <thib@sitedethib.com>2018-10-30 17:52:08 +0100
commit1c448d647488dc3dd3b72e9fe15efb971612157c (patch)
tree2b31e4ed019a29043aa07d9d95e7f8b64e309bbd /app
parent7e18e95716052d5566f2e31559cbe4a68268f493 (diff)
parent66019b0ec4aaa584e58e91583425ed7c0d55c28e (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/controllers/auth/sessions_controller.rb

Upstream reverted something we partially reverted already.
Reverted the rest to match upstream.
Diffstat (limited to 'app')
-rw-r--r--app/controllers/auth/sessions_controller.rb9
-rw-r--r--app/javascript/mastodon/actions/importer/normalizer.js2
-rw-r--r--app/javascript/mastodon/locales/oc.json6
-rw-r--r--app/lib/activitypub/activity/create.rb20
-rw-r--r--app/services/fan_out_on_write_service.rb6
-rw-r--r--app/services/fetch_atom_service.rb10
-rw-r--r--app/services/fetch_link_card_service.rb8
-rw-r--r--app/services/notify_service.rb10
-rw-r--r--app/views/auth/registrations/_sessions.html.haml2
9 files changed, 43 insertions, 30 deletions
diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb
index d4a659409..332f4d7a7 100644
--- a/app/controllers/auth/sessions_controller.rb
+++ b/app/controllers/auth/sessions_controller.rb
@@ -11,7 +11,6 @@ class Auth::SessionsController < Devise::SessionsController
   prepend_before_action :set_pack
   before_action :set_instance_presenter, only: [:new]
   before_action :set_body_classes
-  after_action :clear_site_data, only: [:destroy]
 
   def new
     Devise.omniauth_configs.each do |provider, config|
@@ -130,14 +129,6 @@ class Auth::SessionsController < Devise::SessionsController
     paths
   end
 
-  def clear_site_data
-    return if continue_after?
-
-    # Should be '"*"' but that doesn't work in Chrome (neither does '"executionContexts"')
-    # https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Clear-Site-Data
-    response.headers['Clear-Site-Data'] = '"cache", "cookies"'
-  end
-
   def continue_after?
     truthy_param?(:continue)
   end
diff --git a/app/javascript/mastodon/actions/importer/normalizer.js b/app/javascript/mastodon/actions/importer/normalizer.js
index a2af3222e..34a4150fa 100644
--- a/app/javascript/mastodon/actions/importer/normalizer.js
+++ b/app/javascript/mastodon/actions/importer/normalizer.js
@@ -14,7 +14,7 @@ export function normalizeAccount(account) {
   account = { ...account };
 
   const emojiMap = makeEmojiMap(account);
-  const displayName = account.display_name.length === 0 ? account.username : account.display_name;
+  const displayName = account.display_name.trim().length === 0 ? account.username : account.display_name;
 
   account.display_name_html = emojify(escapeTextContentForBrowser(displayName), emojiMap);
   account.note_emojified = emojify(account.note, emojiMap);
diff --git a/app/javascript/mastodon/locales/oc.json b/app/javascript/mastodon/locales/oc.json
index 64ada60da..93ab4be7d 100644
--- a/app/javascript/mastodon/locales/oc.json
+++ b/app/javascript/mastodon/locales/oc.json
@@ -157,7 +157,7 @@
   "keyboard_shortcuts.legend": "mostrar aquesta legenda",
   "keyboard_shortcuts.local": "per dobrir lo flux public local",
   "keyboard_shortcuts.mention": "mencionar l’autor",
-  "keyboard_shortcuts.muted": "per dorbir la lista dels utilizaires silenciats",
+  "keyboard_shortcuts.muted": "per dobrir la lista dels utilizaires silenciats",
   "keyboard_shortcuts.my_profile": "per dobrir vòstre perfil",
   "keyboard_shortcuts.notifications": "per dobrir la columna de notificacions",
   "keyboard_shortcuts.pinned": "per dobrir la lista dels tuts penjats",
@@ -314,8 +314,8 @@
   "status.show_more_all": "Los desplegar totes",
   "status.unmute_conversation": "Tornar mostrar la conversacion",
   "status.unpin": "Tirar del perfil",
-  "suggestions.dismiss": "Dismiss suggestion",
-  "suggestions.header": "You might be interested in…",
+  "suggestions.dismiss": "Regetar la suggestion",
+  "suggestions.header": "Aquò vos poiriá interessar…",
   "tabs_bar.federated_timeline": "Flux public global",
   "tabs_bar.home": "Acuèlh",
   "tabs_bar.local_timeline": "Flux public local",
diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb
index baa05e14c..45079e2b3 100644
--- a/app/lib/activitypub/activity/create.rb
+++ b/app/lib/activitypub/activity/create.rb
@@ -10,7 +10,12 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
     RedisLock.acquire(lock_options) do |lock|
       if lock.acquired?
         @status = find_existing_status
-        process_status if @status.nil?
+
+        if @status.nil?
+          process_status
+        elsif @options[:delivered_to_account_id].present?
+          postprocess_audience_and_deliver
+        end
       else
         raise Mastodon::RaceConditionError
       end
@@ -99,6 +104,19 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
     @params[:visibility] = :limited
   end
 
+  def postprocess_audience_and_deliver
+    return if @status.mentions.find_by(account_id: @options[:delivered_to_account_id])
+
+    delivered_to_account = Account.find(@options[:delivered_to_account_id])
+
+    @status.mentions.create(account: delivered_to_account, silent: true)
+    @status.update(visibility: :limited) if @status.direct_visibility?
+
+    return unless delivered_to_account.following?(@account)
+
+    FeedInsertWorker.perform_async(@status.id, delivered_to_account.id, :home)
+  end
+
   def attach_tags(status)
     @tags.each do |tag|
       status.tags << tag
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index 63cab8403..de7c031d8 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -61,10 +61,8 @@ class FanOutOnWriteService < BaseService
   def deliver_to_mentioned_followers(status)
     Rails.logger.debug "Delivering status #{status.id} to limited followers"
 
-    status.mentions.includes(:account).each do |mention|
-      mentioned_account = mention.account
-      next if !mentioned_account.local? || !mentioned_account.following?(status.account) || FeedManager.instance.filter?(:home, status, mention.account_id)
-      FeedManager.instance.push_to_home(mentioned_account, status)
+    FeedInsertWorker.push_bulk(status.mentions.includes(:account).map(&:account).select { |mentioned_account| mentioned_account.local? && mentioned_account.following?(status.account) }) do |follower|
+      [status.id, follower.id, :home]
     end
   end
 
diff --git a/app/services/fetch_atom_service.rb b/app/services/fetch_atom_service.rb
index 550e75f33..b6c6cdd1c 100644
--- a/app/services/fetch_atom_service.rb
+++ b/app/services/fetch_atom_service.rb
@@ -29,7 +29,7 @@ class FetchAtomService < BaseService
 
   def perform_request(&block)
     accept = 'text/html'
-    accept = 'application/activity+json, application/ld+json, application/atom+xml, ' + accept unless @unsupported_activity
+    accept = 'application/activity+json, application/ld+json; profile="https://www.w3.org/ns/activitystreams", application/atom+xml, ' + accept unless @unsupported_activity
 
     Request.new(:get, @url).add_headers('Accept' => accept).perform(&block)
   end
@@ -37,9 +37,11 @@ class FetchAtomService < BaseService
   def process_response(response, terminal = false)
     return nil if response.code != 200
 
-    if response.mime_type == 'application/atom+xml'
+    response_type = response.headers['Content-type']
+
+    if response_type == 'application/atom+xml'
       [@url, { prefetched_body: response.body_with_limit }, :ostatus]
-    elsif ['application/activity+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'].include?(response.mime_type)
+    elsif ['application/activity+json', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'].include?(response_type)
       body = response.body_with_limit
       json = body_to_json(body)
       if supported_context?(json) && equals_or_includes_any?(json['type'], ActivityPub::FetchRemoteAccountService::SUPPORTED_TYPES) && json['inbox'].present?
@@ -55,7 +57,7 @@ class FetchAtomService < BaseService
 
       if link_header&.find_link(%w(rel alternate))
         process_link_headers(link_header)
-      elsif response.mime_type == 'text/html'
+      elsif response_type == 'text/html'
         process_html(response)
       end
     end
diff --git a/app/services/fetch_link_card_service.rb b/app/services/fetch_link_card_service.rb
index 462e5ee13..3e77579bb 100644
--- a/app/services/fetch_link_card_service.rb
+++ b/app/services/fetch_link_card_service.rb
@@ -17,8 +17,7 @@ class FetchLinkCardService < BaseService
 
     return if @url.nil? || @status.preview_cards.any?
 
-    @mentions = status.mentions
-    @url      = @url.to_s
+    @url = @url.to_s
 
     RedisLock.acquire(lock_options) do |lock|
       if lock.acquired?
@@ -84,9 +83,8 @@ class FetchLinkCardService < BaseService
   end
 
   def mention_link?(a)
-    return false if @mentions.nil?
-    @mentions.any? do |mention|
-      a['href'] == TagManager.instance.url_for(mention.target)
+    @status.mentions.any? do |mention|
+      a['href'] == TagManager.instance.url_for(mention.account)
     end
   end
 
diff --git a/app/services/notify_service.rb b/app/services/notify_service.rb
index a8b7bb30b..b80ceef03 100644
--- a/app/services/notify_service.rb
+++ b/app/services/notify_service.rb
@@ -51,8 +51,12 @@ class NotifyService < BaseService
     @recipient.user.settings.interactions['must_be_following'] && !following_sender?
   end
 
+  def message?
+    @notification.type == :mention
+  end
+
   def direct_message?
-    @notification.type == :mention && @notification.target_status.direct_visibility?
+    message? && @notification.target_status.direct_visibility?
   end
 
   def response_to_recipient?
@@ -66,7 +70,6 @@ class NotifyService < BaseService
   def optional_non_following_and_direct?
     direct_message? &&
       @recipient.user.settings.interactions['must_be_following_dm'] &&
-      !from_staff? &&
       !following_sender? &&
       !response_to_recipient?
   end
@@ -86,6 +89,9 @@ class NotifyService < BaseService
   def blocked?
     blocked   = @recipient.suspended?                            # Skip if the recipient account is suspended anyway
     blocked ||= from_self?                                       # Skip for interactions with self
+
+    return blocked if message? && from_staff?
+
     blocked ||= domain_blocking?                                 # Skip for domain blocked accounts
     blocked ||= @recipient.blocking?(@notification.from_account) # Skip for blocked accounts
     blocked ||= @recipient.muting_notifications?(@notification.from_account)
diff --git a/app/views/auth/registrations/_sessions.html.haml b/app/views/auth/registrations/_sessions.html.haml
index 8586c0549..d7d96a1bb 100644
--- a/app/views/auth/registrations/_sessions.html.haml
+++ b/app/views/auth/registrations/_sessions.html.haml
@@ -8,7 +8,7 @@
         %th= t 'sessions.browser'
         %th= t 'sessions.ip'
         %th= t 'sessions.activity'
-        %td
+        %th
     %tbody
       - @sessions.each do |session|
         %tr