Skip to content

Commit

Permalink
Fix multiple notifications at once bug (#667)
Browse files Browse the repository at this point in the history
* Deal with multiple notifications
 * attempt to make exipiration notifications work
 * remove unused constant
 * update condition for the dnsRecords query
 * add comments

* update based on feedback
  • Loading branch information
SerpentBytes authored Apr 26, 2023
1 parent 85b77c4 commit 536c65e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 24 deletions.
2 changes: 2 additions & 0 deletions app/models/dns-record.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ export function renewDnsRecordById(id: DnsRecord['id']) {
data: {
// Set expiration date 6 months from now
expiresAt: dayjs().add(6, 'month').toDate(),
// Set lastNotified to null to notify regarding expiration
lastNotified: null,
},
});
}
Expand Down
26 changes: 2 additions & 24 deletions services/expiration/expiration-notification.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ declare global {
var __expiration_init__: boolean;
}

// constant for notification frequency in days
const NOTIFICATION_FREQUENCY = 7;

// name for the queue
const expirationNotificationQueueName = 'expiration-notification';

Expand Down Expand Up @@ -151,17 +148,7 @@ const getExpiringCertificates = () => {
lte: dayjs().add(30, 'd').toDate(),
},
status: 'issued',

OR: [
{
lastNotified: null,
},
{
lastNotified: dayjs()
.subtract(NOTIFICATION_FREQUENCY * 4, 'd')
.toDate(),
},
],
lastNotified: null,
},
include: { user: true },
});
Expand All @@ -173,16 +160,7 @@ const getExpiringDnsRecords = () => {
expiresAt: {
lte: dayjs().add(30, 'd').toDate(),
},
OR: [
{
lastNotified: null,
},
{
lastNotified: dayjs()
.subtract(NOTIFICATION_FREQUENCY * 4, 'd')
.toDate(),
},
],
lastNotified: null,
},
include: { user: true },
});
Expand Down

0 comments on commit 536c65e

Please sign in to comment.