forked from FoundKeyGang/FoundKey
Johann150
9384ce8cf5
Commit fc65190ef7
introduced thread ids but
did not add the thread id to previous notes. This is fixed by this commit.
The original notes in each thread should also have a thread id set which will
be the same as their ID.
These two migrations allow the threadId column be a NOT NULL column.
15 lines
604 B
TypeScript
15 lines
604 B
TypeScript
import { User } from '@/models/entities/user.js';
|
|
import { NoteThreadMutings } from '@/models/index.js';
|
|
import { Brackets, SelectQueryBuilder } from 'typeorm';
|
|
|
|
export function generateMutedNoteThreadQuery(q: SelectQueryBuilder<any>, me: { id: User['id'] }) {
|
|
const mutedQuery = NoteThreadMutings.createQueryBuilder('threadMuted')
|
|
.select('threadMuted.threadId')
|
|
.where('threadMuted.userId = :userId', { userId: me.id });
|
|
|
|
q.andWhere(`note.id NOT IN (${ mutedQuery.getQuery() })`);
|
|
q.andWhere(`note.threadId NOT IN (${ mutedQuery.getQuery() })`);
|
|
|
|
q.setParameters(mutedQuery.getParameters());
|
|
}
|