forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 0
チャンネルの非掲載・フォロー承認制・フォロワー管理に対応 #22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
fb505de
feat: チャンネルのフォロー承認と管理に対応
6f6aa47
fix: フォロー申請の状態遷移を直列化
13e0237
perf: フォロー申請を一括承認する
a4aea95
fix: チャンネル検索とフォロー管理画面を調整
9c4b72b
enhance: チャンネルのフォロー管理表示を改善
70a6f02
fix: チャンネルのフォロワー数を正しく管理
43b075f
fix: チャンネル切り替え時のフォロー状態を同期
9b25dee
fix: アカウント削除時のフォロワー数を同期
d49dd7a
fix: 一括承認時にフォローIDを再生成
d64e5a9
Merge origin/develop into codex/channel-follow-approval
2b6895c
fix: 二重フォローのエラー契約を維持
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
packages/backend/migration/1787278753407-ChannelFollowApproval.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: syuilo and misskey-project | ||
| * SPDX-License-Identifier: AGPL-3.0-only | ||
| */ | ||
|
|
||
| export class ChannelFollowApproval1787278753407 { | ||
| name = 'ChannelFollowApproval1787278753407' | ||
|
|
||
| async up(queryRunner) { | ||
| await queryRunner.query(`CREATE TABLE "channel_follow_request" ("id" character varying(32) NOT NULL, "channelId" character varying(32) NOT NULL, "followerId" character varying(32) NOT NULL, CONSTRAINT "PK_1946cbea7196ec22c747c688880" PRIMARY KEY ("id")); COMMENT ON COLUMN "channel_follow_request"."channelId" IS 'The channel ID.'; COMMENT ON COLUMN "channel_follow_request"."followerId" IS 'The follower user ID.'`); | ||
| await queryRunner.query(`CREATE INDEX "IDX_37dba759526d0abee0a34c8f4e" ON "channel_follow_request" ("channelId")`); | ||
| await queryRunner.query(`CREATE INDEX "IDX_d84a54e9f624e81d0eeb1984a0" ON "channel_follow_request" ("followerId")`); | ||
| await queryRunner.query(`CREATE UNIQUE INDEX "IDX_5847f632d1a682516959b97d20" ON "channel_follow_request" ("followerId", "channelId")`); | ||
| await queryRunner.query(`ALTER TABLE "channel" ADD "isUnlisted" boolean NOT NULL DEFAULT false`); | ||
| await queryRunner.query(`COMMENT ON COLUMN "channel"."isUnlisted" IS 'Whether the channel is hidden from channel discovery surfaces.'`); | ||
| await queryRunner.query(`ALTER TABLE "channel" ADD "isFollowApprovalRequired" boolean NOT NULL DEFAULT false`); | ||
| await queryRunner.query(`COMMENT ON COLUMN "channel"."isFollowApprovalRequired" IS 'Whether following this channel requires approval.'`); | ||
| await queryRunner.query(`ALTER TABLE "channel" ADD "followersCount" integer NOT NULL DEFAULT 0`); | ||
| await queryRunner.query(`COMMENT ON COLUMN "channel"."followersCount" IS 'The count of followers.'`); | ||
| await queryRunner.query(`UPDATE "channel" SET "followersCount" = (SELECT COUNT(*) FROM "channel_following" WHERE "channel_following"."followeeId" = "channel"."id")`); | ||
| await queryRunner.query(`CREATE INDEX "IDX_01d715841fcb2cc4b679950773" ON "channel" ("isUnlisted")`); | ||
| await queryRunner.query(`ALTER TABLE "channel_follow_request" ADD CONSTRAINT "FK_37dba759526d0abee0a34c8f4ed" FOREIGN KEY ("channelId") REFERENCES "channel"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); | ||
| await queryRunner.query(`ALTER TABLE "channel_follow_request" ADD CONSTRAINT "FK_d84a54e9f624e81d0eeb1984a09" FOREIGN KEY ("followerId") REFERENCES "user"("id") ON DELETE CASCADE ON UPDATE NO ACTION`); | ||
| } | ||
|
|
||
| async down(queryRunner) { | ||
| await queryRunner.query(`ALTER TABLE "channel_follow_request" DROP CONSTRAINT "FK_d84a54e9f624e81d0eeb1984a09"`); | ||
| await queryRunner.query(`ALTER TABLE "channel_follow_request" DROP CONSTRAINT "FK_37dba759526d0abee0a34c8f4ed"`); | ||
| await queryRunner.query(`DROP INDEX "public"."IDX_01d715841fcb2cc4b679950773"`); | ||
| await queryRunner.query(`COMMENT ON COLUMN "channel"."followersCount" IS 'The count of followers.'`); | ||
| await queryRunner.query(`ALTER TABLE "channel" DROP COLUMN "followersCount"`); | ||
| await queryRunner.query(`COMMENT ON COLUMN "channel"."isFollowApprovalRequired" IS 'Whether following this channel requires approval.'`); | ||
| await queryRunner.query(`ALTER TABLE "channel" DROP COLUMN "isFollowApprovalRequired"`); | ||
| await queryRunner.query(`COMMENT ON COLUMN "channel"."isUnlisted" IS 'Whether the channel is hidden from channel discovery surfaces.'`); | ||
| await queryRunner.query(`ALTER TABLE "channel" DROP COLUMN "isUnlisted"`); | ||
| await queryRunner.query(`DROP INDEX "public"."IDX_5847f632d1a682516959b97d20"`); | ||
| await queryRunner.query(`DROP INDEX "public"."IDX_d84a54e9f624e81d0eeb1984a0"`); | ||
| await queryRunner.query(`DROP INDEX "public"."IDX_37dba759526d0abee0a34c8f4e"`); | ||
| await queryRunner.query(`DROP TABLE "channel_follow_request"`); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When approval is disabled on a channel with many pending requests, this loop performs a following insert and a separate counter update for every request, sequentially, while holding the channel's write lock. A popular channel with thousands of requests can therefore generate thousands of round trips, time out the
channels/updatecall, and block follow/unfollow operations for the duration; convert the requests to followings and update the count with bounded bulk queries.Useful? React with 👍 / 👎.