about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/about_controller.rb2
-rw-r--r--app/controllers/accounts_controller.rb7
-rw-r--r--app/controllers/api/salmon_controller.rb2
-rw-r--r--app/controllers/api/subscriptions_controller.rb2
-rw-r--r--app/controllers/api/v1/accounts_controller.rb8
-rw-r--r--app/controllers/api/v1/apps_controller.rb2
-rw-r--r--app/controllers/api/v1/follows_controller.rb2
-rw-r--r--app/controllers/api/v1/media_controller.rb2
-rw-r--r--app/controllers/api/v1/statuses_controller.rb8
-rw-r--r--app/controllers/api/v1/timelines_controller.rb10
-rw-r--r--app/controllers/api_controller.rb8
-rw-r--r--app/controllers/application_controller.rb2
-rw-r--r--app/controllers/auth/confirmations_controller.rb2
-rw-r--r--app/controllers/auth/passwords_controller.rb2
-rw-r--r--app/controllers/auth/registrations_controller.rb2
-rw-r--r--app/controllers/auth/sessions_controller.rb2
-rw-r--r--app/controllers/home_controller.rb2
-rw-r--r--app/controllers/media_controller.rb2
-rw-r--r--app/controllers/oauth/authorizations_controller.rb2
-rw-r--r--app/controllers/settings/preferences_controller.rb2
-rw-r--r--app/controllers/settings/profiles_controller.rb2
-rw-r--r--app/controllers/stream_entries_controller.rb6
-rw-r--r--app/controllers/tags_controller.rb2
-rw-r--r--app/controllers/xrd_controller.rb10
24 files changed, 67 insertions, 24 deletions
diff --git a/app/controllers/about_controller.rb b/app/controllers/about_controller.rb
index 4e423e91f..56ad6365d 100644
--- a/app/controllers/about_controller.rb
+++ b/app/controllers/about_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class AboutController < ApplicationController
   before_action :set_body_classes
 
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index b16938845..5d2f4eee0 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class AccountsController < ApplicationController
   layout 'public'
 
@@ -41,10 +43,7 @@ class AccountsController < ApplicationController
   end
 
   def set_link_headers
-    response.headers['Link'] = LinkHeader.new([
-      [webfinger_account_url, [['rel', 'lrdd'], ['type', 'application/xrd+xml']]],
-      [account_url(@account, format: 'atom'), [['rel', 'alternate'], ['type', 'application/atom+xml']]]
-    ])
+    response.headers['Link'] = LinkHeader.new([[webfinger_account_url, [%w(rel lrdd), %w(type application/xrd+xml)]], [account_url(@account, format: 'atom'), [%w(rel alternate), %w(type application/atom+xml)]]])
   end
 
   def webfinger_account_url
diff --git a/app/controllers/api/salmon_controller.rb b/app/controllers/api/salmon_controller.rb
index c0ba32ff2..01862a900 100644
--- a/app/controllers/api/salmon_controller.rb
+++ b/app/controllers/api/salmon_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Api::SalmonController < ApiController
   before_action :set_account
   respond_to :txt
diff --git a/app/controllers/api/subscriptions_controller.rb b/app/controllers/api/subscriptions_controller.rb
index 058ae8f5e..51c476436 100644
--- a/app/controllers/api/subscriptions_controller.rb
+++ b/app/controllers/api/subscriptions_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Api::SubscriptionsController < ApiController
   before_action :set_account
   respond_to :txt
diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb
index 88af41bf8..2dfab0831 100644
--- a/app/controllers/api/v1/accounts_controller.rb
+++ b/app/controllers/api/v1/accounts_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Api::V1::AccountsController < ApiController
   before_action -> { doorkeeper_authorize! :read }, except: [:follow, :unfollow, :block, :unblock]
   before_action -> { doorkeeper_authorize! :follow }, only: [:follow, :unfollow, :block, :unblock]
@@ -20,7 +22,7 @@ class Api::V1::AccountsController < ApiController
     @accounts = results.map { |f| accounts[f.target_account_id] }
 
     next_path = following_api_v1_account_url(max_id: results.last.id)    if results.size == DEFAULT_ACCOUNTS_LIMIT
-    prev_path = following_api_v1_account_url(since_id: results.first.id) if results.size > 0
+    prev_path = following_api_v1_account_url(since_id: results.first.id) unless results.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -33,7 +35,7 @@ class Api::V1::AccountsController < ApiController
     @accounts = results.map { |f| accounts[f.account_id] }
 
     next_path = followers_api_v1_account_url(max_id: results.last.id)    if results.size == DEFAULT_ACCOUNTS_LIMIT
-    prev_path = followers_api_v1_account_url(since_id: results.first.id) if results.size > 0
+    prev_path = followers_api_v1_account_url(since_id: results.first.id) unless results.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -56,7 +58,7 @@ class Api::V1::AccountsController < ApiController
     set_maps(@statuses)
 
     next_path = statuses_api_v1_account_url(max_id: @statuses.last.id)    if @statuses.size == DEFAULT_STATUSES_LIMIT
-    prev_path = statuses_api_v1_account_url(since_id: @statuses.first.id) if @statuses.size > 0
+    prev_path = statuses_api_v1_account_url(since_id: @statuses.first.id) unless @statuses.empty?
 
     set_pagination_headers(next_path, prev_path)
   end
diff --git a/app/controllers/api/v1/apps_controller.rb b/app/controllers/api/v1/apps_controller.rb
index a09c29cc6..d1db16cf2 100644
--- a/app/controllers/api/v1/apps_controller.rb
+++ b/app/controllers/api/v1/apps_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Api::V1::AppsController < ApiController
   respond_to :json
 
diff --git a/app/controllers/api/v1/follows_controller.rb b/app/controllers/api/v1/follows_controller.rb
index 6a77c4d66..c22dacbaa 100644
--- a/app/controllers/api/v1/follows_controller.rb
+++ b/app/controllers/api/v1/follows_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Api::V1::FollowsController < ApiController
   before_action -> { doorkeeper_authorize! :follow }
   before_action :require_user!
diff --git a/app/controllers/api/v1/media_controller.rb b/app/controllers/api/v1/media_controller.rb
index 6b93e47b4..bb8e8d9ee 100644
--- a/app/controllers/api/v1/media_controller.rb
+++ b/app/controllers/api/v1/media_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Api::V1::MediaController < ApiController
   before_action -> { doorkeeper_authorize! :write }
   before_action :require_user!
diff --git a/app/controllers/api/v1/statuses_controller.rb b/app/controllers/api/v1/statuses_controller.rb
index f5dbbd013..e1a417129 100644
--- a/app/controllers/api/v1/statuses_controller.rb
+++ b/app/controllers/api/v1/statuses_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Api::V1::StatusesController < ApiController
   before_action -> { doorkeeper_authorize! :read }, except: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite]
   before_action -> { doorkeeper_authorize! :write }, only:  [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite]
@@ -10,7 +12,7 @@ class Api::V1::StatusesController < ApiController
   end
 
   def context
-    @context = OpenStruct.new({ ancestors: @status.ancestors, descendants: @status.descendants })
+    @context = OpenStruct.new(ancestors: @status.ancestors, descendants: @status.descendants)
     set_maps([@status] + @context[:ancestors] + @context[:descendants])
   end
 
@@ -20,7 +22,7 @@ class Api::V1::StatusesController < ApiController
     @accounts = results.map { |r| accounts[r.account_id] }
 
     next_path = reblogged_by_api_v1_status_url(max_id: results.last.id)    if results.size == DEFAULT_ACCOUNTS_LIMIT
-    prev_path = reblogged_by_api_v1_status_url(since_id: results.first.id) if results.size > 0
+    prev_path = reblogged_by_api_v1_status_url(since_id: results.first.id) unless results.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -33,7 +35,7 @@ class Api::V1::StatusesController < ApiController
     @accounts = results.map { |f| accounts[f.account_id] }
 
     next_path = favourited_by_api_v1_status_url(max_id: results.last.id)    if results.size == DEFAULT_ACCOUNTS_LIMIT
-    prev_path = favourited_by_api_v1_status_url(since_id: results.first.id) if results.size > 0
+    prev_path = favourited_by_api_v1_status_url(since_id: results.first.id) unless results.empty?
 
     set_pagination_headers(next_path, prev_path)
 
diff --git a/app/controllers/api/v1/timelines_controller.rb b/app/controllers/api/v1/timelines_controller.rb
index 6d7858c76..19b76f11d 100644
--- a/app/controllers/api/v1/timelines_controller.rb
+++ b/app/controllers/api/v1/timelines_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Api::V1::TimelinesController < ApiController
   before_action -> { doorkeeper_authorize! :read }
   before_action :require_user!, only: [:home, :mentions]
@@ -10,7 +12,7 @@ class Api::V1::TimelinesController < ApiController
     set_maps(@statuses)
 
     next_path = api_v1_home_timeline_url(max_id: @statuses.last.id)    if @statuses.size == DEFAULT_STATUSES_LIMIT
-    prev_path = api_v1_home_timeline_url(since_id: @statuses.first.id) if @statuses.size > 0
+    prev_path = api_v1_home_timeline_url(since_id: @statuses.first.id) unless @statuses.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -23,7 +25,7 @@ class Api::V1::TimelinesController < ApiController
     set_maps(@statuses)
 
     next_path = api_v1_mentions_timeline_url(max_id: @statuses.last.id)    if @statuses.size == DEFAULT_STATUSES_LIMIT
-    prev_path = api_v1_mentions_timeline_url(since_id: @statuses.first.id) if @statuses.size > 0
+    prev_path = api_v1_mentions_timeline_url(since_id: @statuses.first.id) unless @statuses.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -36,7 +38,7 @@ class Api::V1::TimelinesController < ApiController
     set_maps(@statuses)
 
     next_path = api_v1_public_timeline_url(max_id: @statuses.last.id)    if @statuses.size == DEFAULT_STATUSES_LIMIT
-    prev_path = api_v1_public_timeline_url(since_id: @statuses.first.id) if @statuses.size > 0
+    prev_path = api_v1_public_timeline_url(since_id: @statuses.first.id) unless @statuses.empty?
 
     set_pagination_headers(next_path, prev_path)
 
@@ -50,7 +52,7 @@ class Api::V1::TimelinesController < ApiController
     set_maps(@statuses)
 
     next_path = api_v1_hashtag_timeline_url(params[:id], max_id: @statuses.last.id)    if @statuses.size == DEFAULT_STATUSES_LIMIT
-    prev_path = api_v1_hashtag_timeline_url(params[:id], since_id: @statuses.first.id) if @statuses.size > 0
+    prev_path = api_v1_hashtag_timeline_url(params[:id], since_id: @statuses.first.id) unless @statuses.empty?
 
     set_pagination_headers(next_path, prev_path)
 
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index ef453799b..aafaf843c 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class ApiController < ApplicationController
   DEFAULT_STATUSES_LIMIT = 20
   DEFAULT_ACCOUNTS_LIMIT = 40
@@ -51,8 +53,8 @@ class ApiController < ApplicationController
 
   def set_pagination_headers(next_path = nil, prev_path = nil)
     links = []
-    links << [next_path, [['rel', 'next']]] if next_path
-    links << [prev_path, [['rel', 'prev']]] if prev_path
+    links << [next_path, [%w(rel next)]] if next_path
+    links << [prev_path, [%w(rel prev)]] if prev_path
     response.headers['Link'] = LinkHeader.new(links)
   end
 
@@ -76,7 +78,7 @@ class ApiController < ApplicationController
     render json: {}, status: 200
   end
 
-  def set_maps(statuses)
+  def set_maps(statuses) # rubocop:disable Style/AccessorMethodName
     if current_account.nil?
       @reblogs_map    = {}
       @favourites_map = {}
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index e009fb879..c7a99b22f 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class ApplicationController < ActionController::Base
   # Prevent CSRF attacks by raising an exception.
   # For APIs, you may want to use :null_session instead.
diff --git a/app/controllers/auth/confirmations_controller.rb b/app/controllers/auth/confirmations_controller.rb
index b8e9316f1..2fdb281f4 100644
--- a/app/controllers/auth/confirmations_controller.rb
+++ b/app/controllers/auth/confirmations_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Auth::ConfirmationsController < Devise::ConfirmationsController
   layout 'auth'
 end
diff --git a/app/controllers/auth/passwords_controller.rb b/app/controllers/auth/passwords_controller.rb
index a2fb7bb13..54ee1c39c 100644
--- a/app/controllers/auth/passwords_controller.rb
+++ b/app/controllers/auth/passwords_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Auth::PasswordsController < Devise::PasswordsController
   layout 'auth'
 end
diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb
index 7b7f6b52d..f06a1dce1 100644
--- a/app/controllers/auth/registrations_controller.rb
+++ b/app/controllers/auth/registrations_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Auth::RegistrationsController < Devise::RegistrationsController
   layout 'auth'
 
diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb
index bd41ffd3d..c8350f9a1 100644
--- a/app/controllers/auth/sessions_controller.rb
+++ b/app/controllers/auth/sessions_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Auth::SessionsController < Devise::SessionsController
   include Devise::Controllers::Rememberable
 
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index 8ed88d074..9710aa84f 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class HomeController < ApplicationController
   before_action :authenticate_user!
 
diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb
index edfcdae53..9832a91b4 100644
--- a/app/controllers/media_controller.rb
+++ b/app/controllers/media_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class MediaController < ApplicationController
   before_action :set_media_attachment
 
diff --git a/app/controllers/oauth/authorizations_controller.rb b/app/controllers/oauth/authorizations_controller.rb
index e2d154597..feaad04f6 100644
--- a/app/controllers/oauth/authorizations_controller.rb
+++ b/app/controllers/oauth/authorizations_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Oauth::AuthorizationsController < Doorkeeper::AuthorizationsController
   skip_before_action :authenticate_resource_owner!
 
diff --git a/app/controllers/settings/preferences_controller.rb b/app/controllers/settings/preferences_controller.rb
index 8a038f2fe..7acef5e25 100644
--- a/app/controllers/settings/preferences_controller.rb
+++ b/app/controllers/settings/preferences_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Settings::PreferencesController < ApplicationController
   layout 'auth'
 
diff --git a/app/controllers/settings/profiles_controller.rb b/app/controllers/settings/profiles_controller.rb
index 52b6369a6..bd4fa2c46 100644
--- a/app/controllers/settings/profiles_controller.rb
+++ b/app/controllers/settings/profiles_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class Settings::ProfilesController < ApplicationController
   layout 'auth'
 
diff --git a/app/controllers/stream_entries_controller.rb b/app/controllers/stream_entries_controller.rb
index a364fa01c..caab1237d 100644
--- a/app/controllers/stream_entries_controller.rb
+++ b/app/controllers/stream_entries_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class StreamEntriesController < ApplicationController
   layout 'public'
 
@@ -29,9 +31,7 @@ class StreamEntriesController < ApplicationController
   end
 
   def set_link_headers
-    response.headers['Link'] = LinkHeader.new([
-      [account_stream_entry_url(@account, @stream_entry, format: 'atom'), [['rel', 'alternate'], ['type', 'application/atom+xml']]]
-    ])
+    response.headers['Link'] = LinkHeader.new([[account_stream_entry_url(@account, @stream_entry, format: 'atom'), [%w(rel alternate), %w(type application/atom+xml)]]])
   end
 
   def set_stream_entry
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
index ca5ee2f83..a6b359485 100644
--- a/app/controllers/tags_controller.rb
+++ b/app/controllers/tags_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class TagsController < ApplicationController
   layout 'public'
 
diff --git a/app/controllers/xrd_controller.rb b/app/controllers/xrd_controller.rb
index 003ffc182..9e0277860 100644
--- a/app/controllers/xrd_controller.rb
+++ b/app/controllers/xrd_controller.rb
@@ -1,3 +1,5 @@
+# frozen_string_literal: true
+
 class XrdController < ApplicationController
   before_action :set_default_format_json, only: :webfinger
   before_action :set_default_format_xml, only: :host_meta
@@ -26,11 +28,11 @@ class XrdController < ApplicationController
   private
 
   def set_default_format_xml
-    request.format = 'xml' if request.headers["HTTP_ACCEPT"].nil? && params[:format].nil?
+    request.format = 'xml' if request.headers['HTTP_ACCEPT'].nil? && params[:format].nil?
   end
 
   def set_default_format_json
-    request.format = 'json' if request.headers["HTTP_ACCEPT"].nil? && params[:format].nil?
+    request.format = 'json' if request.headers['HTTP_ACCEPT'].nil? && params[:format].nil?
   end
 
   def username_from_resource
@@ -44,14 +46,14 @@ class XrdController < ApplicationController
 
   def pem_to_magic_key(public_key)
     modulus, exponent = [public_key.n, public_key.e].map do |component|
-      result = ''
+      result = []
 
       until component.zero?
         result << [component % 256].pack('C')
         component >>= 8
       end
 
-      result.reverse!
+      result.reverse.join
     end
 
     (['RSA'] + [modulus, exponent].map { |n| Base64.urlsafe_encode64(n) }).join('.')