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
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
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')})` }}>
<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 && (
}
}
+.account__header .roles {
+ margin-top: 20px;
+ margin-bottom: 20px;
+ padding: 0 15px;
+}
+
.account__header .account__header__fields {
font-size: 14px;
line-height: 20px;
align-items: flex-start;
}
+ &.file .label_input {
+ flex-wrap: nowrap;
+ }
+
&.select .label_input {
align-items: initial;
}
# moved_to_account_id :bigint(8)
# featured_collection_url :string
# fields :jsonb
+# actor_type :string
#
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
end
def type
- 'Person'
+ object.bot? ? 'Service' : 'Person'
end
def following
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
@account.note = @json['summary'] || ''
@account.locked = @json['manuallyApprovesFollowers'] || false
@account.fields = property_values || {}
+ @account.actor_type = @json['type']
end
def set_fetchable_attributes!
%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
.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')
reserved_username: The username is reserved
roles:
admin: Admin
+ bot: Bot
moderator: Mod
unfollow: Unfollow
admin:
hints:
defaults:
avatar: PNG, GIF or JPG. At most 2MB. Will be downscaled to 400x400px
+ bot: Warns people that the account does not represent a person
digest: Only sent after a long period of inactivity and only if you have received any personal messages in your absence
display_name:
one: <span class="name-counter">1</span> character left
value: Content
defaults:
avatar: Avatar
+ bot: This is a bot account
confirm_new_password: Confirm new password
confirm_password: Confirm password
current_password: Current password
--- /dev/null
+class AddActorTypeToAccounts < ActiveRecord::Migration[5.2]
+ def change
+ add_column :accounts, :actor_type, :string
+ end
+end
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 2018_04_16_210259) do
+ActiveRecord::Schema.define(version: 2018_05_06_221944) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
t.bigint "moved_to_account_id"
t.string "featured_collection_url"
t.jsonb "fields"
+ t.string "actor_type"
t.index "(((setweight(to_tsvector('simple'::regconfig, (display_name)::text), 'A'::\"char\") || setweight(to_tsvector('simple'::regconfig, (username)::text), 'B'::\"char\")) || setweight(to_tsvector('simple'::regconfig, (COALESCE(domain, ''::character varying))::text), 'C'::\"char\")))", name: "search_index", using: :gin
t.index "lower((username)::text), lower((domain)::text)", name: "index_accounts_on_username_and_domain_lower"
t.index ["uri"], name: "index_accounts_on_uri"