Bot nameplates (#7391)
* Store actor type in database * Add bot nameplate to web UI, add setting to preferences, API, AP Fix #7365 * Fix code style issues
This commit is contained in:
parent
0f0cc3f2eb
commit
42cd363542
15 changed files with 48 additions and 6 deletions
|
@ -21,7 +21,7 @@ class Api::V1::Accounts::CredentialsController < Api::BaseController
|
|||
private
|
||||
|
||||
def account_params
|
||||
params.permit(:display_name, :note, :avatar, :header, :locked, fields_attributes: [:name, :value])
|
||||
params.permit(:display_name, :note, :avatar, :header, :locked, :bot, fields_attributes: [:name, :value])
|
||||
end
|
||||
|
||||
def user_settings_params
|
||||
|
|
|
@ -27,7 +27,7 @@ class Settings::ProfilesController < ApplicationController
|
|||
private
|
||||
|
||||
def account_params
|
||||
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, fields_attributes: [:name, :value])
|
||||
params.require(:account).permit(:display_name, :note, :avatar, :header, :locked, :bot, fields_attributes: [:name, :value])
|
||||
end
|
||||
|
||||
def set_account
|
||||
|
|
|
@ -131,6 +131,7 @@ export default class Header extends ImmutablePureComponent {
|
|||
const content = { __html: account.get('note_emojified') };
|
||||
const displayNameHtml = { __html: account.get('display_name_html') };
|
||||
const fields = account.get('fields');
|
||||
const badge = account.get('bot') ? (<div className='roles'><div className='account-role bot'><FormattedMessage id='account.badges.bot' defaultMessage='Bot' /></div></div>) : null;
|
||||
|
||||
return (
|
||||
<div className={classNames('account__header', { inactive: !!account.get('moved') })} style={{ backgroundImage: `url(${account.get('header')})` }}>
|
||||
|
@ -139,6 +140,9 @@ export default class Header extends ImmutablePureComponent {
|
|||
|
||||
<span className='account__header__display-name' dangerouslySetInnerHTML={displayNameHtml} />
|
||||
<span className='account__header__username'>@{account.get('acct')} {lockedIcon}</span>
|
||||
|
||||
{badge}
|
||||
|
||||
<div className='account__header__content' dangerouslySetInnerHTML={content} />
|
||||
|
||||
{fields.size > 0 && (
|
||||
|
|
|
@ -5159,6 +5159,12 @@ noscript {
|
|||
}
|
||||
}
|
||||
|
||||
.account__header .roles {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
padding: 0 15px;
|
||||
}
|
||||
|
||||
.account__header .account__header__fields {
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
|
|
|
@ -87,6 +87,10 @@ code {
|
|||
align-items: flex-start;
|
||||
}
|
||||
|
||||
&.file .label_input {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
|
||||
&.select .label_input {
|
||||
align-items: initial;
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
# moved_to_account_id :bigint(8)
|
||||
# featured_collection_url :string
|
||||
# fields :jsonb
|
||||
# actor_type :string
|
||||
#
|
||||
|
||||
class Account < ApplicationRecord
|
||||
|
@ -149,6 +150,16 @@ class Account < ApplicationRecord
|
|||
moved_to_account_id.present?
|
||||
end
|
||||
|
||||
def bot?
|
||||
%w(Application Service).include? actor_type
|
||||
end
|
||||
|
||||
alias bot bot?
|
||||
|
||||
def bot=(val)
|
||||
self.actor_type = ActiveModel::Type::Boolean.new.cast(val) ? 'Service' : 'Person'
|
||||
end
|
||||
|
||||
def acct
|
||||
local? ? username : "#{username}@#{domain}"
|
||||
end
|
||||
|
|
|
@ -37,7 +37,7 @@ class ActivityPub::ActorSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def type
|
||||
'Person'
|
||||
object.bot? ? 'Service' : 'Person'
|
||||
end
|
||||
|
||||
def following
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class REST::AccountSerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attributes :id, :username, :acct, :display_name, :locked, :created_at,
|
||||
attributes :id, :username, :acct, :display_name, :locked, :bot, :created_at,
|
||||
:note, :url, :avatar, :avatar_static, :header, :header_static,
|
||||
:followers_count, :following_count, :statuses_count
|
||||
|
||||
|
|
|
@ -71,6 +71,7 @@ class ActivityPub::ProcessAccountService < BaseService
|
|||
@account.note = @json['summary'] || ''
|
||||
@account.locked = @json['manuallyApprovesFollowers'] || false
|
||||
@account.fields = property_values || {}
|
||||
@account.actor_type = @json['type']
|
||||
end
|
||||
|
||||
def set_fetchable_attributes!
|
||||
|
|
|
@ -10,7 +10,11 @@
|
|||
%span>< @#{account.local_username_and_domain}
|
||||
= fa_icon('lock') if account.locked?
|
||||
|
||||
- if Setting.show_staff_badge
|
||||
- if account.bot?
|
||||
.roles
|
||||
.account-role.bot
|
||||
= t 'accounts.roles.bot'
|
||||
- elsif Setting.show_staff_badge
|
||||
- if account.user_admin?
|
||||
.roles
|
||||
.account-role.admin
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
.fields-group
|
||||
= f.input :locked, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.locked')
|
||||
|
||||
.fields-group
|
||||
= f.input :bot, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.bot')
|
||||
|
||||
.fields-group
|
||||
.input.with_block_label
|
||||
%label= t('simple_form.labels.defaults.fields')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue