From a15871560f80e07386c1dabb8370cd2664ecfd1f Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 31 Jan 2020 16:56:52 +0100 Subject: Move to eslint --- server/models/activitypub/actor-follow.ts | 53 +++++++++++++++---------------- server/models/activitypub/actor.ts | 12 ++++--- 2 files changed, 33 insertions(+), 32 deletions(-) (limited to 'server/models/activitypub') diff --git a/server/models/activitypub/actor-follow.ts b/server/models/activitypub/actor-follow.ts index f21d2b8a2..27643704e 100644 --- a/server/models/activitypub/actor-follow.ts +++ b/server/models/activitypub/actor-follow.ts @@ -1,5 +1,5 @@ import * as Bluebird from 'bluebird' -import { values, difference } from 'lodash' +import { difference, values } from 'lodash' import { AfterCreate, AfterDestroy, @@ -23,7 +23,7 @@ import { logger } from '../../helpers/logger' import { getServerActor } from '../../helpers/utils' import { ACTOR_FOLLOW_SCORE, FOLLOW_STATES, SERVER_ACTOR_NAME } from '../../initializers/constants' import { ServerModel } from '../server/server' -import { createSafeIn, getSort, getFollowsSort } from '../utils' +import { createSafeIn, getFollowsSort, getSort } from '../utils' import { ActorModel, unusedActorAttributesForAPI } from './actor' import { VideoChannelModel } from '../video/video-channel' import { AccountModel } from '../account/account' @@ -36,7 +36,6 @@ import { MActorFollowSubscriptions } from '@server/typings/models' import { ActivityPubActorType } from '@shared/models' -import { afterCommitIfTransaction } from '@server/helpers/database-utils' @Table({ tableName: 'actorFollow', @@ -226,7 +225,7 @@ export class ActorFollowModel extends Model { return ActorFollowModel.findOne(query) .then(result => { - if (result && result.ActorFollowing.VideoChannel) { + if (result?.ActorFollowing.VideoChannel) { result.ActorFollowing.VideoChannel.Actor = result.ActorFollowing } @@ -239,24 +238,24 @@ export class ActorFollowModel extends Model { .map(t => { if (t.host) { return { - [ Op.and ]: [ + [Op.and]: [ { - '$preferredUsername$': t.name + $preferredUsername$: t.name }, { - '$host$': t.host + $host$: t.host } ] } } return { - [ Op.and ]: [ + [Op.and]: [ { - '$preferredUsername$': t.name + $preferredUsername$: t.name }, { - '$serverId$': null + $serverId$: null } ] } @@ -265,9 +264,9 @@ export class ActorFollowModel extends Model { const query = { attributes: [], where: { - [ Op.and ]: [ + [Op.and]: [ { - [ Op.or ]: whereTab + [Op.or]: whereTab }, { actorId @@ -295,12 +294,12 @@ export class ActorFollowModel extends Model { } static listFollowingForApi (options: { - id: number, - start: number, - count: number, - sort: string, - state?: FollowState, - actorType?: ActivityPubActorType, + id: number + start: number + count: number + sort: string + state?: FollowState + actorType?: ActivityPubActorType search?: string }) { const { id, start, count, sort, search, state, actorType } = options @@ -312,7 +311,7 @@ export class ActorFollowModel extends Model { if (search) { Object.assign(followingServerWhere, { host: { - [ Op.iLike ]: '%' + search + '%' + [Op.iLike]: '%' + search + '%' } }) } @@ -362,12 +361,12 @@ export class ActorFollowModel extends Model { } static listFollowersForApi (options: { - actorId: number, - start: number, - count: number, - sort: string, - state?: FollowState, - actorType?: ActivityPubActorType, + actorId: number + start: number + count: number + sort: string + state?: FollowState + actorType?: ActivityPubActorType search?: string }) { const { actorId, start, count, sort, search, state, actorType } = options @@ -379,7 +378,7 @@ export class ActorFollowModel extends Model { if (search) { Object.assign(followerServerWhere, { host: { - [ Op.iLike ]: '%' + search + '%' + [Op.iLike]: '%' + search + '%' } }) } @@ -631,7 +630,7 @@ export class ActorFollowModel extends Model { const tasks: Bluebird[] = [] - for (let selection of selections) { + for (const selection of selections) { let query = 'SELECT ' + selection + ' FROM "actor" ' + 'INNER JOIN "actorFollow" ON "actorFollow"."' + firstJoin + '" = "actor"."id" ' + 'INNER JOIN "actor" AS "Follows" ON "actorFollow"."' + secondJoin + '" = "Follows"."id" ' + diff --git a/server/models/activitypub/actor.ts b/server/models/activitypub/actor.ts index d651a281a..00e8dc954 100644 --- a/server/models/activitypub/actor.ts +++ b/server/models/activitypub/actor.ts @@ -16,7 +16,7 @@ import { Table, UpdatedAt } from 'sequelize-typescript' -import { ActivityPubActorType } from '../../../shared/models/activitypub' +import { ActivityIconObject, ActivityPubActorType } from '../../../shared/models/activitypub' import { Avatar } from '../../../shared/models/avatars/avatar.model' import { activityPubContextify } from '../../helpers/activitypub' import { @@ -335,7 +335,7 @@ export class ActorModel extends Model { const query = { where: { followersUrl: { - [ Op.in ]: followersUrls + [Op.in]: followersUrls } }, transaction @@ -362,7 +362,7 @@ export class ActorModel extends Model { .findOne(query) .then(actor => { if (preferredUsername === SERVER_ACTOR_NAME) { - ActorModel.localNameCache[ preferredUsername ] = actor + ActorModel.localNameCache[preferredUsername] = actor } return actor @@ -388,7 +388,7 @@ export class ActorModel extends Model { .findOne(query) .then(actor => { if (preferredUsername === SERVER_ACTOR_NAME) { - ActorModel.localUrlCache[ preferredUsername ] = actor + ActorModel.localUrlCache[preferredUsername] = actor } return actor @@ -500,9 +500,11 @@ export class ActorModel extends Model { } toActivityPubObject (this: MActorAP, name: string) { - let icon = undefined + let icon: ActivityIconObject + if (this.avatarId) { const extension = extname(this.Avatar.filename) + icon = { type: 'Image', mediaType: extension === '.png' ? 'image/png' : 'image/jpeg', -- cgit v1.2.3