2023-07-27 07:31:52 +02:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2021-11-12 11:47:04 +01:00
|
|
|
import ms from 'ms';
|
2022-09-17 20:27:08 +02:00
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
|
|
|
|
import { Endpoint } from '@/server/api/endpoint-base.js';
|
2022-09-20 22:33:11 +02:00
|
|
|
import type { DriveFilesRepository, GalleryPostsRepository } from '@/models/index.js';
|
2022-09-17 20:27:08 +02:00
|
|
|
import type { DriveFile } from '@/models/entities/DriveFile.js';
|
|
|
|
|
import { GalleryPostEntityService } from '@/core/entities/GalleryPostEntityService.js';
|
|
|
|
|
import { DI } from '@/di-symbols.js';
|
2021-04-26 04:10:45 +02:00
|
|
|
|
|
|
|
|
export const meta = {
|
|
|
|
|
tags: ['gallery'],
|
|
|
|
|
|
2022-01-18 14:27:10 +01:00
|
|
|
requireCredential: true,
|
2021-04-26 04:10:45 +02:00
|
|
|
|
2023-08-13 15:30:19 +02:00
|
|
|
prohibitDeactivated: true,
|
enhance: account migration (#10592)
* copy block and mute then create follow and unfollow jobs
* copy block and mute and update lists when detecting an account has moved
* no need to care promise orders
* refactor updating actor and target
* automatically accept if a locked account had accepted an old account
* fix exception format
* prevent the old account from calling some endpoints
* do not unfollow when moving
* adjust following and follower counts
* check movedToUri when receiving a follow request
* skip if no need to adjust
* Revert "disable account migration"
This reverts commit 2321214c98591bcfe1385c1ab5bf0ff7b471ae1d.
* fix translation specifier
* fix checking alsoKnownAs and uri
* fix updating account
* fix refollowing locked account
* decrease followersCount if followed by the old account
* adjust following and followers counts when unfollowing
* fix copying mutings
* prohibit moved account from moving again
* fix move service
* allow app creation after moving
* fix lint
* remove unnecessary field
* fix cache update
* add e2e test
* add e2e test of accepting the new account automatically
* force follow if any error happens
* remove unnecessary joins
* use Array.map instead of for const of
* ユーザーリストの移行は追加のみを行う
* nanka iroiro
* fix misskey-js?
* :v:
* 移行を行ったアカウントからのフォローリクエストの自動許可を調整
* newUriを外に出す
* newUriを外に出す2
* clean up
* fix newUri
* prevent moving if the destination account has already moved
* set alsoKnownAs via /i/update
* fix database initialization
* add return type
* prohibit updating alsoKnownAs after moving
* skip to add to alsoKnownAs if toUrl is known
* skip adding to the list if it already has
* use Acct.parse instead
* rename error code
* :art:
* 制限を5から10に緩和
* movedTo(Uri), alsoKnownAsはユーザーidを返すように
* test api res
* fix
* 元アカウントはミュートし続ける
* :art:
* unfollow
* fix
* getUserUriをUserEntityServiceに
* ?
* job!
* :art:
* instance => server
* accountMovedShort, forbiddenBecauseYouAreMigrated
* accountMovedShort
* fix test
* import, pin禁止
* 実績を凍結する
* clean up
* :v:
* change message
* ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに
* Revert "ブロック, フォロー, ミュート, リストのインポートファイルの制限を32MiBに"
This reverts commit 3bd7be35d8aa455cb01ae58f8172a71a50485db1.
* validateAlsoKnownAs
* 移行後2時間以内はインポート可能なファイルサイズを拡大
* clean up
* どうせactorをupdatePersonで更新するならupdatePersonしか移行処理を発行しないことにする
* handle error?
* リモートからの移行処理の条件を是正
* log, port
* fix
* fix
* enhance(dev): non-production環境でhttpサーバー間でもユーザー、ノートの連合が可能なように
* refactor (use checkHttps)
* MISSKEY_WEBFINGER_USE_HTTP
* Environment Variable readme
* NEVER USE IN PRODUCTION
* fix punyHost
* fix indent
* fix
* experimental
---------
Co-authored-by: tamaina <tamaina@hotmail.co.jp>
Co-authored-by: syuilo <Syuilotan@yahoo.co.jp>
2023-04-29 17:09:29 +02:00
|
|
|
|
2021-04-26 04:10:45 +02:00
|
|
|
kind: 'write:gallery',
|
|
|
|
|
|
|
|
|
|
limit: {
|
|
|
|
|
duration: ms('1hour'),
|
2021-12-09 15:58:30 +01:00
|
|
|
max: 300,
|
2021-04-26 04:10:45 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
res: {
|
2022-01-18 14:27:10 +01:00
|
|
|
type: 'object',
|
|
|
|
|
optional: false, nullable: false,
|
2021-04-26 04:10:45 +02:00
|
|
|
ref: 'GalleryPost',
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
errors: {
|
|
|
|
|
|
2021-12-09 15:58:30 +01:00
|
|
|
},
|
2022-01-18 14:27:10 +01:00
|
|
|
} as const;
|
2021-04-26 04:10:45 +02:00
|
|
|
|
2022-02-20 05:15:40 +01:00
|
|
|
export const paramDef = {
|
2022-02-19 06:05:32 +01:00
|
|
|
type: 'object',
|
|
|
|
|
properties: {
|
|
|
|
|
postId: { type: 'string', format: 'misskey:id' },
|
|
|
|
|
title: { type: 'string', minLength: 1 },
|
|
|
|
|
description: { type: 'string', nullable: true },
|
|
|
|
|
fileIds: { type: 'array', uniqueItems: true, minItems: 1, maxItems: 32, items: {
|
|
|
|
|
type: 'string', format: 'misskey:id',
|
|
|
|
|
} },
|
|
|
|
|
isSensitive: { type: 'boolean', default: false },
|
|
|
|
|
},
|
|
|
|
|
required: ['postId', 'title', 'fileIds'],
|
|
|
|
|
} as const;
|
|
|
|
|
|
2022-01-02 18:12:50 +01:00
|
|
|
// eslint-disable-next-line import/no-default-export
|
2022-09-17 20:27:08 +02:00
|
|
|
@Injectable()
|
|
|
|
|
export default class extends Endpoint<typeof meta, typeof paramDef> {
|
|
|
|
|
constructor(
|
|
|
|
|
@Inject(DI.galleryPostsRepository)
|
|
|
|
|
private galleryPostsRepository: GalleryPostsRepository,
|
2021-04-26 04:10:45 +02:00
|
|
|
|
2022-09-17 20:27:08 +02:00
|
|
|
@Inject(DI.driveFilesRepository)
|
|
|
|
|
private driveFilesRepository: DriveFilesRepository,
|
|
|
|
|
|
|
|
|
|
private galleryPostEntityService: GalleryPostEntityService,
|
|
|
|
|
) {
|
|
|
|
|
super(meta, paramDef, async (ps, me) => {
|
|
|
|
|
const files = (await Promise.all(ps.fileIds.map(fileId =>
|
|
|
|
|
this.driveFilesRepository.findOneBy({
|
|
|
|
|
id: fileId,
|
|
|
|
|
userId: me.id,
|
|
|
|
|
}),
|
|
|
|
|
))).filter((file): file is DriveFile => file != null);
|
2021-04-26 04:10:45 +02:00
|
|
|
|
2022-09-17 20:27:08 +02:00
|
|
|
if (files.length === 0) {
|
|
|
|
|
throw new Error();
|
|
|
|
|
}
|
2021-04-26 04:10:45 +02:00
|
|
|
|
2022-09-17 20:27:08 +02:00
|
|
|
await this.galleryPostsRepository.update({
|
|
|
|
|
id: ps.postId,
|
|
|
|
|
userId: me.id,
|
|
|
|
|
}, {
|
|
|
|
|
updatedAt: new Date(),
|
|
|
|
|
title: ps.title,
|
|
|
|
|
description: ps.description,
|
|
|
|
|
isSensitive: ps.isSensitive,
|
|
|
|
|
fileIds: files.map(file => file.id),
|
|
|
|
|
});
|
2021-04-26 04:10:45 +02:00
|
|
|
|
2022-09-17 20:27:08 +02:00
|
|
|
const post = await this.galleryPostsRepository.findOneByOrFail({ id: ps.postId });
|
|
|
|
|
|
|
|
|
|
return await this.galleryPostEntityService.pack(post, me);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|