Skip to content

Commit

Permalink
fix(rules): Resolved an issue where the 'Overseerr - Requested by use…
Browse files Browse the repository at this point in the history
…r' rule didn't work for local Overseerr users (#822)
  • Loading branch information
jorenn92 authored Jan 30, 2024
1 parent b864702 commit 5391538
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
4 changes: 2 additions & 2 deletions docs/3-using-maintainerr/1-rules/Glossary.md
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,9 @@ The key is used for identification in Yaml rule files.

### Overseerr

#### Requested by user (Plex username)
#### Requested by user (Plex or local username)

> The username of the Plex user who requested the media in Overseerr.
> The username of the Plex user who requested the media in Overseerr. If a local user requested it, this will be the local username.
- Key: Overseerr.addUser
- Availability: movies, shows, seasons, episodes
Expand Down
2 changes: 1 addition & 1 deletion server/src/modules/rules/constants/rules.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ export class RuleConstants {
{
id: 0,
name: 'addUser',
humanName: 'Requested by user (Plex username)',
humanName: 'Requested by user (Plex or local username)',
mediaType: MediaType.BOTH,
type: RuleType.TEXT,
} as Property, // returns username[]
Expand Down
30 changes: 18 additions & 12 deletions server/src/modules/rules/getter/overseerr-getter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,24 @@ export class OverseerrGetterService {
);
if (includesSeason) {
userNames.push(
plexUsers.find(
(u) =>
u.username === request.requestedBy?.plexUsername,
)?.username,
request.requestedBy?.userType === 2
? request.requestedBy?.username
: plexUsers.find(
(u) =>
u.username ===
request.requestedBy?.plexUsername,
)?.username,
);
}
// for shows, add every request user
} else {
// for shows and movies, add every request user
userNames.push(
plexUsers.find(
(u) => u.username === request.requestedBy?.plexUsername,
)?.username,
request.requestedBy?.userType === 2
? request.requestedBy?.username
: plexUsers.find(
(u) =>
u.username === request.requestedBy?.plexUsername,
)?.username,
);
}
}
Expand Down Expand Up @@ -166,14 +172,14 @@ export class OverseerrGetterService {
return ep?.airDate
? new Date(ep.airDate)
: ep?.firstAirDate
? new Date(ep.firstAirDate)
: null;
? new Date(ep.firstAirDate)
: null;
} else if (EPlexDataType.SEASONS === dataType) {
return seasonMediaResponse?.airDate
? new Date(seasonMediaResponse.airDate)
: seasonMediaResponse?.firstAirDate
? new Date(seasonMediaResponse.firstAirDate)
: null;
? new Date(seasonMediaResponse.firstAirDate)
: null;
} else {
return mediaResponse?.firstAirDate
? new Date(mediaResponse.firstAirDate)
Expand Down
5 changes: 5 additions & 0 deletions server/src/modules/rules/rules.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,12 @@ export class RulesService {
rulegroupId: number,
mediaId: string,
): Promise<any> {
// flush caches
this.plexApi.resetMetadataCache(mediaId);
cacheManager.getCache('overseerr').data.flushAll();
cacheManager.getCache('radarr').data.flushAll();
cacheManager.getCache('sonarr').data.flushAll();

const mediaResp = await this.plexApi.getMetadata(mediaId);
const group = await this.getRuleGroupById(rulegroupId);
if (group && mediaResp) {
Expand Down

0 comments on commit 5391538

Please sign in to comment.