Fix error sending reminder SMS
This commit is contained in:
@@ -33,6 +33,7 @@ type ActivityRow = {
|
||||
reminderAt: Date | null;
|
||||
reminderNotifyApp: boolean;
|
||||
reminderNotifySms: boolean;
|
||||
reminderSentAt: Date | null;
|
||||
completedAt: Date | null;
|
||||
tags: string[];
|
||||
createdAt: Date;
|
||||
@@ -285,7 +286,17 @@ export class ActivitiesService {
|
||||
if ('description' in dto) data.description = emptyToNull(dto.description);
|
||||
if ('dueAt' in dto) data.dueAt = dto.dueAt ? new Date(dto.dueAt) : null;
|
||||
if ('durationMinutes' in dto) data.durationMinutes = dto.durationMinutes ?? null;
|
||||
if ('reminderAt' in dto) data.reminderAt = dto.reminderAt ? new Date(dto.reminderAt) : null;
|
||||
if ('reminderAt' in dto) {
|
||||
const nextReminder = dto.reminderAt ? new Date(dto.reminderAt) : null;
|
||||
const current = await this.prisma.activity.findUnique({
|
||||
where: { id },
|
||||
select: { reminderAt: true },
|
||||
});
|
||||
const prevMs = current?.reminderAt?.getTime() ?? null;
|
||||
const nextMs = nextReminder?.getTime() ?? null;
|
||||
data.reminderAt = nextReminder;
|
||||
if (prevMs !== nextMs) data.reminderSentAt = null;
|
||||
}
|
||||
if (dto.reminderNotifyApp !== undefined) data.reminderNotifyApp = dto.reminderNotifyApp;
|
||||
if (dto.reminderNotifySms !== undefined) data.reminderNotifySms = dto.reminderNotifySms;
|
||||
if ('tags' in dto) data.tags = normalizeTags(dto.tags);
|
||||
@@ -572,6 +583,7 @@ export class ActivitiesService {
|
||||
reminderAt: row.reminderAt?.toISOString() ?? null,
|
||||
reminderNotifyApp: row.reminderNotifyApp,
|
||||
reminderNotifySms: row.reminderNotifySms,
|
||||
reminderSentAt: row.reminderSentAt?.toISOString() ?? null,
|
||||
completedAt: row.completedAt?.toISOString() ?? null,
|
||||
tags: row.tags ?? [],
|
||||
person: row.person
|
||||
|
||||
Reference in New Issue
Block a user