2020-12-08 07:30:29 -06:00
|
|
|
import { FindOptions, Includeable, IncludeOptions, Op, Transaction, WhereOptions } from 'sequelize'
|
2017-12-12 10:53:50 -06:00
|
|
|
import {
|
2018-02-15 07:46:26 -06:00
|
|
|
AllowNull,
|
|
|
|
BeforeDestroy,
|
|
|
|
BelongsTo,
|
|
|
|
Column,
|
2019-08-15 04:53:26 -05:00
|
|
|
CreatedAt,
|
|
|
|
DataType,
|
2018-02-15 07:46:26 -06:00
|
|
|
Default,
|
|
|
|
DefaultScope,
|
|
|
|
ForeignKey,
|
|
|
|
HasMany,
|
|
|
|
Is,
|
2019-03-05 04:30:43 -06:00
|
|
|
Model,
|
|
|
|
Scopes,
|
2018-02-15 07:46:26 -06:00
|
|
|
Table,
|
2017-12-12 10:53:50 -06:00
|
|
|
UpdatedAt
|
|
|
|
} from 'sequelize-typescript'
|
2020-12-08 03:53:41 -06:00
|
|
|
import { ModelCache } from '@server/models/model-cache'
|
2021-12-16 11:04:16 -06:00
|
|
|
import { AttributesOnly } from '@shared/typescript-utils'
|
2019-02-26 03:55:40 -06:00
|
|
|
import { Account, AccountSummary } from '../../../shared/models/actors'
|
2018-02-15 07:46:26 -06:00
|
|
|
import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts'
|
2020-12-08 03:53:41 -06:00
|
|
|
import { CONSTRAINTS_FIELDS, SERVER_ACTOR_NAME, WEBSERVER } from '../../initializers/constants'
|
2021-05-12 07:51:17 -05:00
|
|
|
import { sendDeleteActor } from '../../lib/activitypub/send/send-delete'
|
2020-12-08 03:53:41 -06:00
|
|
|
import {
|
|
|
|
MAccount,
|
|
|
|
MAccountActor,
|
|
|
|
MAccountAP,
|
|
|
|
MAccountDefault,
|
|
|
|
MAccountFormattable,
|
|
|
|
MAccountSummaryFormattable,
|
|
|
|
MChannelActor
|
|
|
|
} from '../../types/models'
|
2021-05-11 04:15:29 -05:00
|
|
|
import { ActorModel } from '../actor/actor'
|
|
|
|
import { ActorFollowModel } from '../actor/actor-follow'
|
|
|
|
import { ActorImageModel } from '../actor/actor-image'
|
2017-12-12 10:53:50 -06:00
|
|
|
import { ApplicationModel } from '../application/application'
|
|
|
|
import { ServerModel } from '../server/server'
|
2020-12-08 03:53:41 -06:00
|
|
|
import { ServerBlocklistModel } from '../server/server-blocklist'
|
2021-05-11 04:15:29 -05:00
|
|
|
import { UserModel } from '../user/user'
|
2023-01-09 03:29:23 -06:00
|
|
|
import { buildSQLAttributes, getSort, throwIfNotValid } from '../utils'
|
2020-12-08 03:53:41 -06:00
|
|
|
import { VideoModel } from '../video/video'
|
2017-12-12 10:53:50 -06:00
|
|
|
import { VideoChannelModel } from '../video/video-channel'
|
2018-01-18 03:53:54 -06:00
|
|
|
import { VideoCommentModel } from '../video/video-comment'
|
2019-02-26 03:55:40 -06:00
|
|
|
import { VideoPlaylistModel } from '../video/video-playlist'
|
2019-07-31 08:57:32 -05:00
|
|
|
import { AccountBlocklistModel } from './account-blocklist'
|
2019-02-26 03:55:40 -06:00
|
|
|
|
|
|
|
export enum ScopeNames {
|
|
|
|
SUMMARY = 'SUMMARY'
|
|
|
|
}
|
2017-12-12 10:53:50 -06:00
|
|
|
|
2019-07-31 08:57:32 -05:00
|
|
|
export type SummaryOptions = {
|
2020-07-07 07:34:16 -05:00
|
|
|
actorRequired?: boolean // Default: true
|
2019-07-31 08:57:32 -05:00
|
|
|
whereActor?: WhereOptions
|
2021-07-28 03:32:40 -05:00
|
|
|
whereServer?: WhereOptions
|
2019-07-31 08:57:32 -05:00
|
|
|
withAccountBlockerIds?: number[]
|
2022-02-28 01:34:43 -06:00
|
|
|
forCount?: boolean
|
2019-07-31 08:57:32 -05:00
|
|
|
}
|
|
|
|
|
2019-04-23 02:50:57 -05:00
|
|
|
@DefaultScope(() => ({
|
2017-12-14 10:38:41 -06:00
|
|
|
include: [
|
2017-12-12 10:53:50 -06:00
|
|
|
{
|
2019-04-23 02:50:57 -05:00
|
|
|
model: ActorModel, // Default scope includes avatar and server
|
2018-08-23 10:58:39 -05:00
|
|
|
required: true
|
2017-11-09 10:51:58 -06:00
|
|
|
}
|
|
|
|
]
|
2019-04-23 02:50:57 -05:00
|
|
|
}))
|
|
|
|
@Scopes(() => ({
|
2020-01-31 09:56:52 -06:00
|
|
|
[ScopeNames.SUMMARY]: (options: SummaryOptions = {}) => {
|
2019-07-31 08:57:32 -05:00
|
|
|
const serverInclude: IncludeOptions = {
|
|
|
|
attributes: [ 'host' ],
|
|
|
|
model: ServerModel.unscoped(),
|
2021-07-28 03:32:40 -05:00
|
|
|
required: !!options.whereServer,
|
|
|
|
where: options.whereServer
|
2019-07-31 08:57:32 -05:00
|
|
|
}
|
|
|
|
|
2022-02-28 01:34:43 -06:00
|
|
|
const actorInclude: Includeable = {
|
|
|
|
attributes: [ 'id', 'preferredUsername', 'url', 'serverId' ],
|
|
|
|
model: ActorModel.unscoped(),
|
|
|
|
required: options.actorRequired ?? true,
|
|
|
|
where: options.whereActor,
|
|
|
|
include: [ serverInclude ]
|
|
|
|
}
|
2019-07-31 08:57:32 -05:00
|
|
|
|
2022-02-28 01:34:43 -06:00
|
|
|
if (options.forCount !== true) {
|
|
|
|
actorInclude.include.push({
|
|
|
|
model: ActorImageModel,
|
|
|
|
as: 'Avatars',
|
|
|
|
required: false
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const queryInclude: Includeable[] = [
|
|
|
|
actorInclude
|
2020-12-08 07:30:29 -06:00
|
|
|
]
|
|
|
|
|
|
|
|
const query: FindOptions = {
|
|
|
|
attributes: [ 'id', 'name', 'actorId' ]
|
2019-02-26 03:55:40 -06:00
|
|
|
}
|
2019-07-31 08:57:32 -05:00
|
|
|
|
|
|
|
if (options.withAccountBlockerIds) {
|
2020-12-08 07:30:29 -06:00
|
|
|
queryInclude.push({
|
2019-07-31 08:57:32 -05:00
|
|
|
attributes: [ 'id' ],
|
|
|
|
model: AccountBlocklistModel.unscoped(),
|
2021-10-29 03:54:27 -05:00
|
|
|
as: 'BlockedBy',
|
2019-07-31 08:57:32 -05:00
|
|
|
required: false,
|
|
|
|
where: {
|
|
|
|
accountId: {
|
|
|
|
[Op.in]: options.withAccountBlockerIds
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
serverInclude.include = [
|
|
|
|
{
|
|
|
|
attributes: [ 'id' ],
|
|
|
|
model: ServerBlocklistModel.unscoped(),
|
|
|
|
required: false,
|
|
|
|
where: {
|
|
|
|
accountId: {
|
|
|
|
[Op.in]: options.withAccountBlockerIds
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2020-12-08 07:30:29 -06:00
|
|
|
query.include = queryInclude
|
|
|
|
|
2019-07-31 08:57:32 -05:00
|
|
|
return query
|
2019-02-26 03:55:40 -06:00
|
|
|
}
|
2019-04-23 02:50:57 -05:00
|
|
|
}))
|
2017-12-14 10:38:41 -06:00
|
|
|
@Table({
|
2018-07-23 13:13:30 -05:00
|
|
|
tableName: 'account',
|
|
|
|
indexes: [
|
|
|
|
{
|
|
|
|
fields: [ 'actorId' ],
|
|
|
|
unique: true
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fields: [ 'applicationId' ]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
fields: [ 'userId' ]
|
|
|
|
}
|
|
|
|
]
|
2017-12-14 10:38:41 -06:00
|
|
|
})
|
2021-05-12 07:09:04 -05:00
|
|
|
export class AccountModel extends Model<Partial<AttributesOnly<AccountModel>>> {
|
2017-12-12 10:53:50 -06:00
|
|
|
|
2017-12-14 10:38:41 -06:00
|
|
|
@AllowNull(false)
|
|
|
|
@Column
|
|
|
|
name: string
|
|
|
|
|
2018-02-15 07:46:26 -06:00
|
|
|
@AllowNull(true)
|
|
|
|
@Default(null)
|
2019-04-18 04:28:17 -05:00
|
|
|
@Is('AccountDescription', value => throwIfNotValid(value, isAccountDescriptionValid, 'description', true))
|
2019-05-13 07:37:30 -05:00
|
|
|
@Column(DataType.STRING(CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max))
|
2018-02-15 07:46:26 -06:00
|
|
|
description: string
|
|
|
|
|
2017-12-12 10:53:50 -06:00
|
|
|
@CreatedAt
|
|
|
|
createdAt: Date
|
|
|
|
|
|
|
|
@UpdatedAt
|
|
|
|
updatedAt: Date
|
|
|
|
|
2017-12-14 04:18:49 -06:00
|
|
|
@ForeignKey(() => ActorModel)
|
2017-12-12 10:53:50 -06:00
|
|
|
@Column
|
2017-12-14 04:18:49 -06:00
|
|
|
actorId: number
|
2017-11-09 10:51:58 -06:00
|
|
|
|
2017-12-14 04:18:49 -06:00
|
|
|
@BelongsTo(() => ActorModel, {
|
2017-11-09 10:51:58 -06:00
|
|
|
foreignKey: {
|
2017-12-14 04:18:49 -06:00
|
|
|
allowNull: false
|
2017-11-09 10:51:58 -06:00
|
|
|
},
|
|
|
|
onDelete: 'cascade'
|
|
|
|
})
|
2017-12-14 04:18:49 -06:00
|
|
|
Actor: ActorModel
|
2017-11-09 10:51:58 -06:00
|
|
|
|
2017-12-12 10:53:50 -06:00
|
|
|
@ForeignKey(() => UserModel)
|
|
|
|
@Column
|
|
|
|
userId: number
|
|
|
|
|
|
|
|
@BelongsTo(() => UserModel, {
|
2017-11-09 10:51:58 -06:00
|
|
|
foreignKey: {
|
|
|
|
allowNull: true
|
|
|
|
},
|
|
|
|
onDelete: 'cascade'
|
|
|
|
})
|
2017-12-12 10:53:50 -06:00
|
|
|
User: UserModel
|
|
|
|
|
|
|
|
@ForeignKey(() => ApplicationModel)
|
|
|
|
@Column
|
|
|
|
applicationId: number
|
2017-11-09 10:51:58 -06:00
|
|
|
|
2017-12-12 10:53:50 -06:00
|
|
|
@BelongsTo(() => ApplicationModel, {
|
2017-11-09 10:51:58 -06:00
|
|
|
foreignKey: {
|
|
|
|
allowNull: true
|
|
|
|
},
|
|
|
|
onDelete: 'cascade'
|
|
|
|
})
|
2018-01-18 03:53:54 -06:00
|
|
|
Application: ApplicationModel
|
2017-11-09 10:51:58 -06:00
|
|
|
|
2017-12-12 10:53:50 -06:00
|
|
|
@HasMany(() => VideoChannelModel, {
|
2017-11-09 10:51:58 -06:00
|
|
|
foreignKey: {
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
onDelete: 'cascade',
|
|
|
|
hooks: true
|
|
|
|
})
|
2017-12-12 10:53:50 -06:00
|
|
|
VideoChannels: VideoChannelModel[]
|
2017-11-09 10:51:58 -06:00
|
|
|
|
2019-02-26 03:55:40 -06:00
|
|
|
@HasMany(() => VideoPlaylistModel, {
|
|
|
|
foreignKey: {
|
|
|
|
allowNull: false
|
|
|
|
},
|
|
|
|
onDelete: 'cascade',
|
|
|
|
hooks: true
|
|
|
|
})
|
|
|
|
VideoPlaylists: VideoPlaylistModel[]
|
|
|
|
|
2018-01-18 03:53:54 -06:00
|
|
|
@HasMany(() => VideoCommentModel, {
|
|
|
|
foreignKey: {
|
2019-11-15 12:05:08 -06:00
|
|
|
allowNull: true
|
2018-01-18 03:53:54 -06:00
|
|
|
},
|
|
|
|
onDelete: 'cascade',
|
|
|
|
hooks: true
|
|
|
|
})
|
|
|
|
VideoComments: VideoCommentModel[]
|
|
|
|
|
2019-07-31 08:57:32 -05:00
|
|
|
@HasMany(() => AccountBlocklistModel, {
|
|
|
|
foreignKey: {
|
|
|
|
name: 'targetAccountId',
|
|
|
|
allowNull: false
|
|
|
|
},
|
2021-10-27 07:37:04 -05:00
|
|
|
as: 'BlockedBy',
|
2019-07-31 08:57:32 -05:00
|
|
|
onDelete: 'CASCADE'
|
|
|
|
})
|
2021-10-27 07:37:04 -05:00
|
|
|
BlockedBy: AccountBlocklistModel[]
|
2019-07-31 08:57:32 -05:00
|
|
|
|
2018-01-18 03:53:54 -06:00
|
|
|
@BeforeDestroy
|
|
|
|
static async sendDeleteIfOwned (instance: AccountModel, options) {
|
|
|
|
if (!instance.Actor) {
|
2020-01-08 08:11:38 -06:00
|
|
|
instance.Actor = await instance.$get('Actor', { transaction: options.transaction })
|
2018-01-18 03:53:54 -06:00
|
|
|
}
|
|
|
|
|
2019-08-02 02:46:48 -05:00
|
|
|
await ActorFollowModel.removeFollowsOf(instance.Actor.id, options.transaction)
|
2020-11-10 09:29:35 -06:00
|
|
|
|
2018-07-30 06:39:20 -05:00
|
|
|
if (instance.isOwned()) {
|
|
|
|
return sendDeleteActor(instance.Actor, options.transaction)
|
|
|
|
}
|
|
|
|
|
|
|
|
return undefined
|
2017-11-09 10:51:58 -06:00
|
|
|
}
|
|
|
|
|
2023-01-09 03:29:23 -06:00
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
static getSQLAttributes (tableName: string, aliasPrefix = '') {
|
|
|
|
return buildSQLAttributes({
|
|
|
|
model: this,
|
|
|
|
tableName,
|
|
|
|
aliasPrefix
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ---------------------------------------------------------------------------
|
|
|
|
|
2020-12-08 07:30:29 -06:00
|
|
|
static load (id: number, transaction?: Transaction): Promise<MAccountDefault> {
|
2019-02-21 07:28:06 -06:00
|
|
|
return AccountModel.findByPk(id, { transaction })
|
2017-12-12 10:53:50 -06:00
|
|
|
}
|
2017-12-04 03:34:40 -06:00
|
|
|
|
2020-12-08 07:30:29 -06:00
|
|
|
static loadByNameWithHost (nameWithHost: string): Promise<MAccountDefault> {
|
2019-02-21 07:06:10 -06:00
|
|
|
const [ accountName, host ] = nameWithHost.split('@')
|
|
|
|
|
2019-04-11 04:33:44 -05:00
|
|
|
if (!host || host === WEBSERVER.HOST) return AccountModel.loadLocalByName(accountName)
|
2019-02-21 07:06:10 -06:00
|
|
|
|
|
|
|
return AccountModel.loadByNameAndHost(accountName, host)
|
|
|
|
}
|
|
|
|
|
2020-12-08 07:30:29 -06:00
|
|
|
static loadLocalByName (name: string): Promise<MAccountDefault> {
|
2020-02-04 04:26:51 -06:00
|
|
|
const fun = () => {
|
|
|
|
const query = {
|
|
|
|
where: {
|
|
|
|
[Op.or]: [
|
|
|
|
{
|
|
|
|
userId: {
|
|
|
|
[Op.ne]: null
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
applicationId: {
|
|
|
|
[Op.ne]: null
|
|
|
|
}
|
2017-12-12 10:53:50 -06:00
|
|
|
}
|
2020-02-04 04:26:51 -06:00
|
|
|
]
|
|
|
|
},
|
|
|
|
include: [
|
2017-12-12 10:53:50 -06:00
|
|
|
{
|
2020-02-04 04:26:51 -06:00
|
|
|
model: ActorModel,
|
|
|
|
required: true,
|
|
|
|
where: {
|
|
|
|
preferredUsername: name
|
2017-12-12 10:53:50 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2020-02-04 04:26:51 -06:00
|
|
|
}
|
2018-02-21 09:44:18 -06:00
|
|
|
|
2020-02-04 04:26:51 -06:00
|
|
|
return AccountModel.findOne(query)
|
|
|
|
}
|
2019-12-27 06:33:16 -06:00
|
|
|
|
2020-02-04 04:26:51 -06:00
|
|
|
return ModelCache.Instance.doCache({
|
|
|
|
cacheType: 'local-account-name',
|
|
|
|
key: name,
|
|
|
|
fun,
|
|
|
|
// The server actor never change, so we can easily cache it
|
|
|
|
whitelist: () => name === SERVER_ACTOR_NAME
|
|
|
|
})
|
2018-02-21 09:44:18 -06:00
|
|
|
}
|
|
|
|
|
2020-12-08 07:30:29 -06:00
|
|
|
static loadByNameAndHost (name: string, host: string): Promise<MAccountDefault> {
|
2018-02-21 09:44:18 -06:00
|
|
|
const query = {
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
model: ActorModel,
|
|
|
|
required: true,
|
|
|
|
where: {
|
|
|
|
preferredUsername: name
|
|
|
|
},
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
model: ServerModel,
|
|
|
|
required: true,
|
|
|
|
where: {
|
|
|
|
host
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2017-12-12 10:53:50 -06:00
|
|
|
}
|
2017-11-13 10:39:41 -06:00
|
|
|
|
2017-12-12 10:53:50 -06:00
|
|
|
return AccountModel.findOne(query)
|
|
|
|
}
|
2017-11-13 10:39:41 -06:00
|
|
|
|
2020-12-08 07:30:29 -06:00
|
|
|
static loadByUrl (url: string, transaction?: Transaction): Promise<MAccountDefault> {
|
2017-12-12 10:53:50 -06:00
|
|
|
const query = {
|
2017-12-14 04:18:49 -06:00
|
|
|
include: [
|
|
|
|
{
|
|
|
|
model: ActorModel,
|
|
|
|
required: true,
|
|
|
|
where: {
|
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
2017-12-12 10:53:50 -06:00
|
|
|
transaction
|
|
|
|
}
|
2017-11-09 10:51:58 -06:00
|
|
|
|
2017-12-12 10:53:50 -06:00
|
|
|
return AccountModel.findOne(query)
|
|
|
|
}
|
2017-11-09 10:51:58 -06:00
|
|
|
|
2018-01-03 09:38:50 -06:00
|
|
|
static listForApi (start: number, count: number, sort: string) {
|
|
|
|
const query = {
|
|
|
|
offset: start,
|
|
|
|
limit: count,
|
2018-02-19 04:31:50 -06:00
|
|
|
order: getSort(sort)
|
2018-01-03 09:38:50 -06:00
|
|
|
}
|
|
|
|
|
2022-02-28 01:34:43 -06:00
|
|
|
return Promise.all([
|
|
|
|
AccountModel.count(),
|
|
|
|
AccountModel.findAll(query)
|
|
|
|
]).then(([ total, data ]) => ({ total, data }))
|
2018-01-03 09:38:50 -06:00
|
|
|
}
|
|
|
|
|
2020-12-08 07:30:29 -06:00
|
|
|
static loadAccountIdFromVideo (videoId: number): Promise<MAccount> {
|
2020-05-22 10:06:26 -05:00
|
|
|
const query = {
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
attributes: [ 'id', 'accountId' ],
|
|
|
|
model: VideoChannelModel.unscoped(),
|
|
|
|
required: true,
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
attributes: [ 'id', 'channelId' ],
|
|
|
|
model: VideoModel.unscoped(),
|
|
|
|
where: {
|
|
|
|
id: videoId
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
return AccountModel.findOne(query)
|
|
|
|
}
|
|
|
|
|
2020-12-08 07:30:29 -06:00
|
|
|
static listLocalsForSitemap (sort: string): Promise<MAccountActor[]> {
|
2018-12-05 10:27:24 -06:00
|
|
|
const query = {
|
|
|
|
attributes: [ ],
|
|
|
|
offset: 0,
|
|
|
|
order: getSort(sort),
|
|
|
|
include: [
|
|
|
|
{
|
|
|
|
attributes: [ 'preferredUsername', 'serverId' ],
|
|
|
|
model: ActorModel.unscoped(),
|
|
|
|
where: {
|
|
|
|
serverId: null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
return AccountModel
|
|
|
|
.unscoped()
|
|
|
|
.findAll(query)
|
|
|
|
}
|
|
|
|
|
2020-07-01 09:05:30 -05:00
|
|
|
getClientUrl () {
|
|
|
|
return WEBSERVER.URL + '/accounts/' + this.Actor.getIdentifier()
|
|
|
|
}
|
|
|
|
|
2019-08-20 12:05:31 -05:00
|
|
|
toFormattedJSON (this: MAccountFormattable): Account {
|
2022-02-28 01:34:43 -06:00
|
|
|
return {
|
|
|
|
...this.Actor.toFormattedJSON(),
|
|
|
|
|
2017-12-12 10:53:50 -06:00
|
|
|
id: this.id,
|
2018-04-16 17:49:04 -05:00
|
|
|
displayName: this.getDisplayName(),
|
2018-02-15 07:46:26 -06:00
|
|
|
description: this.description,
|
2021-05-07 10:14:39 -05:00
|
|
|
updatedAt: this.updatedAt,
|
2022-02-28 01:34:43 -06:00
|
|
|
userId: this.userId ?? undefined
|
2017-12-12 10:53:50 -06:00
|
|
|
}
|
|
|
|
}
|
2017-11-09 10:51:58 -06:00
|
|
|
|
2019-08-20 12:05:31 -05:00
|
|
|
toFormattedSummaryJSON (this: MAccountSummaryFormattable): AccountSummary {
|
|
|
|
const actor = this.Actor.toFormattedSummaryJSON()
|
2019-02-26 03:55:40 -06:00
|
|
|
|
|
|
|
return {
|
|
|
|
id: this.id,
|
|
|
|
displayName: this.getDisplayName(),
|
2022-02-28 01:34:43 -06:00
|
|
|
|
|
|
|
name: actor.name,
|
2019-02-26 03:55:40 -06:00
|
|
|
url: actor.url,
|
|
|
|
host: actor.host,
|
2022-02-28 01:34:43 -06:00
|
|
|
avatars: actor.avatars,
|
|
|
|
|
|
|
|
// TODO: remove, deprecated in 4.2
|
2019-02-26 03:55:40 -06:00
|
|
|
avatar: actor.avatar
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-21 07:31:57 -05:00
|
|
|
toActivityPubObject (this: MAccountAP) {
|
2019-08-30 09:50:12 -05:00
|
|
|
const obj = this.Actor.toActivityPubObject(this.name)
|
2018-02-15 07:46:26 -06:00
|
|
|
|
|
|
|
return Object.assign(obj, {
|
|
|
|
summary: this.description
|
|
|
|
})
|
2017-11-09 10:51:58 -06:00
|
|
|
}
|
|
|
|
|
2017-12-12 10:53:50 -06:00
|
|
|
isOwned () {
|
2017-12-14 04:18:49 -06:00
|
|
|
return this.Actor.isOwned()
|
2017-12-12 10:53:50 -06:00
|
|
|
}
|
2018-04-16 17:49:04 -05:00
|
|
|
|
2019-01-14 04:30:15 -06:00
|
|
|
isOutdated () {
|
|
|
|
return this.Actor.isOutdated()
|
|
|
|
}
|
|
|
|
|
2018-04-16 17:49:04 -05:00
|
|
|
getDisplayName () {
|
|
|
|
return this.name
|
|
|
|
}
|
2019-07-31 08:57:32 -05:00
|
|
|
|
2020-12-08 03:53:41 -06:00
|
|
|
getLocalUrl (this: MAccountActor | MChannelActor) {
|
|
|
|
return WEBSERVER.URL + `/accounts/` + this.Actor.preferredUsername
|
|
|
|
}
|
|
|
|
|
2019-07-31 08:57:32 -05:00
|
|
|
isBlocked () {
|
2021-10-27 07:37:04 -05:00
|
|
|
return this.BlockedBy && this.BlockedBy.length !== 0
|
2019-07-31 08:57:32 -05:00
|
|
|
}
|
2017-11-24 06:41:10 -06:00
|
|
|
}
|