2023-07-27 00:31:52 -05:00
|
|
|
/*
|
2024-02-13 09:59:27 -06:00
|
|
|
* SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 00:31:52 -05:00
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
*/
|
|
|
|
|
2023-10-16 06:11:27 -05:00
|
|
|
import { Inject, Injectable, OnModuleInit } from '@nestjs/common';
|
2023-04-04 23:57:22 -05:00
|
|
|
import { ModuleRef } from '@nestjs/core';
|
2023-07-18 21:27:50 -05:00
|
|
|
import { IsNull } from 'typeorm';
|
2023-09-19 21:33:36 -05:00
|
|
|
import type { MiLocalUser, MiPartialLocalUser, MiPartialRemoteUser, MiRemoteUser, MiUser } from '@/models/User.js';
|
2022-09-17 13:27:08 -05:00
|
|
|
import { IdentifiableError } from '@/misc/identifiable-error.js';
|
|
|
|
import { QueueService } from '@/core/QueueService.js';
|
|
|
|
import PerUserFollowingChart from '@/core/chart/charts/per-user-following.js';
|
|
|
|
import { GlobalEventService } from '@/core/GlobalEventService.js';
|
|
|
|
import { IdService } from '@/core/IdService.js';
|
|
|
|
import { isDuplicateKeyValueError } from '@/misc/is-duplicate-key-value-error.js';
|
2023-03-09 23:22:37 -06:00
|
|
|
import type { Packed } from '@/misc/json-schema.js';
|
2022-09-17 13:27:08 -05:00
|
|
|
import InstanceChart from '@/core/chart/charts/instance.js';
|
|
|
|
import { FederatedInstanceService } from '@/core/FederatedInstanceService.js';
|
|
|
|
import { WebhookService } from '@/core/WebhookService.js';
|
2023-03-16 00:24:11 -05:00
|
|
|
import { NotificationService } from '@/core/NotificationService.js';
|
2022-09-17 13:27:08 -05:00
|
|
|
import { DI } from '@/di-symbols.js';
|
2023-09-15 00:28:29 -05:00
|
|
|
import type { FollowingsRepository, FollowRequestsRepository, InstancesRepository, UserProfilesRepository, UsersRepository } from '@/models/_.js';
|
2022-12-03 19:16:03 -06:00
|
|
|
import { UserEntityService } from '@/core/entities/UserEntityService.js';
|
|
|
|
import { ApRendererService } from '@/core/activitypub/ApRendererService.js';
|
2022-12-04 02:05:32 -06:00
|
|
|
import { bindThis } from '@/decorators.js';
|
2023-02-03 21:40:40 -06:00
|
|
|
import { UserBlockingService } from '@/core/UserBlockingService.js';
|
2023-03-24 05:08:08 -05:00
|
|
|
import { MetaService } from '@/core/MetaService.js';
|
2023-04-04 20:21:10 -05:00
|
|
|
import { CacheService } from '@/core/CacheService.js';
|
2023-04-12 06:22:50 -05:00
|
|
|
import type { Config } from '@/config.js';
|
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 10:09:29 -05:00
|
|
|
import { AccountMoveService } from '@/core/AccountMoveService.js';
|
2023-10-16 06:11:27 -05:00
|
|
|
import { UtilityService } from '@/core/UtilityService.js';
|
2023-11-25 19:02:22 -06:00
|
|
|
import { FanoutTimelineService } from '@/core/FanoutTimelineService.js';
|
2024-02-23 03:04:30 -06:00
|
|
|
import type { ThinUser } from '@/queue/types.js';
|
2023-07-18 21:27:50 -05:00
|
|
|
import Logger from '../logger.js';
|
2022-09-17 13:27:08 -05:00
|
|
|
|
|
|
|
const logger = new Logger('following/create');
|
|
|
|
|
2023-08-16 03:51:28 -05:00
|
|
|
type Local = MiLocalUser | {
|
|
|
|
id: MiLocalUser['id'];
|
|
|
|
host: MiLocalUser['host'];
|
|
|
|
uri: MiLocalUser['uri']
|
2022-09-17 13:27:08 -05:00
|
|
|
};
|
2023-08-16 03:51:28 -05:00
|
|
|
type Remote = MiRemoteUser | {
|
|
|
|
id: MiRemoteUser['id'];
|
|
|
|
host: MiRemoteUser['host'];
|
|
|
|
uri: MiRemoteUser['uri'];
|
|
|
|
inbox: MiRemoteUser['inbox'];
|
2022-09-17 13:27:08 -05:00
|
|
|
};
|
|
|
|
type Both = Local | Remote;
|
|
|
|
|
|
|
|
@Injectable()
|
2023-04-04 23:57:22 -05:00
|
|
|
export class UserFollowingService implements OnModuleInit {
|
|
|
|
private userBlockingService: UserBlockingService;
|
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
constructor(
|
2023-04-04 23:57:22 -05:00
|
|
|
private moduleRef: ModuleRef,
|
2023-04-11 19:13:58 -05:00
|
|
|
|
2023-04-12 06:22:50 -05:00
|
|
|
@Inject(DI.config)
|
|
|
|
private config: Config,
|
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
@Inject(DI.usersRepository)
|
|
|
|
private usersRepository: UsersRepository,
|
|
|
|
|
|
|
|
@Inject(DI.userProfilesRepository)
|
|
|
|
private userProfilesRepository: UserProfilesRepository,
|
|
|
|
|
|
|
|
@Inject(DI.followingsRepository)
|
|
|
|
private followingsRepository: FollowingsRepository,
|
|
|
|
|
|
|
|
@Inject(DI.followRequestsRepository)
|
|
|
|
private followRequestsRepository: FollowRequestsRepository,
|
|
|
|
|
|
|
|
@Inject(DI.instancesRepository)
|
|
|
|
private instancesRepository: InstancesRepository,
|
|
|
|
|
2023-04-04 20:21:10 -05:00
|
|
|
private cacheService: CacheService,
|
2023-10-16 06:11:27 -05:00
|
|
|
private utilityService: UtilityService,
|
2022-09-17 13:27:08 -05:00
|
|
|
private userEntityService: UserEntityService,
|
|
|
|
private idService: IdService,
|
|
|
|
private queueService: QueueService,
|
2023-02-03 19:02:03 -06:00
|
|
|
private globalEventService: GlobalEventService,
|
2023-03-24 05:08:08 -05:00
|
|
|
private metaService: MetaService,
|
2023-03-16 00:24:11 -05:00
|
|
|
private notificationService: NotificationService,
|
2022-09-17 13:27:08 -05:00
|
|
|
private federatedInstanceService: FederatedInstanceService,
|
|
|
|
private webhookService: WebhookService,
|
|
|
|
private apRendererService: ApRendererService,
|
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 10:09:29 -05:00
|
|
|
private accountMoveService: AccountMoveService,
|
2023-11-25 19:02:22 -06:00
|
|
|
private fanoutTimelineService: FanoutTimelineService,
|
2022-09-17 13:27:08 -05:00
|
|
|
private perUserFollowingChart: PerUserFollowingChart,
|
|
|
|
private instanceChart: InstanceChart,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
2023-04-04 23:57:22 -05:00
|
|
|
onModuleInit() {
|
|
|
|
this.userBlockingService = this.moduleRef.get('UserBlockingService');
|
|
|
|
}
|
|
|
|
|
2024-02-23 03:04:30 -06:00
|
|
|
@bindThis
|
|
|
|
public async deliverAccept(follower: MiRemoteUser, followee: MiPartialLocalUser, requestId?: string) {
|
|
|
|
const content = this.apRendererService.addContext(this.apRendererService.renderAccept(this.apRendererService.renderFollow(follower, followee, requestId), followee));
|
|
|
|
this.queueService.deliver(followee, content, follower.inbox, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
@bindThis
|
2024-02-24 21:36:10 -06:00
|
|
|
public async follow(
|
2024-02-23 03:04:30 -06:00
|
|
|
_follower: ThinUser,
|
|
|
|
_followee: ThinUser,
|
2023-10-17 06:56:17 -05:00
|
|
|
{ requestId, silent = false, withReplies }: {
|
|
|
|
requestId?: string,
|
|
|
|
silent?: boolean,
|
|
|
|
withReplies?: boolean,
|
|
|
|
} = {},
|
|
|
|
): Promise<void> {
|
2024-02-24 21:36:10 -06:00
|
|
|
/**
|
|
|
|
* 必ず最新のユーザー情報を取得する
|
|
|
|
*/
|
|
|
|
const [follower, followee] = await Promise.all([
|
|
|
|
this.usersRepository.findOneByOrFail({ id: _follower.id }),
|
|
|
|
this.usersRepository.findOneByOrFail({ id: _followee.id }),
|
|
|
|
]) as [MiLocalUser | MiRemoteUser, MiLocalUser | MiRemoteUser];
|
|
|
|
|
2024-02-23 03:04:30 -06:00
|
|
|
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isRemoteUser(followee)) {
|
|
|
|
// What?
|
|
|
|
throw new Error('Remote user cannot follow remote user.');
|
|
|
|
}
|
2022-09-17 13:27:08 -05:00
|
|
|
|
|
|
|
// check blocking
|
|
|
|
const [blocking, blocked] = await Promise.all([
|
2023-02-03 21:40:40 -06:00
|
|
|
this.userBlockingService.checkBlocked(follower.id, followee.id),
|
|
|
|
this.userBlockingService.checkBlocked(followee.id, follower.id),
|
2022-09-17 13:27:08 -05:00
|
|
|
]);
|
|
|
|
|
|
|
|
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee) && blocked) {
|
2023-02-03 21:40:40 -06:00
|
|
|
// リモートフォローを受けてブロックしていた場合は、エラーにするのではなくRejectを送り返しておしまい。
|
2023-02-12 03:47:30 -06:00
|
|
|
const content = this.apRendererService.addContext(this.apRendererService.renderReject(this.apRendererService.renderFollow(follower, followee, requestId), followee));
|
2023-03-14 05:11:31 -05:00
|
|
|
this.queueService.deliver(followee, content, follower.inbox, false);
|
2022-09-17 13:27:08 -05:00
|
|
|
return;
|
|
|
|
} else if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee) && blocking) {
|
2023-02-03 21:40:40 -06:00
|
|
|
// リモートフォローを受けてブロックされているはずの場合だったら、ブロック解除しておく。
|
|
|
|
await this.userBlockingService.unblock(follower, followee);
|
2022-09-17 13:27:08 -05:00
|
|
|
} else {
|
2023-02-03 21:40:40 -06:00
|
|
|
// それ以外は単純に例外
|
2023-02-04 04:19:30 -06:00
|
|
|
if (blocking) throw new IdentifiableError('710e8fb0-b8c3-4922-be49-d5d93d8e6a6e', 'blocking');
|
|
|
|
if (blocked) throw new IdentifiableError('3338392a-f764-498d-8855-db939dcf8c48', 'blocked');
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
|
2024-02-23 03:04:30 -06:00
|
|
|
if (await this.followingsRepository.exists({
|
|
|
|
where: {
|
|
|
|
followerId: follower.id,
|
|
|
|
followeeId: followee.id,
|
|
|
|
},
|
|
|
|
})) {
|
|
|
|
// すでにフォロー関係が存在している場合
|
|
|
|
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
|
|
|
// リモート → ローカル: acceptを送り返しておしまい
|
|
|
|
this.deliverAccept(follower, followee, requestId);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (this.userEntityService.isLocalUser(follower)) {
|
|
|
|
// ローカル → リモート/ローカル: 例外
|
|
|
|
throw new IdentifiableError('ec3f65c0-a9d1-47d9-8791-b2e7b9dcdced', 'already following');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
const followeeProfile = await this.userProfilesRepository.findOneByOrFail({ userId: followee.id });
|
|
|
|
// フォロー対象が鍵アカウントである or
|
|
|
|
// フォロワーがBotであり、フォロー対象がBotからのフォローに慎重である or
|
2023-10-16 06:11:27 -05:00
|
|
|
// フォロワーがローカルユーザーであり、フォロー対象がリモートユーザーである or
|
|
|
|
// フォロワーがローカルユーザーであり、フォロー対象がサイレンスされているサーバーである
|
2022-09-17 13:27:08 -05:00
|
|
|
// 上記のいずれかに当てはまる場合はすぐフォローせずにフォローリクエストを発行しておく
|
2023-10-03 06:26:11 -05:00
|
|
|
if (
|
|
|
|
followee.isLocked ||
|
|
|
|
(followeeProfile.carefulBot && follower.isBot) ||
|
2023-10-16 06:11:27 -05:00
|
|
|
(this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee) && process.env.FORCE_FOLLOW_REMOTE_USER_FOR_TESTING !== 'true') ||
|
|
|
|
(this.userEntityService.isLocalUser(followee) && this.userEntityService.isRemoteUser(follower) && this.utilityService.isSilencedHost((await this.metaService.fetch()).silencedHosts, follower.host))
|
2023-10-03 06:26:11 -05:00
|
|
|
) {
|
2022-09-17 13:27:08 -05:00
|
|
|
let autoAccept = false;
|
|
|
|
|
|
|
|
// 鍵アカウントであっても、既にフォローされていた場合はスルー
|
2024-02-08 01:04:41 -06:00
|
|
|
const isFollowing = await this.followingsRepository.exists({
|
2023-07-11 00:58:58 -05:00
|
|
|
where: {
|
|
|
|
followerId: follower.id,
|
|
|
|
followeeId: followee.id,
|
|
|
|
},
|
2022-09-17 13:27:08 -05:00
|
|
|
});
|
2023-07-11 00:58:58 -05:00
|
|
|
if (isFollowing) {
|
2022-09-17 13:27:08 -05:00
|
|
|
autoAccept = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// フォローしているユーザーは自動承認オプション
|
|
|
|
if (!autoAccept && (this.userEntityService.isLocalUser(followee) && followeeProfile.autoAcceptFollowed)) {
|
2024-02-08 01:04:41 -06:00
|
|
|
const isFollowed = await this.followingsRepository.exists({
|
2023-07-11 00:58:58 -05:00
|
|
|
where: {
|
|
|
|
followerId: followee.id,
|
|
|
|
followeeId: follower.id,
|
|
|
|
},
|
2022-09-17 13:27:08 -05:00
|
|
|
});
|
|
|
|
|
2023-07-11 00:58:58 -05:00
|
|
|
if (isFollowed) autoAccept = true;
|
2022-09-17 13:27:08 -05: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 10:09:29 -05:00
|
|
|
// Automatically accept if the follower is an account who has moved and the locked followee had accepted the old account.
|
|
|
|
if (followee.isLocked && !autoAccept) {
|
|
|
|
autoAccept = !!(await this.accountMoveService.validateAlsoKnownAs(
|
|
|
|
follower,
|
2024-02-08 01:04:41 -06:00
|
|
|
(oldSrc, newSrc) => this.followingsRepository.exists({
|
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 10:09:29 -05:00
|
|
|
where: {
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerId: newSrc.id,
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
true,
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
if (!autoAccept) {
|
2023-10-17 06:56:17 -05:00
|
|
|
await this.createFollowRequest(follower, followee, requestId, withReplies);
|
2022-09-17 13:27:08 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-10-17 06:56:17 -05:00
|
|
|
await this.insertFollowingDoc(followee, follower, silent, withReplies);
|
2022-09-17 13:27:08 -05:00
|
|
|
|
|
|
|
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
2024-02-23 03:04:30 -06:00
|
|
|
this.deliverAccept(follower, followee, requestId);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-18 13:11:50 -05:00
|
|
|
private async insertFollowingDoc(
|
2022-09-17 13:27:08 -05:00
|
|
|
followee: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
|
|
|
follower: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox']
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
2023-04-11 19:13:58 -05:00
|
|
|
silent = false,
|
2023-10-17 06:56:17 -05:00
|
|
|
withReplies?: boolean,
|
2022-09-17 13:27:08 -05:00
|
|
|
): Promise<void> {
|
|
|
|
if (follower.id === followee.id) return;
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
let alreadyFollowed = false as boolean;
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
await this.followingsRepository.insert({
|
2023-10-15 20:45:22 -05:00
|
|
|
id: this.idService.gen(),
|
2022-09-17 13:27:08 -05:00
|
|
|
followerId: follower.id,
|
|
|
|
followeeId: followee.id,
|
2023-10-17 06:56:17 -05:00
|
|
|
withReplies: withReplies,
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
// 非正規化
|
|
|
|
followerHost: follower.host,
|
|
|
|
followerInbox: this.userEntityService.isRemoteUser(follower) ? follower.inbox : null,
|
|
|
|
followerSharedInbox: this.userEntityService.isRemoteUser(follower) ? follower.sharedInbox : null,
|
|
|
|
followeeHost: followee.host,
|
|
|
|
followeeInbox: this.userEntityService.isRemoteUser(followee) ? followee.inbox : null,
|
|
|
|
followeeSharedInbox: this.userEntityService.isRemoteUser(followee) ? followee.sharedInbox : null,
|
|
|
|
}).catch(err => {
|
|
|
|
if (isDuplicateKeyValueError(err) && this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
|
|
|
logger.info(`Insert duplicated ignore. ${follower.id} => ${followee.id}`);
|
|
|
|
alreadyFollowed = true;
|
|
|
|
} else {
|
|
|
|
throw err;
|
|
|
|
}
|
|
|
|
});
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2023-04-04 20:21:10 -05:00
|
|
|
this.cacheService.userFollowingsCache.refresh(follower.id);
|
|
|
|
|
2024-02-08 01:04:41 -06:00
|
|
|
const requestExist = await this.followRequestsRepository.exists({
|
2023-07-11 00:58:58 -05:00
|
|
|
where: {
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerId: follower.id,
|
|
|
|
},
|
2022-09-17 13:27:08 -05:00
|
|
|
});
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2023-07-11 00:58:58 -05:00
|
|
|
if (requestExist) {
|
2022-09-17 13:27:08 -05:00
|
|
|
await this.followRequestsRepository.delete({
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerId: follower.id,
|
|
|
|
});
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
// 通知を作成
|
2023-03-16 00:24:11 -05:00
|
|
|
this.notificationService.createNotification(follower.id, 'followRequestAccepted', {
|
2023-09-28 21:29:54 -05:00
|
|
|
}, followee.id);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
if (alreadyFollowed) return;
|
2023-01-13 17:27:23 -06:00
|
|
|
|
|
|
|
this.globalEventService.publishInternalEvent('follow', { followerId: follower.id, followeeId: followee.id });
|
2023-03-16 00:24:11 -05: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 10:09:29 -05:00
|
|
|
const [followeeUser, followerUser] = await Promise.all([
|
|
|
|
this.usersRepository.findOneByOrFail({ id: followee.id }),
|
|
|
|
this.usersRepository.findOneByOrFail({ id: follower.id }),
|
2022-09-17 13:27:08 -05:00
|
|
|
]);
|
2023-03-16 00:24:11 -05: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 10:09:29 -05:00
|
|
|
// Neither followee nor follower has moved.
|
|
|
|
if (!followeeUser.movedToUri && !followerUser.movedToUri) {
|
|
|
|
//#region Increment counts
|
|
|
|
await Promise.all([
|
|
|
|
this.usersRepository.increment({ id: follower.id }, 'followingCount', 1),
|
|
|
|
this.usersRepository.increment({ id: followee.id }, 'followersCount', 1),
|
|
|
|
]);
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region Update instance stats
|
|
|
|
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
|
|
|
this.federatedInstanceService.fetch(follower.host).then(async i => {
|
|
|
|
this.instancesRepository.increment({ id: i.id }, 'followingCount', 1);
|
|
|
|
if ((await this.metaService.fetch()).enableChartsForFederatedInstances) {
|
|
|
|
this.instanceChart.updateFollowing(i.host, true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee)) {
|
|
|
|
this.federatedInstanceService.fetch(followee.host).then(async i => {
|
|
|
|
this.instancesRepository.increment({ id: i.id }, 'followersCount', 1);
|
|
|
|
if ((await this.metaService.fetch()).enableChartsForFederatedInstances) {
|
|
|
|
this.instanceChart.updateFollowers(i.host, true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//#endregion
|
2023-03-16 00:24:11 -05: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 10:09:29 -05:00
|
|
|
this.perUserFollowingChart.update(follower, followee, true);
|
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2023-04-11 19:13:58 -05:00
|
|
|
if (this.userEntityService.isLocalUser(follower) && !silent) {
|
2023-10-17 22:26:16 -05:00
|
|
|
// Publish follow event
|
2022-09-17 13:27:08 -05:00
|
|
|
this.userEntityService.pack(followee.id, follower, {
|
2024-01-31 00:45:35 -06:00
|
|
|
schema: 'UserDetailedNotMe',
|
2022-09-17 13:27:08 -05:00
|
|
|
}).then(async packed => {
|
2024-01-31 00:45:35 -06:00
|
|
|
this.globalEventService.publishMainStream(follower.id, 'follow', packed);
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('follow'));
|
|
|
|
for (const webhook of webhooks) {
|
|
|
|
this.queueService.webhookDeliver(webhook, 'follow', {
|
|
|
|
user: packed,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
// Publish followed event
|
|
|
|
if (this.userEntityService.isLocalUser(followee)) {
|
|
|
|
this.userEntityService.pack(follower.id, followee).then(async packed => {
|
2023-02-03 19:02:03 -06:00
|
|
|
this.globalEventService.publishMainStream(followee.id, 'followed', packed);
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === followee.id && x.on.includes('followed'));
|
|
|
|
for (const webhook of webhooks) {
|
|
|
|
this.queueService.webhookDeliver(webhook, 'followed', {
|
|
|
|
user: packed,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
// 通知を作成
|
2023-03-16 00:24:11 -05:00
|
|
|
this.notificationService.createNotification(followee.id, 'follow', {
|
2023-09-28 21:29:54 -05:00
|
|
|
}, follower.id);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-17 13:27:08 -05:00
|
|
|
public async unfollow(
|
|
|
|
follower: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
|
|
|
followee: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
|
|
|
silent = false,
|
|
|
|
): Promise<void> {
|
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 10:09:29 -05:00
|
|
|
const following = await this.followingsRepository.findOne({
|
|
|
|
relations: {
|
|
|
|
follower: true,
|
|
|
|
followee: true,
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
followerId: follower.id,
|
|
|
|
followeeId: followee.id,
|
2023-07-18 21:27:50 -05:00
|
|
|
},
|
2022-09-17 13:27:08 -05:00
|
|
|
});
|
2023-03-16 00:24:11 -05: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 10:09:29 -05:00
|
|
|
if (following === null || !following.follower || !following.followee) {
|
2022-09-17 13:27:08 -05:00
|
|
|
logger.warn('フォロー解除がリクエストされましたがフォローしていませんでした');
|
|
|
|
return;
|
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
await this.followingsRepository.delete(following.id);
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2023-04-04 20:21:10 -05:00
|
|
|
this.cacheService.userFollowingsCache.refresh(follower.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 10:09:29 -05:00
|
|
|
this.decrementFollowing(following.follower, following.followee);
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
if (!silent && this.userEntityService.isLocalUser(follower)) {
|
2023-10-17 22:26:16 -05:00
|
|
|
// Publish unfollow event
|
2022-09-17 13:27:08 -05:00
|
|
|
this.userEntityService.pack(followee.id, follower, {
|
2024-01-31 00:45:35 -06:00
|
|
|
schema: 'UserDetailedNotMe',
|
2022-09-17 13:27:08 -05:00
|
|
|
}).then(async packed => {
|
2023-02-03 19:02:03 -06:00
|
|
|
this.globalEventService.publishMainStream(follower.id, 'unfollow', packed);
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('unfollow'));
|
|
|
|
for (const webhook of webhooks) {
|
|
|
|
this.queueService.webhookDeliver(webhook, 'unfollow', {
|
|
|
|
user: packed,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
if (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee)) {
|
2023-08-16 03:51:28 -05:00
|
|
|
const content = this.apRendererService.addContext(this.apRendererService.renderUndo(this.apRendererService.renderFollow(follower as MiPartialLocalUser, followee as MiPartialRemoteUser), follower));
|
2023-03-14 05:11:31 -05:00
|
|
|
this.queueService.deliver(follower, content, followee.inbox, false);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
if (this.userEntityService.isLocalUser(followee) && this.userEntityService.isRemoteUser(follower)) {
|
|
|
|
// local user has null host
|
2023-08-16 03:51:28 -05:00
|
|
|
const content = this.apRendererService.addContext(this.apRendererService.renderReject(this.apRendererService.renderFollow(follower as MiPartialRemoteUser, followee as MiPartialLocalUser), followee));
|
2023-03-14 05:11:31 -05:00
|
|
|
this.queueService.deliver(followee, content, follower.inbox, false);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-18 13:11:50 -05:00
|
|
|
private async decrementFollowing(
|
2023-08-16 03:51:28 -05:00
|
|
|
follower: MiUser,
|
|
|
|
followee: MiUser,
|
2022-09-17 13:27:08 -05:00
|
|
|
): Promise<void> {
|
2023-01-13 17:27:23 -06:00
|
|
|
this.globalEventService.publishInternalEvent('unfollow', { followerId: follower.id, followeeId: followee.id });
|
2023-03-16 00:24:11 -05: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 10:09:29 -05:00
|
|
|
// Neither followee nor follower has moved.
|
|
|
|
if (!follower.movedToUri && !followee.movedToUri) {
|
|
|
|
//#region Decrement following / followers counts
|
|
|
|
await Promise.all([
|
|
|
|
this.usersRepository.decrement({ id: follower.id }, 'followingCount', 1),
|
|
|
|
this.usersRepository.decrement({ id: followee.id }, 'followersCount', 1),
|
|
|
|
]);
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
//#region Update instance stats
|
|
|
|
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
|
|
|
this.federatedInstanceService.fetch(follower.host).then(async i => {
|
|
|
|
this.instancesRepository.decrement({ id: i.id }, 'followingCount', 1);
|
|
|
|
if ((await this.metaService.fetch()).enableChartsForFederatedInstances) {
|
|
|
|
this.instanceChart.updateFollowing(i.host, false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else if (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee)) {
|
|
|
|
this.federatedInstanceService.fetch(followee.host).then(async i => {
|
|
|
|
this.instancesRepository.decrement({ id: i.id }, 'followersCount', 1);
|
|
|
|
if ((await this.metaService.fetch()).enableChartsForFederatedInstances) {
|
|
|
|
this.instanceChart.updateFollowers(i.host, false);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
//#endregion
|
2023-03-16 00:24:11 -05: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 10:09:29 -05:00
|
|
|
this.perUserFollowingChart.update(follower, followee, false);
|
|
|
|
} else {
|
|
|
|
// Adjust following/followers counts
|
|
|
|
for (const user of [follower, followee]) {
|
|
|
|
if (user.movedToUri) continue; // No need to update if the user has already moved.
|
|
|
|
|
|
|
|
const nonMovedFollowees = await this.followingsRepository.count({
|
|
|
|
relations: {
|
|
|
|
followee: true,
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
followerId: user.id,
|
|
|
|
followee: {
|
|
|
|
movedToUri: IsNull(),
|
2023-07-18 21:27:50 -05: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 10:09:29 -05:00
|
|
|
});
|
|
|
|
const nonMovedFollowers = await this.followingsRepository.count({
|
|
|
|
relations: {
|
|
|
|
follower: true,
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
followeeId: user.id,
|
|
|
|
follower: {
|
|
|
|
movedToUri: IsNull(),
|
2023-07-18 21:27:50 -05: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 10:09:29 -05:00
|
|
|
});
|
|
|
|
await this.usersRepository.update(
|
|
|
|
{ id: user.id },
|
|
|
|
{ followingCount: nonMovedFollowees, followersCount: nonMovedFollowers },
|
|
|
|
);
|
|
|
|
}
|
2023-03-16 00:24:11 -05: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 10:09:29 -05:00
|
|
|
// TODO: adjust charts
|
|
|
|
}
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-17 13:27:08 -05:00
|
|
|
public async createFollowRequest(
|
|
|
|
follower: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
|
|
|
followee: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
|
|
|
requestId?: string,
|
2023-10-17 06:56:17 -05:00
|
|
|
withReplies?: boolean,
|
2022-09-17 13:27:08 -05:00
|
|
|
): Promise<void> {
|
|
|
|
if (follower.id === followee.id) return;
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
// check blocking
|
|
|
|
const [blocking, blocked] = await Promise.all([
|
2023-02-03 21:40:40 -06:00
|
|
|
this.userBlockingService.checkBlocked(follower.id, followee.id),
|
|
|
|
this.userBlockingService.checkBlocked(followee.id, follower.id),
|
2022-09-17 13:27:08 -05:00
|
|
|
]);
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2023-02-04 04:19:30 -06:00
|
|
|
if (blocking) throw new Error('blocking');
|
|
|
|
if (blocked) throw new Error('blocked');
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
const followRequest = await this.followRequestsRepository.insert({
|
2023-10-15 20:45:22 -05:00
|
|
|
id: this.idService.gen(),
|
2022-09-17 13:27:08 -05:00
|
|
|
followerId: follower.id,
|
|
|
|
followeeId: followee.id,
|
|
|
|
requestId,
|
2023-10-17 06:56:17 -05:00
|
|
|
withReplies,
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
// 非正規化
|
|
|
|
followerHost: follower.host,
|
|
|
|
followerInbox: this.userEntityService.isRemoteUser(follower) ? follower.inbox : undefined,
|
|
|
|
followerSharedInbox: this.userEntityService.isRemoteUser(follower) ? follower.sharedInbox : undefined,
|
|
|
|
followeeHost: followee.host,
|
|
|
|
followeeInbox: this.userEntityService.isRemoteUser(followee) ? followee.inbox : undefined,
|
|
|
|
followeeSharedInbox: this.userEntityService.isRemoteUser(followee) ? followee.sharedInbox : undefined,
|
|
|
|
}).then(x => this.followRequestsRepository.findOneByOrFail(x.identifiers[0]));
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
// Publish receiveRequest event
|
|
|
|
if (this.userEntityService.isLocalUser(followee)) {
|
2023-02-03 19:02:03 -06:00
|
|
|
this.userEntityService.pack(follower.id, followee).then(packed => this.globalEventService.publishMainStream(followee.id, 'receiveFollowRequest', packed));
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
this.userEntityService.pack(followee.id, followee, {
|
2024-01-31 00:45:35 -06:00
|
|
|
schema: 'MeDetailed',
|
2023-02-03 19:02:03 -06:00
|
|
|
}).then(packed => this.globalEventService.publishMainStream(followee.id, 'meUpdated', packed));
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
// 通知を作成
|
2023-03-16 00:24:11 -05:00
|
|
|
this.notificationService.createNotification(followee.id, 'receiveFollowRequest', {
|
2023-09-28 21:29:54 -05:00
|
|
|
}, follower.id);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
if (this.userEntityService.isLocalUser(follower) && this.userEntityService.isRemoteUser(followee)) {
|
2023-08-16 03:51:28 -05:00
|
|
|
const content = this.apRendererService.addContext(this.apRendererService.renderFollow(follower as MiPartialLocalUser, followee as MiPartialRemoteUser, requestId ?? `${this.config.url}/follows/${followRequest.id}`));
|
2023-03-14 05:11:31 -05:00
|
|
|
this.queueService.deliver(follower, content, followee.inbox, false);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-17 13:27:08 -05:00
|
|
|
public async cancelFollowRequest(
|
|
|
|
followee: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
|
|
|
follower: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
|
|
|
): Promise<void> {
|
|
|
|
if (this.userEntityService.isRemoteUser(followee)) {
|
2023-08-16 03:51:28 -05:00
|
|
|
const content = this.apRendererService.addContext(this.apRendererService.renderUndo(this.apRendererService.renderFollow(follower as MiPartialLocalUser | MiPartialRemoteUser, followee as MiPartialRemoteUser), follower));
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
if (this.userEntityService.isLocalUser(follower)) { // 本来このチェックは不要だけどTSに怒られるので
|
2023-03-14 05:11:31 -05:00
|
|
|
this.queueService.deliver(follower, content, followee.inbox, false);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2024-02-08 01:04:41 -06:00
|
|
|
const requestExist = await this.followRequestsRepository.exists({
|
2023-07-11 00:58:58 -05:00
|
|
|
where: {
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerId: follower.id,
|
|
|
|
},
|
2022-09-17 13:27:08 -05:00
|
|
|
});
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2023-07-11 00:58:58 -05:00
|
|
|
if (!requestExist) {
|
2022-09-17 13:27:08 -05:00
|
|
|
throw new IdentifiableError('17447091-ce07-46dd-b331-c1fd4f15b1e7', 'request not found');
|
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
await this.followRequestsRepository.delete({
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerId: follower.id,
|
|
|
|
});
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
this.userEntityService.pack(followee.id, followee, {
|
2024-01-31 00:45:35 -06:00
|
|
|
schema: 'MeDetailed',
|
2023-02-03 19:02:03 -06:00
|
|
|
}).then(packed => this.globalEventService.publishMainStream(followee.id, 'meUpdated', packed));
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-17 13:27:08 -05:00
|
|
|
public async acceptFollowRequest(
|
|
|
|
followee: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
2023-08-16 03:51:28 -05:00
|
|
|
follower: MiUser,
|
2022-09-17 13:27:08 -05:00
|
|
|
): Promise<void> {
|
|
|
|
const request = await this.followRequestsRepository.findOneBy({
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerId: follower.id,
|
|
|
|
});
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
if (request == null) {
|
|
|
|
throw new IdentifiableError('8884c2dd-5795-4ac9-b27e-6a01d38190f9', 'No follow request.');
|
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2023-10-17 06:56:17 -05:00
|
|
|
await this.insertFollowingDoc(followee, follower, false, request.withReplies);
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
if (this.userEntityService.isRemoteUser(follower) && this.userEntityService.isLocalUser(followee)) {
|
2024-02-23 03:04:30 -06:00
|
|
|
this.deliverAccept(follower, followee as MiPartialLocalUser, request.requestId ?? undefined);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
this.userEntityService.pack(followee.id, followee, {
|
2024-01-31 00:45:35 -06:00
|
|
|
schema: 'MeDetailed',
|
2023-02-03 19:02:03 -06:00
|
|
|
}).then(packed => this.globalEventService.publishMainStream(followee.id, 'meUpdated', packed));
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-17 13:27:08 -05:00
|
|
|
public async acceptAllFollowRequests(
|
|
|
|
user: {
|
2023-08-16 03:51:28 -05:00
|
|
|
id: MiUser['id']; host: MiUser['host']; uri: MiUser['host']; inbox: MiUser['inbox']; sharedInbox: MiUser['sharedInbox'];
|
2022-09-17 13:27:08 -05:00
|
|
|
},
|
|
|
|
): Promise<void> {
|
|
|
|
const requests = await this.followRequestsRepository.findBy({
|
|
|
|
followeeId: user.id,
|
|
|
|
});
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
for (const request of requests) {
|
|
|
|
const follower = await this.usersRepository.findOneByOrFail({ id: request.followerId });
|
|
|
|
this.acceptFollowRequest(user, follower);
|
|
|
|
}
|
|
|
|
}
|
2023-03-16 00:24:11 -05:00
|
|
|
|
2022-09-17 13:27:08 -05:00
|
|
|
/**
|
|
|
|
* API following/request/reject
|
|
|
|
*/
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-17 13:27:08 -05:00
|
|
|
public async rejectFollowRequest(user: Local, follower: Both): Promise<void> {
|
|
|
|
if (this.userEntityService.isRemoteUser(follower)) {
|
2022-09-18 13:11:50 -05:00
|
|
|
this.deliverReject(user, follower);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
|
2022-09-18 13:11:50 -05:00
|
|
|
await this.removeFollowRequest(user, follower);
|
2022-09-17 13:27:08 -05:00
|
|
|
|
|
|
|
if (this.userEntityService.isLocalUser(follower)) {
|
2022-09-18 13:11:50 -05:00
|
|
|
this.publishUnfollow(user, follower);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* API following/reject
|
|
|
|
*/
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-17 13:27:08 -05:00
|
|
|
public async rejectFollow(user: Local, follower: Both): Promise<void> {
|
|
|
|
if (this.userEntityService.isRemoteUser(follower)) {
|
2022-09-18 13:11:50 -05:00
|
|
|
this.deliverReject(user, follower);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
|
2022-09-18 13:11:50 -05:00
|
|
|
await this.removeFollow(user, follower);
|
2022-09-17 13:27:08 -05:00
|
|
|
|
|
|
|
if (this.userEntityService.isLocalUser(follower)) {
|
2022-09-18 13:11:50 -05:00
|
|
|
this.publishUnfollow(user, follower);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* AP Reject/Follow
|
|
|
|
*/
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-17 13:27:08 -05:00
|
|
|
public async remoteReject(actor: Remote, follower: Local): Promise<void> {
|
2022-09-18 13:11:50 -05:00
|
|
|
await this.removeFollowRequest(actor, follower);
|
|
|
|
await this.removeFollow(actor, follower);
|
|
|
|
this.publishUnfollow(actor, follower);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove follow request record
|
|
|
|
*/
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-18 13:11:50 -05:00
|
|
|
private async removeFollowRequest(followee: Both, follower: Both): Promise<void> {
|
2022-09-17 13:27:08 -05:00
|
|
|
const request = await this.followRequestsRepository.findOneBy({
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerId: follower.id,
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!request) return;
|
|
|
|
|
|
|
|
await this.followRequestsRepository.delete(request.id);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove follow record
|
|
|
|
*/
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-18 13:11:50 -05:00
|
|
|
private async removeFollow(followee: Both, follower: Both): Promise<void> {
|
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 10:09:29 -05:00
|
|
|
const following = await this.followingsRepository.findOne({
|
|
|
|
relations: {
|
|
|
|
followee: true,
|
|
|
|
follower: true,
|
|
|
|
},
|
|
|
|
where: {
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerId: follower.id,
|
2023-07-18 21:27:50 -05:00
|
|
|
},
|
2022-09-17 13:27:08 -05: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 10:09:29 -05:00
|
|
|
if (!following || !following.followee || !following.follower) return;
|
2022-09-17 13:27:08 -05:00
|
|
|
|
|
|
|
await this.followingsRepository.delete(following.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 10:09:29 -05:00
|
|
|
|
|
|
|
this.decrementFollowing(following.follower, following.followee);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deliver Reject to remote
|
|
|
|
*/
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-18 13:11:50 -05:00
|
|
|
private async deliverReject(followee: Local, follower: Remote): Promise<void> {
|
2022-09-17 13:27:08 -05:00
|
|
|
const request = await this.followRequestsRepository.findOneBy({
|
|
|
|
followeeId: followee.id,
|
|
|
|
followerId: follower.id,
|
|
|
|
});
|
|
|
|
|
2023-02-12 03:47:30 -06:00
|
|
|
const content = this.apRendererService.addContext(this.apRendererService.renderReject(this.apRendererService.renderFollow(follower, followee, request?.requestId ?? undefined), followee));
|
2023-03-14 05:11:31 -05:00
|
|
|
this.queueService.deliver(followee, content, follower.inbox, false);
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Publish unfollow to local
|
|
|
|
*/
|
2022-12-04 00:03:09 -06:00
|
|
|
@bindThis
|
2022-09-18 13:11:50 -05:00
|
|
|
private async publishUnfollow(followee: Both, follower: Local): Promise<void> {
|
2022-09-17 13:27:08 -05:00
|
|
|
const packedFollowee = await this.userEntityService.pack(followee.id, follower, {
|
2024-01-31 00:45:35 -06:00
|
|
|
schema: 'UserDetailedNotMe',
|
2022-09-17 13:27:08 -05:00
|
|
|
});
|
|
|
|
|
2023-02-03 19:02:03 -06:00
|
|
|
this.globalEventService.publishMainStream(follower.id, 'unfollow', packedFollowee);
|
2022-09-17 13:27:08 -05:00
|
|
|
|
|
|
|
const webhooks = (await this.webhookService.getActiveWebhooks()).filter(x => x.userId === follower.id && x.on.includes('unfollow'));
|
|
|
|
for (const webhook of webhooks) {
|
|
|
|
this.queueService.webhookDeliver(webhook, 'unfollow', {
|
|
|
|
user: packedFollowee,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2023-10-17 22:26:16 -05:00
|
|
|
|
|
|
|
@bindThis
|
|
|
|
public getFollowees(userId: MiUser['id']) {
|
|
|
|
return this.followingsRepository.createQueryBuilder('following')
|
|
|
|
.select('following.followeeId')
|
|
|
|
.where('following.followerId = :followerId', { followerId: userId })
|
|
|
|
.getMany();
|
|
|
|
}
|
2022-09-17 13:27:08 -05:00
|
|
|
}
|