forked from misskey-dev/misskey
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from anatawa12/hard-mute
Hard mute
- Loading branch information
Showing
18 changed files
with
172 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
## 2023.11.1-kinel.1 | ||
|
||
### General | ||
- Feat: TL上からノートが見えなくなるワードミュートであるハードミュートを追加 | ||
|
||
### Client | ||
|
||
|
This file contains 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 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 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,11 @@ | ||
export class HardMute1700383825690 { | ||
name = 'HardMute1700383825690' | ||
|
||
async up(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "user_profile" ADD "hardMutedWords" jsonb NOT NULL DEFAULT '[]'`); | ||
} | ||
|
||
async down(queryRunner) { | ||
await queryRunner.query(`ALTER TABLE "user_profile" DROP COLUMN "hardMutedWords"`); | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/backend/migration/1700906353915-HardMuteAndSoftMuteFromRegistory.js
This file contains 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,56 @@ | ||
export class HardMuteAndSoftMuteFromRegistory1700906353915 { | ||
async up(queryRunner) { | ||
// until 2023.9.3-kinel.4, `mutedWords` means hard muted words | ||
// since 2023.11.1-kinel.1, `mutedWords` means soft muted words and `hardMutedWords` means hard muted words | ||
// so migrate hard muted words to `hardMutedWords` | ||
await queryRunner.query(`UPDATE "user_profile" SET "hardMutedWords" = "mutedWords";`); | ||
|
||
// then, migrate soft muted words from registry | ||
let entries = await queryRunner.query( | ||
`SELECT "userId", "value" FROM "registry_item" | ||
WHERE "registry_item"."domain" IS NULL | ||
AND "registry_item"."key" = $1 | ||
AND "registry_item"."scope" = $2;`, | ||
['mutedWords', ['client', 'base']]); | ||
|
||
for (let entry of entries) { | ||
await queryRunner.query(`UPDATE "user_profile" SET "mutedWords" = $1 WHERE "user_profile"."userId" = $2;`, | ||
[JSON.stringify(entry.value), entry.userId]); | ||
} | ||
} | ||
|
||
async down(queryRunner) { | ||
const entries = await queryRunner.query(`SELECT "userId", "mutedWords" FROM "user_profile";`); | ||
for (let entry of entries) { | ||
let existingEntry = await queryRunner.query( | ||
`SELECT "id", "userId", "value" FROM "registry_item" | ||
WHERE "registry_item"."domain" IS NULL | ||
AND "registry_item"."key" = $1 | ||
AND "registry_item"."scope" = $2 | ||
AND "registry_item"."userId" = $3;`, | ||
['mutedWords', ['client', 'base'], entry.userId]); | ||
|
||
if (existingEntry.length > 0) { | ||
await queryRunner.connection.createQueryBuilder() | ||
.update('registry_item') | ||
.set({ value: entry.mutedWords }) | ||
.where('id = :id', { id: existingEntry[0].id }) | ||
.execute(); | ||
} else { | ||
await queryRunner.connection.createQueryBuilder() | ||
.insert() | ||
.into('registry_item') | ||
.values({ | ||
key: 'mutedWords', | ||
scope: ['client', 'base'], | ||
userId: entry.userId, | ||
domain: null, | ||
value: entry.mutedWords | ||
}) | ||
.execute(); | ||
} | ||
} | ||
|
||
await queryRunner.query(`UPDATE "user_profile" SET "mutedWords" = "hardMutedWords";`); | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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 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 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 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.