From 453e83ea5d81d203ba34bc43cd5c2c750ba40568 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 15 Aug 2019 11:53:26 +0200 Subject: Stronger model typings --- server/models/account/account.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'server/models/account/account.ts') diff --git a/server/models/account/account.ts b/server/models/account/account.ts index 4dc412301..4cc731075 100644 --- a/server/models/account/account.ts +++ b/server/models/account/account.ts @@ -3,7 +3,8 @@ import { BeforeDestroy, BelongsTo, Column, - CreatedAt, DataType, + CreatedAt, + DataType, Default, DefaultScope, ForeignKey, @@ -31,6 +32,8 @@ import { FindOptions, IncludeOptions, Op, Transaction, WhereOptions } from 'sequ import { AccountBlocklistModel } from './account-blocklist' import { ServerBlocklistModel } from '../server/server-blocklist' import { ActorFollowModel } from '../activitypub/actor-follow' +import { MAccountActor, MAccountDefault } from '../../typings/models' +import * as Bluebird from 'bluebird' export enum ScopeNames { SUMMARY = 'SUMMARY' @@ -229,11 +232,11 @@ export class AccountModel extends Model { return undefined } - static load (id: number, transaction?: Transaction) { + static load (id: number, transaction?: Transaction): Bluebird { return AccountModel.findByPk(id, { transaction }) } - static loadByNameWithHost (nameWithHost: string) { + static loadByNameWithHost (nameWithHost: string): Bluebird { const [ accountName, host ] = nameWithHost.split('@') if (!host || host === WEBSERVER.HOST) return AccountModel.loadLocalByName(accountName) @@ -241,7 +244,7 @@ export class AccountModel extends Model { return AccountModel.loadByNameAndHost(accountName, host) } - static loadLocalByName (name: string) { + static loadLocalByName (name: string): Bluebird { const query = { where: { [ Op.or ]: [ @@ -271,7 +274,7 @@ export class AccountModel extends Model { return AccountModel.findOne(query) } - static loadByNameAndHost (name: string, host: string) { + static loadByNameAndHost (name: string, host: string): Bluebird { const query = { include: [ { @@ -296,7 +299,7 @@ export class AccountModel extends Model { return AccountModel.findOne(query) } - static loadByUrl (url: string, transaction?: Transaction) { + static loadByUrl (url: string, transaction?: Transaction): Bluebird { const query = { include: [ { @@ -329,7 +332,7 @@ export class AccountModel extends Model { }) } - static listLocalsForSitemap (sort: string) { + static listLocalsForSitemap (sort: string): Bluebird { const query = { attributes: [ ], offset: 0, -- cgit v1.2.3