Skip to content

Commit 6e0da4b

Browse files
committed
fix diff calculation of quiet ending period
1 parent cfc7d34 commit 6e0da4b

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/firebase/functions/src/moderation/business/hideContent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export const hideContent = async (hideContentPayload: HideContentPayload): Promi
5454
flag: FLAGS.hidden,
5555
reasons: item.moderation?.reasons || [],
5656
moderatorNote: item.moderation?.moderatorNote || '',
57-
quietEnding: item.moderation?.countdownStart || null,
57+
quietEnding: item.moderation?.quietEnding || null,
5858
updatedAt,
5959
countdownPeriod,
6060
reporter: userId,

packages/firebase/functions/src/proposals/business/getNewCountdown.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ import { firestore } from 'firebase-admin';
99
*/
1010
export const getNewCountdown = (currCountdown: number, quietEndingPeriod: number) : number => {
1111

12-
const now = firestore.Timestamp.now();
13-
const countdownHour = (new Date(currCountdown * 1000)).getHours();
14-
const diff = (Math.abs((now.toDate()).getHours() - countdownHour)) % 24;
12+
const nowMillis = (firestore.Timestamp.now()).toMillis();
13+
const countdownMillis = currCountdown * 1000;
14+
15+
const diff = (countdownMillis - nowMillis) / 1000 / 60 / 60;
1516

1617
if (diff > 0 && diff < quietEndingPeriod / 3600)
1718
{

0 commit comments

Comments
 (0)