about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-05-15 16:18:58 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:23 -0500
commitc961429dc2895ba10f9498496e1d2d252d28df4d (patch)
tree4f074e888bc9dfce0fe523fc34c5e5e71100c452 /app
parent89c5d8ec4e5798763de44adec79e6e065bb59b9c (diff)
Accounts, UI: Expose kobold badges over the API. Render badges in the web app.
Diffstat (limited to 'app')
-rw-r--r--app/javascript/flavours/glitch/features/account/components/header.js5
-rw-r--r--app/javascript/mastodon/locales/en.json2
-rw-r--r--app/serializers/rest/account_serializer.rb10
3 files changed, 15 insertions, 2 deletions
diff --git a/app/javascript/flavours/glitch/features/account/components/header.js b/app/javascript/flavours/glitch/features/account/components/header.js
index ef5915382..e3a08019c 100644
--- a/app/javascript/flavours/glitch/features/account/components/header.js
+++ b/app/javascript/flavours/glitch/features/account/components/header.js
@@ -191,6 +191,8 @@ class Header extends ImmutablePureComponent {
     const fields          = account.get('fields');
     const badge_bot       = account.get('bot') ? (<div className='account-role bot'><FormattedMessage id='account.badges.bot' defaultMessage='Bot' /></div>) : null;
     const badge_ao        = account.get('adults_only') ? (<div className='account-role adults-only'><FormattedMessage id='account.badges.adults_only' defaultMessage="🔞 Adult content"  /></div>) : null;
+    const badge_gntly_kbld = account.get('gentlies_kobolds') ? (<div className='account-role gentlies'><FormattedMessage id='account.badges.gentlies_kobolds' defaultMessage="Gentlies kobolds"  /></div>) : null;
+    const badge_kobold    = account.get('is_a_kobold') ? (<div className='account-role kobold'><FormattedMessage id='account.badges.kobold' defaultMessage="Gently the kobold"  /></div>) : null;
     const acct            = account.get('acct').indexOf('@') === -1 && domain ? `${account.get('acct')}@${domain}` : account.get('acct');
 
     return (
@@ -220,8 +222,9 @@ class Header extends ImmutablePureComponent {
 
           <div className='account__header__tabs__name'>
             <h1>
-              <span dangerouslySetInnerHTML={displayNameHtml} /> {badge_ao}{badge_bot}
+              <span dangerouslySetInnerHTML={displayNameHtml} />
               <small>@{acct} {lockedIcon}</small>
+              <div className='roles'>{badge_ao}{badge_bot}{badge_gntly_kbld}{badge_kobold}</div>
             </h1>
           </div>
 
diff --git a/app/javascript/mastodon/locales/en.json b/app/javascript/mastodon/locales/en.json
index d61dc27ad..83bad114c 100644
--- a/app/javascript/mastodon/locales/en.json
+++ b/app/javascript/mastodon/locales/en.json
@@ -2,6 +2,8 @@
   "account.add_or_remove_from_list": "Add or Remove from lists",
   "account.badges.bot": "Bot",
   "account.badges.adults_only": "🔞 Adult content",
+  "account.badges.gentlies_kobolds": "Gentlies kobolds",
+  "account.badges.kobold": "Gently the kobold",
   "account.block": "Block @{name}",
   "account.block_domain": "Hide {domain}",
   "account.blocked": "Blocked",
diff --git a/app/serializers/rest/account_serializer.rb b/app/serializers/rest/account_serializer.rb
index 04df81225..019bac26a 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,
-             :adults_only
+             :adults_only, :gentlies_kobolds, :is_a_kobold
 
   has_one :moved_to_account, key: :moved, serializer: REST::AccountSerializer, if: :moved_and_not_nested?
   has_many :emojis, serializer: REST::CustomEmojiSerializer
@@ -56,4 +56,12 @@ class REST::AccountSerializer < ActiveModel::Serializer
   def followers_count
     (Setting.hide_followers_count || object.user&.setting_hide_followers_count) ? -1 : object.followers_count
   end
+
+  def gentlies_kobolds
+    object.user_gentlies_kobolds? || false
+  end
+
+  def is_a_kobold
+    object.user_is_a_kobold? || false
+  end
 end