From 16c016e8b1d5ca46343d3363f9a49e24c5d7c944 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 12 May 2021 14:09:04 +0200 Subject: Stricter models typing --- server/models/actor/actor-follow.ts | 5 +++-- server/models/actor/actor-image.ts | 3 ++- server/models/actor/actor.ts | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) (limited to 'server/models/actor') diff --git a/server/models/actor/actor-follow.ts b/server/models/actor/actor-follow.ts index 4c5f37620..3a09e51d6 100644 --- a/server/models/actor/actor-follow.ts +++ b/server/models/actor/actor-follow.ts @@ -28,6 +28,7 @@ import { MActorFollowFormattable, MActorFollowSubscriptions } from '@server/types/models' +import { AttributesOnly } from '@shared/core-utils' import { ActivityPubActorType } from '@shared/models' import { FollowState } from '../../../shared/models/actors' import { ActorFollow } from '../../../shared/models/actors/follow.model' @@ -61,7 +62,7 @@ import { ActorModel, unusedActorAttributesForAPI } from './actor' } ] }) -export class ActorFollowModel extends Model { +export class ActorFollowModel extends Model>> { @AllowNull(false) @Column(DataType.ENUM(...values(FOLLOW_STATES))) @@ -619,7 +620,7 @@ export class ActorFollowModel extends Model { if (serverIds.length === 0) return const me = await getServerActor() - const serverIdsString = createSafeIn(ActorFollowModel, serverIds) + const serverIdsString = createSafeIn(ActorFollowModel.sequelize, serverIds) const query = `UPDATE "actorFollow" SET "score" = LEAST("score" + ${value}, ${ACTOR_FOLLOW_SCORE.MAX}) ` + 'WHERE id IN (' + diff --git a/server/models/actor/actor-image.ts b/server/models/actor/actor-image.ts index ae05b4969..a35f9edb0 100644 --- a/server/models/actor/actor-image.ts +++ b/server/models/actor/actor-image.ts @@ -2,6 +2,7 @@ import { remove } from 'fs-extra' import { join } from 'path' import { AfterDestroy, AllowNull, Column, CreatedAt, Default, Is, Model, Table, UpdatedAt } from 'sequelize-typescript' import { MActorImageFormattable } from '@server/types/models' +import { AttributesOnly } from '@shared/core-utils' import { ActorImageType } from '@shared/models' import { ActorImage } from '../../../shared/models/actors/actor-image.model' import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc' @@ -19,7 +20,7 @@ import { throwIfNotValid } from '../utils' } ] }) -export class ActorImageModel extends Model { +export class ActorImageModel extends Model>> { @AllowNull(false) @Column diff --git a/server/models/actor/actor.ts b/server/models/actor/actor.ts index 5cf6fb8f1..65c53f8f8 100644 --- a/server/models/actor/actor.ts +++ b/server/models/actor/actor.ts @@ -18,6 +18,7 @@ import { UpdatedAt } from 'sequelize-typescript' import { ModelCache } from '@server/models/model-cache' +import { AttributesOnly } from '@shared/core-utils' import { ActivityIconObject, ActivityPubActorType } from '../../../shared/models/activitypub' import { ActorImage } from '../../../shared/models/actors/actor-image.model' import { activityPubContextify } from '../../helpers/activitypub' @@ -159,7 +160,7 @@ export const unusedActorAttributesForAPI = [ } ] }) -export class ActorModel extends Model { +export class ActorModel extends Model>> { @AllowNull(false) @Column(DataType.ENUM(...values(ACTIVITY_PUB_ACTOR_TYPES))) -- cgit v1.2.3