Skip to content

Commit

Permalink
Fix timestamp error
Browse files Browse the repository at this point in the history
  • Loading branch information
HitomaruKonpaku committed Sep 24, 2024
1 parent 2827d17 commit b78287c
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions apps/back-end/src/module/youtube/base/base-action-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,13 @@ export abstract class BaseActionHandler<T1 extends HandlerAction, T2 extends Pro
return
}

await Promise.allSettled(tracks.map((track) => this.handleTrack(track)))
await Promise.all(tracks.map(async (track) => {
try {
await this.handleTrack(track)
} catch (error) {
this.logger.error(`handleTrack: ${error.message} | ${JSON.stringify({ action: this.action, track })}`)
}
}))
}

protected hasMessage(): boolean {
Expand All @@ -108,17 +114,20 @@ export abstract class BaseActionHandler<T1 extends HandlerAction, T2 extends Pro
if (!this.data.video.isLive && !track.allowReplay) {
return
}

if (this.data.video.isLive && action.timestamp) {
const age = Date.now() - action.timestamp.getTime()
const age = Date.now() - NumberUtil.fromDate(action.timestamp)
const maxAge = (NumberUtil.parse(process.env.YOUTUBE_ACTION_MAX_AGE) || 3600) * 1000
this.logger.warn(`ACTION_TIMESTAMP | ${JSON.stringify({ age, maxAge, valid: age > maxAge, action })}`)
if (age > maxAge) {
// return
}
}

if (this.data.video.isMembersOnly && !track.allowMemberChat) {
return
}

if (!this.data.video.isMembersOnly && !track.allowPublicChat) {
return
}
Expand Down

0 comments on commit b78287c

Please sign in to comment.