about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--app/assets/javascripts/components/features/account/components/header.jsx7
-rw-r--r--app/controllers/follow_requests_controller.rb28
-rw-r--r--app/helpers/admin/accounts_helper.rb4
-rw-r--r--app/helpers/follow_requests_helper.rb2
-rw-r--r--app/views/about/index.html.haml1
-rw-r--r--app/views/accounts/_header.html.haml4
-rw-r--r--app/views/follow_requests/index.html.haml16
-rw-r--r--app/views/layouts/auth.html.haml3
-rw-r--r--app/views/settings/shared/_links.html.haml2
-rw-r--r--config/locales/en.yml6
-rw-r--r--config/locales/simple_form.en.yml8
-rw-r--r--config/routes.rb7
-rw-r--r--spec/controllers/follow_requests_controller_spec.rb16
-rw-r--r--spec/helpers/follow_requests_helper_spec.rb5
14 files changed, 99 insertions, 10 deletions
diff --git a/app/assets/javascripts/components/features/account/components/header.jsx b/app/assets/javascripts/components/features/account/components/header.jsx
index fe400e50b..adf9ab5ae 100644
--- a/app/assets/javascripts/components/features/account/components/header.jsx
+++ b/app/assets/javascripts/components/features/account/components/header.jsx
@@ -27,6 +27,7 @@ const Header = React.createClass({
     let displayName = account.get('display_name');
     let info        = '';
     let actionBtn   = '';
+    let lockedIcon  = '';
 
     if (displayName.length === 0) {
       displayName = account.get('username');
@@ -52,6 +53,10 @@ const Header = React.createClass({
       }
     }
 
+    if (account.get('locked')) {
+      lockedIcon = <i className='fa fa-lock' />;
+    }
+
     const content         = { __html: emojify(account.get('note')) };
     const displayNameHTML = { __html: emojify(escapeTextContentForBrowser(displayName)) };
 
@@ -66,7 +71,7 @@ const Header = React.createClass({
             <span style={{ display: 'inline-block', color: '#fff', fontSize: '20px', lineHeight: '27px', fontWeight: '500' }} className='account__header__display-name' dangerouslySetInnerHTML={displayNameHTML} />
           </a>
 
-          <span style={{ fontSize: '14px', fontWeight: '400', display: 'block', color: '#2b90d9', marginBottom: '10px' }}>@{account.get('acct')}</span>
+          <span style={{ fontSize: '14px', fontWeight: '400', display: 'block', color: '#2b90d9', marginBottom: '10px' }}>@{account.get('acct')} {lockedIcon}</span>
           <div style={{ color: '#616b86', fontSize: '14px' }} className='account__header__content' dangerouslySetInnerHTML={content} />
 
           {info}
diff --git a/app/controllers/follow_requests_controller.rb b/app/controllers/follow_requests_controller.rb
new file mode 100644
index 000000000..d4368f773
--- /dev/null
+++ b/app/controllers/follow_requests_controller.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+class FollowRequestsController < ApplicationController
+  layout 'auth'
+
+  before_action :authenticate_user!
+  before_action :set_follow_request, except: :index
+
+  def index
+    @follow_requests = FollowRequest.where(target_account: current_account)
+  end
+
+  def authorize
+    @follow_request.authorize!
+    redirect_to follow_requests_path
+  end
+
+  def reject
+    @follow_request.reject!
+    redirect_to follow_requests_path
+  end
+
+  private
+
+  def set_follow_request
+    @follow_request = FollowRequest.find(params[:id])
+  end
+end
diff --git a/app/helpers/admin/accounts_helper.rb b/app/helpers/admin/accounts_helper.rb
index 57cd972fa..c539229b3 100644
--- a/app/helpers/admin/accounts_helper.rb
+++ b/app/helpers/admin/accounts_helper.rb
@@ -9,7 +9,7 @@ module Admin::AccountsHelper
     link_to text, filter_params(more_params), class: params.merge(more_params).compact == params.compact ? 'selected' : ''
   end
 
-  def table_link_to(icon, text, path)
-    link_to safe_join([fa_icon(icon), text]), path, class: 'table-action-link'
+  def table_link_to(icon, text, path, options = {})
+    link_to safe_join([fa_icon(icon), text]), path, options.merge(class: 'table-action-link')
   end
 end
diff --git a/app/helpers/follow_requests_helper.rb b/app/helpers/follow_requests_helper.rb
new file mode 100644
index 000000000..cfd350e53
--- /dev/null
+++ b/app/helpers/follow_requests_helper.rb
@@ -0,0 +1,2 @@
+module FollowRequestsHelper
+end
diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml
index fe13de837..6dd182205 100644
--- a/app/views/about/index.html.haml
+++ b/app/views/about/index.html.haml
@@ -2,7 +2,6 @@
   = Rails.configuration.x.local_domain
 
 - content_for :header_tags do
-  = javascript_include_tag 'application_public'
   %meta{ property: 'og:site_name', content: 'Mastodon' }/
   %meta{ property: 'og:type', content: 'website' }/
   %meta{ property: 'og:title', content: Rails.configuration.x.local_domain }/
diff --git a/app/views/accounts/_header.html.haml b/app/views/accounts/_header.html.haml
index 77fd6c457..12c9b069d 100644
--- a/app/views/accounts/_header.html.haml
+++ b/app/views/accounts/_header.html.haml
@@ -9,7 +9,9 @@
   .avatar= image_tag @account.avatar.url( :original)
   %h1.name
     = display_name(@account)
-    %small= "@#{@account.username}"
+    %small
+      = "@#{@account.username}"
+      = fa_icon('lock') if @account.locked?
   .details
     .bio
       .account__header__content= Formatter.instance.simplified_format(@account)
diff --git a/app/views/follow_requests/index.html.haml b/app/views/follow_requests/index.html.haml
new file mode 100644
index 000000000..9db2d5c42
--- /dev/null
+++ b/app/views/follow_requests/index.html.haml
@@ -0,0 +1,16 @@
+- content_for :page_title do
+  = t('follow_requests.title')
+
+- if @follow_requests.empty?
+  %p.nothing-here= t('accounts.nothing_here')
+- else
+  %table.table
+    %tbody
+      - @follow_requests.each do |follow_request|
+        %tr
+          %td= link_to follow_request.account.acct, web_path("accounts/#{follow_request.account.id}")
+          %td
+            = table_link_to 'check-circle', t('follow_requests.authorize'), authorize_follow_request_path(follow_request), method: :post
+            = table_link_to 'times-circle', t('follow_requests.reject'), reject_follow_request_path(follow_request), method: :post
+
+.form-footer= render "settings/shared/links"
diff --git a/app/views/layouts/auth.html.haml b/app/views/layouts/auth.html.haml
index 1fa0b5ae0..db841d27a 100644
--- a/app/views/layouts/auth.html.haml
+++ b/app/views/layouts/auth.html.haml
@@ -1,3 +1,6 @@
+- content_for :header_tags do
+  = javascript_include_tag 'application_public'
+
 - content_for :content do
   .container
     .logo-container
diff --git a/app/views/settings/shared/_links.html.haml b/app/views/settings/shared/_links.html.haml
index 44f097950..b6a0b1fc1 100644
--- a/app/views/settings/shared/_links.html.haml
+++ b/app/views/settings/shared/_links.html.haml
@@ -1,6 +1,8 @@
 %ul.no-list
   - if controller_name != 'profiles'
     %li= link_to t('settings.edit_profile'), settings_profile_path
+  - if controller_name != 'follow_requests'
+    %li= link_to t('follow_requests.title'), follow_requests_path
   - if controller_name != 'preferences'
     %li= link_to t('settings.preferences'), settings_preferences_path
   - if controller_name != 'registrations'
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 684c86f4a..4cf958517 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -40,6 +40,10 @@ en:
       x_minutes: "%{count}m"
       x_months: "%{count}mo"
       x_seconds: "%{count}s"
+  follow_requests:
+    authorize: Authorize
+    reject: Reject
+    title: Follow requests
   generic:
     changes_saved_msg: Changes successfully saved!
     powered_by: powered by %{link}
@@ -70,8 +74,8 @@ en:
     click_to_show: Click to show
     favourited: favourited a post by
     is_now_following: is now following
-    sensitive_content: Sensitive content
     reblogged: boosted
+    sensitive_content: Sensitive content
   time:
     formats:
       default: "%b %d, %Y, %H:%M"
diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml
index 50c0f99fd..12b717877 100644
--- a/config/locales/simple_form.en.yml
+++ b/config/locales/simple_form.en.yml
@@ -1,6 +1,9 @@
 ---
 en:
   simple_form:
+    hints:
+      defaults:
+        locked: Requires you to manually approve followers and defaults post privacy to followers-only
     labels:
       defaults:
         avatar: Avatar
@@ -11,11 +14,11 @@ en:
         email: E-mail address
         header: Header
         locale: Language
+        locked: Make account private
         new_password: New password
         note: Bio
         password: Password
         username: Username
-        locked: Make account private
       interactions:
         must_be_follower: Block notifications from non-followers
         must_be_following: Block notifications from people you don't follow
@@ -24,9 +27,6 @@ en:
         follow: Send e-mail when someone follows you
         mention: Send e-mail when someone mentions you
         reblog: Send e-mail when someone reblogs your status
-    hints:
-      defaults:
-        locked: Requires you to manually approve followers and defaults post privacy to followers-only
     'no': 'No'
     required:
       mark: "*"
diff --git a/config/routes.rb b/config/routes.rb
index fd187dc42..e8c8f619d 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -48,6 +48,13 @@ Rails.application.routes.draw do
   resources :media, only: [:show]
   resources :tags,  only: [:show]
 
+  resources :follow_requests do
+    member do
+      post :authorize
+      post :reject
+    end
+  end
+
   namespace :admin do
     resources :pubsubhubbub, only: [:index]
     resources :domain_blocks, only: [:index, :create]
diff --git a/spec/controllers/follow_requests_controller_spec.rb b/spec/controllers/follow_requests_controller_spec.rb
new file mode 100644
index 000000000..72f5fd9b9
--- /dev/null
+++ b/spec/controllers/follow_requests_controller_spec.rb
@@ -0,0 +1,16 @@
+require 'rails_helper'
+
+RSpec.describe FollowRequestsController, type: :controller do
+  render_views
+
+  before do
+    sign_in Fabricate(:user), scope: :user
+  end
+
+  describe 'GET #index' do
+    it 'returns http success' do
+      get :index
+      expect(response).to have_http_status(:success)
+    end
+  end
+end
diff --git a/spec/helpers/follow_requests_helper_spec.rb b/spec/helpers/follow_requests_helper_spec.rb
new file mode 100644
index 000000000..e031cf402
--- /dev/null
+++ b/spec/helpers/follow_requests_helper_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe FollowRequestsHelper, type: :helper do
+
+end