diff --git a/api/V1/recordingUtil.ts b/api/V1/recordingUtil.ts index 8d695070..4d8a898c 100644 --- a/api/V1/recordingUtil.ts +++ b/api/V1/recordingUtil.ts @@ -249,7 +249,7 @@ async function reportRecordings(request: RecordingQuery) { const audioFileIds: Set = new Set(); for (const r of result) { const event = findLatestEvent(r.Device.Events); - if (event) { + if (event && event.EventDetail) { const fileId = event.EventDetail.details.fileId; audioEvents[r.id] = { timestamp: event.dateTime, diff --git a/emailUtil.ts b/emailUtil.ts index 40a3e8e5..aa8632a9 100644 --- a/emailUtil.ts +++ b/emailUtil.ts @@ -14,11 +14,11 @@ function alertBody( .tz(config.timeZone) .format("h:mma Do MMM"); let html = `

${camera} has detected a ${tag.what} - ${dateTime}

`; - html += `View Recording`; + html += `View Recording`; html += "

Thanks,
Cacophony Team

"; let text = `${camera} has detected a ${tag.what} - ${dateTime}\r\n`; - text += `Go to ${config.server.recording_url_base}/${recording.id}?device=${recording.DeviceId} to view this recording\r\n`; + text += `Go to ${config.server.recording_url_base}/${recording.id}/${tag.TrackId}?device=${recording.DeviceId} to view this recording\r\n`; text += "Thanks, Cacophony Team"; return [html, text]; } diff --git a/models/Recording.ts b/models/Recording.ts index 30c100e8..d9155fa8 100644 --- a/models/Recording.ts +++ b/models/Recording.ts @@ -799,9 +799,7 @@ from ( }; /* eslint-disable indent */ - Recording.prototype.getActiveTracksTagsAndTagger = async function (): Promise< - any - > { + Recording.prototype.getActiveTracksTagsAndTagger = async function (): Promise { return await this.getTracks({ where: { archivedAt: null diff --git a/models/TrackTag.ts b/models/TrackTag.ts index b01062f1..ed4867d7 100644 --- a/models/TrackTag.ts +++ b/models/TrackTag.ts @@ -19,12 +19,14 @@ along with this program. If not, see . import Sequelize from "sequelize"; import { ModelCommon, ModelStaticCommon } from "./index"; import { UserId as UserIdAlias } from "./User"; - +import { TrackId } from "./Track"; export const AI_MASTER = "Master"; export type TrackTagId = number; + export interface TrackTag extends Sequelize.Model, ModelCommon { isAdditionalTag: () => boolean; id: TrackTagId; + TrackId: TrackId; what: string; automatic: boolean; UserId: UserIdAlias;