about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-07-19 15:43:59 -0500
committermultiple creatures <dev@multiple-creature.party>2019-07-19 17:03:15 -0500
commit6d07ba50f31f82633019b62dc83ec7099e3926b3 (patch)
tree7d3d329b88c60a04d3aee35e71d932203fc73ba4 /app
parent3fda862ea004c1c417a442b2a8f38a67d0535979 (diff)
keep `locked` badge for approves-followers + add `frozen` badge for admin-locked accts, also federate `frozen` state
Diffstat (limited to 'app')
-rw-r--r--app/helpers/stream_entries_helper.rb2
-rw-r--r--app/javascript/flavours/glitch/features/account/components/header.js6
-rw-r--r--app/javascript/flavours/glitch/styles/accounts.scss6
-rw-r--r--app/javascript/mastodon/locales/en.json1
-rw-r--r--app/lib/activitypub/adapter.rb4
-rw-r--r--app/models/account.rb5
-rw-r--r--app/serializers/activitypub/actor_serializer.rb8
-rw-r--r--app/serializers/rest/account_serializer.rb6
-rw-r--r--app/services/activitypub/process_account_service.rb1
9 files changed, 32 insertions, 7 deletions
diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb
index ed58efdb4..fcf98fd70 100644
--- a/app/helpers/stream_entries_helper.rb
+++ b/app/helpers/stream_entries_helper.rb
@@ -36,7 +36,9 @@ module StreamEntriesHelper
 
   def account_badge(account, all: false)
     content_tag(:div, class: 'roles') do
+      froze = account.local? ? (account&.user.nil? ? true : account.user.disabled?) : account.froze?
       roles = []
+      roles << content_tag(:div, t('accounts.roles.froze'), class: 'account-role froze') if froze
       roles << content_tag(:div, t('accounts.roles.locked'), class: 'account-role locked') if account.locked?
       roles << content_tag(:div, t('accounts.roles.bot'), class: 'account-role bot') if account.bot?
       roles << content_tag(:div, t('accounts.roles.adult'), class: 'account-role adult') if account.adult_content?
diff --git a/app/javascript/flavours/glitch/features/account/components/header.js b/app/javascript/flavours/glitch/features/account/components/header.js
index 0f03770b7..f70593868 100644
--- a/app/javascript/flavours/glitch/features/account/components/header.js
+++ b/app/javascript/flavours/glitch/features/account/components/header.js
@@ -191,6 +191,7 @@ class Header extends ImmutablePureComponent {
     const fields          = account.get('fields');
 
     const badge_locked    = account.get('locked') ? (<div className='account-role locked'><FormattedMessage id='account.badges.locked' defaultMessage='🔒 Locked' /></div>) : null;
+    const badge_froze     = account.get('froze') ? (<div className='account-role froze'><FormattedMessage id='account.badges.froze' defaultMessage='❄️ Frozen by admin' /></div>) : null;
     const badge_bot       = account.get('bot') ? (<div className='account-role bot'><FormattedMessage id='account.badges.bot' defaultMessage='Bot' /></div>) : null;
     const badge_ac        = account.get('adult_content') ? (<div className='account-role adult'><FormattedMessage id='account.badges.adult' defaultMessage="🔞 Adult content" /></div>) : null;
     const badge_gently    = account.get('gently') ? (<div className='account-role gently'><FormattedMessage id='account.badges.gently' defaultMessage="Gentlies kobolds" /></div>) : null;
@@ -226,9 +227,10 @@ class Header extends ImmutablePureComponent {
 
           <div className='account__header__tabs__name'>
             <h1>
+              <span className='account__header__locked'>{lockedIcon}</span>
               <span dangerouslySetInnerHTML={displayNameHtml} />
-              <small>@{acct} {lockedIcon}</small>
-              <div className='roles'>{badge_locked}{badge_admin}{badge_mod}{badge_ac}{badge_bot}{badge_gently}{badge_kobold}</div>
+              <small>@{acct}</small>
+              <div className='roles'>{badge_froze}{badge_locked}{badge_admin}{badge_mod}{badge_ac}{badge_bot}{badge_gently}{badge_kobold}</div>
             </h1>
           </div>
 
diff --git a/app/javascript/flavours/glitch/styles/accounts.scss b/app/javascript/flavours/glitch/styles/accounts.scss
index 49236fe4c..6c1de090e 100644
--- a/app/javascript/flavours/glitch/styles/accounts.scss
+++ b/app/javascript/flavours/glitch/styles/accounts.scss
@@ -236,6 +236,12 @@
   }
 
   &.locked {
+    color: lighten(pink, 12%);
+    background-color: rgba(lighten(pink, 12%), 0.1);
+    border-color: rgba(lighten(pink, 12%), 0.5);
+  }
+
+  &.froze {
     color: lighten($warning-red, 12%);
     background-color: rgba(lighten($warning-red, 12%), 0.1);
     border-color: rgba(lighten($warning-red, 12%), 0.5);
diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json
index d61277d76..11c828494 100644
--- a/app/javascript/mastodon/locales/en.json
+++ b/app/javascript/mastodon/locales/en.json
@@ -5,6 +5,7 @@
   "account.badges.gently": "Gentlies kobolds",
   "account.badges.kobold": "Gently the kobold",
   "account.badges.locked": "🔒 Locked",
+  "account.badges.froze": "❄️ Frozen by admin",
   "account.block": "Block @{name}",
   "account.block_domain": "Hide {domain}",
   "account.blocked": "Blocked",
diff --git a/app/lib/activitypub/adapter.rb b/app/lib/activitypub/adapter.rb
index 7b0b1390c..21a2c167b 100644
--- a/app/lib/activitypub/adapter.rb
+++ b/app/lib/activitypub/adapter.rb
@@ -36,9 +36,9 @@ class ActivityPub::Adapter < ActiveModelSerializers::Adapter::Base
       'mp' => 'https://monsterpit.net/ns#',
       'supportsChat' => 'mp:supportsChat'
     },
-    locked: {
+    froze: {
       'mp' => 'https://monsterpit.net/ns#',
-      'locked' => 'mp:locked'
+      'froze' => 'mp:froze'
     },
   }.freeze
 
diff --git a/app/models/account.rb b/app/models/account.rb
index 778b3fcbb..4b39cf022 100644
--- a/app/models/account.rb
+++ b/app/models/account.rb
@@ -51,6 +51,7 @@
 #  supports_chat           :boolean          default(FALSE), not null
 #  gently                  :boolean          default(FALSE), not null
 #  kobold                  :boolean          default(FALSE), not null
+#  froze                   :boolean
 #
 
 class Account < ApplicationRecord
@@ -172,6 +173,10 @@ class Account < ApplicationRecord
     moved_to_account_id.present?
   end
 
+  def frozen?
+    local? ? (self&.user.nil? ? true : user.disabled?) : frozen
+  end
+
   def bot?
     %w(Application Service).include? actor_type
   end
diff --git a/app/serializers/activitypub/actor_serializer.rb b/app/serializers/activitypub/actor_serializer.rb
index 95110bfc2..85d2482db 100644
--- a/app/serializers/activitypub/actor_serializer.rb
+++ b/app/serializers/activitypub/actor_serializer.rb
@@ -7,14 +7,14 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
 
   context_extensions :manually_approves_followers, :featured, :also_known_as,
                      :moved_to, :property_value, :hashtag, :emoji, :identity_proof,
-                     :adult_content, :gently, :kobold, :supports_chat, :locked
+                     :adult_content, :gently, :kobold, :supports_chat, :froze
 
   attributes :id, :type, :following, :followers,
              :inbox, :outbox, :featured,
              :preferred_username, :name, :summary,
              :url, :manually_approves_followers,
              :gently, :kobold, :adult_content,
-             :supports_chat, :locked
+             :supports_chat, :froze
 
   has_one :public_key, serializer: ActivityPub::PublicKeySerializer
 
@@ -113,6 +113,10 @@ class ActivityPub::ActorSerializer < ActivityPub::Serializer
     object.locked
   end
 
+  def froze
+    object.local? ? (object&.user.nil? ? true : object.user.disabled?) : object.froze?
+  end
+
   def virtual_tags
     object.emojis + object.tags
   end
diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb
index 852ecdae1..bd98989e2 100644
--- a/app/serializers/rest/account_serializer.rb
+++ b/app/serializers/rest/account_serializer.rb
@@ -6,7 +6,7 @@ class REST::AccountSerializer < ActiveModel::Serializer
   attributes :id, :username, :acct, :display_name, :locked, :bot, :created_at,
              :note, :url, :avatar, :avatar_static, :header, :header_static,
              :followers_count, :following_count, :statuses_count, :replies,
-             :adult_content, :supports_chat, :gently, :kobold, :role
+             :adult_content, :supports_chat, :gently, :kobold, :role, :froze
 
   has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
   has_many :emojis, serializer: REST::CustomEmojiSerializer
@@ -62,4 +62,8 @@ class REST::AccountSerializer < ActiveModel::Serializer
     return 'moderator' if object.user_moderator?
     'user'
   end
+
+  def froze
+    object.local? ? (object&.user.nil? ? true : object.user.disabled?) : object.froze?
+  end
 end
diff --git a/app/services/activitypub/process_account_service.rb b/app/services/activitypub/process_account_service.rb
index 6846f6d4e..bc1eb2057 100644
--- a/app/services/activitypub/process_account_service.rb
+++ b/app/services/activitypub/process_account_service.rb
@@ -79,6 +79,7 @@ class ActivityPub::ProcessAccountService < BaseService
     @account.display_name            = @json['name'] || ''
     @account.note                    = @json['summary'] || ''
     @account.locked                  = @json['manuallyApprovesFollowers'] || false
+    @account.froze                   = @json['froze'] || false
     @account.adult_content           = @json['adultContent'] || (@json['suggestedMinAge'].to_i >= 18)
     @account.supports_chat           = @json['supportsChat'] || false
     @account.gently                  = @json['gently'] || false