fix imports

This commit is contained in:
ThatOneCalculator 2022-12-04 12:46:10 -08:00
parent c5141db8f2
commit df1359e392
2 changed files with 25 additions and 23 deletions

View file

@ -1,5 +1,6 @@
import type { CacheableRemoteUser } from '@/models/entities/user.js';
import { toArray } from '@/prelude/array.js';
import { import {
IObject,
isCreate, isCreate,
isDelete, isDelete,
isUpdate, isUpdate,
@ -16,9 +17,10 @@ import {
isCollectionOrOrderedCollection, isCollectionOrOrderedCollection,
isCollection, isCollection,
isFlag, isFlag,
isMove isMove,
} from '../type.js'; } from '../type.js';
import { CacheableRemoteUser } from '@/models/entities/user.js'; import { apLogger } from '../logger.js';
import Resolver from '../resolver.js';
import create from './create/index.js'; import create from './create/index.js';
import performDeleteActivity from './delete/index.js'; import performDeleteActivity from './delete/index.js';
import performUpdateActivity from './update/index.js'; import performUpdateActivity from './update/index.js';
@ -33,10 +35,8 @@ import add from './add/index.js';
import remove from './remove/index.js'; import remove from './remove/index.js';
import block from './block/index.js'; import block from './block/index.js';
import flag from './flag/index.js'; import flag from './flag/index.js';
import { apLogger } from '../logger.js';
import Resolver from '../resolver.js';
import { toArray } from '@/prelude/array.js';
import move from './move/index.js'; import move from './move/index.js';
import type { IObject } from '../type.js';
export async function performActivity(actor: CacheableRemoteUser, activity: IObject) { export async function performActivity(actor: CacheableRemoteUser, activity: IObject) {
if (isCollectionOrOrderedCollection(activity)) { if (isCollectionOrOrderedCollection(activity)) {

View file

@ -1,15 +1,17 @@
import {CacheableRemoteUser, IRemoteUser, User} from '@/models/entities/user.js'; import type { CacheableRemoteUser } from '@/models/entities/user.js';
import {IMove, IObject, IActor} from '../../type.js'; import { IRemoteUser, User } from '@/models/entities/user.js';
import DbResolver from "@/remote/activitypub/db-resolver"; import DbResolver from '@/remote/activitypub/db-resolver';
import {getRemoteUser} from '@/server/api/common/getters.js'; import { getRemoteUser } from '@/server/api/common/getters.js';
import { updatePerson } from '@/remote/activitypub/models/person.js'; import { updatePerson } from '@/remote/activitypub/models/person.js';
import {Followings, Users} from "@/models"; import { Followings, Users } from '@/models';
import {makePaginationQuery} from "@/server/api/common/make-pagination-query"; import { makePaginationQuery } from '@/server/api/common/make-pagination-query';
import deleteFollowing from '@/services/following/delete.js'; import deleteFollowing from '@/services/following/delete.js';
import create from '@/services/following/create.js'; import create from '@/services/following/create.js';
import {IdentifiableError} from "@/misc/identifiable-error"; import { IdentifiableError } from '@/misc/identifiable-error';
import {ApiError} from "@/server/api/error"; import { ApiError } from '@/server/api/error';
import {meta} from "@/server/api/endpoints/following/create"; import { meta } from '@/server/api/endpoints/following/create';
import { IObject, IActor } from '../../type.js';
import type { IMove } from '../../type.js';
export default async (actor: CacheableRemoteUser, activity: IMove): Promise<string> => { export default async (actor: CacheableRemoteUser, activity: IMove): Promise<string> => {
// ※ There is a block target in activity.object, which should be a local user that exists. // ※ There is a block target in activity.object, which should be a local user that exists.
@ -22,19 +24,19 @@ export default async (actor: CacheableRemoteUser, activity: IMove): Promise<stri
if (!old_acc) new_acc = await getRemoteUser(<string>activity.actor); if (!old_acc) new_acc = await getRemoteUser(<string>activity.actor);
if (!new_acc || new_acc.uri === null) { if (!new_acc || new_acc.uri === null) {
return `move: new acc not found`; return 'move: new acc not found';
} }
if (!old_acc || old_acc.uri === null) { if (!old_acc || old_acc.uri === null) {
return `move: old acc not found`; return 'move: old acc not found';
} }
await updatePerson(new_acc.uri); await updatePerson(new_acc.uri);
await updatePerson(old_acc.uri); await updatePerson(old_acc.uri);
new_acc = await getRemoteUser(new_acc.uri); new_acc = await getRemoteUser(new_acc.uri);
old_acc = await getRemoteUser(old_acc.uri); old_acc = await getRemoteUser(old_acc.uri);
if(old_acc === null || old_acc.uri === null || !new_acc?.alsoKnownAs?.includes(old_acc.uri)) return `move: accounts invalid`; if (old_acc === null || old_acc.uri === null || !new_acc.alsoKnownAs?.includes(old_acc.uri)) return 'move: accounts invalid';
old_acc.movedToUri = new_acc?.uri old_acc.movedToUri = new_acc.uri;
const query = makePaginationQuery(Followings.createQueryBuilder('following')) const query = makePaginationQuery(Followings.createQueryBuilder('following'))
.andWhere('following.followeeId = :userId', { userId: old_acc.id }) .andWhere('following.followeeId = :userId', { userId: old_acc.id })
@ -44,8 +46,8 @@ export default async (actor: CacheableRemoteUser, activity: IMove): Promise<stri
.getMany(); .getMany();
followings.forEach(following => { followings.forEach(following => {
if(!following.follower?.host) { if (!following.follower?.host) {
let follower = following.follower; const follower = following.follower;
deleteFollowing(follower!, old_acc!); deleteFollowing(follower!, old_acc!);
try { try {
create(follower!, new_acc!); create(follower!, new_acc!);
@ -57,7 +59,7 @@ export default async (actor: CacheableRemoteUser, activity: IMove): Promise<stri
throw e; throw e;
} }
} }
}) });
return `ok`; return 'ok';
}; };