fix(server): 他人の通知を既読にできる可能性があるのを修正
This commit is contained in:
parent
a9e13693a5
commit
1b014bc3e5
2 changed files with 7 additions and 3 deletions
|
@ -14,6 +14,9 @@ You should also include the user name that made the change.
|
||||||
### Improvements
|
### Improvements
|
||||||
- Client: Add following badge to user preview popup @nvisser
|
- Client: Add following badge to user preview popup @nvisser
|
||||||
|
|
||||||
|
### Bugfixes
|
||||||
|
- Server: 他人の通知を既読にできる可能性があるのを修正 @syuilo
|
||||||
|
|
||||||
## 12.118.1 (2022/08/08)
|
## 12.118.1 (2022/08/08)
|
||||||
|
|
||||||
### Bugfixes
|
### Bugfixes
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
|
import { In } from 'typeorm';
|
||||||
import { publishMainStream } from '@/services/stream.js';
|
import { publishMainStream } from '@/services/stream.js';
|
||||||
import { pushNotification } from '@/services/push-notification.js';
|
import { pushNotification } from '@/services/push-notification.js';
|
||||||
import { User } from '@/models/entities/user.js';
|
import { User } from '@/models/entities/user.js';
|
||||||
import { Notification } from '@/models/entities/notification.js';
|
import { Notification } from '@/models/entities/notification.js';
|
||||||
import { Notifications, Users } from '@/models/index.js';
|
import { Notifications, Users } from '@/models/index.js';
|
||||||
import { In } from 'typeorm';
|
|
||||||
|
|
||||||
export async function readNotification(
|
export async function readNotification(
|
||||||
userId: User['id'],
|
userId: User['id'],
|
||||||
notificationIds: Notification['id'][]
|
notificationIds: Notification['id'][],
|
||||||
) {
|
) {
|
||||||
if (notificationIds.length === 0) return;
|
if (notificationIds.length === 0) return;
|
||||||
|
|
||||||
// Update documents
|
// Update documents
|
||||||
const result = await Notifications.update({
|
const result = await Notifications.update({
|
||||||
|
notifieeId: userId,
|
||||||
id: In(notificationIds),
|
id: In(notificationIds),
|
||||||
isRead: false,
|
isRead: false,
|
||||||
}, {
|
}, {
|
||||||
|
@ -27,7 +28,7 @@ export async function readNotification(
|
||||||
|
|
||||||
export async function readNotificationByQuery(
|
export async function readNotificationByQuery(
|
||||||
userId: User['id'],
|
userId: User['id'],
|
||||||
query: Record<string, any>
|
query: Record<string, any>,
|
||||||
) {
|
) {
|
||||||
const notificationIds = await Notifications.findBy({
|
const notificationIds = await Notifications.findBy({
|
||||||
...query,
|
...query,
|
||||||
|
|
Loading…
Reference in a new issue