Skip to content

Commit

Permalink
fix: クエリ条件の変更
Browse files Browse the repository at this point in the history
  • Loading branch information
nacika-ins committed Mar 29, 2024
1 parent 0382e37 commit 268cf6d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions packages/backend/src/server/api/endpoints/messaging/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,21 @@ export default class extends Endpoint<typeof meta, typeof paramDef> {
.where(qb => {
qb.where('root.id IN (' + this.messagingMessagesRepository
.createQueryBuilder('message')
.where('message.userId IN (:...userIds)', { userIds: userIds })
.andWhere('message.recipientId = :meId', { meId: me.id })
.where(new Brackets(qb => {
qb.where(new Brackets(qb => {
// 他人が送信したメッセージ
qb.where('message.userId IN (:...userIds)', { userIds: userIds })
.andWhere('message.recipientId = :meId', { meId: me.id });
})).orWhere(new Brackets(qb => {
// 自分が送信したメッセージ
qb.where('message.userId = :meId', { meId: me.id });
}));
}))
.andWhere('message.groupId IS NULL')
.groupBy('message.userId')
.select('max(message.id) as id')
.getQuery() + ')');
}).setParameter('userIds', userIds).getMany();
}).setParameters({ userIds, meId: me.id }).getMany();

const messages = Array.from(new Map([
...groupMessages,
Expand Down

0 comments on commit 268cf6d

Please sign in to comment.