-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat: アンテナでセンシティブなチャンネルからのノートを除外できるように #15346
base: develop
Are you sure you want to change the base?
Changes from all commits
66f23a2
3deaf92
bc8250b
6216235
3ec48a2
da6c80a
eb9d1e9
7fff5b3
1e0a3b1
f98076e
799af23
8e95c9d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
## Unreleased | ||
|
||
### General | ||
- | ||
- Enhance: アンテナでセンシティブなチャンネルのノートを除外できるように ( #14177 ) | ||
|
||
### Client | ||
- | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* SPDX-FileCopyrightText: syuilo and misskey-project | ||
* SPDX-License-Identifier: AGPL-3.0-only | ||
*/ | ||
|
||
export class AddAntennaHideNotesInSensitiveChannel1736230492103 { | ||
name = 'AddAntennaHideNotesInSensitiveChannel1736230492103' | ||
|
||
async up(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "antenna" ADD "hideNotesInSensitiveChannel" boolean NOT NULL DEFAULT false`); | ||
} | ||
|
||
async down(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "antenna" DROP COLUMN "hideNotesInSensitiveChannel"`); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -113,6 +113,18 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint- | |
.leftJoinAndSelect('reply.user', 'replyUser') | ||
.leftJoinAndSelect('renote.user', 'renoteUser'); | ||
|
||
if (antenna.hideNotesInSensitiveChannel) { | ||
// TypeORMにはRIGHT JOINがないので、サブクエリで代用。 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 「channelIdがNULL、またはchannelIdの指すchannelのisSensitiveがfalse」を「channelIdがNULL、またはisSensitive = falseなid = channelIdのchannelが存在する」で代用しました。 |
||
query | ||
.andWhere('note.channelId IS NULL OR EXISTS(' + | ||
query.subQuery() | ||
.from('channel', 'channel') | ||
.where('channel.id = note.channelId') | ||
.andWhere('channel.isSensitive = false') | ||
.getQuery() + | ||
' )'); | ||
} | ||
|
||
Comment on lines
+116
to
+127
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. このクエリ、悩ましいですね…
というケースでしか作用せず、コスト対効果がいまいちな気がしております。 @syuilo どうでしょう |
||
this.queryService.generateVisibilityQuery(query, me); | ||
this.queryService.generateMutedUserQuery(query, me); | ||
this.queryService.generateBlockedUserQuery(query, me); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -146,6 +146,7 @@ describe('アンテナ', () => { | |
caseSensitive: false, | ||
createdAt: new Date(response.createdAt).toISOString(), | ||
excludeKeywords: [['']], | ||
hideNotesInSensitiveChannel: false, | ||
hasUnreadNote: false, | ||
isActive: true, | ||
keywords: [['keyword']], | ||
|
@@ -217,6 +218,8 @@ describe('アンテナ', () => { | |
{ parameters: () => ({ withReplies: true }) }, | ||
{ parameters: () => ({ withFile: false }) }, | ||
{ parameters: () => ({ withFile: true }) }, | ||
{ parameters: () => ({ hideNotesInSensitiveChannel: false }) }, | ||
{ parameters: () => ({ hideNotesInSensitiveChannel: true }) }, | ||
]; | ||
test.each(antennaParamPattern)('を作成できること($#)', async ({ parameters }) => { | ||
const response = await successfulApiCall({ | ||
|
@@ -626,6 +629,42 @@ describe('アンテナ', () => { | |
assert.deepStrictEqual(response, expected); | ||
}); | ||
|
||
test('が取得できること(センシティブチャンネルのノートを除く)', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. これだけチャンネル作成が必要になってくるので上のeachとは別に書いています。 |
||
const keyword = 'キーワード'; | ||
const antenna = await successfulApiCall({ | ||
endpoint: 'antennas/create', | ||
parameters: { ...defaultParam, keywords: [[keyword]], hideNotesInSensitiveChannel: true }, | ||
user: alice, | ||
}); | ||
const nonSensitiveChannel = await successfulApiCall({ | ||
endpoint: 'channels/create', | ||
parameters: { name: 'test', isSensitive: false }, | ||
user: alice, | ||
}); | ||
const sensitiveChannel = await successfulApiCall({ | ||
endpoint: 'channels/create', | ||
parameters: { name: 'test', isSensitive: true }, | ||
user: alice, | ||
}); | ||
|
||
const noteInLocal = await post(bob, { text: `test ${keyword}` }); | ||
const noteInNonSensitiveChannel = await post(bob, { text: `test ${keyword}`, channelId: nonSensitiveChannel.id }); | ||
await post(bob, { text: `test ${keyword}`, channelId: sensitiveChannel.id }); | ||
|
||
const response = await successfulApiCall({ | ||
endpoint: 'antennas/notes', | ||
parameters: { antennaId: antenna.id }, | ||
user: alice, | ||
}); | ||
// 最後に投稿したものが先頭に来る。 | ||
const expected = [ | ||
noteInNonSensitiveChannel, | ||
noteInLocal, | ||
]; | ||
assert.deepStrictEqual(response, expected); | ||
}); | ||
|
||
|
||
test.skip('が取得でき、日付指定のPaginationに一貫性があること', async () => { }); | ||
test.each([ | ||
{ label: 'ID指定', offsetBy: 'id' }, | ||
|
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.
センシティブチャンネルかどうかの情報を取得するためにここのコンストラクタにチャンネルを渡していますが、もしかしたらORM的にはよくないかもしれません。
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.
channneldを挿入しているのでここでchannelを追加せずともチャンネル情報はjoinして取得することが可能となってはいないでしょうか
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.
センシティブチャンネルかどうかを取得するcheckHitAntennaでjoinのクエリをするとクエリがアンテナの数だけ行われて結構負荷がかかりそうなんですよね。
そもそもここでchannel: data.channelをしておけばクエリ数が増えることも無いのでここに増やしました。
が、これはもしかしたら何らかのしきたりに反するかもしれないな...というのが上のコメントの意図でした(ごめんなさい)。