refactor(backend): simplify media schema and recording metadata
This commit is contained in:
@@ -3,7 +3,7 @@ import { Router } from 'express';
|
||||
import { z } from 'zod';
|
||||
|
||||
import { db } from '../db/client';
|
||||
import { pushNotifications } from '../db/schema';
|
||||
import { notificationDeliveries } from '../db/schema';
|
||||
import { requireDeviceAuth } from '../middleware/device-auth';
|
||||
import { dispatchPushQueueOnce } from '../services/push';
|
||||
|
||||
@@ -33,12 +33,12 @@ router.get('/me', requireDeviceAuth, async (req, res) => {
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await db.query.pushNotifications.findMany({
|
||||
const result = await db.query.notificationDeliveries.findMany({
|
||||
where: and(
|
||||
eq(pushNotifications.ownerUserId, deviceAuth.userId),
|
||||
eq(pushNotifications.recipientDeviceId, deviceAuth.deviceId),
|
||||
eq(notificationDeliveries.ownerUserId, deviceAuth.userId),
|
||||
eq(notificationDeliveries.recipientDeviceId, deviceAuth.deviceId),
|
||||
),
|
||||
orderBy: [desc(pushNotifications.createdAt)],
|
||||
orderBy: [desc(notificationDeliveries.createdAt)],
|
||||
limit: parsed.data.limit,
|
||||
});
|
||||
|
||||
@@ -63,16 +63,16 @@ router.post('/:notificationId/read', requireDeviceAuth, async (req, res) => {
|
||||
}
|
||||
|
||||
const [updated] = await db
|
||||
.update(pushNotifications)
|
||||
.update(notificationDeliveries)
|
||||
.set({
|
||||
status: 'read',
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(
|
||||
and(
|
||||
eq(pushNotifications.id, parsedParams.data.notificationId),
|
||||
eq(pushNotifications.ownerUserId, deviceAuth.userId),
|
||||
eq(pushNotifications.recipientDeviceId, deviceAuth.deviceId),
|
||||
eq(notificationDeliveries.id, parsedParams.data.notificationId),
|
||||
eq(notificationDeliveries.ownerUserId, deviceAuth.userId),
|
||||
eq(notificationDeliveries.recipientDeviceId, deviceAuth.deviceId),
|
||||
),
|
||||
)
|
||||
.returning();
|
||||
|
||||
Reference in New Issue
Block a user