sq
This commit is contained in:
parent
9ea3af662d
commit
9b3e578c9e
1 changed files with 12 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
||||||
import define from '../../define.js';
|
|
||||||
import { MessagingMessage } from '@/models/entities/messaging-message.js';
|
|
||||||
import { MessagingMessages, Mutings, UserGroupJoinings } from '@/models/index.js';
|
|
||||||
import { Brackets } from 'typeorm';
|
import { Brackets } from 'typeorm';
|
||||||
|
import type { MessagingMessage } from '@/models/entities/messaging-message.js';
|
||||||
|
import { MessagingMessages, Mutings, UserGroupJoinings } from '@/models/index.js';
|
||||||
|
import define from '../../define.js';
|
||||||
|
|
||||||
export const meta = {
|
export const meta = {
|
||||||
tags: ['messaging'],
|
tags: ['messaging'],
|
||||||
|
@ -55,26 +55,26 @@ export default define(meta, paramDef, async (ps, user) => {
|
||||||
.orderBy('message.createdAt', 'DESC');
|
.orderBy('message.createdAt', 'DESC');
|
||||||
|
|
||||||
if (ps.group) {
|
if (ps.group) {
|
||||||
query.where(`message.groupId IN (:...groups)`, { groups: groups });
|
query.where('message.groupId IN (:...groups)', { groups: groups });
|
||||||
|
|
||||||
if (found.length > 0) {
|
if (found.length > 0) {
|
||||||
query.andWhere(`message.groupId NOT IN (:...found)`, { found: found });
|
query.andWhere('message.groupId NOT IN (:...found)', { found: found });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
query.where(new Brackets(qb => { qb
|
query.where(new Brackets(qb => { qb
|
||||||
.where(`message.userId = :userId`, { userId: user.id })
|
.where('message.userId = :userId', { userId: user.id })
|
||||||
.orWhere(`message.recipientId = :userId`, { userId: user.id });
|
.orWhere('message.recipientId = :userId', { userId: user.id });
|
||||||
}));
|
}));
|
||||||
query.andWhere(`message.groupId IS NULL`);
|
query.andWhere('message.groupId IS NULL');
|
||||||
|
|
||||||
if (found.length > 0) {
|
if (found.length > 0) {
|
||||||
query.andWhere(`message.userId NOT IN (:...found)`, { found: found });
|
query.andWhere('message.userId NOT IN (:...found)', { found: found });
|
||||||
query.andWhere(`message.recipientId NOT IN (:...found)`, { found: found });
|
query.andWhere('message.recipientId NOT IN (:...found)', { found: found });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mute.length > 0) {
|
if (mute.length > 0) {
|
||||||
query.andWhere(`message.userId NOT IN (:...mute)`, { mute: mute.map(m => m.muteeId) });
|
query.andWhere('message.userId NOT IN (:...mute)', { mute: mute.map(m => m.muteeId) });
|
||||||
query.andWhere(`message.recipientId NOT IN (:...mute)`, { mute: mute.map(m => m.muteeId) });
|
query.andWhere('message.recipientId NOT IN (:...mute)', { mute: mute.map(m => m.muteeId) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue