mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-27 01:03:09 +02:00
* Resolve #6563 * Update note.ts * Update generate-visibility-query.ts
This commit is contained in:
parent
0108b8bfe3
commit
da34acd35f
4 changed files with 21 additions and 3 deletions
16
migration/1621479946000-add-note-indexes.ts
Normal file
16
migration/1621479946000-add-note-indexes.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import {MigrationInterface, QueryRunner} from "typeorm";
|
||||||
|
|
||||||
|
export class addNoteIndexes1621479946000 implements MigrationInterface {
|
||||||
|
name = 'addNoteIndexes1621479946000'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE INDEX "IDX_NOTE_MENTIONS" ON "note" USING gin ("mentions")`, undefined);
|
||||||
|
await queryRunner.query(`CREATE INDEX "IDX_NOTE_VISIBLE_USER_IDS" ON "note" USING gin ("visibleUserIds")`, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP INDEX "IDX_NOTE_MENTIONS"`, undefined);
|
||||||
|
await queryRunner.query(`DROP INDEX "IDX_NOTE_VISIBLE_USER_IDS"`, undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -7,6 +7,8 @@ import { Channel } from './channel';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
@Index('IDX_NOTE_TAGS', { synchronize: false })
|
@Index('IDX_NOTE_TAGS', { synchronize: false })
|
||||||
|
@Index('IDX_NOTE_MENTIONS', { synchronize: false })
|
||||||
|
@Index('IDX_NOTE_VISIBLE_USER_IDS', { synchronize: false })
|
||||||
export class Note {
|
export class Note {
|
||||||
@PrimaryColumn(id())
|
@PrimaryColumn(id())
|
||||||
public id: string;
|
public id: string;
|
||||||
|
|
|
@ -22,7 +22,7 @@ export function generateVisibilityQuery(q: SelectQueryBuilder<any>, me?: { id: U
|
||||||
// または 自分自身
|
// または 自分自身
|
||||||
.orWhere('note.userId = :userId1', { userId1: me.id })
|
.orWhere('note.userId = :userId1', { userId1: me.id })
|
||||||
// または 自分宛て
|
// または 自分宛て
|
||||||
.orWhere(':userId2 = ANY(note.visibleUserIds)', { userId2: me.id })
|
.orWhere(`'{"${me.id}"}' <@ note.visibleUserIds`)
|
||||||
.orWhere(new Brackets(qb => { qb
|
.orWhere(new Brackets(qb => { qb
|
||||||
// または フォロワー宛ての投稿であり、
|
// または フォロワー宛ての投稿であり、
|
||||||
.where('note.visibility = \'followers\'')
|
.where('note.visibility = \'followers\'')
|
||||||
|
|
|
@ -60,8 +60,8 @@ export default define(meta, async (ps, user) => {
|
||||||
|
|
||||||
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
const query = makePaginationQuery(Notes.createQueryBuilder('note'), ps.sinceId, ps.untilId)
|
||||||
.andWhere(new Brackets(qb => { qb
|
.andWhere(new Brackets(qb => { qb
|
||||||
.where(`:meId = ANY(note.mentions)`, { meId: user.id })
|
.where(`'{"${user.id}"}' <@ note.mentions`)
|
||||||
.orWhere(`:meId = ANY(note.visibleUserIds)`, { meId: user.id });
|
.orWhere(`'{"${user.id}"}' <@ note.visibleUserIds`);
|
||||||
}))
|
}))
|
||||||
.innerJoinAndSelect('note.user', 'user')
|
.innerJoinAndSelect('note.user', 'user')
|
||||||
.leftJoinAndSelect('note.reply', 'reply')
|
.leftJoinAndSelect('note.reply', 'reply')
|
||||||
|
|
Loading…
Reference in a new issue