Skip to content

Commit

Permalink
fix(tautulli): More response formatting safeguards #77
Browse files Browse the repository at this point in the history
* Log warning if payload is empty
* Destructure request body with default empty object
  • Loading branch information
FoxxMD committed May 25, 2023
1 parent c10d46b commit 6d9783c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
40 changes: 21 additions & 19 deletions src/sources/TautulliSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,27 @@ export default class TautulliSource extends PlexSource {
static formatPlayObj(obj: Request, options: FormatPlayObjectOptions = {}): PlayObject {
const {newFromSource = false} = options;
const {
artist_name,
track_name,
track_artist,
album_name,
media_type,
title,
library_name,
server,
version,
duration,
username,
library,
machine_id = '',
session_key,
action,
platform,
device,
player,
} = obj.body;
body :{
artist_name,
track_name,
track_artist,
album_name,
media_type,
title,
library_name,
server,
version,
duration,
username,
library,
machine_id = '',
session_key,
action,
platform,
device,
player,
} = {}
} = obj;
let artists = [artist_name];
if (track_artist !== undefined && track_artist !== artist_name) {
artists.push(track_artist);
Expand Down
5 changes: 4 additions & 1 deletion src/sources/ingressNotifiers/TautulliNotifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ export class TautulliNotifier extends IngressNotifier {

if(!this.seenServers.includes(playObj.meta.server)) {
this.seenServers.push(playObj.meta.server);
let msg = [`Received valid data from server ${playObj.meta.server} for the first time.`];
let msg = [`Received data from server ${playObj.meta.server} for the first time.`];
if(req.body === undefined) {
msg.push('WARNING: Payload was empty.');
}
if(playObj.meta.library === undefined) {
msg.push('WARNING: library was not defined in payload. If you want to filter plays by library this must be present in webhook payload.');
}
Expand Down

0 comments on commit 6d9783c

Please sign in to comment.