Table,
UpdatedAt
} from 'sequelize-typescript'
-import { ModelCache } from '@server/models/model-cache'
+import { ModelCache } from '@server/models/shared/model-cache'
import { AttributesOnly } from '@shared/typescript-utils'
import { Account, AccountSummary } from '../../../shared/models/actors'
import { isAccountDescriptionValid } from '../../helpers/custom-validators/accounts'
MAccountAP,
MAccountDefault,
MAccountFormattable,
+ MAccountHost,
MAccountSummaryFormattable,
- MChannelActor
+ MChannelHost
} from '../../types/models'
import { ActorModel } from '../actor/actor'
import { ActorFollowModel } from '../actor/actor-follow'
import { ApplicationModel } from '../application/application'
import { ServerModel } from '../server/server'
import { ServerBlocklistModel } from '../server/server-blocklist'
+import { buildSQLAttributes, getSort, throwIfNotValid } from '../shared'
import { UserModel } from '../user/user'
-import { getSort, throwIfNotValid } from '../utils'
import { VideoModel } from '../video/video'
import { VideoChannelModel } from '../video/video-channel'
import { VideoCommentModel } from '../video/video-comment'
return undefined
}
+ // ---------------------------------------------------------------------------
+
+ static getSQLAttributes (tableName: string, aliasPrefix = '') {
+ return buildSQLAttributes({
+ model: this,
+ tableName,
+ aliasPrefix
+ })
+ }
+
+ // ---------------------------------------------------------------------------
+
static load (id: number, transaction?: Transaction): Promise<MAccountDefault> {
return AccountModel.findByPk(id, { transaction })
}
{
model: ActorModel,
required: true,
- where: {
- preferredUsername: name
- }
+ where: ActorModel.wherePreferredUsername(name)
}
]
}
{
model: ActorModel,
required: true,
- where: {
- preferredUsername: name
- },
+ where: ActorModel.wherePreferredUsername(name),
include: [
{
model: ServerModel,
.findAll(query)
}
- getClientUrl () {
- return WEBSERVER.URL + '/accounts/' + this.Actor.getIdentifier()
- }
-
toFormattedJSON (this: MAccountFormattable): Account {
return {
...this.Actor.toFormattedJSON(),
}
}
- toActivityPubObject (this: MAccountAP) {
- const obj = this.Actor.toActivityPubObject(this.name)
+ async toActivityPubObject (this: MAccountAP) {
+ const obj = await this.Actor.toActivityPubObject(this.name)
return Object.assign(obj, {
summary: this.description
return this.name
}
- getLocalUrl (this: MAccountActor | MChannelActor) {
- return WEBSERVER.URL + `/accounts/` + this.Actor.preferredUsername
+ // Avoid error when running this method on MAccount... | MChannel...
+ getClientUrl (this: MAccountHost | MChannelHost) {
+ return WEBSERVER.URL + '/a/' + this.Actor.getIdentifier()
}
isBlocked () {