mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
fix: address unhandled promise rejections & bump node to v16.13 (#2398)
* fix: unhandled promise rejections * build(deps): bump node from 14.18 to 16.13 * fix: unhandled promise rejection in new Plex users endpoint * fix: build error Co-authored-by: Ryan Cohen <ryan@sct.dev>
This commit is contained in:
@@ -12,6 +12,7 @@ import IssueComment from '../entity/IssueComment';
|
||||
import Media from '../entity/Media';
|
||||
import notificationManager, { Notification } from '../lib/notifications';
|
||||
import { Permission } from '../lib/permissions';
|
||||
import logger from '../logger';
|
||||
|
||||
@EventSubscriber()
|
||||
export class IssueCommentSubscriber
|
||||
@@ -26,62 +27,67 @@ export class IssueCommentSubscriber
|
||||
let image: string;
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const issue = (
|
||||
await getRepository(IssueComment).findOne({
|
||||
where: { id: entity.id },
|
||||
relations: ['issue'],
|
||||
})
|
||||
)?.issue;
|
||||
if (!issue) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const issue = (
|
||||
await getRepository(IssueComment).findOneOrFail({
|
||||
where: { id: entity.id },
|
||||
relations: ['issue'],
|
||||
})
|
||||
).issue;
|
||||
|
||||
const media = await getRepository(Media).findOne({
|
||||
where: { id: issue.media.id },
|
||||
});
|
||||
if (!media) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (media.mediaType === MediaType.MOVIE) {
|
||||
const movie = await tmdb.getMovie({ movieId: media.tmdbId });
|
||||
|
||||
title = `${movie.title}${
|
||||
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
|
||||
}`;
|
||||
image = `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`;
|
||||
} else {
|
||||
const tvshow = await tmdb.getTvShow({ tvId: media.tmdbId });
|
||||
|
||||
title = `${tvshow.name}${
|
||||
tvshow.first_air_date ? ` (${tvshow.first_air_date.slice(0, 4)})` : ''
|
||||
}`;
|
||||
image = `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tvshow.poster_path}`;
|
||||
}
|
||||
|
||||
const [firstComment] = sortBy(issue.comments, 'id');
|
||||
|
||||
if (entity.id !== firstComment.id) {
|
||||
// Send notifications to all issue managers
|
||||
notificationManager.sendNotification(Notification.ISSUE_COMMENT, {
|
||||
event: `New Comment on ${
|
||||
issue.issueType !== IssueType.OTHER
|
||||
? `${IssueTypeName[issue.issueType]} `
|
||||
: ''
|
||||
}Issue`,
|
||||
subject: title,
|
||||
message: firstComment.message,
|
||||
comment: entity,
|
||||
issue,
|
||||
media,
|
||||
image,
|
||||
notifyAdmin: true,
|
||||
notifyUser:
|
||||
!issue.createdBy.hasPermission(Permission.MANAGE_ISSUES) &&
|
||||
issue.createdBy.id !== entity.user.id
|
||||
? issue.createdBy
|
||||
: undefined,
|
||||
const media = await getRepository(Media).findOneOrFail({
|
||||
where: { id: issue.media.id },
|
||||
});
|
||||
|
||||
if (media.mediaType === MediaType.MOVIE) {
|
||||
const movie = await tmdb.getMovie({ movieId: media.tmdbId });
|
||||
|
||||
title = `${movie.title}${
|
||||
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
|
||||
}`;
|
||||
image = `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`;
|
||||
} else {
|
||||
const tvshow = await tmdb.getTvShow({ tvId: media.tmdbId });
|
||||
|
||||
title = `${tvshow.name}${
|
||||
tvshow.first_air_date ? ` (${tvshow.first_air_date.slice(0, 4)})` : ''
|
||||
}`;
|
||||
image = `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tvshow.poster_path}`;
|
||||
}
|
||||
|
||||
const [firstComment] = sortBy(issue.comments, 'id');
|
||||
|
||||
if (entity.id !== firstComment.id) {
|
||||
// Send notifications to all issue managers
|
||||
notificationManager.sendNotification(Notification.ISSUE_COMMENT, {
|
||||
event: `New Comment on ${
|
||||
issue.issueType !== IssueType.OTHER
|
||||
? `${IssueTypeName[issue.issueType]} `
|
||||
: ''
|
||||
}Issue`,
|
||||
subject: title,
|
||||
message: firstComment.message,
|
||||
comment: entity,
|
||||
issue,
|
||||
media,
|
||||
image,
|
||||
notifyAdmin: true,
|
||||
notifyUser:
|
||||
!issue.createdBy.hasPermission(Permission.MANAGE_ISSUES) &&
|
||||
issue.createdBy.id !== entity.user.id
|
||||
? issue.createdBy
|
||||
: undefined,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Something went wrong sending issue comment notification(s)',
|
||||
{
|
||||
label: 'Notifications',
|
||||
errorMessage: e.message,
|
||||
commentId: entity.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user