2023-07-27 05:31:52 +00:00
|
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
*/
|
|
|
|
|
|
2023-07-15 09:39:38 +00:00
|
|
|
|
import { createPublicKey, randomUUID } from 'node:crypto';
|
2022-09-17 18:27:08 +00:00
|
|
|
|
import { Inject, Injectable } from '@nestjs/common';
|
2023-07-13 03:48:34 +00:00
|
|
|
|
import { In } from 'typeorm';
|
2024-02-03 14:01:09 +00:00
|
|
|
|
import * as mfm from '@transfem-org/sfm-js';
|
2022-09-17 18:27:08 +00:00
|
|
|
|
import { DI } from '@/di-symbols.js';
|
2022-09-20 20:33:11 +00:00
|
|
|
|
import type { Config } from '@/config.js';
|
2023-09-20 02:33:36 +00:00
|
|
|
|
import type { MiPartialLocalUser, MiLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
|
|
|
|
import type { IMentionedRemoteUsers, MiNote } from '@/models/Note.js';
|
|
|
|
|
import type { MiBlocking } from '@/models/Blocking.js';
|
|
|
|
|
import type { MiRelay } from '@/models/Relay.js';
|
|
|
|
|
import type { MiDriveFile } from '@/models/DriveFile.js';
|
|
|
|
|
import type { MiNoteReaction } from '@/models/NoteReaction.js';
|
|
|
|
|
import type { MiEmoji } from '@/models/Emoji.js';
|
|
|
|
|
import type { MiPoll } from '@/models/Poll.js';
|
|
|
|
|
import type { MiPollVote } from '@/models/PollVote.js';
|
2023-04-05 03:10:40 +00:00
|
|
|
|
import { UserKeypairService } from '@/core/UserKeypairService.js';
|
2022-09-17 18:27:08 +00:00
|
|
|
|
import { MfmService } from '@/core/MfmService.js';
|
|
|
|
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
|
|
|
|
import { DriveFileEntityService } from '@/core/entities/DriveFileEntityService.js';
|
2023-09-20 02:33:36 +00:00
|
|
|
|
import type { MiUserKeypair } from '@/models/UserKeypair.js';
|
2023-11-12 21:16:47 +00:00
|
|
|
|
import type { UsersRepository, UserProfilesRepository, NotesRepository, DriveFilesRepository, PollsRepository, InstancesRepository } from '@/models/_.js';
|
2023-01-25 02:23:57 +00:00
|
|
|
|
import { bindThis } from '@/decorators.js';
|
2023-04-06 02:14:43 +00:00
|
|
|
|
import { CustomEmojiService } from '@/core/CustomEmojiService.js';
|
|
|
|
|
import { isNotNull } from '@/misc/is-not-null.js';
|
2023-10-16 01:45:22 +00:00
|
|
|
|
import { IdService } from '@/core/IdService.js';
|
2024-02-03 14:01:09 +00:00
|
|
|
|
import { MetaService } from '../MetaService.js';
|
2022-09-17 18:27:08 +00:00
|
|
|
|
import { LdSignatureService } from './LdSignatureService.js';
|
|
|
|
|
import { ApMfmService } from './ApMfmService.js';
|
2023-04-08 05:16:26 +00:00
|
|
|
|
import type { IAccept, IActivity, IAdd, IAnnounce, IApDocument, IApEmoji, IApHashtag, IApImage, IApMention, IBlock, ICreate, IDelete, IFlag, IFollow, IKey, ILike, IMove, IObject, IPost, IQuestion, IReject, IRemove, ITombstone, IUndo, IUpdate } from './type.js';
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
|
export class ApRendererService {
|
|
|
|
|
constructor(
|
|
|
|
|
@Inject(DI.config)
|
|
|
|
|
private config: Config,
|
|
|
|
|
|
|
|
|
|
@Inject(DI.usersRepository)
|
|
|
|
|
private usersRepository: UsersRepository,
|
|
|
|
|
|
|
|
|
|
@Inject(DI.userProfilesRepository)
|
|
|
|
|
private userProfilesRepository: UserProfilesRepository,
|
|
|
|
|
|
|
|
|
|
@Inject(DI.notesRepository)
|
|
|
|
|
private notesRepository: NotesRepository,
|
|
|
|
|
|
|
|
|
|
@Inject(DI.driveFilesRepository)
|
|
|
|
|
private driveFilesRepository: DriveFilesRepository,
|
|
|
|
|
|
|
|
|
|
@Inject(DI.pollsRepository)
|
|
|
|
|
private pollsRepository: PollsRepository,
|
|
|
|
|
|
2023-11-12 21:16:47 +00:00
|
|
|
|
@Inject(DI.instancesRepository)
|
|
|
|
|
private instancesRepository: InstancesRepository,
|
|
|
|
|
|
2023-04-06 02:14:43 +00:00
|
|
|
|
private customEmojiService: CustomEmojiService,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
private userEntityService: UserEntityService,
|
|
|
|
|
private driveFileEntityService: DriveFileEntityService,
|
|
|
|
|
private ldSignatureService: LdSignatureService,
|
2023-04-05 03:10:40 +00:00
|
|
|
|
private userKeypairService: UserKeypairService,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
private apMfmService: ApMfmService,
|
|
|
|
|
private mfmService: MfmService,
|
2023-10-16 01:45:22 +00:00
|
|
|
|
private idService: IdService,
|
2023-11-12 21:16:47 +00:00
|
|
|
|
private metaService: MetaService,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
) {
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderAccept(object: string | IObject, user: { id: MiUser['id']; host: null }): IAccept {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Accept',
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
object,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderAdd(user: MiLocalUser, target: string | IObject | undefined, object: string | IObject): IAdd {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Add',
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
target,
|
|
|
|
|
object,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderAnnounce(object: string | IObject, note: MiNote): IAnnounce {
|
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 15:09:29 +00:00
|
|
|
|
const attributedTo = this.userEntityService.genLocalUserUri(note.userId);
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
|
|
|
|
let to: string[] = [];
|
|
|
|
|
let cc: string[] = [];
|
|
|
|
|
|
|
|
|
|
if (note.visibility === 'public') {
|
|
|
|
|
to = ['https://www.w3.org/ns/activitystreams#Public'];
|
|
|
|
|
cc = [`${attributedTo}/followers`];
|
|
|
|
|
} else if (note.visibility === 'home') {
|
|
|
|
|
to = [`${attributedTo}/followers`];
|
|
|
|
|
cc = ['https://www.w3.org/ns/activitystreams#Public'];
|
2023-03-12 03:11:37 +00:00
|
|
|
|
} else if (note.visibility === 'followers') {
|
|
|
|
|
to = [`${attributedTo}/followers`];
|
|
|
|
|
cc = [];
|
2022-09-17 18:27:08 +00:00
|
|
|
|
} else {
|
2023-02-12 09:47:30 +00:00
|
|
|
|
throw new Error('renderAnnounce: cannot render non-public note');
|
2022-09-17 18:27:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: `${this.config.url}/notes/${note.id}/activity`,
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(note.userId),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
type: 'Announce',
|
2023-10-16 01:45:22 +00:00
|
|
|
|
published: this.idService.parse(note.id).date.toISOString(),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
to,
|
|
|
|
|
cc,
|
|
|
|
|
object,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Renders a block into its ActivityPub representation.
|
|
|
|
|
*
|
|
|
|
|
* @param block The block to be rendered. The blockee relation must be loaded.
|
|
|
|
|
*/
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderBlock(block: MiBlocking): IBlock {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (block.blockee?.uri == null) {
|
|
|
|
|
throw new Error('renderBlock: missing blockee uri');
|
|
|
|
|
}
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Block',
|
|
|
|
|
id: `${this.config.url}/blocks/${block.id}`,
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(block.blockerId),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
object: block.blockee.uri,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderCreate(object: IObject, note: MiNote): ICreate {
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const activity: ICreate = {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
id: `${this.config.url}/notes/${note.id}/activity`,
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(note.userId),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
type: 'Create',
|
2023-10-16 01:45:22 +00:00
|
|
|
|
published: this.idService.parse(note.id).date.toISOString(),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
object,
|
2023-07-13 03:48:34 +00:00
|
|
|
|
};
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (object.to) activity.to = object.to;
|
|
|
|
|
if (object.cc) activity.cc = object.cc;
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return activity;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderDelete(object: IObject | string, user: { id: MiUser['id']; host: null }): IDelete {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Delete',
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
object,
|
|
|
|
|
published: new Date().toISOString(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderDocument(file: MiDriveFile): IApDocument {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Document',
|
2023-03-10 00:37:22 +00:00
|
|
|
|
mediaType: file.webpublicType ?? file.type,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
url: this.driveFileEntityService.getPublicUrl(file),
|
|
|
|
|
name: file.comment,
|
2023-11-30 03:05:11 +00:00
|
|
|
|
summary: file.comment,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderEmoji(emoji: MiEmoji): IApEmoji {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
id: `${this.config.url}/emojis/${emoji.name}`,
|
|
|
|
|
type: 'Emoji',
|
|
|
|
|
name: `:${emoji.name}:`,
|
2023-02-12 09:47:30 +00:00
|
|
|
|
updated: emoji.updatedAt != null ? emoji.updatedAt.toISOString() : new Date().toISOString(),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
icon: {
|
|
|
|
|
type: 'Image',
|
|
|
|
|
mediaType: emoji.type ?? 'image/png',
|
2022-12-30 13:37:58 +00:00
|
|
|
|
// || emoji.originalUrl してるのは後方互換性のため(publicUrlはstringなので??はだめ)
|
|
|
|
|
url: emoji.publicUrl || emoji.originalUrl,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// to anonymise reporters, the reporting actor must be a system user
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderFlag(user: MiLocalUser, object: IObject | string, content: string): IFlag {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Flag',
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
content,
|
|
|
|
|
object,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderFollowRelay(relay: MiRelay, relayActor: MiLocalUser): IFollow {
|
2023-02-12 09:47:30 +00:00
|
|
|
|
return {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
id: `${this.config.url}/activities/follow-relay/${relay.id}`,
|
|
|
|
|
type: 'Follow',
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(relayActor.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
object: 'https://www.w3.org/ns/activitystreams#Public',
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convert (local|remote)(Follower|Followee)ID to URL
|
|
|
|
|
* @param id Follower|Followee ID
|
|
|
|
|
*/
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public async renderFollowUser(id: MiUser['id']): Promise<string> {
|
|
|
|
|
const user = await this.usersRepository.findOneByOrFail({ id: id }) as MiPartialLocalUser | MiPartialRemoteUser;
|
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 15:09:29 +00:00
|
|
|
|
return this.userEntityService.getUserUri(user);
|
2022-09-17 18:27:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2022-09-17 18:27:08 +00:00
|
|
|
|
public renderFollow(
|
2023-08-16 08:51:28 +00:00
|
|
|
|
follower: MiPartialLocalUser | MiPartialRemoteUser,
|
|
|
|
|
followee: MiPartialLocalUser | MiPartialRemoteUser,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
requestId?: string,
|
2023-02-12 09:47:30 +00:00
|
|
|
|
): IFollow {
|
|
|
|
|
return {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
id: requestId ?? `${this.config.url}/follows/${follower.id}/${followee.id}`,
|
|
|
|
|
type: 'Follow',
|
2023-07-13 03:48:34 +00:00
|
|
|
|
actor: this.userEntityService.getUserUri(follower),
|
|
|
|
|
object: this.userEntityService.getUserUri(followee),
|
2023-02-12 09:47:30 +00:00
|
|
|
|
};
|
2022-09-17 18:27:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-02-12 09:47:30 +00:00
|
|
|
|
public renderHashtag(tag: string): IApHashtag {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Hashtag',
|
|
|
|
|
href: `${this.config.url}/tags/${encodeURIComponent(tag)}`,
|
|
|
|
|
name: `#${tag}`,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderImage(file: MiDriveFile): IApImage {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Image',
|
|
|
|
|
url: this.driveFileEntityService.getPublicUrl(file),
|
|
|
|
|
sensitive: file.isSensitive,
|
|
|
|
|
name: file.comment,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderKey(user: MiLocalUser, key: MiUserKeypair, postfix?: string): IKey {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
id: `${this.config.url}/users/${user.id}${postfix ?? '/publickey'}`,
|
|
|
|
|
type: 'Key',
|
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 15:09:29 +00:00
|
|
|
|
owner: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
publicKeyPem: createPublicKey(key.publicKey).export({
|
|
|
|
|
type: 'spki',
|
|
|
|
|
format: 'pem',
|
|
|
|
|
}),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public async renderLike(noteReaction: MiNoteReaction, note: { uri: string | null }): Promise<ILike> {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const reaction = noteReaction.reaction;
|
2023-11-12 21:16:47 +00:00
|
|
|
|
const meta = await this.metaService.fetch(true);
|
|
|
|
|
let isMastodon = false;
|
|
|
|
|
|
|
|
|
|
if (meta.defaultLike && reaction.replaceAll(':', '') === meta.defaultLike.replaceAll(':', '')) {
|
|
|
|
|
const note = await this.notesRepository.findOneBy({ id: noteReaction.noteId });
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
2023-11-12 21:16:47 +00:00
|
|
|
|
if (note && note.userHost) {
|
|
|
|
|
const instance = await this.instancesRepository.findOneBy({ host: note.userHost });
|
|
|
|
|
|
|
|
|
|
if (instance && instance.softwareName === 'mastodon') isMastodon = true;
|
2023-11-12 21:27:20 +00:00
|
|
|
|
if (instance && instance.softwareName === 'akkoma') isMastodon = true;
|
|
|
|
|
if (instance && instance.softwareName === 'pleroma') isMastodon = true;
|
2023-11-12 21:16:47 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const object: ILike = {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
type: 'Like',
|
|
|
|
|
id: `${this.config.url}/likes/${noteReaction.id}`,
|
|
|
|
|
actor: `${this.config.url}/users/${noteReaction.userId}`,
|
|
|
|
|
object: note.uri ? note.uri : `${this.config.url}/notes/${noteReaction.noteId}`,
|
2023-11-12 21:16:47 +00:00
|
|
|
|
content: isMastodon ? undefined : reaction,
|
|
|
|
|
_misskey_reaction: isMastodon ? undefined : reaction,
|
2023-07-13 03:48:34 +00:00
|
|
|
|
};
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
|
|
|
|
if (reaction.startsWith(':')) {
|
2023-02-03 08:44:25 +00:00
|
|
|
|
const name = reaction.replaceAll(':', '');
|
2023-04-06 02:14:43 +00:00
|
|
|
|
const emoji = (await this.customEmojiService.localEmojisCache.fetch()).get(name);
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
2023-05-18 09:48:35 +00:00
|
|
|
|
if (emoji && !emoji.localOnly) object.tag = [this.renderEmoji(emoji)];
|
2022-09-17 18:27:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return object;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderMention(mention: MiPartialLocalUser | MiPartialRemoteUser): IApMention {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Mention',
|
2023-07-13 03:48:34 +00:00
|
|
|
|
href: this.userEntityService.getUserUri(mention),
|
2023-08-16 08:51:28 +00:00
|
|
|
|
name: this.userEntityService.isRemoteUser(mention) ? `@${mention.username}@${mention.host}` : `@${(mention as MiLocalUser).username}`,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-08 05:16:26 +00:00
|
|
|
|
@bindThis
|
|
|
|
|
public renderMove(
|
2023-08-16 08:51:28 +00:00
|
|
|
|
src: MiPartialLocalUser | MiPartialRemoteUser,
|
|
|
|
|
dst: MiPartialLocalUser | MiPartialRemoteUser,
|
2023-04-08 05:16:26 +00:00
|
|
|
|
): IMove {
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const actor = this.userEntityService.getUserUri(src);
|
|
|
|
|
const target = this.userEntityService.getUserUri(dst);
|
2023-04-08 05:16:26 +00:00
|
|
|
|
return {
|
|
|
|
|
id: `${this.config.url}/moves/${src.id}/${dst.id}`,
|
|
|
|
|
actor,
|
|
|
|
|
type: 'Move',
|
|
|
|
|
object: actor,
|
|
|
|
|
target,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public async renderNote(note: MiNote, dive = true): Promise<IPost> {
|
|
|
|
|
const getPromisedFiles = async (ids: string[]): Promise<MiDriveFile[]> => {
|
2023-07-13 03:48:34 +00:00
|
|
|
|
if (ids.length === 0) return [];
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const items = await this.driveFilesRepository.findBy({ id: In(ids) });
|
2023-08-16 08:51:28 +00:00
|
|
|
|
return ids.map(id => items.find(item => item.id === id)).filter((item): item is MiDriveFile => item != null);
|
2022-09-17 18:27:08 +00:00
|
|
|
|
};
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
let inReplyTo;
|
2023-08-16 08:51:28 +00:00
|
|
|
|
let inReplyToNote: MiNote | null;
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (note.replyId) {
|
|
|
|
|
inReplyToNote = await this.notesRepository.findOneBy({ id: note.replyId });
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (inReplyToNote != null) {
|
2023-07-11 05:58:58 +00:00
|
|
|
|
const inReplyToUserExist = await this.usersRepository.exist({ where: { id: inReplyToNote.userId } });
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2023-07-11 05:58:58 +00:00
|
|
|
|
if (inReplyToUserExist) {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (inReplyToNote.uri) {
|
|
|
|
|
inReplyTo = inReplyToNote.uri;
|
|
|
|
|
} else {
|
|
|
|
|
if (dive) {
|
|
|
|
|
inReplyTo = await this.renderNote(inReplyToNote, false);
|
|
|
|
|
} else {
|
|
|
|
|
inReplyTo = `${this.config.url}/notes/${inReplyToNote.id}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
inReplyTo = null;
|
|
|
|
|
}
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
let quote;
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (note.renoteId) {
|
|
|
|
|
const renote = await this.notesRepository.findOneBy({ id: note.renoteId });
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (renote) {
|
|
|
|
|
quote = renote.uri ? renote.uri : `${this.config.url}/notes/${renote.id}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
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 15:09:29 +00:00
|
|
|
|
const attributedTo = this.userEntityService.genLocalUserUri(note.userId);
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2023-09-22 20:42:01 +00:00
|
|
|
|
const mentions = note.mentionedRemoteUsers ? (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri) : [];
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
let to: string[] = [];
|
|
|
|
|
let cc: string[] = [];
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (note.visibility === 'public') {
|
|
|
|
|
to = ['https://www.w3.org/ns/activitystreams#Public'];
|
|
|
|
|
cc = [`${attributedTo}/followers`].concat(mentions);
|
|
|
|
|
} else if (note.visibility === 'home') {
|
|
|
|
|
to = [`${attributedTo}/followers`];
|
|
|
|
|
cc = ['https://www.w3.org/ns/activitystreams#Public'].concat(mentions);
|
|
|
|
|
} else if (note.visibility === 'followers') {
|
|
|
|
|
to = [`${attributedTo}/followers`];
|
|
|
|
|
cc = mentions;
|
|
|
|
|
} else {
|
|
|
|
|
to = mentions;
|
|
|
|
|
}
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2023-09-22 20:42:01 +00:00
|
|
|
|
const mentionedUsers = note.mentions && note.mentions.length > 0 ? await this.usersRepository.findBy({
|
2022-09-17 18:27:08 +00:00
|
|
|
|
id: In(note.mentions),
|
|
|
|
|
}) : [];
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const hashtagTags = note.tags.map(tag => this.renderHashtag(tag));
|
2023-08-16 08:51:28 +00:00
|
|
|
|
const mentionTags = mentionedUsers.map(u => this.renderMention(u as MiLocalUser | MiRemoteUser));
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const files = await getPromisedFiles(note.fileIds);
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const text = note.text ?? '';
|
2023-08-16 08:51:28 +00:00
|
|
|
|
let poll: MiPoll | null = null;
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (note.hasPoll) {
|
|
|
|
|
poll = await this.pollsRepository.findOneBy({ noteId: note.id });
|
|
|
|
|
}
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
let apText = text;
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (quote) {
|
|
|
|
|
apText += `\n\nRE: ${quote}`;
|
|
|
|
|
}
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const summary = note.cw === '' ? String.fromCharCode(0x200B) : note.cw;
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const content = this.apMfmService.getNoteHtml(Object.assign({}, note, {
|
|
|
|
|
text: apText,
|
|
|
|
|
}));
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-18 18:11:50 +00:00
|
|
|
|
const emojis = await this.getEmojis(note.emojis);
|
2023-05-18 09:48:35 +00:00
|
|
|
|
const apemojis = emojis.filter(emoji => !emoji.localOnly).map(emoji => this.renderEmoji(emoji));
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const tag = [
|
|
|
|
|
...hashtagTags,
|
|
|
|
|
...mentionTags,
|
|
|
|
|
...apemojis,
|
|
|
|
|
];
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const asPoll = poll ? {
|
|
|
|
|
type: 'Question',
|
|
|
|
|
content: this.apMfmService.getNoteHtml(Object.assign({}, note, {
|
|
|
|
|
text: text,
|
|
|
|
|
})),
|
|
|
|
|
[poll.expiresAt && poll.expiresAt < new Date() ? 'closed' : 'endTime']: poll.expiresAt,
|
|
|
|
|
[poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({
|
|
|
|
|
type: 'Note',
|
|
|
|
|
name: text,
|
|
|
|
|
replies: {
|
|
|
|
|
type: 'Collection',
|
|
|
|
|
totalItems: poll!.votes[i],
|
|
|
|
|
},
|
|
|
|
|
})),
|
2023-02-12 11:06:10 +00:00
|
|
|
|
} as const : {};
|
2023-02-15 04:06:06 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
id: `${this.config.url}/notes/${note.id}`,
|
|
|
|
|
type: 'Note',
|
|
|
|
|
attributedTo,
|
2022-09-24 22:44:42 +00:00
|
|
|
|
summary: summary ?? undefined,
|
|
|
|
|
content: content ?? undefined,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
_misskey_content: text,
|
|
|
|
|
source: {
|
|
|
|
|
content: text,
|
|
|
|
|
mediaType: 'text/x.misskeymarkdown',
|
|
|
|
|
},
|
|
|
|
|
_misskey_quote: quote,
|
|
|
|
|
quoteUrl: quote,
|
2023-03-16 10:41:59 +00:00
|
|
|
|
quoteUri: quote,
|
2023-10-16 01:45:22 +00:00
|
|
|
|
published: this.idService.parse(note.id).date.toISOString(),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
to,
|
|
|
|
|
cc,
|
|
|
|
|
inReplyTo,
|
|
|
|
|
attachment: files.map(x => this.renderDocument(x)),
|
|
|
|
|
sensitive: note.cw != null || files.some(file => file.isSensitive),
|
|
|
|
|
tag,
|
|
|
|
|
...asPoll,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public async renderPerson(user: MiLocalUser) {
|
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 15:09:29 +00:00
|
|
|
|
const id = this.userEntityService.genLocalUserUri(user.id);
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const isSystem = user.username.includes('.');
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
2023-10-06 00:32:09 +00:00
|
|
|
|
const [avatar, banner, background, profile] = await Promise.all([
|
2023-07-13 03:48:34 +00:00
|
|
|
|
user.avatarId ? this.driveFilesRepository.findOneBy({ id: user.avatarId }) : undefined,
|
|
|
|
|
user.bannerId ? this.driveFilesRepository.findOneBy({ id: user.bannerId }) : undefined,
|
2023-10-06 00:32:09 +00:00
|
|
|
|
user.backgroundId ? this.driveFilesRepository.findOneBy({ id: user.backgroundId }) : undefined,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
this.userProfilesRepository.findOneByOrFail({ userId: user.id }),
|
|
|
|
|
]);
|
|
|
|
|
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const attachment = profile.fields.map(field => ({
|
2022-09-17 18:27:08 +00:00
|
|
|
|
type: 'PropertyValue',
|
2023-07-13 03:48:34 +00:00
|
|
|
|
name: field.name,
|
2023-11-15 07:10:05 +00:00
|
|
|
|
value: (field.value.startsWith('http://') || field.value.startsWith('https://'))
|
2023-07-13 03:48:34 +00:00
|
|
|
|
? `<a href="${new URL(field.value).href}" rel="me nofollow noopener" target="_blank">${new URL(field.value).href}</a>`
|
|
|
|
|
: field.value,
|
|
|
|
|
}));
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
2022-09-18 18:11:50 +00:00
|
|
|
|
const emojis = await this.getEmojis(user.emojis);
|
2023-05-18 09:48:35 +00:00
|
|
|
|
const apemojis = emojis.filter(emoji => !emoji.localOnly).map(emoji => this.renderEmoji(emoji));
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const hashtagTags = user.tags.map(tag => this.renderHashtag(tag));
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
|
|
|
|
const tag = [
|
|
|
|
|
...apemojis,
|
|
|
|
|
...hashtagTags,
|
|
|
|
|
];
|
|
|
|
|
|
2023-04-05 03:10:40 +00:00
|
|
|
|
const keypair = await this.userKeypairService.getUserKeypair(user.id);
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const person: any = {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
type: isSystem ? 'Application' : user.isBot ? 'Service' : 'Person',
|
|
|
|
|
id,
|
|
|
|
|
inbox: `${id}/inbox`,
|
|
|
|
|
outbox: `${id}/outbox`,
|
|
|
|
|
followers: `${id}/followers`,
|
|
|
|
|
following: `${id}/following`,
|
|
|
|
|
featured: `${id}/collections/featured`,
|
|
|
|
|
sharedInbox: `${this.config.url}/inbox`,
|
|
|
|
|
endpoints: { sharedInbox: `${this.config.url}/inbox` },
|
|
|
|
|
url: `${this.config.url}/@${user.username}`,
|
|
|
|
|
preferredUsername: user.username,
|
|
|
|
|
name: user.name,
|
|
|
|
|
summary: profile.description ? this.mfmService.toHtml(mfm.parse(profile.description)) : null,
|
2023-10-29 10:33:35 +00:00
|
|
|
|
_misskey_summary: profile.description,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
icon: avatar ? this.renderImage(avatar) : null,
|
|
|
|
|
image: banner ? this.renderImage(banner) : null,
|
2023-10-06 00:32:09 +00:00
|
|
|
|
backgroundUrl: background ? this.renderImage(background) : null,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
tag,
|
|
|
|
|
manuallyApprovesFollowers: user.isLocked,
|
2023-07-13 03:48:34 +00:00
|
|
|
|
discoverable: user.isExplorable,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
publicKey: this.renderKey(user, keypair, '#main-key'),
|
|
|
|
|
isCat: user.isCat,
|
2023-11-17 14:05:58 +00:00
|
|
|
|
noindex: user.noindex,
|
2023-10-04 02:35:58 +00:00
|
|
|
|
speakAsCat: user.speakAsCat,
|
2022-09-17 18:27:08 +00:00
|
|
|
|
attachment: attachment.length ? attachment : undefined,
|
2023-07-13 03:48:34 +00:00
|
|
|
|
};
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
2023-04-08 05:16:26 +00:00
|
|
|
|
if (user.movedToUri) {
|
|
|
|
|
person.movedTo = user.movedToUri;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (user.alsoKnownAs) {
|
|
|
|
|
person.alsoKnownAs = user.alsoKnownAs;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (profile.birthday) {
|
|
|
|
|
person['vcard:bday'] = profile.birthday;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (profile.location) {
|
|
|
|
|
person['vcard:Address'] = profile.location;
|
|
|
|
|
}
|
|
|
|
|
|
2023-10-06 18:53:34 +00:00
|
|
|
|
if (profile.listenbrainz) {
|
|
|
|
|
person.listenbrainz = profile.listenbrainz;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return person;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderQuestion(user: { id: MiUser['id'] }, note: MiNote, poll: MiPoll): IQuestion {
|
2023-02-12 09:47:30 +00:00
|
|
|
|
return {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
type: 'Question',
|
|
|
|
|
id: `${this.config.url}/questions/${note.id}`,
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
content: note.text ?? '',
|
|
|
|
|
[poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({
|
|
|
|
|
name: text,
|
|
|
|
|
_misskey_votes: poll.votes[i],
|
|
|
|
|
replies: {
|
|
|
|
|
type: 'Collection',
|
|
|
|
|
totalItems: poll.votes[i],
|
|
|
|
|
},
|
|
|
|
|
})),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderReject(object: string | IObject, user: { id: MiUser['id'] }): IReject {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Reject',
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
object,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderRemove(user: { id: MiUser['id'] }, target: string | IObject | undefined, object: string | IObject): IRemove {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
type: 'Remove',
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
target,
|
|
|
|
|
object,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-02-12 09:47:30 +00:00
|
|
|
|
public renderTombstone(id: string): ITombstone {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
id,
|
|
|
|
|
type: 'Tombstone',
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderUndo(object: string | IObject, user: { id: MiUser['id'] }): IUndo {
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const id = typeof object !== 'string' && typeof object.id === 'string' && object.id.startsWith(this.config.url) ? `${object.id}/undo` : undefined;
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
type: 'Undo',
|
|
|
|
|
...(id ? { id } : {}),
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
object,
|
|
|
|
|
published: new Date().toISOString(),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderUpdate(object: string | IObject, user: { id: MiUser['id'] }): IUpdate {
|
2023-02-12 09:47:30 +00:00
|
|
|
|
return {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
id: `${this.config.url}/users/${user.id}#updates/${new Date().getTime()}`,
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
type: 'Update',
|
|
|
|
|
to: ['https://www.w3.org/ns/activitystreams#Public'],
|
|
|
|
|
object,
|
|
|
|
|
published: new Date().toISOString(),
|
2023-02-12 09:47:30 +00:00
|
|
|
|
};
|
2022-09-17 18:27:08 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-06 17:00:41 +00:00
|
|
|
|
@bindThis
|
|
|
|
|
public async renderUpNote(note: MiNote, dive = true): Promise<IPost> {
|
|
|
|
|
const getPromisedFiles = async (ids: string[]): Promise<MiDriveFile[]> => {
|
|
|
|
|
if (ids.length === 0) return [];
|
|
|
|
|
const items = await this.driveFilesRepository.findBy({ id: In(ids) });
|
|
|
|
|
return ids.map(id => items.find(item => item.id === id)).filter((item): item is MiDriveFile => item != null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let inReplyTo;
|
|
|
|
|
let inReplyToNote: MiNote | null;
|
|
|
|
|
|
|
|
|
|
if (note.replyId) {
|
|
|
|
|
inReplyToNote = await this.notesRepository.findOneBy({ id: note.replyId });
|
|
|
|
|
|
|
|
|
|
if (inReplyToNote != null) {
|
|
|
|
|
const inReplyToUserExist = await this.usersRepository.exist({ where: { id: inReplyToNote.userId } });
|
|
|
|
|
|
|
|
|
|
if (inReplyToUserExist) {
|
|
|
|
|
if (inReplyToNote.uri) {
|
|
|
|
|
inReplyTo = inReplyToNote.uri;
|
|
|
|
|
} else {
|
|
|
|
|
if (dive) {
|
|
|
|
|
inReplyTo = await this.renderUpNote(inReplyToNote, false);
|
|
|
|
|
} else {
|
|
|
|
|
inReplyTo = `${this.config.url}/notes/${inReplyToNote.id}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
inReplyTo = null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let quote;
|
|
|
|
|
|
|
|
|
|
if (note.renoteId) {
|
|
|
|
|
const renote = await this.notesRepository.findOneBy({ id: note.renoteId });
|
|
|
|
|
|
|
|
|
|
if (renote) {
|
|
|
|
|
quote = renote.uri ? renote.uri : `${this.config.url}/notes/${renote.id}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const attributedTo = this.userEntityService.genLocalUserUri(note.userId);
|
|
|
|
|
|
|
|
|
|
const mentions = note.mentionedRemoteUsers ? (JSON.parse(note.mentionedRemoteUsers) as IMentionedRemoteUsers).map(x => x.uri) : [];
|
|
|
|
|
|
|
|
|
|
let to: string[] = [];
|
|
|
|
|
let cc: string[] = [];
|
|
|
|
|
|
|
|
|
|
if (note.visibility === 'public') {
|
|
|
|
|
to = ['https://www.w3.org/ns/activitystreams#Public'];
|
|
|
|
|
cc = [`${attributedTo}/followers`].concat(mentions);
|
|
|
|
|
} else if (note.visibility === 'home') {
|
|
|
|
|
to = [`${attributedTo}/followers`];
|
|
|
|
|
cc = ['https://www.w3.org/ns/activitystreams#Public'].concat(mentions);
|
|
|
|
|
} else if (note.visibility === 'followers') {
|
|
|
|
|
to = [`${attributedTo}/followers`];
|
|
|
|
|
cc = mentions;
|
|
|
|
|
} else {
|
|
|
|
|
to = mentions;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mentionedUsers = note.mentions && note.mentions.length > 0 ? await this.usersRepository.findBy({
|
|
|
|
|
id: In(note.mentions),
|
|
|
|
|
}) : [];
|
|
|
|
|
|
|
|
|
|
const hashtagTags = note.tags.map(tag => this.renderHashtag(tag));
|
|
|
|
|
const mentionTags = mentionedUsers.map(u => this.renderMention(u as MiLocalUser | MiRemoteUser));
|
|
|
|
|
|
|
|
|
|
const files = await getPromisedFiles(note.fileIds);
|
|
|
|
|
|
|
|
|
|
const text = note.text ?? '';
|
|
|
|
|
let poll: MiPoll | null = null;
|
|
|
|
|
|
|
|
|
|
if (note.hasPoll) {
|
|
|
|
|
poll = await this.pollsRepository.findOneBy({ noteId: note.id });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let apText = text;
|
|
|
|
|
|
|
|
|
|
if (quote) {
|
|
|
|
|
apText += `\n\nRE: ${quote}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const summary = note.cw === '' ? String.fromCharCode(0x200B) : note.cw;
|
|
|
|
|
|
|
|
|
|
const content = this.apMfmService.getNoteHtml(Object.assign({}, note, {
|
|
|
|
|
text: apText,
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
const emojis = await this.getEmojis(note.emojis);
|
|
|
|
|
const apemojis = emojis.filter(emoji => !emoji.localOnly).map(emoji => this.renderEmoji(emoji));
|
|
|
|
|
|
|
|
|
|
const tag = [
|
|
|
|
|
...hashtagTags,
|
|
|
|
|
...mentionTags,
|
|
|
|
|
...apemojis,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const asPoll = poll ? {
|
|
|
|
|
type: 'Question',
|
|
|
|
|
content: this.apMfmService.getNoteHtml(Object.assign({}, note, {
|
|
|
|
|
text: text,
|
|
|
|
|
})),
|
|
|
|
|
[poll.expiresAt && poll.expiresAt < new Date() ? 'closed' : 'endTime']: poll.expiresAt,
|
|
|
|
|
[poll.multiple ? 'anyOf' : 'oneOf']: poll.choices.map((text, i) => ({
|
|
|
|
|
type: 'Note',
|
|
|
|
|
name: text,
|
|
|
|
|
replies: {
|
|
|
|
|
type: 'Collection',
|
|
|
|
|
totalItems: poll!.votes[i],
|
|
|
|
|
},
|
|
|
|
|
})),
|
|
|
|
|
} as const : {};
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
id: `${this.config.url}/notes/${note.id}`,
|
|
|
|
|
type: 'Note',
|
|
|
|
|
attributedTo,
|
|
|
|
|
summary: summary ?? undefined,
|
|
|
|
|
content: content ?? undefined,
|
|
|
|
|
updated: note.updatedAt?.toISOString(),
|
|
|
|
|
_misskey_content: text,
|
|
|
|
|
source: {
|
|
|
|
|
content: text,
|
|
|
|
|
mediaType: 'text/x.misskeymarkdown',
|
|
|
|
|
},
|
|
|
|
|
_misskey_quote: quote,
|
|
|
|
|
quoteUrl: quote,
|
|
|
|
|
quoteUri: quote,
|
2023-10-16 21:38:21 +00:00
|
|
|
|
published: this.idService.parse(note.id).date.toISOString(),
|
2023-10-06 17:00:41 +00:00
|
|
|
|
to,
|
|
|
|
|
cc,
|
|
|
|
|
inReplyTo,
|
|
|
|
|
attachment: files.map(x => this.renderDocument(x)),
|
|
|
|
|
sensitive: note.cw != null || files.some(file => file.isSensitive),
|
|
|
|
|
tag,
|
|
|
|
|
...asPoll,
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public renderVote(user: { id: MiUser['id'] }, vote: MiPollVote, note: MiNote, poll: MiPoll, pollOwner: MiRemoteUser): ICreate {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return {
|
|
|
|
|
id: `${this.config.url}/users/${user.id}#votes/${vote.id}/activity`,
|
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 15:09:29 +00:00
|
|
|
|
actor: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
type: 'Create',
|
|
|
|
|
to: [pollOwner.uri],
|
|
|
|
|
published: new Date().toISOString(),
|
|
|
|
|
object: {
|
|
|
|
|
id: `${this.config.url}/users/${user.id}#votes/${vote.id}`,
|
|
|
|
|
type: 'Note',
|
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 15:09:29 +00:00
|
|
|
|
attributedTo: this.userEntityService.genLocalUserUri(user.id),
|
2022-09-17 18:27:08 +00:00
|
|
|
|
to: [pollOwner.uri],
|
|
|
|
|
inReplyTo: note.uri,
|
|
|
|
|
name: poll.choices[vote.choice],
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-02-12 09:47:30 +00:00
|
|
|
|
public addContext<T extends IObject>(x: T): T & { '@context': any; id: string; } {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (typeof x === 'object' && x.id == null) {
|
2023-07-15 09:39:38 +00:00
|
|
|
|
x.id = `${this.config.url}/${randomUUID()}`;
|
2022-09-17 18:27:08 +00:00
|
|
|
|
}
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return Object.assign({
|
|
|
|
|
'@context': [
|
|
|
|
|
'https://www.w3.org/ns/activitystreams',
|
|
|
|
|
'https://w3id.org/security/v1',
|
|
|
|
|
{
|
|
|
|
|
// as non-standards
|
|
|
|
|
manuallyApprovesFollowers: 'as:manuallyApprovesFollowers',
|
|
|
|
|
sensitive: 'as:sensitive',
|
|
|
|
|
Hashtag: 'as:Hashtag',
|
|
|
|
|
quoteUrl: 'as:quoteUrl',
|
2023-03-16 10:41:59 +00:00
|
|
|
|
fedibird: 'http://fedibird.com/ns#',
|
|
|
|
|
quoteUri: 'fedibird:quoteUri',
|
2022-09-17 18:27:08 +00:00
|
|
|
|
// Mastodon
|
|
|
|
|
toot: 'http://joinmastodon.org/ns#',
|
|
|
|
|
Emoji: 'toot:Emoji',
|
|
|
|
|
featured: 'toot:featured',
|
|
|
|
|
discoverable: 'toot:discoverable',
|
|
|
|
|
// schema
|
|
|
|
|
schema: 'http://schema.org#',
|
|
|
|
|
PropertyValue: 'schema:PropertyValue',
|
|
|
|
|
value: 'schema:value',
|
|
|
|
|
// Misskey
|
|
|
|
|
misskey: 'https://misskey-hub.net/ns#',
|
|
|
|
|
'_misskey_content': 'misskey:_misskey_content',
|
|
|
|
|
'_misskey_quote': 'misskey:_misskey_quote',
|
|
|
|
|
'_misskey_reaction': 'misskey:_misskey_reaction',
|
|
|
|
|
'_misskey_votes': 'misskey:_misskey_votes',
|
2023-10-29 10:33:35 +00:00
|
|
|
|
'_misskey_summary': 'misskey:_misskey_summary',
|
2022-09-17 18:27:08 +00:00
|
|
|
|
'isCat': 'misskey:isCat',
|
2023-10-04 02:35:58 +00:00
|
|
|
|
// Firefish
|
2024-02-03 14:01:09 +00:00
|
|
|
|
firefish: 'https://joinfirefish.org/ns#',
|
|
|
|
|
speakAsCat: 'firefish:speakAsCat',
|
2023-10-06 00:32:09 +00:00
|
|
|
|
// Sharkey
|
2024-02-03 14:01:09 +00:00
|
|
|
|
sharkey: 'https://joinsharkey.org/ns#',
|
|
|
|
|
backgroundUrl: 'sharkey:backgroundUrl',
|
|
|
|
|
listenbrainz: 'sharkey:listenbrainz',
|
2022-09-17 18:27:08 +00:00
|
|
|
|
// vcard
|
|
|
|
|
vcard: 'http://www.w3.org/2006/vcard/ns#',
|
|
|
|
|
},
|
|
|
|
|
],
|
2023-07-13 03:48:34 +00:00
|
|
|
|
}, x as T & { id: string });
|
2022-09-17 18:27:08 +00:00
|
|
|
|
}
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
public async attachLdSignature(activity: any, user: { id: MiUser['id']; host: null; }): Promise<IActivity> {
|
2023-04-05 03:10:40 +00:00
|
|
|
|
const keypair = await this.userKeypairService.getUserKeypair(user.id);
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const ldSignature = this.ldSignatureService.use();
|
|
|
|
|
ldSignature.debug = false;
|
|
|
|
|
activity = await ldSignature.signRsaSignature2017(activity, keypair.privateKey, `${this.config.url}/users/${user.id}#main-key`);
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return activity;
|
|
|
|
|
}
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
/**
|
|
|
|
|
* Render OrderedCollectionPage
|
|
|
|
|
* @param id URL of self
|
|
|
|
|
* @param totalItems Number of total items
|
|
|
|
|
* @param orderedItems Items
|
|
|
|
|
* @param partOf URL of base
|
|
|
|
|
* @param prev URL of prev page (optional)
|
|
|
|
|
* @param next URL of next page (optional)
|
|
|
|
|
*/
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2022-09-17 18:27:08 +00:00
|
|
|
|
public renderOrderedCollectionPage(id: string, totalItems: any, orderedItems: any, partOf: string, prev?: string, next?: string) {
|
2023-07-13 03:48:34 +00:00
|
|
|
|
const page: any = {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
id,
|
|
|
|
|
partOf,
|
|
|
|
|
type: 'OrderedCollectionPage',
|
|
|
|
|
totalItems,
|
|
|
|
|
orderedItems,
|
2023-07-13 03:48:34 +00:00
|
|
|
|
};
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
|
|
|
|
if (prev) page.prev = prev;
|
|
|
|
|
if (next) page.next = next;
|
|
|
|
|
|
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Render OrderedCollection
|
|
|
|
|
* @param id URL of self
|
|
|
|
|
* @param totalItems Total number of items
|
|
|
|
|
* @param first URL of first page (optional)
|
|
|
|
|
* @param last URL of last page (optional)
|
|
|
|
|
* @param orderedItems attached objects (optional)
|
|
|
|
|
*/
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-07-13 03:48:34 +00:00
|
|
|
|
public renderOrderedCollection(id: string, totalItems: number, first?: string, last?: string, orderedItems?: IObject[]) {
|
2022-09-17 18:27:08 +00:00
|
|
|
|
const page: any = {
|
|
|
|
|
id,
|
|
|
|
|
type: 'OrderedCollection',
|
|
|
|
|
totalItems,
|
|
|
|
|
};
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
if (first) page.first = first;
|
|
|
|
|
if (last) page.last = last;
|
|
|
|
|
if (orderedItems) page.orderedItems = orderedItems;
|
2023-03-10 00:37:22 +00:00
|
|
|
|
|
2022-09-17 18:27:08 +00:00
|
|
|
|
return page;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 06:03:09 +00:00
|
|
|
|
@bindThis
|
2023-08-16 08:51:28 +00:00
|
|
|
|
private async getEmojis(names: string[]): Promise<MiEmoji[]> {
|
2023-07-13 03:48:34 +00:00
|
|
|
|
if (names.length === 0) return [];
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
2023-04-06 02:14:43 +00:00
|
|
|
|
const allEmojis = await this.customEmojiService.localEmojisCache.fetch();
|
|
|
|
|
const emojis = names.map(name => allEmojis.get(name)).filter(isNotNull);
|
2022-09-17 18:27:08 +00:00
|
|
|
|
|
2023-04-06 02:14:43 +00:00
|
|
|
|
return emojis;
|
2022-09-17 18:27:08 +00:00
|
|
|
|
}
|
|
|
|
|
}
|