feat(notif): 4K media notifications (#2324)

This commit is contained in:
TheCatLady
2021-12-07 18:56:41 -05:00
committed by GitHub
parent 68112faefb
commit 88a8c1aa59
4 changed files with 101 additions and 30 deletions

View File

@@ -72,28 +72,41 @@ class EmailAgent
? 'movie'
: 'series'
: undefined;
const is4k = payload.request?.is4k;
if (payload.request) {
let body = '';
switch (type) {
case Notification.MEDIA_PENDING:
body = `A new request for the following ${mediaType} is pending approval:`;
body = `A new request for the following ${mediaType} ${
is4k ? 'in 4K ' : ''
}is pending approval:`;
break;
case Notification.MEDIA_APPROVED:
body = `Your request for the following ${mediaType} has been approved:`;
body = `Your request for the following ${mediaType} ${
is4k ? 'in 4K ' : ''
}has been approved:`;
break;
case Notification.MEDIA_AUTO_APPROVED:
body = `A new request for the following ${mediaType} has been automatically approved:`;
body = `A new request for the following ${mediaType} ${
is4k ? 'in 4K ' : ''
}has been automatically approved:`;
break;
case Notification.MEDIA_AVAILABLE:
body = `Your request for the following ${mediaType} is now available:`;
body = `Your request for the following ${mediaType} ${
is4k ? 'in 4K ' : ''
}is now available:`;
break;
case Notification.MEDIA_DECLINED:
body = `Your request for the following ${mediaType} was declined:`;
body = `Your request for the following ${mediaType} ${
is4k ? 'in 4K ' : ''
}was declined:`;
break;
case Notification.MEDIA_FAILED:
body = `A request for the following ${mediaType} failed to be added to ${
body = `A request for the following ${mediaType} ${
is4k ? 'in 4K ' : ''
}failed to be added to ${
payload.media?.mediaType === MediaType.MOVIE ? 'Radarr' : 'Sonarr'
}:`;
break;

View File

@@ -46,6 +46,7 @@ class WebPushAgent
? 'movie'
: 'series'
: undefined;
const is4k = payload.request?.is4k;
const issueType = payload.issue
? payload.issue.issueType !== IssueType.OTHER
@@ -59,22 +60,34 @@ class WebPushAgent
message = payload.message;
break;
case Notification.MEDIA_APPROVED:
message = `Your ${mediaType} request has been approved.`;
message = `Your ${
is4k ? '4K ' : ''
}${mediaType} request has been approved.`;
break;
case Notification.MEDIA_AUTO_APPROVED:
message = `Automatically approved a new ${mediaType} request from ${payload.request?.requestedBy.displayName}.`;
message = `Automatically approved a new ${
is4k ? '4K ' : ''
}${mediaType} request from ${
payload.request?.requestedBy.displayName
}.`;
break;
case Notification.MEDIA_AVAILABLE:
message = `Your ${mediaType} request is now available!`;
message = `Your ${
is4k ? '4K ' : ''
}${mediaType} request is now available!`;
break;
case Notification.MEDIA_DECLINED:
message = `Your ${mediaType} request was declined.`;
message = `Your ${is4k ? '4K ' : ''}${mediaType} request was declined.`;
break;
case Notification.MEDIA_FAILED:
message = `Failed to process ${mediaType} request.`;
message = `Failed to process ${is4k ? '4K ' : ''}${mediaType} request.`;
break;
case Notification.MEDIA_PENDING:
message = `Approval required for a new ${mediaType} request from ${payload.request?.requestedBy.displayName}.`;
message = `Approval required for a new ${
is4k ? '4K ' : ''
}${mediaType} request from ${
payload.request?.requestedBy.displayName
}.`;
break;
case Notification.ISSUE_CREATED:
message = `A new ${issueType} was reported by ${payload.issue?.createdBy.displayName}.`;