Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
check for null value, also add trackid to alert link (#375)
Browse files Browse the repository at this point in the history
* check for null value, also add trackid to alert link
  • Loading branch information
GP authored May 6, 2021
1 parent f6d9f3a commit cda6e29
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/V1/recordingUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ async function reportRecordings(request: RecordingQuery) {
const audioFileIds: Set<number> = 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,
Expand Down
4 changes: 2 additions & 2 deletions emailUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ function alertBody(
.tz(config.timeZone)
.format("h:mma Do MMM");
let html = `<h1>${camera} has detected a ${tag.what} - ${dateTime}</h1>`;
html += `<a href="${config.server.recording_url_base}/${recording.id}?device=${recording.DeviceId}">View Recording</a>`;
html += `<a href="${config.server.recording_url_base}/${recording.id}/${tag.TrackId}?device=${recording.DeviceId}">View Recording</a>`;
html += "<br><p>Thanks,<br> Cacophony Team</p>";

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];
}
Expand Down
4 changes: 1 addition & 3 deletions models/Recording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -799,9 +799,7 @@ from (
};

/* eslint-disable indent */
Recording.prototype.getActiveTracksTagsAndTagger = async function (): Promise<
any
> {
Recording.prototype.getActiveTracksTagsAndTagger = async function (): Promise<any> {
return await this.getTracks({
where: {
archivedAt: null
Expand Down
4 changes: 3 additions & 1 deletion models/TrackTag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
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<TrackTag> {
isAdditionalTag: () => boolean;
id: TrackTagId;
TrackId: TrackId;
what: string;
automatic: boolean;
UserId: UserIdAlias;
Expand Down

0 comments on commit cda6e29

Please sign in to comment.