aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/models/account/user-notification.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/server/models/account/user-notification.ts b/server/models/account/user-notification.ts
index ccb81b891..a05f30175 100644
--- a/server/models/account/user-notification.ts
+++ b/server/models/account/user-notification.ts
@@ -337,25 +337,25 @@ export class UserNotificationModel extends Model<UserNotificationModel> {
337 ActorFollow: ActorFollowModel 337 ActorFollow: ActorFollowModel
338 338
339 static listForApi (userId: number, start: number, count: number, sort: string, unread?: boolean) { 339 static listForApi (userId: number, start: number, count: number, sort: string, unread?: boolean) {
340 const where = { userId }
341
340 const query: FindOptions = { 342 const query: FindOptions = {
341 offset: start, 343 offset: start,
342 limit: count, 344 limit: count,
343 order: getSort(sort), 345 order: getSort(sort),
344 where: { 346 where
345 userId
346 }
347 } 347 }
348 348
349 if (unread !== undefined) query.where['read'] = !unread 349 if (unread !== undefined) query.where['read'] = !unread
350 350
351 return UserNotificationModel.scope(ScopeNames.WITH_ALL) 351 return Promise.all([
352 .findAndCountAll(query) 352 UserNotificationModel.count({ where })
353 .then(({ rows, count }) => { 353 .then(count => count || 0),
354 return { 354
355 data: rows, 355 count === 0
356 total: count 356 ? []
357 } 357 : UserNotificationModel.scope(ScopeNames.WITH_ALL).findAll(query)
358 }) 358 ]).then(([ total, data ]) => ({ total, data }))
359 } 359 }
360 360
361 static markAsRead (userId: number, notificationIds: number[]) { 361 static markAsRead (userId: number, notificationIds: number[]) {