Compare commits
135 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
512f6e51e4 | ||
|
|
1b36dded3f | ||
|
|
77511bf199 | ||
|
|
26d77af3a4 | ||
|
|
341e3b8f06 | ||
|
|
ca112d33ad | ||
|
|
418a533588 | ||
|
|
1d0cbd2e76 | ||
|
|
d4f9650cd0 | ||
|
|
26a3d7c4d2 | ||
|
|
19cdedd2a6 | ||
|
|
0c7373c7e8 | ||
|
|
d92f169375 | ||
|
|
81c75c800e | ||
|
|
7d19de6a4a | ||
|
|
72c825d2a5 | ||
|
|
30644f65ea | ||
|
|
4c50727a32 | ||
|
|
d06f2cdb08 | ||
|
|
086f0b6ce2 | ||
|
|
1f964b576a | ||
|
|
a229b15e7a | ||
|
|
fac809b18b | ||
|
|
c3dbd0d691 | ||
|
|
85bb30e252 | ||
|
|
aa79dc1c42 | ||
|
|
e40e024132 | ||
|
|
3d32462f50 | ||
|
|
4549ed389e | ||
|
|
82d16177bf | ||
|
|
223c1f03e6 | ||
|
|
648b346cbe | ||
|
|
74d5c1ca67 | ||
|
|
aa062d921c | ||
|
|
54b32ebfd6 | ||
|
|
eff665ef4b | ||
|
|
9f4ae34da7 | ||
|
|
1dc900d5ce | ||
|
|
a76b608ab7 | ||
|
|
61681857b1 | ||
|
|
d863a55de2 | ||
|
|
ec08fa6793 | ||
|
|
5d4b06bbcc | ||
|
|
92b2d32d2e | ||
|
|
cbcd22dfda | ||
|
|
8cba486249 | ||
|
|
ca184728e9 | ||
|
|
822ae9eec7 | ||
|
|
5b2a8f682b | ||
|
|
d7779408d1 | ||
|
|
b5bd6ee78f | ||
|
|
99c04072e9 | ||
|
|
f9200b7977 | ||
|
|
eb9ca2e86f | ||
|
|
0842c233d0 | ||
|
|
86dff12cde | ||
|
|
ce31bef8a1 | ||
|
|
1f5785d6c5 | ||
|
|
114366fa4b | ||
|
|
5707566cf7 | ||
|
|
f8b1bccda4 | ||
|
|
e9d4b6327b | ||
|
|
2535edcc7f | ||
|
|
d4438c82e3 | ||
|
|
10651baa67 | ||
|
|
ff28c9bfeb | ||
|
|
88536b1f9d | ||
|
|
9cb97db13c | ||
|
|
256163971f | ||
|
|
b31cdbf074 | ||
|
|
e0b6abe479 | ||
|
|
879df20022 | ||
|
|
5f7538ae2b | ||
|
|
1b29b15d7c | ||
|
|
399b037918 | ||
|
|
4e56bae985 | ||
|
|
b4b2acd4fc | ||
|
|
d2241a4187 | ||
|
|
bd93168ba1 | ||
|
|
3e5eb4e148 | ||
|
|
2b111f1c34 | ||
|
|
a6392cb2db | ||
|
|
b9bedac7d7 | ||
|
|
1b3797cf6e | ||
|
|
340f1a2119 | ||
|
|
cc2b2bc7a8 | ||
|
|
d36c1d2929 | ||
|
|
5af06bd872 | ||
|
|
d437cc2539 | ||
|
|
30b20df37a | ||
|
|
af40212a73 | ||
|
|
488874fc17 | ||
|
|
2ded8f5484 | ||
|
|
50dc9341dd | ||
|
|
fcb0dcf5be | ||
|
|
33fe0bdd1e | ||
|
|
3f7ef7af97 | ||
|
|
91bfff71b7 | ||
|
|
dc7f959cb4 | ||
|
|
93b5ea20ca | ||
|
|
f284e4ab97 | ||
|
|
febf0677b8 | ||
|
|
7f330aff2e | ||
|
|
88a8c1aa59 | ||
|
|
68112faefb | ||
|
|
f2375c902b | ||
|
|
ed53810fb3 | ||
|
|
c9ffac33f7 | ||
|
|
6245be1e10 | ||
|
|
c760ceaa5f | ||
|
|
92732fcb42 | ||
|
|
d48a7ba518 | ||
|
|
d401e33249 | ||
|
|
b423dc167d | ||
|
|
f1cd0878a5 | ||
|
|
b1b367aac6 | ||
|
|
99d50004e5 | ||
|
|
c79dc9f70f | ||
|
|
3ec4a9c76e | ||
|
|
8c49309c35 | ||
|
|
78a8091bcd | ||
|
|
bba09d69c1 | ||
|
|
0828b008ba | ||
|
|
05d2dac3ab | ||
|
|
2b0b8e05d9 | ||
|
|
62b3dc5471 | ||
|
|
8d2968572a | ||
|
|
216447121b | ||
|
|
aeb7a48d72 | ||
|
|
ab20c21184 | ||
|
|
a35209c739 | ||
|
|
e402c42aaa | ||
|
|
6565c7dd9b | ||
|
|
dca363809d | ||
|
|
85aec4f892 |
@@ -620,6 +620,51 @@
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "schambers",
|
||||
"name": "Sean Chambers",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/31563?v=4",
|
||||
"profile": "https://github.com/schambers",
|
||||
"contributions": [
|
||||
"code"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "deniscerri",
|
||||
"name": "deniscerri",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/64997243?v=4",
|
||||
"profile": "https://github.com/deniscerri",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "tomgacz",
|
||||
"name": "tomgacz",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/14138209?v=4",
|
||||
"profile": "https://github.com/tomgacz",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Andersborrits",
|
||||
"name": "Andersborrits",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/29452218?v=4",
|
||||
"profile": "https://github.com/Andersborrits",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
},
|
||||
{
|
||||
"login": "Maxentr",
|
||||
"name": "Maxent",
|
||||
"avatar_url": "https://avatars.githubusercontent.com/u/67283154?v=4",
|
||||
"profile": "http://maxentrouault.fr",
|
||||
"contributions": [
|
||||
"translation"
|
||||
]
|
||||
}
|
||||
],
|
||||
"badgeTemplate": "<a href=\"#contributors-\"><img alt=\"All Contributors\" src=\"https://img.shields.io/badge/all_contributors-<%= contributors.length %>-orange.svg\"/></a>",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
.gitconfig
|
||||
.github
|
||||
.gitignore
|
||||
.husky
|
||||
.next
|
||||
.prettierignore
|
||||
config/db/*
|
||||
|
||||
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
@@ -1,5 +1,5 @@
|
||||
# Global code ownership
|
||||
* @sct
|
||||
* @sct @TheCatLady @danshilm
|
||||
|
||||
# Documentation
|
||||
/.all-contributorsrc @TheCatLady @samwiseg0 @danshilm
|
||||
@@ -12,3 +12,4 @@
|
||||
|
||||
# i18n locale files
|
||||
/src/i18n/locale/ @sct @TheCatLady
|
||||
/src/i18n/locale/en.json @sct @TheCatLady @danshilm
|
||||
|
||||
40
.github/stale.yml
vendored
40
.github/stale.yml
vendored
@@ -1,18 +1,44 @@
|
||||
# Number of days of inactivity before an issue becomes stale
|
||||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
||||
daysUntilStale: 60
|
||||
# Number of days of inactivity before a stale issue is closed
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
|
||||
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
||||
daysUntilClose: 7
|
||||
# Issues with these labels will never be considered stale
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
- dependencies
|
||||
# Label to use when marking an issue as stale
|
||||
- never-stale
|
||||
- priority:high
|
||||
- priority:medium
|
||||
|
||||
# Label to use when marking as stale
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
|
||||
# Comment to post when marking as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
# Comment to post when closing a stale issue. Set to `false` to disable
|
||||
closeComment: false
|
||||
|
||||
# Comment to post when removing the stale label.
|
||||
# unmarkComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Comment to post when closing a stale Issue or Pull Request.
|
||||
# closeComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
# only: issues
|
||||
|
||||
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
|
||||
pulls:
|
||||
markComment: >
|
||||
This pull request has been automatically marked as stale because it has not had
|
||||
recent activity. It will be closed if no further activity occurs. Thank you
|
||||
for your contributions.
|
||||
|
||||
22
.github/workflows/ci.yml
vendored
22
.github/workflows/ci.yml
vendored
@@ -11,11 +11,12 @@ on:
|
||||
jobs:
|
||||
test:
|
||||
name: Lint & Test Build
|
||||
if: github.event_name == 'pull_request'
|
||||
runs-on: ubuntu-20.04
|
||||
container: node:14.18-alpine
|
||||
container: node:16.14-alpine
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
uses: actions/checkout@v3
|
||||
- name: Install dependencies
|
||||
env:
|
||||
HUSKY_SKIP_INSTALL: 1
|
||||
@@ -27,36 +28,35 @@ jobs:
|
||||
|
||||
build_and_push:
|
||||
name: Build & Publish Docker Images
|
||||
needs: test
|
||||
if: github.ref == 'refs/heads/develop' && !contains(github.event.head_commit.message, '[skip ci]')
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
uses: actions/checkout@v3
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1.2.0
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1.3.0
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v2.1.6
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-buildx-
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v1.9.0
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v1.9.0
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2.5.0
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
@@ -86,7 +86,7 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Get Build Job Status
|
||||
uses: technote-space/workflow-conclusion-action@v2.1.6
|
||||
uses: technote-space/workflow-conclusion-action@v2
|
||||
- name: Combine Job Status
|
||||
id: status
|
||||
run: |
|
||||
|
||||
6
.github/workflows/deploy_docs.yml
vendored
6
.github/workflows/deploy_docs.yml
vendored
@@ -9,14 +9,14 @@ jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: Generate Swagger UI
|
||||
uses: Legion2/swagger-ui-action@v1.1.2
|
||||
uses: Legion2/swagger-ui-action@v1
|
||||
with:
|
||||
output: swagger-ui
|
||||
spec-file: overseerr-api.yml
|
||||
- name: Deploy to GitHub Pages
|
||||
uses: peaceiris/actions-gh-pages@v3.8.0
|
||||
uses: peaceiris/actions-gh-pages@v3
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
publish_dir: swagger-ui
|
||||
|
||||
12
.github/workflows/preview.yml
vendored
12
.github/workflows/preview.yml
vendored
@@ -11,27 +11,27 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
uses: actions/checkout@v3
|
||||
- name: Get the version
|
||||
id: get_version
|
||||
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1.2.0
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1.3.0
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v1.9.0
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v1.9.0
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v2.5.0
|
||||
uses: docker/build-push-action@v2
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile
|
||||
|
||||
41
.github/workflows/release.yml
vendored
41
.github/workflows/release.yml
vendored
@@ -6,46 +6,31 @@ on:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: Lint & Test Build
|
||||
runs-on: ubuntu-20.04
|
||||
container: node:14.18-alpine
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
- name: Install dependencies
|
||||
env:
|
||||
HUSKY_SKIP_INSTALL: 1
|
||||
run: yarn
|
||||
- name: Lint
|
||||
run: yarn lint
|
||||
- name: Build
|
||||
run: yarn build
|
||||
|
||||
semantic-release:
|
||||
name: Tag and release latest version
|
||||
needs: test
|
||||
runs-on: ubuntu-20.04
|
||||
env:
|
||||
HUSKY: 0
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Set up Node.js
|
||||
uses: actions/setup-node@v2
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 14
|
||||
node-version: 16
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v1.2.0
|
||||
uses: docker/setup-qemu-action@v1
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1.3.0
|
||||
uses: docker/setup-buildx-action@v1
|
||||
- name: Log in to Docker Hub
|
||||
uses: docker/login-action@v1.9.0
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
username: ${{ secrets.DOCKER_USERNAME }}
|
||||
password: ${{ secrets.DOCKER_TOKEN }}
|
||||
- name: Log in to GitHub Container Registry
|
||||
uses: docker/login-action@v1.9.0
|
||||
uses: docker/login-action@v1
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
@@ -72,7 +57,7 @@ jobs:
|
||||
- armhf
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2.3.4
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Switch to master branch
|
||||
@@ -89,7 +74,7 @@ jobs:
|
||||
echo ::set-output name=RELEASE::edge
|
||||
fi
|
||||
- name: Set Up QEMU
|
||||
uses: docker/setup-qemu-action@v1.2.0
|
||||
uses: docker/setup-qemu-action@v1
|
||||
with:
|
||||
image: tonistiigi/binfmt@sha256:df15403e06a03c2f461c1f7938b171fda34a5849eb63a70e2a2109ed5a778bde
|
||||
- name: Build Snap Package
|
||||
@@ -103,7 +88,7 @@ jobs:
|
||||
name: overseerr-snap-package-${{ matrix.architecture }}
|
||||
path: ${{ steps.build.outputs.snap }}
|
||||
- name: Review Snap Package
|
||||
uses: diddlesnaps/snapcraft-review-tools-action@v1.3.0
|
||||
uses: diddlesnaps/snapcraft-review-tools-action@v1
|
||||
with:
|
||||
snap: ${{ steps.build.outputs.snap }}
|
||||
- name: Publish Snap Package
|
||||
@@ -120,7 +105,7 @@ jobs:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Get Build Job Status
|
||||
uses: technote-space/workflow-conclusion-action@v2.1.6
|
||||
uses: technote-space/workflow-conclusion-action@v2
|
||||
- name: Combine Job Status
|
||||
id: status
|
||||
run: |
|
||||
|
||||
107
.github/workflows/snap.yaml
vendored
107
.github/workflows/snap.yaml
vendored
@@ -1,107 +0,0 @@
|
||||
name: Publish Snap
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- develop
|
||||
|
||||
jobs:
|
||||
jobs:
|
||||
name: Job Check
|
||||
runs-on: ubuntu-20.04
|
||||
if: "!contains(github.event.head_commit.message, '[skip ci]')"
|
||||
steps:
|
||||
- name: Cancel Previous Runs
|
||||
uses: styfle/cancel-workflow-action@0.9.0
|
||||
with:
|
||||
access_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
test:
|
||||
name: Lint & Test Build
|
||||
needs: jobs
|
||||
runs-on: ubuntu-20.04
|
||||
container: node:14.18-alpine
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v2.3.4
|
||||
- name: Install dependencies
|
||||
env:
|
||||
HUSKY_SKIP_INSTALL: 1
|
||||
run: yarn
|
||||
- name: Lint
|
||||
run: yarn lint
|
||||
- name: Build
|
||||
run: yarn build
|
||||
|
||||
build-snap:
|
||||
name: Build Snap Package (${{ matrix.architecture }})
|
||||
needs: test
|
||||
runs-on: ubuntu-20.04
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
architecture:
|
||||
- amd64
|
||||
- arm64
|
||||
- armhf
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v2.3.4
|
||||
- name: Prepare
|
||||
id: prepare
|
||||
run: |
|
||||
git fetch --prune --unshallow --tags
|
||||
if [[ $GITHUB_REF == refs/tags/* || $GITHUB_REF == refs/heads/master ]]; then
|
||||
echo ::set-output name=RELEASE::stable
|
||||
else
|
||||
echo ::set-output name=RELEASE::edge
|
||||
fi
|
||||
- name: Set Up QEMU
|
||||
uses: docker/setup-qemu-action@v1.2.0
|
||||
with:
|
||||
image: tonistiigi/binfmt@sha256:df15403e06a03c2f461c1f7938b171fda34a5849eb63a70e2a2109ed5a778bde
|
||||
- name: Build Snap Package
|
||||
uses: diddlesnaps/snapcraft-multiarch-action@v1
|
||||
id: build
|
||||
with:
|
||||
architecture: ${{ matrix.architecture }}
|
||||
- name: Upload Snap Package
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: overseerr-snap-package-${{ matrix.architecture }}
|
||||
path: ${{ steps.build.outputs.snap }}
|
||||
- name: Review Snap Package
|
||||
uses: diddlesnaps/snapcraft-review-tools-action@v1.3.0
|
||||
with:
|
||||
snap: ${{ steps.build.outputs.snap }}
|
||||
- name: Publish Snap Package
|
||||
uses: snapcore/action-publish@v1
|
||||
with:
|
||||
store_login: ${{ secrets.SNAP_LOGIN }}
|
||||
snap: ${{ steps.build.outputs.snap }}
|
||||
release: ${{ steps.prepare.outputs.RELEASE }}
|
||||
|
||||
discord:
|
||||
name: Send Discord Notification
|
||||
needs: build-snap
|
||||
if: always() && !contains(github.event.head_commit.message, '[skip ci]')
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- name: Get Build Job Status
|
||||
uses: technote-space/workflow-conclusion-action@v2.1.6
|
||||
- name: Combine Job Status
|
||||
id: status
|
||||
run: |
|
||||
failures=(neutral, skipped, timed_out, action_required)
|
||||
if [[ ${array[@]} =~ $WORKFLOW_CONCLUSION ]]; then
|
||||
echo ::set-output name=status::failure
|
||||
else
|
||||
echo ::set-output name=status::$WORKFLOW_CONCLUSION
|
||||
fi
|
||||
- name: Post Status to Discord
|
||||
uses: sarisia/actions-status-discord@v1
|
||||
with:
|
||||
webhook: ${{ secrets.DISCORD_WEBHOOK }}
|
||||
status: ${{ steps.status.outputs.status }}
|
||||
title: ${{ github.workflow }}
|
||||
nofail: true
|
||||
2
.github/workflows/support.yml
vendored
2
.github/workflows/support.yml
vendored
@@ -8,7 +8,7 @@ jobs:
|
||||
support:
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: dessant/support-requests@v2.0.1
|
||||
- uses: dessant/support-requests@v2
|
||||
with:
|
||||
github-token: ${{ github.token }}
|
||||
support-label: 'support'
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -39,6 +39,7 @@ config/settings.json
|
||||
config/logs/*.log*
|
||||
config/logs/*.json
|
||||
config/logs/*.log.gz
|
||||
config/logs/*.json.gz
|
||||
config/logs/*-audit.json
|
||||
|
||||
# anidb mapping file
|
||||
|
||||
4
.husky/commit-msg
Executable file
4
.husky/commit-msg
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
[[ -n $HUSKY_BYPASS ]] || npx commitlint --edit $1
|
||||
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
npx lint-staged
|
||||
4
.husky/prepare-commit-msg
Executable file
4
.husky/prepare-commit-msg
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
. "$(dirname "$0")/_/husky.sh"
|
||||
|
||||
exec < /dev/tty && npx cz --hook || true
|
||||
5
.vscode/extensions.json
vendored
5
.vscode/extensions.json
vendored
@@ -19,9 +19,6 @@
|
||||
|
||||
"stylelint.vscode-stylelint",
|
||||
|
||||
"bradlc.vscode-tailwindcss",
|
||||
|
||||
// https://marketplace.visualstudio.com/items?itemName=heybourn.headwind
|
||||
"heybourn.headwind"
|
||||
"bradlc.vscode-tailwindcss"
|
||||
]
|
||||
}
|
||||
|
||||
125
CHANGELOG.md
125
CHANGELOG.md
@@ -1,3 +1,128 @@
|
||||
# [1.29.0](https://github.com/sct/overseerr/compare/v1.28.0...v1.29.0) (2022-04-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add Discord ID setting to general user settings page ([#2406](https://github.com/sct/overseerr/issues/2406)) ([eff665e](https://github.com/sct/overseerr/commit/eff665ef4b688aac881408790304b77bd9a31ddb))
|
||||
* address unhandled promise rejections & bump node to v16.13 ([#2398](https://github.com/sct/overseerr/issues/2398)) ([8cba486](https://github.com/sct/overseerr/commit/8cba486249fed88232e93a688c8bfe0f6179c589))
|
||||
* **css:** rename form-input to form-input-area ([#2613](https://github.com/sct/overseerr/issues/2613)) ([086f0b6](https://github.com/sct/overseerr/commit/086f0b6ce23f607d20c2cec3c73b2e4d1ce9b426))
|
||||
* **email:** enclose PGP encryption logic in try/catch ([#2519](https://github.com/sct/overseerr/issues/2519)) ([a76b608](https://github.com/sct/overseerr/commit/a76b608ab796944c0c660e3296a7aca6615d69f3))
|
||||
* **frontend:** disable autocomplete on search field ([#2592](https://github.com/sct/overseerr/issues/2592)) ([82d1617](https://github.com/sct/overseerr/commit/82d16177bf763fe8097b4aae326793e3e21e847d))
|
||||
* **frontend:** theme-color meta tag ([#2420](https://github.com/sct/overseerr/issues/2420)) ([ff28c9b](https://github.com/sct/overseerr/commit/ff28c9bfebf4a930e2542ee3b3c35f8af4e1b97e))
|
||||
* **frontend:** various fixes ([#2524](https://github.com/sct/overseerr/issues/2524)) ([c3dbd0d](https://github.com/sct/overseerr/commit/c3dbd0d6913946e0e1b5308edfbb5ca744740223))
|
||||
* **lang:** rename 'Media' notification types for clarity ([#2400](https://github.com/sct/overseerr/issues/2400)) ([399b037](https://github.com/sct/overseerr/commit/399b0379186ed34dcc436bd95330fd1a05fef4b3))
|
||||
* **lang:** translations update from Hosted Weblate ([#2625](https://github.com/sct/overseerr/issues/2625)) ([19cdedd](https://github.com/sct/overseerr/commit/19cdedd2a6656b1a852e1cc653bbdb140e978b51))
|
||||
* **lang:** translations update from Hosted Weblate ([#2639](https://github.com/sct/overseerr/issues/2639)) ([418a533](https://github.com/sct/overseerr/commit/418a533588bbbdbbbb4caee1ef91d57c1ca35717))
|
||||
* **logs:** handle log message nested extra properties ([#2459](https://github.com/sct/overseerr/issues/2459)) ([d777940](https://github.com/sct/overseerr/commit/d7779408d162949b2eafcacefc8eabe53fae229f))
|
||||
* **notif:** duplicate notification check logic ([#2424](https://github.com/sct/overseerr/issues/2424)) ([10651ba](https://github.com/sct/overseerr/commit/10651baa675993f7109989bbac67f54661c8693f))
|
||||
* **notif:** show event in pop up notification for slack ([#2413](https://github.com/sct/overseerr/issues/2413)) ([d4438c8](https://github.com/sct/overseerr/commit/d4438c82e3753c9b29b6269ad406d263b3fcef4c)), closes [#2408](https://github.com/sct/overseerr/issues/2408)
|
||||
* **plex:** correctly generate uuid for safari ([#2614](https://github.com/sct/overseerr/issues/2614)) ([d06f2cd](https://github.com/sct/overseerr/commit/d06f2cdb08bfa6f05cf7cec2c408a258fa926b09))
|
||||
* **plex:** find TV series in addition to movies from IMDb IDs ([#1830](https://github.com/sct/overseerr/issues/1830)) ([30644f6](https://github.com/sct/overseerr/commit/30644f65ea2e8437676422ae0b083c642a836887))
|
||||
* **plex:** include 'Overseerr' in X-Plex-Device-Name header ([#2635](https://github.com/sct/overseerr/issues/2635)) ([d4f9650](https://github.com/sct/overseerr/commit/d4f9650cd07704a97f8b591b7de7351c1e85b825))
|
||||
* **plex:** use unique client identifier ([#2602](https://github.com/sct/overseerr/issues/2602)) ([648b346](https://github.com/sct/overseerr/commit/648b346cbe5a941c7e1ec4ddfb276fb0e27ed502))
|
||||
* **plex:** user import ([#2442](https://github.com/sct/overseerr/issues/2442)) ([86dff12](https://github.com/sct/overseerr/commit/86dff12cdeef6dca92527dd31757a3a4c7f921bf))
|
||||
* **radarr:** correctly check for existing movies ([#2490](https://github.com/sct/overseerr/issues/2490)) ([5d4b06b](https://github.com/sct/overseerr/commit/5d4b06bbcc6cf6d328f6b4a86c4c0f9b0f3aff3e))
|
||||
* **radarr:** remove PreDB minimum availability option ([#2386](https://github.com/sct/overseerr/issues/2386)) ([3e5eb4e](https://github.com/sct/overseerr/commit/3e5eb4e148a9f88b871abc4ee1784b870f691534))
|
||||
* **requests:** check for existing media of same type when requesting ([#2445](https://github.com/sct/overseerr/issues/2445)) ([eb9ca2e](https://github.com/sct/overseerr/commit/eb9ca2e86f3be3f4ff8ee2e7c4aecdf337d8976d))
|
||||
* **sonarr:** monitor existing series upon request approval ([#2553](https://github.com/sct/overseerr/issues/2553)) ([aa062d9](https://github.com/sct/overseerr/commit/aa062d921c425d4b64bfdb28a5f102b0c92f7d87))
|
||||
* **sonarr:** only scan seasons that exist in TMDb ([#2523](https://github.com/sct/overseerr/issues/2523)) ([6168185](https://github.com/sct/overseerr/commit/61681857b123802aaeff02a8f61b1ba046c5d333))
|
||||
* **tautulli:** fetch additional user history as necessary to return 20 unique media ([#2446](https://github.com/sct/overseerr/issues/2446)) ([7d19de6](https://github.com/sct/overseerr/commit/7d19de6a4af6297be18140ca59402b40f7bbb30b))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **about:** show config directory ([#2600](https://github.com/sct/overseerr/issues/2600)) ([0c7373c](https://github.com/sct/overseerr/commit/0c7373c7e89a4ff717efaa7d6a5854f7ccd6a8d3))
|
||||
* **api:** add additional request counts ([#2426](https://github.com/sct/overseerr/issues/2426)) ([2535edc](https://github.com/sct/overseerr/commit/2535edcc7fd6ec66fd45ad754c03929f1fe94871))
|
||||
* **discord:** add 'Enable Mentions' setting ([#1779](https://github.com/sct/overseerr/issues/1779)) ([5f7538a](https://github.com/sct/overseerr/commit/5f7538ae2bf9c6e2feea385cc299bd08df071218))
|
||||
* **frontend:** open media management slideover on status badge click ([#2407](https://github.com/sct/overseerr/issues/2407)) ([1f5785d](https://github.com/sct/overseerr/commit/1f5785d6c53b2ca2da67a8ccee72165c052c61a1))
|
||||
* **lang:** add Albanian display language ([#2605](https://github.com/sct/overseerr/issues/2605)) ([3d32462](https://github.com/sct/overseerr/commit/3d32462f50b4ced0d9205b79003c35d6d1c948a3))
|
||||
* **lang:** translations update from Hosted Weblate ([#2379](https://github.com/sct/overseerr/issues/2379)) ([bd93168](https://github.com/sct/overseerr/commit/bd93168ba1ed650baf4024569bb6a76811a99820))
|
||||
* **lang:** translations update from Hosted Weblate ([#2389](https://github.com/sct/overseerr/issues/2389)) ([d2241a4](https://github.com/sct/overseerr/commit/d2241a41877d126a802fc53c925d258af31f34fd))
|
||||
* **lang:** translations update from Hosted Weblate ([#2404](https://github.com/sct/overseerr/issues/2404)) ([1b29b15](https://github.com/sct/overseerr/commit/1b29b15d7c9a7ec918cb59116d60e1ae2e797dc4))
|
||||
* **lang:** translations update from Hosted Weblate ([#2405](https://github.com/sct/overseerr/issues/2405)) ([879df20](https://github.com/sct/overseerr/commit/879df20022c8c5d9b32858ac5499d3e4369fc064))
|
||||
* **lang:** translations update from Hosted Weblate ([#2414](https://github.com/sct/overseerr/issues/2414)) ([88536b1](https://github.com/sct/overseerr/commit/88536b1f9d6e8c1a11e1adf91b85bab4f34b751c))
|
||||
* **lang:** translations update from Hosted Weblate ([#2425](https://github.com/sct/overseerr/issues/2425)) ([e9d4b63](https://github.com/sct/overseerr/commit/e9d4b6327b50a005ee6c2c3292b6f107e90fc50c))
|
||||
* **lang:** translations update from Hosted Weblate ([#2428](https://github.com/sct/overseerr/issues/2428)) ([f8b1bcc](https://github.com/sct/overseerr/commit/f8b1bccda44371bb6f3f8f4ceeab900b1df3de31))
|
||||
* **lang:** translations update from Hosted Weblate ([#2436](https://github.com/sct/overseerr/issues/2436)) ([99c0407](https://github.com/sct/overseerr/commit/99c04072e9f7be8191f25cbcfd5103017b8796eb))
|
||||
* **lang:** translations update from Hosted Weblate ([#2452](https://github.com/sct/overseerr/issues/2452)) ([b5bd6ee](https://github.com/sct/overseerr/commit/b5bd6ee78f3d4aa14f0c440d1f2a8323dccfa399))
|
||||
* **lang:** translations update from Hosted Weblate ([#2457](https://github.com/sct/overseerr/issues/2457)) ([92b2d32](https://github.com/sct/overseerr/commit/92b2d32d2e1e1d319410a9e357e1304065a77598))
|
||||
* **lang:** translations update from Hosted Weblate ([#2489](https://github.com/sct/overseerr/issues/2489)) ([ec08fa6](https://github.com/sct/overseerr/commit/ec08fa67934715ff4a4d618d5b9ff97853913b78))
|
||||
* **lang:** translations update from Hosted Weblate ([#2508](https://github.com/sct/overseerr/issues/2508)) ([9f4ae34](https://github.com/sct/overseerr/commit/9f4ae34da76707a40e2c89a50c722ffa1c0327c0))
|
||||
* **lang:** translations update from Hosted Weblate ([#2531](https://github.com/sct/overseerr/issues/2531)) ([54b32eb](https://github.com/sct/overseerr/commit/54b32ebfd6b2eb6aeeea98c25939166eda8cc17f))
|
||||
* **lang:** translations update from Hosted Weblate ([#2541](https://github.com/sct/overseerr/issues/2541)) ([4549ed3](https://github.com/sct/overseerr/commit/4549ed389e4f25c0946dc01526387e5ac000c3cf))
|
||||
* **lang:** translations update from Hosted Weblate ([#2611](https://github.com/sct/overseerr/issues/2611)) ([81c75c8](https://github.com/sct/overseerr/commit/81c75c800edf6d36a1082a291ef7e308f338d005))
|
||||
* **lang:** translations update from Hosted Weblate ([#2629](https://github.com/sct/overseerr/issues/2629)) ([1d0cbd2](https://github.com/sct/overseerr/commit/1d0cbd2e761072be0b4b3de461397ad9f9f681f3))
|
||||
* **lang:** translations update from Hosted Weblate ([#2645](https://github.com/sct/overseerr/issues/2645)) ([341e3b8](https://github.com/sct/overseerr/commit/341e3b8f0657e09f53ad0b813b051290947343c0))
|
||||
* **logs:** use separate json file to parse logs for log viewer ([#2399](https://github.com/sct/overseerr/issues/2399)) ([ce31bef](https://github.com/sct/overseerr/commit/ce31bef8a125c5492f2a1cfef0dcf3d8a4e9ee11))
|
||||
* **notif:** add Gotify agent ([#2196](https://github.com/sct/overseerr/issues/2196)) ([e0b6abe](https://github.com/sct/overseerr/commit/e0b6abe4796f5a324c0ff78cff317fcaead671f1)), closes [#2183](https://github.com/sct/overseerr/issues/2183) [#2183](https://github.com/sct/overseerr/issues/2183) [#2077](https://github.com/sct/overseerr/issues/2077) [#2183](https://github.com/sct/overseerr/issues/2183) [#2183](https://github.com/sct/overseerr/issues/2183) [#2183](https://github.com/sct/overseerr/issues/2183) [#2077](https://github.com/sct/overseerr/issues/2077) [#2183](https://github.com/sct/overseerr/issues/2183) [#2183](https://github.com/sct/overseerr/issues/2183) [#2183](https://github.com/sct/overseerr/issues/2183)
|
||||
* **notif:** add Pushbullet channel tag ([#2198](https://github.com/sct/overseerr/issues/2198)) ([f9200b7](https://github.com/sct/overseerr/commit/f9200b7977208f9b8267ce3a74bd8a86d6f28f7b))
|
||||
* **plex:** selective user import ([#2188](https://github.com/sct/overseerr/issues/2188)) ([9cb97db](https://github.com/sct/overseerr/commit/9cb97db13ced5df2dc595cd9033470b1a0750093))
|
||||
* **search:** filter search results by year ([#2460](https://github.com/sct/overseerr/issues/2460)) ([72c825d](https://github.com/sct/overseerr/commit/72c825d2a5109688bcc1991a30249284bf281500))
|
||||
* **search:** search by id ([#2082](https://github.com/sct/overseerr/issues/2082)) ([b31cdbf](https://github.com/sct/overseerr/commit/b31cdbf074d5dbecbbf6da135a9b686aea9e3c0e))
|
||||
* Tautulli integration ([#2230](https://github.com/sct/overseerr/issues/2230)) ([0842c23](https://github.com/sct/overseerr/commit/0842c233d0fc56d44824cad18749492cd52cbed5))
|
||||
* **tautulli:** validate upon saving settings ([#2511](https://github.com/sct/overseerr/issues/2511)) ([1dc900d](https://github.com/sct/overseerr/commit/1dc900d5ce9689d179c9d2f554abc74ca50bd9cb))
|
||||
* **ui:** add trakt external link ([#2367](https://github.com/sct/overseerr/issues/2367)) ([4e56bae](https://github.com/sct/overseerr/commit/4e56bae98508c1a60aeb3a08560ba1c00acce7e7))
|
||||
* verify Plex server access during auth for existing users with Plex IDs ([#2458](https://github.com/sct/overseerr/issues/2458)) ([85bb30e](https://github.com/sct/overseerr/commit/85bb30e252c27047ae367491f0e5bb92a7d52605))
|
||||
|
||||
# [1.28.0](https://github.com/sct/overseerr/compare/v1.27.0...v1.28.0) (2022-01-01)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* add missing route guards to issues pages ([#2235](https://github.com/sct/overseerr/issues/2235)) ([c79dc9f](https://github.com/sct/overseerr/commit/c79dc9f70f512dbec0e3460ee78dbc9feccfbbb1))
|
||||
* allow basic HTTP auth in hostname validation ([#2307](https://github.com/sct/overseerr/issues/2307)) ([d48a7ba](https://github.com/sct/overseerr/commit/d48a7ba518f9c79d70e499037cb730eb3efe2c08))
|
||||
* **docker:** explicitly install python3 ([#2273](https://github.com/sct/overseerr/issues/2273)) [skip ci] ([f1cd087](https://github.com/sct/overseerr/commit/f1cd0878a5c74bddc864f5f8ce9e2f041bdde5ec))
|
||||
* **email:** use decrypted private key ([#2232](https://github.com/sct/overseerr/issues/2232)) ([8d29685](https://github.com/sct/overseerr/commit/8d2968572a569ed77a4d7c14ae1dc69935fa847e))
|
||||
* **frontend:** more issues-related fixes ([#2234](https://github.com/sct/overseerr/issues/2234)) ([3ec4a9c](https://github.com/sct/overseerr/commit/3ec4a9c76e1f31bee5c8801b389721bf8e5884e0))
|
||||
* **frontend:** setup page backdrops ([#2251](https://github.com/sct/overseerr/issues/2251)) ([78a8091](https://github.com/sct/overseerr/commit/78a8091bcd29a7cf50cc7c493c28710389817adf))
|
||||
* **frontend:** use consistent formatting & strings ([#2231](https://github.com/sct/overseerr/issues/2231)) ([2164471](https://github.com/sct/overseerr/commit/216447121b686b6d01a31b95ec0c8eb005f6b103))
|
||||
* handle Plex library settings migration failure gracefully ([#2254](https://github.com/sct/overseerr/issues/2254)) ([ed53810](https://github.com/sct/overseerr/commit/ed53810fb33f70722361c67d176ff4edf531ba45))
|
||||
* **issues:** only allow edit of own comments & do not allow non-admin delete of issues with comments ([#2248](https://github.com/sct/overseerr/issues/2248)) ([bba09d6](https://github.com/sct/overseerr/commit/bba09d69c1bc55c2f35db5a7986e7c935cc9619c))
|
||||
* **lang:** add missing string ([#2370](https://github.com/sct/overseerr/issues/2370)) ([d36c1d2](https://github.com/sct/overseerr/commit/d36c1d29295020efb76bac21a443b6f9049802f3))
|
||||
* **lang:** string edits ([#2229](https://github.com/sct/overseerr/issues/2229)) ([ab20c21](https://github.com/sct/overseerr/commit/ab20c21184639e1c7725f7cae96249c6fa157351))
|
||||
* **lang:** translations update from Weblate ([#2212](https://github.com/sct/overseerr/issues/2212)) ([85aec4f](https://github.com/sct/overseerr/commit/85aec4f8925746ebae9bcc99d8480b78ccfd851e))
|
||||
* **logs:** handle unexpected log messages ([#2303](https://github.com/sct/overseerr/issues/2303)) ([f284e4a](https://github.com/sct/overseerr/commit/f284e4ab978e502d2cc08e76226a8ebac91bb48f))
|
||||
* **logs:** lazily parse log message label ([#2359](https://github.com/sct/overseerr/issues/2359)) ([5af06bd](https://github.com/sct/overseerr/commit/5af06bd87226fbc6176b0c5e362824793165a34e))
|
||||
* **notif:** correct issue notif action URLs ([#2333](https://github.com/sct/overseerr/issues/2333)) ([dc7f959](https://github.com/sct/overseerr/commit/dc7f959cb422a8d89bcebc78377f1513412e542c))
|
||||
* **notif:** only send MEDIA_AVAILABLE notifications for non-declined requests ([#2343](https://github.com/sct/overseerr/issues/2343)) ([fcb0dcf](https://github.com/sct/overseerr/commit/fcb0dcf5be64bf9ca814bfe119586908922099c5))
|
||||
* **requests:** do not fail request edits if acting user lacks Manage Users permission ([#2338](https://github.com/sct/overseerr/issues/2338)) ([91bfff7](https://github.com/sct/overseerr/commit/91bfff71b7c05c9b9aad2c95282533eefbb6b2e7))
|
||||
* secure session cookie ([#2308](https://github.com/sct/overseerr/issues/2308)) ([7f330af](https://github.com/sct/overseerr/commit/7f330aff2e1d3546e8dd1a3e4b037b9beb1cc7f0))
|
||||
* **servarr:** handle baseurl error when testing connection ([#2294](https://github.com/sct/overseerr/issues/2294)) ([93b5ea2](https://github.com/sct/overseerr/commit/93b5ea20ca590996f6dc90713a76800180d0621c))
|
||||
* **servarr:** handle servaarr server being unavailable when scanning downloads ([#2358](https://github.com/sct/overseerr/issues/2358)) ([488874f](https://github.com/sct/overseerr/commit/488874fc17e4e4719e90d383b83b1e1a5217213b))
|
||||
* sort collection parts by release date ([#2368](https://github.com/sct/overseerr/issues/2368)) ([1b3797c](https://github.com/sct/overseerr/commit/1b3797cf6e6ef6b3d8c81e644382f6e3f68cfaaa))
|
||||
* **ui:** request badge styling in request list ([#2302](https://github.com/sct/overseerr/issues/2302)) ([f2375c9](https://github.com/sct/overseerr/commit/f2375c902b79dcb1f349500862775ae57ea7d406))
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* add production countries to movie/TV detail pages ([#2170](https://github.com/sct/overseerr/issues/2170)) ([30b20df](https://github.com/sct/overseerr/commit/30b20df37a9604ba1c066f89e54a5482a09575ea))
|
||||
* add quotas, advanced options, and toggles to collection request modal ([#1742](https://github.com/sct/overseerr/issues/1742)) ([af40212](https://github.com/sct/overseerr/commit/af40212a738f8d6d9a5bf26dc20c0c87780d6020))
|
||||
* **frontend:** add Discovery+ to network slider ([#2345](https://github.com/sct/overseerr/issues/2345)) ([2ded8f5](https://github.com/sct/overseerr/commit/2ded8f5484168bd7b8f45124d9ebdd296a5708d5))
|
||||
* issues ([#2180](https://github.com/sct/overseerr/issues/2180)) ([e402c42](https://github.com/sct/overseerr/commit/e402c42aaa7d795cd724856a2e23615bb1a3695d))
|
||||
* **lang:** add Polish display language ([#2261](https://github.com/sct/overseerr/issues/2261)) ([c760cea](https://github.com/sct/overseerr/commit/c760ceaa5f36c77fa3ce320fae1b4597d2d8b976))
|
||||
* **lang:** translated using Weblate (Chinese (Traditional)) ([#2272](https://github.com/sct/overseerr/issues/2272)) ([d401e33](https://github.com/sct/overseerr/commit/d401e33249cbbca6e707479e5f0207e298ef3248))
|
||||
* **lang:** translations update from Hosted Weblate ([#2277](https://github.com/sct/overseerr/issues/2277)) ([92732fc](https://github.com/sct/overseerr/commit/92732fcb42c56242d16daab00e2d38740b92dea0))
|
||||
* **lang:** translations update from Hosted Weblate ([#2315](https://github.com/sct/overseerr/issues/2315)) ([6245be1](https://github.com/sct/overseerr/commit/6245be1e10dda67c869b59522c1290e7c100145f))
|
||||
* **lang:** translations update from Hosted Weblate ([#2320](https://github.com/sct/overseerr/issues/2320)) ([68112fa](https://github.com/sct/overseerr/commit/68112faefbd64d5c71d3eff21620767f88ccfc34))
|
||||
* **lang:** translations update from Hosted Weblate ([#2325](https://github.com/sct/overseerr/issues/2325)) ([febf067](https://github.com/sct/overseerr/commit/febf0677b880d2fed2822ce510db7cbb0826a920))
|
||||
* **lang:** translations update from Hosted Weblate ([#2336](https://github.com/sct/overseerr/issues/2336)) ([3f7ef7a](https://github.com/sct/overseerr/commit/3f7ef7af97a807ef38041f4f2642b565aa33d066))
|
||||
* **lang:** translations update from Hosted Weblate ([#2341](https://github.com/sct/overseerr/issues/2341)) ([33fe0bd](https://github.com/sct/overseerr/commit/33fe0bdd1e00da40e85b4e4b4780134b31a105d2))
|
||||
* **lang:** translations update from Hosted Weblate ([#2346](https://github.com/sct/overseerr/issues/2346)) ([50dc934](https://github.com/sct/overseerr/commit/50dc9341dd98cb2d8ef3ef6471882a5a9b060afa))
|
||||
* **lang:** translations update from Hosted Weblate ([#2364](https://github.com/sct/overseerr/issues/2364)) ([d437cc2](https://github.com/sct/overseerr/commit/d437cc25392e9c0881888371ffabc82892a1b15c))
|
||||
* **lang:** translations update from Hosted Weblate ([#2366](https://github.com/sct/overseerr/issues/2366)) ([cc2b2bc](https://github.com/sct/overseerr/commit/cc2b2bc7a8ecd89e1feb38a907596b16df9bf0fc))
|
||||
* **lang:** translations update from Hosted Weblate ([#2374](https://github.com/sct/overseerr/issues/2374)) ([b9bedac](https://github.com/sct/overseerr/commit/b9bedac7d7ba85223ecf1d9b93b96e2a490d571a))
|
||||
* **lang:** translations update from Weblate ([#2226](https://github.com/sct/overseerr/issues/2226)) ([62b3dc5](https://github.com/sct/overseerr/commit/62b3dc5471c28f4d0e4399cb3bc8bfab94cff5ea))
|
||||
* **lang:** translations update from Weblate ([#2241](https://github.com/sct/overseerr/issues/2241)) ([2b0b8e0](https://github.com/sct/overseerr/commit/2b0b8e05d9c95ff9218cea858a920a2815871186))
|
||||
* **lang:** translations update from Weblate ([#2244](https://github.com/sct/overseerr/issues/2244)) ([0828b00](https://github.com/sct/overseerr/commit/0828b008badc8b512316799a6787bb7c403658d5))
|
||||
* **lang:** translations update from Weblate ([#2247](https://github.com/sct/overseerr/issues/2247)) ([8c49309](https://github.com/sct/overseerr/commit/8c49309c35c31f7bcd0b84b0a307febc16842f68))
|
||||
* **lang:** translations update from Weblate ([#2252](https://github.com/sct/overseerr/issues/2252)) ([99d5000](https://github.com/sct/overseerr/commit/99d50004e58f6b4594df0a171f6bc668635ec50c))
|
||||
* **lang:** translations update from Weblate ([#2265](https://github.com/sct/overseerr/issues/2265)) ([b1b367a](https://github.com/sct/overseerr/commit/b1b367aac625ed3eb865832c94c2352e5a5c40f5))
|
||||
* **notif:** 4K media notifications ([#2324](https://github.com/sct/overseerr/issues/2324)) ([88a8c1a](https://github.com/sct/overseerr/commit/88a8c1aa596e1113d6da52e5e8cbe443abc6384f))
|
||||
* **notif:** add Pushbullet and Pushover agents to user notification settings ([#1740](https://github.com/sct/overseerr/issues/1740)) ([aeb7a48](https://github.com/sct/overseerr/commit/aeb7a48d72cec3fa2b857030aad3eaa0a457a896))
|
||||
* **notif:** issue notifications ([#2242](https://github.com/sct/overseerr/issues/2242)) ([c9ffac3](https://github.com/sct/overseerr/commit/c9ffac33f7c04d926f8c45295703689d42fe87af))
|
||||
* **search:** close search bar when hitting return ([#2260](https://github.com/sct/overseerr/issues/2260)) ([b423dc1](https://github.com/sct/overseerr/commit/b423dc167d12f0ba49f902876bceb2e876e35f58))
|
||||
* **ui:** allow admins to edit & approve request from advanced request modal ([#2067](https://github.com/sct/overseerr/issues/2067)) ([340f1a2](https://github.com/sct/overseerr/commit/340f1a211952bd2e8f40f0ea4622b52dbe934e85))
|
||||
|
||||
# [1.27.0](https://github.com/sct/overseerr/compare/v1.26.1...v1.27.0) (2021-10-19)
|
||||
|
||||
|
||||
|
||||
@@ -68,9 +68,9 @@ All help is welcome and greatly appreciated! If you would like to contribute to
|
||||
|
||||
- If you are taking on an existing bug or feature ticket, please comment on the [issue](https://github.com/sct/overseerr/issues) to avoid multiple people working on the same thing.
|
||||
- All commits **must** follow [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/)
|
||||
- It is okay to squash your pull request down into a single commit that fits this standard.
|
||||
- Pull requests with commits not following this standard will **not** be merged.
|
||||
- Please make meaningful commits, or squash them.
|
||||
- Please make meaningful commits, or squash them prior to opening a pull request.
|
||||
- Do not squash commits once people have begun reviewing your changes.
|
||||
- Always rebase your commit to the latest `develop` branch. Do **not** merge `develop` into your branch.
|
||||
- It is your responsibility to keep your branch up-to-date. Your work will **not** be merged unless it is rebased off the latest `develop` branch.
|
||||
- You can create a "draft" pull request early to get feedback on your work.
|
||||
|
||||
14
Dockerfile
14
Dockerfile
@@ -1,4 +1,4 @@
|
||||
FROM node:14.18-alpine AS BUILD_IMAGE
|
||||
FROM node:16.14-alpine AS BUILD_IMAGE
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -7,8 +7,10 @@ ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64}
|
||||
|
||||
RUN \
|
||||
case "${TARGETPLATFORM}" in \
|
||||
'linux/arm64') apk add --no-cache python make g++ ;; \
|
||||
'linux/arm/v7') apk add --no-cache python make g++ ;; \
|
||||
'linux/arm64' | 'linux/arm/v7') \
|
||||
apk add --no-cache python3 make g++ && \
|
||||
ln -s /usr/bin/python3 /usr/bin/python \
|
||||
;; \
|
||||
esac
|
||||
|
||||
COPY package.json yarn.lock ./
|
||||
@@ -24,18 +26,18 @@ RUN yarn build
|
||||
# remove development dependencies
|
||||
RUN yarn install --production --ignore-scripts --prefer-offline
|
||||
|
||||
RUN rm -rf src server
|
||||
RUN rm -rf src server .next/cache
|
||||
|
||||
RUN touch config/DOCKER
|
||||
|
||||
RUN echo "{\"commitTag\": \"${COMMIT_TAG}\"}" > committag.json
|
||||
|
||||
|
||||
FROM node:14.18-alpine
|
||||
FROM node:16.14-alpine
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
RUN apk add --no-cache tzdata tini
|
||||
RUN apk add --no-cache tzdata tini && rm -rf /tmp/*
|
||||
|
||||
# copy from build image
|
||||
COPY --from=BUILD_IMAGE /app ./
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM node:14.18-alpine
|
||||
FROM node:16.14-alpine
|
||||
|
||||
COPY . /app
|
||||
WORKDIR /app
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
<a href="https://lgtm.com/projects/g/sct/overseerr/context:javascript"><img alt="Language grade: JavaScript" src="https://img.shields.io/lgtm/grade/javascript/g/sct/overseerr.svg?logo=lgtm&logoWidth=18"/></a>
|
||||
<a href="https://github.com/sct/overseerr/blob/develop/LICENSE"><img alt="GitHub" src="https://img.shields.io/github/license/sct/overseerr"></a>
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
|
||||
<a href="#contributors-"><img alt="All Contributors" src="https://img.shields.io/badge/all_contributors-67-orange.svg"/></a>
|
||||
<a href="#contributors-"><img alt="All Contributors" src="https://img.shields.io/badge/all_contributors-72-orange.svg"/></a>
|
||||
<!-- ALL-CONTRIBUTORS-BADGE:END -->
|
||||
</p>
|
||||
|
||||
@@ -160,6 +160,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
|
||||
<td align="center"><a href="https://github.com/skafte1990"><img src="https://avatars.githubusercontent.com/u/31465453?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Shaaft</b></sub></a><br /><a href="#translation-skafte1990" title="Translation">🌍</a></td>
|
||||
<td align="center"><a href="https://github.com/sr093906"><img src="https://avatars.githubusercontent.com/u/8369201?v=4?s=100" width="100px;" alt=""/><br /><sub><b>sr093906</b></sub></a><br /><a href="#translation-sr093906" title="Translation">🌍</a></td>
|
||||
<td align="center"><a href="https://github.com/Nackophilz"><img src="https://avatars.githubusercontent.com/u/61667226?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Nackophilz</b></sub></a><br /><a href="#translation-Nackophilz" title="Translation">🌍</a></td>
|
||||
<td align="center"><a href="https://github.com/schambers"><img src="https://avatars.githubusercontent.com/u/31563?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Sean Chambers</b></sub></a><br /><a href="https://github.com/sct/overseerr/commits?author=schambers" title="Code">💻</a></td>
|
||||
<td align="center"><a href="https://github.com/deniscerri"><img src="https://avatars.githubusercontent.com/u/64997243?v=4?s=100" width="100px;" alt=""/><br /><sub><b>deniscerri</b></sub></a><br /><a href="#translation-deniscerri" title="Translation">🌍</a></td>
|
||||
<td align="center"><a href="https://github.com/tomgacz"><img src="https://avatars.githubusercontent.com/u/14138209?v=4?s=100" width="100px;" alt=""/><br /><sub><b>tomgacz</b></sub></a><br /><a href="#translation-tomgacz" title="Translation">🌍</a></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><a href="https://github.com/Andersborrits"><img src="https://avatars.githubusercontent.com/u/29452218?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Andersborrits</b></sub></a><br /><a href="#translation-Andersborrits" title="Translation">🌍</a></td>
|
||||
<td align="center"><a href="http://maxentrouault.fr"><img src="https://avatars.githubusercontent.com/u/67283154?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Maxent</b></sub></a><br /><a href="#translation-Maxentr" title="Translation">🌍</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
- [Email](using-overseerr/notifications/email.md)
|
||||
- [Web Push](using-overseerr/notifications/webpush.md)
|
||||
- [Discord](using-overseerr/notifications/discord.md)
|
||||
- [Gotify](using-overseerr/notifications/gotify.md)
|
||||
- [LunaSea](using-overseerr/notifications/lunasea.md)
|
||||
- [Pushbullet](using-overseerr/notifications/pushbullet.md)
|
||||
- [Pushover](using-overseerr/notifications/pushover.md)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Third-Party Integrations
|
||||
|
||||
{% hint style="warning" %}
|
||||
We do not officially support these third-party integrations. If you run into any issues, please seek help on the appropriate support channels for the integration itself!
|
||||
**We do not officially support these third-party integrations.** If you run into any issues, please seek help on the appropriate support channels for the integration itself!
|
||||
{% endhint %}
|
||||
|
||||
- [Organizr](https://organizr.app/), a HTPC/homelab services organizer
|
||||
@@ -9,6 +9,7 @@ We do not officially support these third-party integrations. If you run into any
|
||||
- [LunaSea](https://docs.lunasea.app/modules/overseerr), a self-hosted controller for mobile and macOS
|
||||
- [Requestrr](https://github.com/darkalfx/requestrr/wiki/Configuring-Overseerr), a Discord chatbot
|
||||
- [Doplarr](https://github.com/kiranshila/Doplarr), a Discord request bot
|
||||
- [Overseerr Assistant](https://github.com/RemiRigal/Overseerr-Assistant), a browser extension for requesting directly from TMDb and IMDb
|
||||
- [ha-overseerr](https://github.com/vaparr/ha-overseerr), a custom Home Assistant component
|
||||
- [OverCLIrr](https://github.com/WillFantom/OverCLIrr), a command-line tool
|
||||
- [Overseerr Exporter](https://github.com/WillFantom/overseerr-exporter), a Prometheus exporter
|
||||
|
||||
@@ -143,7 +143,7 @@ or the Docker Desktop app:
|
||||
Then, create and start the Overseerr container:
|
||||
|
||||
```bash
|
||||
docker run -d -e LOG_LEVEL=debug -e TZ=Asia/Tokyo -p 5055:5055 -v "overseerr-data:/app/config" --restart unless-stopped sctx/overseerr
|
||||
docker run -d --name overseerr -e LOG_LEVEL=debug -e TZ=Asia/Tokyo -p 5055:5055 -v "overseerr-data:/app/config" --restart unless-stopped sctx/overseerr:latest
|
||||
```
|
||||
|
||||
If using a named volume like above, you can safely ignore the warning about the `/app/config` folder being incorrectly mounted on the setup page.
|
||||
|
||||
@@ -20,6 +20,12 @@ A more advanced, user-friendly, and secure (if using SSL) method is to set up a
|
||||
|
||||
The most secure method (but also the most inconvenient method) is to set up a VPN tunnel to your home server. You would then be able to access Overseerr as if you were on your local network, via `http://LOCAL-IP-ADDRESS:5055`.
|
||||
|
||||
### Are there mobile apps for Overseerr?
|
||||
|
||||
Since Overseerr has an almost native app experience when installed as a Progressive Web App (PWA), there are no plans to develop mobile apps for Overseerr.
|
||||
|
||||
Out of the box, Overseerr already fulfills most of the [PWA install criteria](https://web.dev/install-criteria/). You simply need to make sure that your Overseerr instance is being served over HTTPS (e.g., via a [reverse proxy](../extending-overseerr/reverse-proxy.md)).
|
||||
|
||||
### Overseerr is amazing! But it is not translated in my language yet! Can I help with translations?
|
||||
|
||||
You sure can! We are using [Weblate](https://hosted.weblate.org/engage/overseerr/) for translations. If your language is not listed, please [open a feature request on GitHub](https://github.com/sct/overseerr/issues/new/choose).
|
||||
|
||||
@@ -19,6 +19,11 @@ Please try to include as much information as possible. A vague statement like "i
|
||||
|
||||
Try to answer the following questions:
|
||||
|
||||
- What version of Overseerr are you running? (You can find this in Settings → About → Version.)
|
||||
- How did you install Overseerr? Are you using the official Docker or snap images, or images published by a third-party?
|
||||
- How are you accessing Overseerr?
|
||||
- Are you accessing Overseerr through your reverse proxy or via a local IP address?
|
||||
- What browser are you using? What browser extensions are enabled?
|
||||
- What were you trying to do, and how did you attempt it?
|
||||
- What command did you enter?
|
||||
- What did you click on?
|
||||
|
||||
@@ -7,6 +7,7 @@ Overseerr currently supports the following notification agents:
|
||||
- [Email](./email.md)
|
||||
- [Web Push](./webpush.md)
|
||||
- [Discord](./discord.md)
|
||||
- [Gotify](./gotify.md)
|
||||
- [LunaSea](./lunasea.md)
|
||||
- [Pushbullet](./pushbullet.md)
|
||||
- [Pushover](./pushover.md)
|
||||
|
||||
15
docs/using-overseerr/notifications/gotify.md
Normal file
15
docs/using-overseerr/notifications/gotify.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Gotify
|
||||
|
||||
## Configuration
|
||||
|
||||
### Server URL
|
||||
|
||||
Set this to the URL of your Gotify server.
|
||||
|
||||
### Application Token
|
||||
|
||||
Add an application to your Gotify server, and set this field to the generated application token.
|
||||
|
||||
{% hint style="info" %}
|
||||
Please refer to the [Gotify API documentation](https://gotify.net/docs) for more details on configuring these notifications.
|
||||
{% endhint %}
|
||||
@@ -1,7 +1,17 @@
|
||||
# Pushbullet
|
||||
|
||||
{% hint style="info" %}
|
||||
Users can optionally configure personal notifications in their user settings.
|
||||
|
||||
User notifications are separate from system notifications, and the available notification types are dependent on user permissions.
|
||||
{% endhint %}
|
||||
|
||||
## Configuration
|
||||
|
||||
### Access Token
|
||||
|
||||
[Create an access token](https://www.pushbullet.com/#settings) and set it here to grant Overseerr access to the Pushbullet API.
|
||||
|
||||
### Channel Tag (optional)
|
||||
|
||||
Optionally, [create a channel](https://www.pushbullet.com/my-channel) to allow other users to follow the notification feed using the specified channel tag.
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
# Pushover
|
||||
|
||||
{% hint style="info" %}
|
||||
Users can optionally configure personal notifications in their user settings.
|
||||
|
||||
User notifications are separate from system notifications, and the available notification types are dependent on user permissions.
|
||||
{% endhint %}
|
||||
|
||||
## Configuration
|
||||
|
||||
### Application/API Token
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
# Telegram
|
||||
|
||||
{% hint style="info" %}
|
||||
Users can optionally configure their own notifications in their user settings.
|
||||
Users can optionally configure personal notifications in their user settings.
|
||||
|
||||
User notifications are separate from system notifications, and the available notification types are dependent on user permissions.
|
||||
{% endhint %}
|
||||
|
||||
## Configuration
|
||||
|
||||
@@ -24,33 +24,38 @@ Customize the JSON payload to suit your needs. Overseerr provides several [templ
|
||||
|
||||
### General
|
||||
|
||||
- `{{notification_type}}` The type of notification. (Ex. `MEDIA_PENDING` or `MEDIA_APPROVED`)
|
||||
- `{{subject}}` The notification subject message. (For request notifications, this is the media title)
|
||||
- `{{message}}` Notification message body. (For request notifications, this is the media's overview/synopsis)
|
||||
- `{{image}}` Associated image with the request. (For request notifications, this is the media's poster)
|
||||
| Variable | Value |
|
||||
| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `{{notification_type}}` | The type of notification (e.g. `MEDIA_PENDING` or `ISSUE_COMMENT`) |
|
||||
| `{{event}}` | A friendly description of the notification event |
|
||||
| `{{subject}}` | The notification subject (typically the media title) |
|
||||
| `{{message}}` | The notification message body (the media overview/synopsis for request notifications; the issue description for issue notificatons) |
|
||||
| `{{image}}` | The notification image (typically the media poster) |
|
||||
|
||||
### User
|
||||
### Notify User
|
||||
|
||||
These variables are for the target recipient of the notification.
|
||||
|
||||
- `{{notifyuser_username}}` Target user's username.
|
||||
- `{{notifyuser_email}}` Target user's email address.
|
||||
- `{{notifyuser_avatar}}` Target user's avatar URL.
|
||||
- `{{notifyuser_settings_discordId}}` Target user's Discord ID (if one is set).
|
||||
- `{{notifyuser_settings_telegramChatId}}` Target user's Telegram Chat ID (if one is set).
|
||||
| Variable | Value |
|
||||
| ---------------------------------------- | ------------------------------------------------------------- |
|
||||
| `{{notifyuser_username}}` | The target notification recipient's username |
|
||||
| `{{notifyuser_email}}` | The target notification recipient's email address |
|
||||
| `{{notifyuser_avatar}}` | The target notification recipient's avatar URL |
|
||||
| `{{notifyuser_settings_discordId}}` | The target notification recipient's Discord ID (if set) |
|
||||
| `{{notifyuser_settings_telegramChatId}}` | The target notification recipient's Telegram Chat ID (if set) |
|
||||
|
||||
{% hint style="info" %}
|
||||
The `notifyuser` variables are not set for the following notification types, as they are intended for application administrators rather than end users:
|
||||
The `notifyuser` variables are not defined for the following request notification types, as they are intended for application administrators rather than end users:
|
||||
|
||||
- Media Requested
|
||||
- Media Automatically Approved
|
||||
- Media Failed
|
||||
- Request Pending Approval
|
||||
- Request Automatically Approved
|
||||
- Request Processing Failed
|
||||
|
||||
On the other hand, the `notifyuser` variables _will_ be replaced with the requesting user's information for the below notification types:
|
||||
|
||||
- Media Approved
|
||||
- Media Declined
|
||||
- Media Available
|
||||
- Request Approved
|
||||
- Request Declined
|
||||
- Request Available
|
||||
|
||||
If you would like to use the requesting user's information in your webhook, please instead include the relevant variables from the [Request](#request) section below.
|
||||
{% endhint %}
|
||||
@@ -59,28 +64,69 @@ If you would like to use the requesting user's information in your webhook, plea
|
||||
|
||||
The following variables must be used as a key in the JSON payload (e.g., `"{{extra}}": []`).
|
||||
|
||||
- `{{request}}` This object will be `null` if there is no relevant request object for the notification.
|
||||
- `{{media}}` This object will be `null` if there is no relevant media object for the notification.
|
||||
- `{{extra}}` This object will contain the "extra" array of additional data for certain notifications.
|
||||
| Variable | Value |
|
||||
| ------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `{{media}}` | The relevant media object |
|
||||
| `{{request}}` | The relevant request object |
|
||||
| `{{issue}}` | The relevant issue object |
|
||||
| `{{comment}}` | The relevant issue comment object |
|
||||
| `{{extra}}` | The "extra" array of additional data for certain notifications (e.g., season/episode numbers for series-related notifications) |
|
||||
|
||||
#### Media
|
||||
|
||||
These `{{media}}` special variables are only included in media-related notifications, such as requests.
|
||||
The `{{media}}` will be `null` if there is no relevant media object for the notification.
|
||||
|
||||
- `{{media_type}}` Media type (`movie` or `tv`).
|
||||
- `{{media_tmdbid}}` Media's TMDb ID.
|
||||
- `{{media_imdbid}}` Media's IMDb ID.
|
||||
- `{{media_tvdbid}}` Media's TVDB ID.
|
||||
- `{{media_status}}` Media's availability status (`UNKNOWN`, `PENDING`, `PROCESSING`, `PARTIALLY_AVAILABLE`, or `AVAILABLE`).
|
||||
- `{{media_status4k}}` Media's 4K availability status (`UNKNOWN`, `PENDING`, `PROCESSING`, `PARTIALLY_AVAILABLE`, or `AVAILABLE`)
|
||||
These following special variables are only included in media-related notifications, such as requests.
|
||||
|
||||
| Variable | Value |
|
||||
| -------------------- | -------------------------------------------------------------------------------------------------------------- |
|
||||
| `{{media_type}}` | The media type (`movie` or `tv`) |
|
||||
| `{{media_tmdbid}}` | The media's TMDb ID |
|
||||
| `{{media_tvdbid}}` | The media's TheTVDB ID |
|
||||
| `{{media_status}}` | The media's availability status (`UNKNOWN`, `PENDING`, `PROCESSING`, `PARTIALLY_AVAILABLE`, or `AVAILABLE`) |
|
||||
| `{{media_status4k}}` | The media's 4K availability status (`UNKNOWN`, `PENDING`, `PROCESSING`, `PARTIALLY_AVAILABLE`, or `AVAILABLE`) |
|
||||
|
||||
#### Request
|
||||
|
||||
The `{{request}}` special variables are only included in request-related notifications.
|
||||
The `{{request}}` will be `null` if there is no relevant media object for the notification.
|
||||
|
||||
- `{{request_id}}` Request ID.
|
||||
- `{{requestedBy_username}}` Requesting user's username.
|
||||
- `{{requestedBy_email}}` Requesting user's email address.
|
||||
- `{{requestedBy_avatar}}` Requesting user's avatar URL.
|
||||
- `{{requestedBy_settings_discordId}}` Requesting user's Discord ID (if set).
|
||||
- `{{requestedBy_settings_telegramChatId}}` Requesting user's Telegram Chat ID (if set).
|
||||
The following special variables are only included in request-related notifications.
|
||||
|
||||
| Variable | Value |
|
||||
| ----------------------------------------- | ----------------------------------------------- |
|
||||
| `{{request_id}}` | The request ID |
|
||||
| `{{requestedBy_username}}` | The requesting user's username |
|
||||
| `{{requestedBy_email}}` | The requesting user's email address |
|
||||
| `{{requestedBy_avatar}}` | The requesting user's avatar URL |
|
||||
| `{{requestedBy_settings_discordId}}` | The requesting user's Discord ID (if set) |
|
||||
| `{{requestedBy_settings_telegramChatId}}` | The requesting user's Telegram Chat ID (if set) |
|
||||
|
||||
#### Issue
|
||||
|
||||
The `{{issue}}` will be `null` if there is no relevant media object for the notification.
|
||||
|
||||
The following special variables are only included in issue-related notifications.
|
||||
|
||||
| Variable | Value |
|
||||
| ---------------------------------------- | ----------------------------------------------- |
|
||||
| `{{issue_id}}` | The issue ID |
|
||||
| `{{reportedBy_username}}` | The requesting user's username |
|
||||
| `{{reportedBy_email}}` | The requesting user's email address |
|
||||
| `{{reportedBy_avatar}}` | The requesting user's avatar URL |
|
||||
| `{{reportedBy_settings_discordId}}` | The requesting user's Discord ID (if set) |
|
||||
| `{{reportedBy_settings_telegramChatId}}` | The requesting user's Telegram Chat ID (if set) |
|
||||
|
||||
#### Comment
|
||||
|
||||
The `{{comment}}` will be `null` if there is no relevant media object for the notification.
|
||||
|
||||
The following special variables are only included in issue comment-related notifications.
|
||||
|
||||
| Variable | Value |
|
||||
| ----------------------------------------- | ----------------------------------------------- |
|
||||
| `{{comment_message}}` | The comment message |
|
||||
| `{{commentedBy_username}}` | The commenting user's username |
|
||||
| `{{commentedBy_email}}` | The commenting user's email address |
|
||||
| `{{commentedBy_avatar}}` | The commenting user's avatar URL |
|
||||
| `{{commentedBy_settings_discordId}}` | The commenting user's Discord ID (if set) |
|
||||
| `{{commentedBy_settings_telegramChatId}}` | The commenting user's Telegram Chat ID (if set) |
|
||||
|
||||
@@ -8,9 +8,9 @@ The user account created during Overseerr setup is the "Owner" account, which ca
|
||||
|
||||
There are currently two methods to add users to Overseerr: importing Plex users and creating "local users." All new users are created with the [default permissions](../settings/README.md#default-permissions) defined in **Settings → Users**.
|
||||
|
||||
### Importing Users from Plex
|
||||
### Importing Plex Users
|
||||
|
||||
Clicking the **Import Users from Plex** button on the **User List** page will fetch the list of users with access to the Plex server from [plex.tv](https://www.plex.tv/), and add them to Overseerr automatically.
|
||||
Clicking the **Import Plex Users** button on the **User List** page will fetch the list of users with access to the Plex server from [plex.tv](https://www.plex.tv/), and add them to Overseerr automatically.
|
||||
|
||||
Importing Plex users is not required, however. Any user with access to the Plex server can log in to Overseerr even if they have not been imported, and will be assigned the configured [default permissions](../settings/README.md#default-permissions) upon their first login.
|
||||
|
||||
|
||||
1
next-env.d.ts
vendored
1
next-env.d.ts
vendored
@@ -1,5 +1,4 @@
|
||||
/// <reference types="next" />
|
||||
/// <reference types="next/types/global" />
|
||||
/// <reference types="next/image-types/global" />
|
||||
|
||||
// NOTE: This file should not be edited
|
||||
|
||||
@@ -165,6 +165,9 @@ components:
|
||||
port:
|
||||
type: number
|
||||
example: 32400
|
||||
useSsl:
|
||||
type: boolean
|
||||
nullable: true
|
||||
libraries:
|
||||
type: array
|
||||
readOnly: true
|
||||
@@ -172,6 +175,7 @@ components:
|
||||
$ref: '#/components/schemas/PlexLibrary'
|
||||
webAppUrl:
|
||||
type: string
|
||||
nullable: true
|
||||
example: 'https://app.plex.tv/desktop'
|
||||
required:
|
||||
- name
|
||||
@@ -298,6 +302,26 @@ components:
|
||||
- provides
|
||||
- owned
|
||||
- connection
|
||||
TautulliSettings:
|
||||
type: object
|
||||
properties:
|
||||
hostname:
|
||||
type: string
|
||||
nullable: true
|
||||
example: 'tautulli.example.com'
|
||||
port:
|
||||
type: number
|
||||
nullable: true
|
||||
example: 8181
|
||||
useSsl:
|
||||
type: boolean
|
||||
nullable: true
|
||||
apiKey:
|
||||
type: string
|
||||
nullable: true
|
||||
externalUrl:
|
||||
type: string
|
||||
nullable: true
|
||||
RadarrSettings:
|
||||
type: object
|
||||
properties:
|
||||
@@ -909,6 +933,15 @@ components:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/ProductionCompany'
|
||||
productionCountries:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
iso_3166_1:
|
||||
type: string
|
||||
name:
|
||||
type: string
|
||||
spokenLanguages:
|
||||
type: array
|
||||
items:
|
||||
@@ -1129,6 +1162,8 @@ components:
|
||||
type: string
|
||||
webhookUrl:
|
||||
type: string
|
||||
enableMentions:
|
||||
type: boolean
|
||||
SlackSettings:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1204,6 +1239,9 @@ components:
|
||||
properties:
|
||||
accessToken:
|
||||
type: string
|
||||
channelTag:
|
||||
type: string
|
||||
nullable: true
|
||||
PushoverSettings:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1220,6 +1258,22 @@ components:
|
||||
type: string
|
||||
userToken:
|
||||
type: string
|
||||
GotifySettings:
|
||||
type: object
|
||||
properties:
|
||||
enabled:
|
||||
type: boolean
|
||||
example: false
|
||||
types:
|
||||
type: number
|
||||
example: 2
|
||||
options:
|
||||
type: object
|
||||
properties:
|
||||
url:
|
||||
type: string
|
||||
token:
|
||||
type: string
|
||||
LunaSeaSettings:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1299,7 +1353,7 @@ components:
|
||||
running:
|
||||
type: boolean
|
||||
example: false
|
||||
PersonDetail:
|
||||
PersonDetails:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
@@ -1630,6 +1684,15 @@ components:
|
||||
discordId:
|
||||
type: string
|
||||
nullable: true
|
||||
pushbulletAccessToken:
|
||||
type: string
|
||||
nullable: true
|
||||
pushoverApplicationToken:
|
||||
type: string
|
||||
nullable: true
|
||||
pushoverUserKey:
|
||||
type: string
|
||||
nullable: true
|
||||
telegramEnabled:
|
||||
type: boolean
|
||||
telegramBotUsername:
|
||||
@@ -1687,6 +1750,36 @@ components:
|
||||
type: number
|
||||
name:
|
||||
type: string
|
||||
Issue:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: number
|
||||
example: 1
|
||||
issueType:
|
||||
type: number
|
||||
example: 1
|
||||
media:
|
||||
$ref: '#/components/schemas/MediaInfo'
|
||||
createdBy:
|
||||
$ref: '#/components/schemas/User'
|
||||
modifiedBy:
|
||||
$ref: '#/components/schemas/User'
|
||||
comments:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/IssueComment'
|
||||
IssueComment:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: number
|
||||
example: 1
|
||||
user:
|
||||
$ref: '#/components/schemas/User'
|
||||
message:
|
||||
type: string
|
||||
example: A comment
|
||||
securitySchemes:
|
||||
cookieAuth:
|
||||
type: apiKey
|
||||
@@ -1928,6 +2021,67 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/PlexDevice'
|
||||
/settings/plex/users:
|
||||
get:
|
||||
summary: Get Plex users
|
||||
description: |
|
||||
Returns a list of Plex users in a JSON array.
|
||||
|
||||
Requires the `MANAGE_USERS` permission.
|
||||
tags:
|
||||
- settings
|
||||
- users
|
||||
responses:
|
||||
'200':
|
||||
description: Plex users
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
title:
|
||||
type: string
|
||||
username:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
thumb:
|
||||
type: string
|
||||
/settings/tautulli:
|
||||
get:
|
||||
summary: Get Tautulli settings
|
||||
description: Retrieves current Tautulli settings.
|
||||
tags:
|
||||
- settings
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TautulliSettings'
|
||||
post:
|
||||
summary: Update Tautulli settings
|
||||
description: Updates Tautulli settings with the provided values.
|
||||
tags:
|
||||
- settings
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TautulliSettings'
|
||||
responses:
|
||||
'200':
|
||||
description: 'Values were successfully updated'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/TautulliSettings'
|
||||
/settings/radarr:
|
||||
get:
|
||||
summary: Get Radarr settings
|
||||
@@ -2631,6 +2785,52 @@ paths:
|
||||
responses:
|
||||
'204':
|
||||
description: Test notification attempted
|
||||
/settings/notifications/gotify:
|
||||
get:
|
||||
summary: Get Gotify notification settings
|
||||
description: Returns current Gotify notification settings in a JSON object.
|
||||
tags:
|
||||
- settings
|
||||
responses:
|
||||
'200':
|
||||
description: Returned Gotify settings
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GotifySettings'
|
||||
post:
|
||||
summary: Update Gotify notification settings
|
||||
description: Update Gotify notification settings with the provided values.
|
||||
tags:
|
||||
- settings
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GotifySettings'
|
||||
responses:
|
||||
'200':
|
||||
description: 'Values were sucessfully updated'
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GotifySettings'
|
||||
/settings/notifications/gotify/test:
|
||||
post:
|
||||
summary: Test Gotify settings
|
||||
description: Sends a test notification to the Gotify agent.
|
||||
tags:
|
||||
- settings
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/GotifySettings'
|
||||
responses:
|
||||
'204':
|
||||
description: Test notification attempted
|
||||
/settings/notifications/slack:
|
||||
get:
|
||||
summary: Get Slack notification settings
|
||||
@@ -2842,6 +3042,9 @@ paths:
|
||||
type: string
|
||||
nullable: true
|
||||
example: Asia/Tokyo
|
||||
appDataPath:
|
||||
type: string
|
||||
example: /app/config
|
||||
/auth/me:
|
||||
get:
|
||||
summary: Get logged-in user
|
||||
@@ -2962,6 +3165,13 @@ paths:
|
||||
security: []
|
||||
tags:
|
||||
- users
|
||||
parameters:
|
||||
- in: path
|
||||
name: guid
|
||||
required: true
|
||||
schema:
|
||||
type: number
|
||||
example: 1
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
@@ -3084,11 +3294,22 @@ paths:
|
||||
post:
|
||||
summary: Import all users from Plex
|
||||
description: |
|
||||
Requests users from the Plex Server and creates a new user for each of them
|
||||
Fetches and imports users from the Plex server. If a list of Plex IDs is provided in the request body, only the specified users will be imported. Otherwise, all users will be imported.
|
||||
|
||||
Requires the `MANAGE_USERS` permission.
|
||||
tags:
|
||||
- users
|
||||
requestBody:
|
||||
required: false
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
plexIds:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
responses:
|
||||
'201':
|
||||
description: A list of the newly created users
|
||||
@@ -3490,6 +3711,35 @@ paths:
|
||||
permissions:
|
||||
type: number
|
||||
example: 2
|
||||
/user/{userId}/watch_data:
|
||||
get:
|
||||
summary: Get watch data
|
||||
description: |
|
||||
Returns play count, play duration, and recently watched media.
|
||||
|
||||
Requires the `ADMIN` permission to fetch results for other users.
|
||||
tags:
|
||||
- users
|
||||
parameters:
|
||||
- in: path
|
||||
name: userId
|
||||
required: true
|
||||
schema:
|
||||
type: number
|
||||
responses:
|
||||
'200':
|
||||
description: Users
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
recentlyWatched:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/MediaInfo'
|
||||
playCount:
|
||||
type: number
|
||||
/search:
|
||||
get:
|
||||
summary: Search for movies, TV shows, or people
|
||||
@@ -4269,21 +4519,22 @@ paths:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
total:
|
||||
type: number
|
||||
movie:
|
||||
type: number
|
||||
tv:
|
||||
type: number
|
||||
pending:
|
||||
type: number
|
||||
example: 0
|
||||
approved:
|
||||
type: number
|
||||
example: 10
|
||||
declined:
|
||||
type: number
|
||||
processing:
|
||||
type: number
|
||||
example: 4
|
||||
available:
|
||||
type: number
|
||||
example: 6
|
||||
required:
|
||||
- pending
|
||||
- approved
|
||||
/request/{requestId}:
|
||||
get:
|
||||
summary: Get MediaRequest
|
||||
@@ -4759,8 +5010,7 @@ paths:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/PersonDetail'
|
||||
|
||||
$ref: '#/components/schemas/PersonDetails'
|
||||
/person/{personId}/combined_credits:
|
||||
get:
|
||||
summary: Get combined credits
|
||||
@@ -4897,6 +5147,57 @@ paths:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/MediaInfo'
|
||||
/media/{mediaId}/watch_data:
|
||||
get:
|
||||
summary: Get watch data
|
||||
description: |
|
||||
Returns play count, play duration, and users who have watched the media.
|
||||
|
||||
Requires the `ADMIN` permission.
|
||||
tags:
|
||||
- media
|
||||
parameters:
|
||||
- in: path
|
||||
name: mediaId
|
||||
description: Media ID
|
||||
required: true
|
||||
example: '1'
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Users
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
data:
|
||||
type: object
|
||||
properties:
|
||||
playCount7Days:
|
||||
type: number
|
||||
playCount30Days:
|
||||
type: number
|
||||
playCount:
|
||||
type: number
|
||||
users:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
data4k:
|
||||
type: object
|
||||
properties:
|
||||
playCount7Days:
|
||||
type: number
|
||||
playCount30Days:
|
||||
type: number
|
||||
playCount:
|
||||
type: number
|
||||
users:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/User'
|
||||
/collection/{collectionId}:
|
||||
get:
|
||||
summary: Get collection details
|
||||
@@ -5183,7 +5484,251 @@ paths:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
/issue:
|
||||
get:
|
||||
summary: Get all issues
|
||||
description: |
|
||||
Returns a list of issues in JSON format.
|
||||
tags:
|
||||
- issue
|
||||
parameters:
|
||||
- in: query
|
||||
name: take
|
||||
schema:
|
||||
type: number
|
||||
nullable: true
|
||||
example: 20
|
||||
- in: query
|
||||
name: skip
|
||||
schema:
|
||||
type: number
|
||||
nullable: true
|
||||
example: 0
|
||||
- in: query
|
||||
name: sort
|
||||
schema:
|
||||
type: string
|
||||
enum: [added, modified]
|
||||
default: added
|
||||
- in: query
|
||||
name: filter
|
||||
schema:
|
||||
type: string
|
||||
enum: [all, open, resolved]
|
||||
default: open
|
||||
- in: query
|
||||
name: requestedBy
|
||||
schema:
|
||||
type: number
|
||||
nullable: true
|
||||
example: 1
|
||||
responses:
|
||||
'200':
|
||||
description: Issues returned
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
pageInfo:
|
||||
$ref: '#/components/schemas/PageInfo'
|
||||
results:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/Issue'
|
||||
post:
|
||||
summary: Create new issue
|
||||
description: |
|
||||
Creates a new issue
|
||||
tags:
|
||||
- issue
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
issueType:
|
||||
type: number
|
||||
message:
|
||||
type: string
|
||||
mediaId:
|
||||
type: number
|
||||
responses:
|
||||
'201':
|
||||
description: Succesfully created the issue
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Issue'
|
||||
/issue/{issueId}:
|
||||
get:
|
||||
summary: Get issue
|
||||
description: |
|
||||
Returns a single issue in JSON format.
|
||||
tags:
|
||||
- issue
|
||||
parameters:
|
||||
- in: path
|
||||
name: issueId
|
||||
required: true
|
||||
schema:
|
||||
type: number
|
||||
example: 1
|
||||
responses:
|
||||
'200':
|
||||
description: Issues returned
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Issue'
|
||||
delete:
|
||||
summary: Delete issue
|
||||
description: Removes an issue. If the user has the `MANAGE_ISSUES` permission, any issue can be removed. Otherwise, only a users own issues can be removed.
|
||||
tags:
|
||||
- issue
|
||||
parameters:
|
||||
- in: path
|
||||
name: issueId
|
||||
description: Issue ID
|
||||
required: true
|
||||
example: '1'
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'204':
|
||||
description: Succesfully removed issue
|
||||
/issue/{issueId}/comment:
|
||||
post:
|
||||
summary: Create a comment
|
||||
description: |
|
||||
Creates a comment and returns associated issue in JSON format.
|
||||
tags:
|
||||
- issue
|
||||
parameters:
|
||||
- in: path
|
||||
name: issueId
|
||||
required: true
|
||||
schema:
|
||||
type: number
|
||||
example: 1
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
required:
|
||||
- message
|
||||
responses:
|
||||
'200':
|
||||
description: Issue returned with new comment
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Issue'
|
||||
/issueComment/{commentId}:
|
||||
get:
|
||||
summary: Get issue comment
|
||||
description: |
|
||||
Returns a single issue comment in JSON format.
|
||||
tags:
|
||||
- issue
|
||||
parameters:
|
||||
- in: path
|
||||
name: commentId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
example: 1
|
||||
responses:
|
||||
'200':
|
||||
description: Comment returned
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/IssueComment'
|
||||
put:
|
||||
summary: Update issue comment
|
||||
description: |
|
||||
Updates and returns a single issue comment in JSON format.
|
||||
tags:
|
||||
- issue
|
||||
parameters:
|
||||
- in: path
|
||||
name: commentId
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
example: 1
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
message:
|
||||
type: string
|
||||
responses:
|
||||
'200':
|
||||
description: Comment updated
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/IssueComment'
|
||||
delete:
|
||||
summary: Delete issue comment
|
||||
description: |
|
||||
Deletes an issue comment. Only users with `MANAGE_ISSUES` or the user who created the comment can perform this action.
|
||||
tags:
|
||||
- issue
|
||||
parameters:
|
||||
- in: path
|
||||
name: commentId
|
||||
description: Issue Comment ID
|
||||
required: true
|
||||
example: '1'
|
||||
schema:
|
||||
type: string
|
||||
responses:
|
||||
'204':
|
||||
description: Succesfully removed issue comment
|
||||
/issue/{issueId}/{status}:
|
||||
post:
|
||||
summary: Update an issue's status
|
||||
description: |
|
||||
Updates an issue's status to approved or declined. Also returns the issue in a JSON object.
|
||||
|
||||
Requires the `MANAGE_ISSUES` permission or `ADMIN`.
|
||||
tags:
|
||||
- issue
|
||||
parameters:
|
||||
- in: path
|
||||
name: issueId
|
||||
description: Issue ID
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
example: '1'
|
||||
- in: path
|
||||
name: status
|
||||
description: New status
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
enum: [open, resolved]
|
||||
responses:
|
||||
'200':
|
||||
description: Issue status changed
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Issue'
|
||||
security:
|
||||
- cookieAuth: []
|
||||
- apiKey: []
|
||||
|
||||
159
package.json
159
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "overseerr",
|
||||
"version": "1.27.0",
|
||||
"version": "1.29.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "nodemon -e ts --watch server --watch overseerr-api.yml -e .json,.ts,.yml -x ts-node --files --project server/tsconfig.json server/index.ts",
|
||||
@@ -13,149 +13,148 @@
|
||||
"migration:generate": "ts-node --project server/tsconfig.json ./node_modules/typeorm/cli.js migration:generate",
|
||||
"migration:create": "ts-node --project server/tsconfig.json ./node_modules/typeorm/cli.js migration:create",
|
||||
"migration:run": "ts-node --project server/tsconfig.json ./node_modules/typeorm/cli.js migration:run",
|
||||
"format": "prettier --write ."
|
||||
"format": "prettier --write .",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sct/overseerr.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@headlessui/react": "^1.4.1",
|
||||
"@heroicons/react": "^1.0.4",
|
||||
"@supercharge/request-ip": "^1.1.2",
|
||||
"@svgr/webpack": "^5.5.0",
|
||||
"@tanem/react-nprogress": "^3.0.79",
|
||||
"ace-builds": "^1.4.12",
|
||||
"axios": "^0.21.4",
|
||||
"@headlessui/react": "^1.5.0",
|
||||
"@heroicons/react": "^1.0.6",
|
||||
"@supercharge/request-ip": "^1.2.0",
|
||||
"@svgr/webpack": "^6.2.1",
|
||||
"@tanem/react-nprogress": "^4.0.10",
|
||||
"ace-builds": "^1.4.14",
|
||||
"axios": "^0.26.1",
|
||||
"bcrypt": "^5.0.1",
|
||||
"bowser": "^2.11.0",
|
||||
"connect-typeorm": "^1.1.4",
|
||||
"cookie-parser": "^1.4.5",
|
||||
"cookie-parser": "^1.4.6",
|
||||
"copy-to-clipboard": "^3.3.1",
|
||||
"country-flag-icons": "^1.4.10",
|
||||
"country-flag-icons": "^1.4.21",
|
||||
"csurf": "^1.11.0",
|
||||
"email-templates": "^8.0.8",
|
||||
"express": "^4.17.1",
|
||||
"express-openapi-validator": "^4.13.1",
|
||||
"express-rate-limit": "^5.3.0",
|
||||
"email-templates": "^8.0.10",
|
||||
"express": "^4.17.3",
|
||||
"express-openapi-validator": "^4.13.6",
|
||||
"express-rate-limit": "^6.3.0",
|
||||
"express-session": "^1.17.2",
|
||||
"formik": "^2.2.9",
|
||||
"gravatar-url": "3.1.0",
|
||||
"gravatar-url": "^3.1.0",
|
||||
"intl": "^1.2.5",
|
||||
"lodash": "^4.17.21",
|
||||
"next": "11.1.2",
|
||||
"next": "12.1.0",
|
||||
"node-cache": "^5.1.2",
|
||||
"node-schedule": "^2.0.0",
|
||||
"nodemailer": "^6.6.3",
|
||||
"openpgp": "^5.0.0-3",
|
||||
"plex-api": "^5.3.1",
|
||||
"node-gyp": "^9.0.0",
|
||||
"node-schedule": "^2.1.0",
|
||||
"nodemailer": "^6.7.2",
|
||||
"openpgp": "^5.2.0",
|
||||
"plex-api": "^5.3.2",
|
||||
"pug": "^3.0.2",
|
||||
"react": "17.0.2",
|
||||
"react-ace": "^9.3.0",
|
||||
"react-ace": "^9.5.0",
|
||||
"react-animate-height": "^2.0.23",
|
||||
"react-dom": "17.0.2",
|
||||
"react-intersection-observer": "^8.32.1",
|
||||
"react-intl": "5.20.10",
|
||||
"react-markdown": "^6.0.2",
|
||||
"react-select": "^4.3.1",
|
||||
"react-spring": "^9.2.4",
|
||||
"react-intersection-observer": "^8.33.1",
|
||||
"react-intl": "5.24.7",
|
||||
"react-markdown": "^8.0.0",
|
||||
"react-select": "^5.2.2",
|
||||
"react-spring": "^9.4.4",
|
||||
"react-toast-notifications": "^2.5.1",
|
||||
"react-transition-group": "^4.4.2",
|
||||
"react-truncate-markup": "^5.1.0",
|
||||
"react-use-clipboard": "1.0.7",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"secure-random-password": "^0.2.3",
|
||||
"semver": "^7.3.5",
|
||||
"sqlite3": "^5.0.2",
|
||||
"swagger-ui-express": "^4.1.6",
|
||||
"swr": "^0.5.6",
|
||||
"typeorm": "0.2.37",
|
||||
"swagger-ui-express": "^4.3.0",
|
||||
"swr": "^1.2.2",
|
||||
"typeorm": "0.2.45",
|
||||
"web-push": "^3.4.5",
|
||||
"winston": "^3.3.3",
|
||||
"winston-daily-rotate-file": "^4.5.5",
|
||||
"winston": "^3.6.0",
|
||||
"winston-daily-rotate-file": "^4.6.1",
|
||||
"xml2js": "^0.4.23",
|
||||
"yamljs": "^0.3.0",
|
||||
"yup": "^0.32.9"
|
||||
"yup": "^0.32.11"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.15.7",
|
||||
"@commitlint/cli": "^13.1.0",
|
||||
"@commitlint/config-conventional": "^13.1.0",
|
||||
"@semantic-release/changelog": "^5.0.1",
|
||||
"@semantic-release/commit-analyzer": "^9.0.1",
|
||||
"@semantic-release/exec": "^5.0.0",
|
||||
"@semantic-release/git": "^9.0.1",
|
||||
"@tailwindcss/aspect-ratio": "^0.2.1",
|
||||
"@tailwindcss/forms": "^0.3.3",
|
||||
"@tailwindcss/typography": "^0.4.1",
|
||||
"@babel/cli": "^7.17.6",
|
||||
"@commitlint/cli": "^16.2.1",
|
||||
"@commitlint/config-conventional": "^16.2.1",
|
||||
"@semantic-release/changelog": "^6.0.1",
|
||||
"@semantic-release/commit-analyzer": "^9.0.2",
|
||||
"@semantic-release/exec": "^6.0.3",
|
||||
"@semantic-release/git": "^10.0.1",
|
||||
"@tailwindcss/aspect-ratio": "^0.4.0",
|
||||
"@tailwindcss/forms": "^0.5.0",
|
||||
"@tailwindcss/typography": "^0.5.2",
|
||||
"@types/bcrypt": "^5.0.0",
|
||||
"@types/cookie-parser": "^1.4.2",
|
||||
"@types/country-flag-icons": "^1.2.0",
|
||||
"@types/csurf": "^1.11.2",
|
||||
"@types/email-templates": "^8.0.4",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/express-rate-limit": "^5.1.3",
|
||||
"@types/express-session": "^1.17.3",
|
||||
"@types/lodash": "^4.14.173",
|
||||
"@types/node": "^15.6.1",
|
||||
"@types/express-session": "^1.17.4",
|
||||
"@types/lodash": "^4.14.179",
|
||||
"@types/node": "^17.0.21",
|
||||
"@types/node-schedule": "^1.3.2",
|
||||
"@types/nodemailer": "^6.4.4",
|
||||
"@types/react": "^17.0.22",
|
||||
"@types/react-dom": "^17.0.9",
|
||||
"@types/react-select": "^4.0.17",
|
||||
"@types/react-toast-notifications": "^2.4.1",
|
||||
"@types/react-transition-group": "^4.4.3",
|
||||
"@types/react": "^17.0.40",
|
||||
"@types/react-dom": "^17.0.13",
|
||||
"@types/react-transition-group": "^4.4.4",
|
||||
"@types/secure-random-password": "^0.2.1",
|
||||
"@types/semver": "^7.3.9",
|
||||
"@types/swagger-ui-express": "^4.1.3",
|
||||
"@types/web-push": "^3.3.2",
|
||||
"@types/xml2js": "^0.4.9",
|
||||
"@types/yamljs": "^0.2.31",
|
||||
"@types/yup": "^0.29.13",
|
||||
"@typescript-eslint/eslint-plugin": "^4.31.1",
|
||||
"@typescript-eslint/parser": "^4.31.1",
|
||||
"autoprefixer": "^10.3.4",
|
||||
"@typescript-eslint/eslint-plugin": "^5.14.0",
|
||||
"@typescript-eslint/parser": "^5.14.0",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"babel-plugin-react-intl": "^8.2.25",
|
||||
"babel-plugin-react-intl-auto": "^3.3.0",
|
||||
"commitizen": "^4.2.4",
|
||||
"copyfiles": "^2.4.1",
|
||||
"cz-conventional-changelog": "^3.3.0",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-next": "^11.1.2",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-formatjs": "^2.17.6",
|
||||
"eslint-plugin-jsx-a11y": "^6.4.1",
|
||||
"eslint": "^8.11.0",
|
||||
"eslint-config-next": "^12.1.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-formatjs": "^3.0.0",
|
||||
"eslint-plugin-jsx-a11y": "^6.5.1",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"eslint-plugin-react": "^7.25.3",
|
||||
"eslint-plugin-react-hooks": "^4.2.0",
|
||||
"eslint-plugin-react": "^7.29.3",
|
||||
"eslint-plugin-react-hooks": "^4.3.0",
|
||||
"extract-react-intl-messages": "^4.1.1",
|
||||
"husky": "4.3.8",
|
||||
"lint-staged": "^11.1.2",
|
||||
"nodemon": "^2.0.12",
|
||||
"postcss": "^8.3.6",
|
||||
"prettier": "^2.4.1",
|
||||
"semantic-release": "^18.0.0",
|
||||
"husky": "^7.0.4",
|
||||
"lint-staged": "^12.3.5",
|
||||
"nodemon": "^2.0.15",
|
||||
"postcss": "^8.4.8",
|
||||
"prettier": "^2.5.1",
|
||||
"prettier-plugin-tailwindcss": "^0.1.8",
|
||||
"semantic-release": "^19.0.2",
|
||||
"semantic-release-docker-buildx": "^1.0.1",
|
||||
"tailwindcss": "^2.2.15",
|
||||
"ts-node": "^10.2.1",
|
||||
"typescript": "^4.4.3"
|
||||
"tailwindcss": "^3.0.23",
|
||||
"ts-node": "^10.7.0",
|
||||
"typescript": "^4.6.2"
|
||||
},
|
||||
"resolutions": {
|
||||
"sqlite3/node-gyp": "^5.1.0"
|
||||
"sqlite3/node-gyp": "^8.4.1"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
}
|
||||
},
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged",
|
||||
"prepare-commit-msg": "exec < /dev/tty && git cz --hook || true",
|
||||
"commit-msg": "[[ -n $HUSKY_BYPASS ]] || commitlint -E HUSKY_GIT_PARAMS"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"**/*.{ts,tsx,js}": [
|
||||
"prettier --write",
|
||||
"eslint"
|
||||
],
|
||||
"**/*.{json,md}": [
|
||||
"**/*.{json,md,css}": [
|
||||
"prettier --write"
|
||||
]
|
||||
},
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<meta name="theme-color" content="#1f2937" />
|
||||
|
||||
<title>You are offline</title>
|
||||
|
||||
|
||||
16
public/sw.js
16
public/sw.js
@@ -90,8 +90,8 @@ self.addEventListener('push', (event) => {
|
||||
if (payload.actionUrl){
|
||||
options.actions.push(
|
||||
{
|
||||
action: 'viewmedia',
|
||||
title: 'View Media',
|
||||
action: 'view',
|
||||
title: payload.actionUrlTitle ?? 'View',
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -119,21 +119,17 @@ self.addEventListener('notificationclick', (event) => {
|
||||
|
||||
event.notification.close();
|
||||
|
||||
if (event.action === 'viewmedia') {
|
||||
clients.openWindow(notificationData.actionUrl);
|
||||
} else if (event.action === 'approve') {
|
||||
if (event.action === 'approve') {
|
||||
fetch(`/api/v1/request/${notificationData.requestId}/approve`, {
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
clients.openWindow(notificationData.actionUrl);
|
||||
} else if (event.action === 'decline') {
|
||||
fetch(`/api/v1/request/${notificationData.requestId}/decline`, {
|
||||
method: 'POST',
|
||||
});
|
||||
|
||||
clients.openWindow(notificationData.actionUrl);
|
||||
} else if (notificationData.actionUrl) {
|
||||
}
|
||||
|
||||
if (notificationData.actionUrl) {
|
||||
clients.openWindow(notificationData.actionUrl);
|
||||
}
|
||||
}, false);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import NodePlexAPI from 'plex-api';
|
||||
import { getSettings, Library, PlexSettings } from '../lib/settings';
|
||||
import logger from '../logger';
|
||||
|
||||
export interface PlexLibraryItem {
|
||||
ratingKey: string;
|
||||
@@ -145,28 +146,40 @@ class PlexAPI {
|
||||
public async syncLibraries(): Promise<void> {
|
||||
const settings = getSettings();
|
||||
|
||||
const libraries = await this.getLibraries();
|
||||
try {
|
||||
const libraries = await this.getLibraries();
|
||||
|
||||
const newLibraries: Library[] = libraries
|
||||
// Remove libraries that are not movie or show
|
||||
.filter((library) => library.type === 'movie' || library.type === 'show')
|
||||
// Remove libraries that do not have a metadata agent set (usually personal video libraries)
|
||||
.filter((library) => library.agent !== 'com.plexapp.agents.none')
|
||||
.map((library) => {
|
||||
const existing = settings.plex.libraries.find(
|
||||
(l) => l.id === library.key && l.name === library.title
|
||||
);
|
||||
const newLibraries: Library[] = libraries
|
||||
// Remove libraries that are not movie or show
|
||||
.filter(
|
||||
(library) => library.type === 'movie' || library.type === 'show'
|
||||
)
|
||||
// Remove libraries that do not have a metadata agent set (usually personal video libraries)
|
||||
.filter((library) => library.agent !== 'com.plexapp.agents.none')
|
||||
.map((library) => {
|
||||
const existing = settings.plex.libraries.find(
|
||||
(l) => l.id === library.key && l.name === library.title
|
||||
);
|
||||
|
||||
return {
|
||||
id: library.key,
|
||||
name: library.title,
|
||||
enabled: existing?.enabled ?? false,
|
||||
type: library.type,
|
||||
lastScan: existing?.lastScan,
|
||||
};
|
||||
return {
|
||||
id: library.key,
|
||||
name: library.title,
|
||||
enabled: existing?.enabled ?? false,
|
||||
type: library.type,
|
||||
lastScan: existing?.lastScan,
|
||||
};
|
||||
});
|
||||
|
||||
settings.plex.libraries = newLibraries;
|
||||
} catch (e) {
|
||||
logger.error('Failed to fetch Plex libraries', {
|
||||
label: 'Plex API',
|
||||
message: e.message,
|
||||
});
|
||||
|
||||
settings.plex.libraries = newLibraries;
|
||||
settings.plex.libraries = [];
|
||||
}
|
||||
|
||||
settings.save();
|
||||
}
|
||||
|
||||
|
||||
@@ -224,7 +224,7 @@ class PlexTvAPI {
|
||||
|
||||
const users = friends.MediaContainer.User;
|
||||
|
||||
const user = users.find((u) => Number(u.$.id) === userId);
|
||||
const user = users.find((u) => parseInt(u.$.id) === userId);
|
||||
|
||||
if (!user) {
|
||||
throw new Error(
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logger from '../../logger';
|
||||
import ServarrBase from './base';
|
||||
|
||||
interface RadarrMovieOptions {
|
||||
export interface RadarrMovieOptions {
|
||||
title: string;
|
||||
qualityProfileId: number;
|
||||
minimumAvailability: string;
|
||||
@@ -27,7 +27,6 @@ export interface RadarrMovie {
|
||||
profileId: number;
|
||||
qualityProfileId: number;
|
||||
added: string;
|
||||
downloaded: boolean;
|
||||
hasFile: boolean;
|
||||
}
|
||||
|
||||
@@ -85,7 +84,7 @@ class RadarrAPI extends ServarrBase<{ movieId: number }> {
|
||||
try {
|
||||
const movie = await this.getMovieByTmdbId(options.tmdbId);
|
||||
|
||||
if (movie.downloaded) {
|
||||
if (movie.hasFile) {
|
||||
logger.info(
|
||||
'Title already exists and is available. Skipping add and returning success',
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ export interface SonarrSeries {
|
||||
};
|
||||
}
|
||||
|
||||
interface AddSeriesOptions {
|
||||
export interface AddSeriesOptions {
|
||||
tvdbid: number;
|
||||
title: string;
|
||||
profileId: number;
|
||||
@@ -149,6 +149,7 @@ class SonarrAPI extends ServarrBase<{ seriesId: number; episodeId: number }> {
|
||||
|
||||
// If the series already exists, we will simply just update it
|
||||
if (series.id) {
|
||||
series.monitored = options.monitored ?? series.monitored;
|
||||
series.tags = options.tags ?? series.tags;
|
||||
series.seasons = this.buildSeasonList(options.seasons, series.seasons);
|
||||
|
||||
|
||||
293
server/api/tautulli.ts
Normal file
293
server/api/tautulli.ts
Normal file
@@ -0,0 +1,293 @@
|
||||
import axios, { AxiosInstance } from 'axios';
|
||||
import { uniqWith } from 'lodash';
|
||||
import { User } from '../entity/User';
|
||||
import { TautulliSettings } from '../lib/settings';
|
||||
import logger from '../logger';
|
||||
|
||||
export interface TautulliHistoryRecord {
|
||||
date: number;
|
||||
duration: number;
|
||||
friendly_name: string;
|
||||
full_title: string;
|
||||
grandparent_rating_key: number;
|
||||
grandparent_title: string;
|
||||
original_title: string;
|
||||
group_count: number;
|
||||
group_ids?: string;
|
||||
guid: string;
|
||||
ip_address: string;
|
||||
live: number;
|
||||
machine_id: string;
|
||||
media_index: number;
|
||||
media_type: string;
|
||||
originally_available_at: string;
|
||||
parent_media_index: number;
|
||||
parent_rating_key: number;
|
||||
parent_title: string;
|
||||
paused_counter: number;
|
||||
percent_complete: number;
|
||||
platform: string;
|
||||
product: string;
|
||||
player: string;
|
||||
rating_key: number;
|
||||
reference_id?: number;
|
||||
row_id?: number;
|
||||
session_key?: string;
|
||||
started: number;
|
||||
state?: string;
|
||||
stopped: number;
|
||||
thumb: string;
|
||||
title: string;
|
||||
transcode_decision: string;
|
||||
user: string;
|
||||
user_id: number;
|
||||
watched_status: number;
|
||||
year: number;
|
||||
}
|
||||
|
||||
interface TautulliHistoryResponse {
|
||||
response: {
|
||||
result: string;
|
||||
message?: string;
|
||||
data: {
|
||||
draw: number;
|
||||
recordsTotal: number;
|
||||
recordsFiltered: number;
|
||||
total_duration: string;
|
||||
filter_duration: string;
|
||||
data: TautulliHistoryRecord[];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
interface TautulliWatchStats {
|
||||
query_days: number;
|
||||
total_time: number;
|
||||
total_plays: number;
|
||||
}
|
||||
|
||||
interface TautulliWatchStatsResponse {
|
||||
response: {
|
||||
result: string;
|
||||
message?: string;
|
||||
data: TautulliWatchStats[];
|
||||
};
|
||||
}
|
||||
|
||||
interface TautulliWatchUser {
|
||||
friendly_name: string;
|
||||
user_id: number;
|
||||
user_thumb: string;
|
||||
username: string;
|
||||
total_plays: number;
|
||||
total_time: number;
|
||||
}
|
||||
|
||||
interface TautulliWatchUsersResponse {
|
||||
response: {
|
||||
result: string;
|
||||
message?: string;
|
||||
data: TautulliWatchUser[];
|
||||
};
|
||||
}
|
||||
|
||||
interface TautulliInfo {
|
||||
tautulli_install_type: string;
|
||||
tautulli_version: string;
|
||||
tautulli_branch: string;
|
||||
tautulli_commit: string;
|
||||
tautulli_platform: string;
|
||||
tautulli_platform_release: string;
|
||||
tautulli_platform_version: string;
|
||||
tautulli_platform_linux_distro: string;
|
||||
tautulli_platform_device_name: string;
|
||||
tautulli_python_version: string;
|
||||
}
|
||||
|
||||
interface TautulliInfoResponse {
|
||||
response: {
|
||||
result: string;
|
||||
message?: string;
|
||||
data: TautulliInfo;
|
||||
};
|
||||
}
|
||||
|
||||
class TautulliAPI {
|
||||
private axios: AxiosInstance;
|
||||
|
||||
constructor(settings: TautulliSettings) {
|
||||
this.axios = axios.create({
|
||||
baseURL: `${settings.useSsl ? 'https' : 'http'}://${settings.hostname}:${
|
||||
settings.port
|
||||
}${settings.urlBase ?? ''}`,
|
||||
params: { apikey: settings.apiKey },
|
||||
});
|
||||
}
|
||||
|
||||
public async getInfo(): Promise<TautulliInfo> {
|
||||
try {
|
||||
return (
|
||||
await this.axios.get<TautulliInfoResponse>('/api/v2', {
|
||||
params: { cmd: 'get_tautulli_info' },
|
||||
})
|
||||
).data.response.data;
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong fetching Tautulli server info', {
|
||||
label: 'Tautulli API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
throw new Error(
|
||||
`[Tautulli] Failed to fetch Tautulli server info: ${e.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public async getMediaWatchStats(
|
||||
ratingKey: string
|
||||
): Promise<TautulliWatchStats[]> {
|
||||
try {
|
||||
return (
|
||||
await this.axios.get<TautulliWatchStatsResponse>('/api/v2', {
|
||||
params: {
|
||||
cmd: 'get_item_watch_time_stats',
|
||||
rating_key: ratingKey,
|
||||
grouping: 1,
|
||||
},
|
||||
})
|
||||
).data.response.data;
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Something went wrong fetching media watch stats from Tautulli',
|
||||
{
|
||||
label: 'Tautulli API',
|
||||
errorMessage: e.message,
|
||||
ratingKey,
|
||||
}
|
||||
);
|
||||
throw new Error(
|
||||
`[Tautulli] Failed to fetch media watch stats: ${e.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public async getMediaWatchUsers(
|
||||
ratingKey: string
|
||||
): Promise<TautulliWatchUser[]> {
|
||||
try {
|
||||
return (
|
||||
await this.axios.get<TautulliWatchUsersResponse>('/api/v2', {
|
||||
params: {
|
||||
cmd: 'get_item_user_stats',
|
||||
rating_key: ratingKey,
|
||||
grouping: 1,
|
||||
},
|
||||
})
|
||||
).data.response.data;
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Something went wrong fetching media watch users from Tautulli',
|
||||
{
|
||||
label: 'Tautulli API',
|
||||
errorMessage: e.message,
|
||||
ratingKey,
|
||||
}
|
||||
);
|
||||
throw new Error(
|
||||
`[Tautulli] Failed to fetch media watch users: ${e.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public async getUserWatchStats(user: User): Promise<TautulliWatchStats> {
|
||||
try {
|
||||
if (!user.plexId) {
|
||||
throw new Error('User does not have an associated Plex ID');
|
||||
}
|
||||
|
||||
return (
|
||||
await this.axios.get<TautulliWatchStatsResponse>('/api/v2', {
|
||||
params: {
|
||||
cmd: 'get_user_watch_time_stats',
|
||||
user_id: user.plexId,
|
||||
query_days: 0,
|
||||
grouping: 1,
|
||||
},
|
||||
})
|
||||
).data.response.data[0];
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Something went wrong fetching user watch stats from Tautulli',
|
||||
{
|
||||
label: 'Tautulli API',
|
||||
errorMessage: e.message,
|
||||
user: user.displayName,
|
||||
}
|
||||
);
|
||||
throw new Error(
|
||||
`[Tautulli] Failed to fetch user watch stats: ${e.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public async getUserWatchHistory(
|
||||
user: User
|
||||
): Promise<TautulliHistoryRecord[]> {
|
||||
let results: TautulliHistoryRecord[] = [];
|
||||
|
||||
try {
|
||||
if (!user.plexId) {
|
||||
throw new Error('User does not have an associated Plex ID');
|
||||
}
|
||||
|
||||
const take = 100;
|
||||
let start = 0;
|
||||
|
||||
while (results.length < 20) {
|
||||
const tautulliData = (
|
||||
await this.axios.get<TautulliHistoryResponse>('/api/v2', {
|
||||
params: {
|
||||
cmd: 'get_history',
|
||||
grouping: 1,
|
||||
order_column: 'date',
|
||||
order_dir: 'desc',
|
||||
user_id: user.plexId,
|
||||
media_type: 'movie,episode',
|
||||
length: take,
|
||||
start,
|
||||
},
|
||||
})
|
||||
).data.response.data.data;
|
||||
|
||||
if (!tautulliData.length) {
|
||||
return results;
|
||||
}
|
||||
|
||||
results = uniqWith(results.concat(tautulliData), (recordA, recordB) =>
|
||||
recordA.grandparent_rating_key && recordB.grandparent_rating_key
|
||||
? recordA.grandparent_rating_key === recordB.grandparent_rating_key
|
||||
: recordA.parent_rating_key && recordB.parent_rating_key
|
||||
? recordA.parent_rating_key === recordB.parent_rating_key
|
||||
: recordA.rating_key === recordB.rating_key
|
||||
);
|
||||
|
||||
start += take;
|
||||
}
|
||||
|
||||
return results.slice(0, 20);
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Something went wrong fetching user watch history from Tautulli',
|
||||
{
|
||||
label: 'Tautulli API',
|
||||
errorMessage: e.message,
|
||||
user: user.displayName,
|
||||
}
|
||||
);
|
||||
throw new Error(
|
||||
`[Tautulli] Failed to fetch user watch history: ${e.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default TautulliAPI;
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
TmdbMovieDetails,
|
||||
TmdbNetwork,
|
||||
TmdbPersonCombinedCredits,
|
||||
TmdbPersonDetail,
|
||||
TmdbPersonDetails,
|
||||
TmdbProductionCompany,
|
||||
TmdbRegion,
|
||||
TmdbSearchMovieResponse,
|
||||
@@ -28,6 +28,10 @@ interface SearchOptions {
|
||||
language?: string;
|
||||
}
|
||||
|
||||
interface SingleSearchOptions extends SearchOptions {
|
||||
year?: number;
|
||||
}
|
||||
|
||||
interface DiscoverMovieOptions {
|
||||
page?: number;
|
||||
includeAdult?: boolean;
|
||||
@@ -116,15 +120,67 @@ class TheMovieDb extends ExternalAPI {
|
||||
}
|
||||
};
|
||||
|
||||
public searchMovies = async ({
|
||||
query,
|
||||
page = 1,
|
||||
includeAdult = false,
|
||||
language = 'en',
|
||||
year,
|
||||
}: SingleSearchOptions): Promise<TmdbSearchMovieResponse> => {
|
||||
try {
|
||||
const data = await this.get<TmdbSearchMovieResponse>('/search/movie', {
|
||||
params: { query, page, include_adult: includeAdult, language, year },
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
page: 1,
|
||||
results: [],
|
||||
total_pages: 1,
|
||||
total_results: 0,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
public searchTvShows = async ({
|
||||
query,
|
||||
page = 1,
|
||||
includeAdult = false,
|
||||
language = 'en',
|
||||
year,
|
||||
}: SingleSearchOptions): Promise<TmdbSearchTvResponse> => {
|
||||
try {
|
||||
const data = await this.get<TmdbSearchTvResponse>('/search/tv', {
|
||||
params: {
|
||||
query,
|
||||
page,
|
||||
include_adult: includeAdult,
|
||||
language,
|
||||
first_air_date_year: year,
|
||||
},
|
||||
});
|
||||
|
||||
return data;
|
||||
} catch (e) {
|
||||
return {
|
||||
page: 1,
|
||||
results: [],
|
||||
total_pages: 1,
|
||||
total_results: 0,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
public getPerson = async ({
|
||||
personId,
|
||||
language = 'en',
|
||||
}: {
|
||||
personId: number;
|
||||
language?: string;
|
||||
}): Promise<TmdbPersonDetail> => {
|
||||
}): Promise<TmdbPersonDetails> => {
|
||||
try {
|
||||
const data = await this.get<TmdbPersonDetail>(`/person/${personId}`, {
|
||||
const data = await this.get<TmdbPersonDetails>(`/person/${personId}`, {
|
||||
params: { language },
|
||||
});
|
||||
|
||||
@@ -561,13 +617,13 @@ class TheMovieDb extends ExternalAPI {
|
||||
}
|
||||
}
|
||||
|
||||
public async getMovieByImdbId({
|
||||
public async getMediaByImdbId({
|
||||
imdbId,
|
||||
language = 'en',
|
||||
}: {
|
||||
imdbId: string;
|
||||
language?: string;
|
||||
}): Promise<TmdbMovieDetails> {
|
||||
}): Promise<TmdbMovieDetails | TmdbTvDetails> {
|
||||
try {
|
||||
const extResponse = await this.getByExternalId({
|
||||
externalId: imdbId,
|
||||
@@ -583,12 +639,19 @@ class TheMovieDb extends ExternalAPI {
|
||||
return movie;
|
||||
}
|
||||
|
||||
throw new Error(
|
||||
'[TMDb] Failed to find a title with the provided IMDB id'
|
||||
);
|
||||
if (extResponse.tv_results[0]) {
|
||||
const tvshow = await this.getTvShow({
|
||||
tvId: extResponse.tv_results[0].id,
|
||||
language,
|
||||
});
|
||||
|
||||
return tvshow;
|
||||
}
|
||||
|
||||
throw new Error(`No movie or show returned from API for ID ${imdbId}`);
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`[TMDb] Failed to get movie by external imdb ID: ${e.message}`
|
||||
`[TMDb] Failed to find media using external IMDb ID: ${e.message}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ export interface TmdbUpcomingMoviesResponse extends TmdbPaginatedResponse {
|
||||
export interface TmdbExternalIdResponse {
|
||||
movie_results: TmdbMovieResult[];
|
||||
tv_results: TmdbTvResult[];
|
||||
person_results: TmdbPersonResult[];
|
||||
}
|
||||
|
||||
export interface TmdbCreditCast {
|
||||
@@ -251,6 +252,10 @@ export interface TmdbTvDetails {
|
||||
name: string;
|
||||
origin_country: string;
|
||||
}[];
|
||||
production_countries: {
|
||||
iso_3166_1: string;
|
||||
name: string;
|
||||
}[];
|
||||
spoken_languages: {
|
||||
english_name: string;
|
||||
iso_639_1: string;
|
||||
@@ -311,7 +316,7 @@ export interface TmdbKeyword {
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface TmdbPersonDetail {
|
||||
export interface TmdbPersonDetails {
|
||||
id: number;
|
||||
name: string;
|
||||
birthday: string;
|
||||
@@ -320,7 +325,7 @@ export interface TmdbPersonDetail {
|
||||
also_known_as?: string[];
|
||||
gender: number;
|
||||
biography: string;
|
||||
popularity: string;
|
||||
popularity: number;
|
||||
place_of_birth?: string;
|
||||
profile_path?: string;
|
||||
adult: boolean;
|
||||
|
||||
18
server/constants/issue.ts
Normal file
18
server/constants/issue.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export enum IssueType {
|
||||
VIDEO = 1,
|
||||
AUDIO = 2,
|
||||
SUBTITLES = 3,
|
||||
OTHER = 4,
|
||||
}
|
||||
|
||||
export enum IssueStatus {
|
||||
OPEN = 1,
|
||||
RESOLVED = 2,
|
||||
}
|
||||
|
||||
export const IssueTypeName = {
|
||||
[IssueType.AUDIO]: 'Audio',
|
||||
[IssueType.VIDEO]: 'Video',
|
||||
[IssueType.SUBTITLES]: 'Subtitle',
|
||||
[IssueType.OTHER]: 'Other',
|
||||
};
|
||||
68
server/entity/Issue.ts
Normal file
68
server/entity/Issue.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
OneToMany,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import { IssueStatus, IssueType } from '../constants/issue';
|
||||
import IssueComment from './IssueComment';
|
||||
import Media from './Media';
|
||||
import { User } from './User';
|
||||
|
||||
@Entity()
|
||||
class Issue {
|
||||
@PrimaryGeneratedColumn()
|
||||
public id: number;
|
||||
|
||||
@Column({ type: 'int' })
|
||||
public issueType: IssueType;
|
||||
|
||||
@Column({ type: 'int', default: IssueStatus.OPEN })
|
||||
public status: IssueStatus;
|
||||
|
||||
@Column({ type: 'int', default: 0 })
|
||||
public problemSeason: number;
|
||||
|
||||
@Column({ type: 'int', default: 0 })
|
||||
public problemEpisode: number;
|
||||
|
||||
@ManyToOne(() => Media, (media) => media.issues, {
|
||||
eager: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
public media: Media;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.createdIssues, {
|
||||
eager: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
public createdBy: User;
|
||||
|
||||
@ManyToOne(() => User, {
|
||||
eager: true,
|
||||
onDelete: 'CASCADE',
|
||||
nullable: true,
|
||||
})
|
||||
public modifiedBy?: User;
|
||||
|
||||
@OneToMany(() => IssueComment, (comment) => comment.issue, {
|
||||
cascade: true,
|
||||
eager: true,
|
||||
})
|
||||
public comments: IssueComment[];
|
||||
|
||||
@CreateDateColumn()
|
||||
public createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
public updatedAt: Date;
|
||||
|
||||
constructor(init?: Partial<Issue>) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export default Issue;
|
||||
42
server/entity/IssueComment.ts
Normal file
42
server/entity/IssueComment.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
ManyToOne,
|
||||
PrimaryGeneratedColumn,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import Issue from './Issue';
|
||||
import { User } from './User';
|
||||
|
||||
@Entity()
|
||||
class IssueComment {
|
||||
@PrimaryGeneratedColumn()
|
||||
public id: number;
|
||||
|
||||
@ManyToOne(() => User, {
|
||||
eager: true,
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
public user: User;
|
||||
|
||||
@ManyToOne(() => Issue, (issue) => issue.comments, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
public issue: Issue;
|
||||
|
||||
@Column({ type: 'text' })
|
||||
public message: string;
|
||||
|
||||
@CreateDateColumn()
|
||||
public createdAt: Date;
|
||||
|
||||
@UpdateDateColumn()
|
||||
public updatedAt: Date;
|
||||
|
||||
constructor(init?: Partial<IssueComment>) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
}
|
||||
|
||||
export default IssueComment;
|
||||
@@ -16,6 +16,7 @@ import { MediaStatus, MediaType } from '../constants/media';
|
||||
import downloadTracker, { DownloadingItem } from '../lib/downloadtracker';
|
||||
import { getSettings } from '../lib/settings';
|
||||
import logger from '../logger';
|
||||
import Issue from './Issue';
|
||||
import { MediaRequest } from './MediaRequest';
|
||||
import Season from './Season';
|
||||
|
||||
@@ -54,7 +55,7 @@ class Media {
|
||||
try {
|
||||
const media = await mediaRepository.findOne({
|
||||
where: { tmdbId: id, mediaType },
|
||||
relations: ['requests'],
|
||||
relations: ['requests', 'issues'],
|
||||
});
|
||||
|
||||
return media;
|
||||
@@ -97,6 +98,9 @@ class Media {
|
||||
})
|
||||
public seasons: Season[];
|
||||
|
||||
@OneToMany(() => Issue, (issue) => issue.media, { cascade: true })
|
||||
public issues: Issue[];
|
||||
|
||||
@CreateDateColumn()
|
||||
public createdAt: Date;
|
||||
|
||||
@@ -141,6 +145,9 @@ class Media {
|
||||
public plexUrl?: string;
|
||||
public plexUrl4k?: string;
|
||||
|
||||
public tautulliUrl?: string;
|
||||
public tautulliUrl4k?: string;
|
||||
|
||||
constructor(init?: Partial<Media>) {
|
||||
Object.assign(this, init);
|
||||
}
|
||||
@@ -148,6 +155,7 @@ class Media {
|
||||
@AfterLoad()
|
||||
public setPlexUrls(): void {
|
||||
const { machineId, webAppUrl } = getSettings().plex;
|
||||
const { externalUrl: tautulliUrl } = getSettings().tautulli;
|
||||
|
||||
if (this.ratingKey) {
|
||||
this.plexUrl = `${
|
||||
@@ -155,6 +163,10 @@ class Media {
|
||||
}#!/server/${machineId}/details?key=%2Flibrary%2Fmetadata%2F${
|
||||
this.ratingKey
|
||||
}`;
|
||||
|
||||
if (tautulliUrl) {
|
||||
this.tautulliUrl = `${tautulliUrl}/info?rating_key=${this.ratingKey}`;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.ratingKey4k) {
|
||||
@@ -163,6 +175,10 @@ class Media {
|
||||
}#!/server/${machineId}/details?key=%2Flibrary%2Fmetadata%2F${
|
||||
this.ratingKey4k
|
||||
}`;
|
||||
|
||||
if (tautulliUrl) {
|
||||
this.tautulliUrl4k = `${tautulliUrl}/info?rating_key=${this.ratingKey4k}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,8 +13,11 @@ import {
|
||||
RelationCount,
|
||||
UpdateDateColumn,
|
||||
} from 'typeorm';
|
||||
import RadarrAPI from '../api/servarr/radarr';
|
||||
import SonarrAPI, { SonarrSeries } from '../api/servarr/sonarr';
|
||||
import RadarrAPI, { RadarrMovieOptions } from '../api/servarr/radarr';
|
||||
import SonarrAPI, {
|
||||
AddSeriesOptions,
|
||||
SonarrSeries,
|
||||
} from '../api/servarr/sonarr';
|
||||
import TheMovieDb from '../api/themoviedb';
|
||||
import { ANIME_KEYWORD_ID } from '../api/themoviedb/constants';
|
||||
import { MediaRequestStatus, MediaStatus, MediaType } from '../constants/media';
|
||||
@@ -135,51 +138,15 @@ export class MediaRequest {
|
||||
where: { id: this.media.id },
|
||||
});
|
||||
if (!media) {
|
||||
logger.error('No parent media!', { label: 'Media Request' });
|
||||
logger.error('Media data not found', {
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const tmdb = new TheMovieDb();
|
||||
if (this.type === MediaType.MOVIE) {
|
||||
const movie = await tmdb.getMovie({ movieId: media.tmdbId });
|
||||
notificationManager.sendNotification(Notification.MEDIA_PENDING, {
|
||||
subject: `${movie.title}${
|
||||
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
|
||||
}`,
|
||||
message: truncate(movie.overview, {
|
||||
length: 500,
|
||||
separator: /\s/,
|
||||
omission: '…',
|
||||
}),
|
||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
|
||||
media,
|
||||
request: this,
|
||||
});
|
||||
}
|
||||
|
||||
if (this.type === MediaType.TV) {
|
||||
const tv = await tmdb.getTvShow({ tvId: media.tmdbId });
|
||||
notificationManager.sendNotification(Notification.MEDIA_PENDING, {
|
||||
subject: `${tv.name}${
|
||||
tv.first_air_date ? ` (${tv.first_air_date.slice(0, 4)})` : ''
|
||||
}`,
|
||||
message: truncate(tv.overview, {
|
||||
length: 500,
|
||||
separator: /\s/,
|
||||
omission: '…',
|
||||
}),
|
||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
|
||||
media,
|
||||
extra: [
|
||||
{
|
||||
name: 'Seasons',
|
||||
value: this.seasons
|
||||
.map((season) => season.seasonNumber)
|
||||
.join(', '),
|
||||
},
|
||||
],
|
||||
request: this,
|
||||
});
|
||||
}
|
||||
this.sendNotification(media, Notification.MEDIA_PENDING);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -200,74 +167,30 @@ export class MediaRequest {
|
||||
where: { id: this.media.id },
|
||||
});
|
||||
if (!media) {
|
||||
logger.error('No parent media!', { label: 'Media Request' });
|
||||
logger.error('Media data not found', {
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (media[this.is4k ? 'status4k' : 'status'] === MediaStatus.AVAILABLE) {
|
||||
logger.warn(
|
||||
'Media became available before request was approved. Approval notification will be skipped.',
|
||||
{ label: 'Media Request' }
|
||||
'Media became available before request was approved. Skipping approval notification',
|
||||
{ label: 'Media Request', requestId: this.id, mediaId: this.media.id }
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const tmdb = new TheMovieDb();
|
||||
if (this.media.mediaType === MediaType.MOVIE) {
|
||||
const movie = await tmdb.getMovie({ movieId: this.media.tmdbId });
|
||||
notificationManager.sendNotification(
|
||||
this.status === MediaRequestStatus.APPROVED
|
||||
? autoApproved
|
||||
? Notification.MEDIA_AUTO_APPROVED
|
||||
: Notification.MEDIA_APPROVED
|
||||
: Notification.MEDIA_DECLINED,
|
||||
{
|
||||
subject: `${movie.title}${
|
||||
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
|
||||
}`,
|
||||
message: truncate(movie.overview, {
|
||||
length: 500,
|
||||
separator: /\s/,
|
||||
omission: '…',
|
||||
}),
|
||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
|
||||
notifyUser: autoApproved ? undefined : this.requestedBy,
|
||||
media,
|
||||
request: this,
|
||||
}
|
||||
);
|
||||
} else if (this.media.mediaType === MediaType.TV) {
|
||||
const tv = await tmdb.getTvShow({ tvId: this.media.tmdbId });
|
||||
notificationManager.sendNotification(
|
||||
this.status === MediaRequestStatus.APPROVED
|
||||
? autoApproved
|
||||
? Notification.MEDIA_AUTO_APPROVED
|
||||
: Notification.MEDIA_APPROVED
|
||||
: Notification.MEDIA_DECLINED,
|
||||
{
|
||||
subject: `${tv.name}${
|
||||
tv.first_air_date ? ` (${tv.first_air_date.slice(0, 4)})` : ''
|
||||
}`,
|
||||
message: truncate(tv.overview, {
|
||||
length: 500,
|
||||
separator: /\s/,
|
||||
omission: '…',
|
||||
}),
|
||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
|
||||
notifyUser: autoApproved ? undefined : this.requestedBy,
|
||||
media,
|
||||
extra: [
|
||||
{
|
||||
name: 'Seasons',
|
||||
value: this.seasons
|
||||
.map((season) => season.seasonNumber)
|
||||
.join(', '),
|
||||
},
|
||||
],
|
||||
request: this,
|
||||
}
|
||||
);
|
||||
}
|
||||
this.sendNotification(
|
||||
media,
|
||||
this.status === MediaRequestStatus.APPROVED
|
||||
? autoApproved
|
||||
? Notification.MEDIA_AUTO_APPROVED
|
||||
: Notification.MEDIA_APPROVED
|
||||
: Notification.MEDIA_DECLINED
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -287,7 +210,11 @@ export class MediaRequest {
|
||||
relations: ['requests'],
|
||||
});
|
||||
if (!media) {
|
||||
logger.error('No parent media!', { label: 'Media Request' });
|
||||
logger.error('Media data not found', {
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
return;
|
||||
}
|
||||
const seasonRequestRepository = getRepository(SeasonRequest);
|
||||
@@ -375,8 +302,12 @@ export class MediaRequest {
|
||||
const settings = getSettings();
|
||||
if (settings.radarr.length === 0 && !settings.radarr[0]) {
|
||||
logger.info(
|
||||
'Skipped Radarr request as there is no Radarr server configured',
|
||||
{ label: 'Media Request' }
|
||||
'No Radarr server configured, skipping request processing',
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -395,18 +326,26 @@ export class MediaRequest {
|
||||
);
|
||||
logger.info(
|
||||
`Request has an override server: ${radarrSettings?.name}`,
|
||||
{ label: 'Media Request' }
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!radarrSettings) {
|
||||
logger.info(
|
||||
logger.warn(
|
||||
`There is no default ${
|
||||
this.is4k ? '4K ' : ''
|
||||
}Radarr server configured. Did you set any of your ${
|
||||
this.is4k ? '4K ' : ''
|
||||
}Radarr servers as default?`,
|
||||
{ label: 'Media Request' }
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -423,6 +362,8 @@ export class MediaRequest {
|
||||
rootFolder = this.rootFolder;
|
||||
logger.info(`Request has an override root folder: ${rootFolder}`, {
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -431,15 +372,22 @@ export class MediaRequest {
|
||||
this.profileId !== radarrSettings.activeProfileId
|
||||
) {
|
||||
qualityProfile = this.profileId;
|
||||
logger.info(`Request has an override profile id: ${qualityProfile}`, {
|
||||
label: 'Media Request',
|
||||
});
|
||||
logger.info(
|
||||
`Request has an override quality profile ID: ${qualityProfile}`,
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (this.tags && !isEqual(this.tags, radarrSettings.tags)) {
|
||||
tags = this.tags;
|
||||
logger.info(`Request has override tags`, {
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
tagIds: tags,
|
||||
});
|
||||
}
|
||||
@@ -456,7 +404,11 @@ export class MediaRequest {
|
||||
});
|
||||
|
||||
if (!media) {
|
||||
logger.error('Media not present');
|
||||
logger.error('Media data not found', {
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -466,20 +418,22 @@ export class MediaRequest {
|
||||
throw new Error('Media already available');
|
||||
}
|
||||
|
||||
const radarrMovieOptions: RadarrMovieOptions = {
|
||||
profileId: qualityProfile,
|
||||
qualityProfileId: qualityProfile,
|
||||
rootFolderPath: rootFolder,
|
||||
minimumAvailability: radarrSettings.minimumAvailability,
|
||||
title: movie.title,
|
||||
tmdbId: movie.id,
|
||||
year: Number(movie.release_date.slice(0, 4)),
|
||||
monitored: true,
|
||||
tags,
|
||||
searchNow: !radarrSettings.preventSearch,
|
||||
};
|
||||
|
||||
// Run this asynchronously so we don't wait for it on the UI side
|
||||
radarr
|
||||
.addMovie({
|
||||
profileId: qualityProfile,
|
||||
qualityProfileId: qualityProfile,
|
||||
rootFolderPath: rootFolder,
|
||||
minimumAvailability: radarrSettings.minimumAvailability,
|
||||
title: movie.title,
|
||||
tmdbId: movie.id,
|
||||
year: Number(movie.release_date.slice(0, 4)),
|
||||
monitored: true,
|
||||
tags,
|
||||
searchNow: !radarrSettings.preventSearch,
|
||||
})
|
||||
.addMovie(radarrMovieOptions)
|
||||
.then(async (radarrMovie) => {
|
||||
// We grab media again here to make sure we have the latest version of it
|
||||
const media = await mediaRepository.findOne({
|
||||
@@ -487,7 +441,7 @@ export class MediaRequest {
|
||||
});
|
||||
|
||||
if (!media) {
|
||||
throw new Error('Media data is missing');
|
||||
throw new Error('Media data not found');
|
||||
}
|
||||
|
||||
media[this.is4k ? 'externalServiceId4k' : 'externalServiceId'] =
|
||||
@@ -501,34 +455,30 @@ export class MediaRequest {
|
||||
media[this.is4k ? 'status4k' : 'status'] = MediaStatus.UNKNOWN;
|
||||
await mediaRepository.save(media);
|
||||
logger.warn(
|
||||
'Newly added movie request failed to add to Radarr, marking as unknown',
|
||||
'Something went wrong sending movie request to Radarr, marking status as UNKNOWN',
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
radarrMovieOptions,
|
||||
}
|
||||
);
|
||||
|
||||
notificationManager.sendNotification(Notification.MEDIA_FAILED, {
|
||||
subject: `${movie.title}${
|
||||
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
|
||||
}`,
|
||||
message: truncate(movie.overview, {
|
||||
length: 500,
|
||||
separator: /\s/,
|
||||
omission: '…',
|
||||
}),
|
||||
media,
|
||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
|
||||
request: this,
|
||||
});
|
||||
this.sendNotification(media, Notification.MEDIA_FAILED);
|
||||
});
|
||||
logger.info('Sent request to Radarr', { label: 'Media Request' });
|
||||
} catch (e) {
|
||||
const errorMessage = `Request failed to send to Radarr: ${e.message}`;
|
||||
logger.error('Request failed to send to Radarr', {
|
||||
logger.info('Sent request to Radarr', {
|
||||
label: 'Media Request',
|
||||
errorMessage,
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
throw new Error(errorMessage);
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong sending request to Radarr', {
|
||||
label: 'Media Request',
|
||||
errorMessage: e.message,
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
throw new Error(e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -542,9 +492,13 @@ export class MediaRequest {
|
||||
const mediaRepository = getRepository(Media);
|
||||
const settings = getSettings();
|
||||
if (settings.sonarr.length === 0 && !settings.sonarr[0]) {
|
||||
logger.info(
|
||||
'Skipped Sonarr request as there is no Sonarr server configured',
|
||||
{ label: 'Media Request' }
|
||||
logger.warn(
|
||||
'No Sonarr server configured, skipping request processing',
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -563,18 +517,26 @@ export class MediaRequest {
|
||||
);
|
||||
logger.info(
|
||||
`Request has an override server: ${sonarrSettings?.name}`,
|
||||
{ label: 'Media Request' }
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (!sonarrSettings) {
|
||||
logger.info(
|
||||
logger.warn(
|
||||
`There is no default ${
|
||||
this.is4k ? '4K ' : ''
|
||||
}Sonarr server configured. Did you set any of your ${
|
||||
this.is4k ? '4K ' : ''
|
||||
}Sonarr servers as default?`,
|
||||
{ label: 'Media Request' }
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
}
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -585,7 +547,7 @@ export class MediaRequest {
|
||||
});
|
||||
|
||||
if (!media) {
|
||||
throw new Error('Media data is missing');
|
||||
throw new Error('Media data not found');
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -606,7 +568,7 @@ export class MediaRequest {
|
||||
const requestRepository = getRepository(MediaRequest);
|
||||
await mediaRepository.remove(media);
|
||||
await requestRepository.remove(this);
|
||||
throw new Error('Series was missing tvdb id');
|
||||
throw new Error('TVDB ID not found');
|
||||
}
|
||||
|
||||
let seriesType: SonarrSeries['seriesType'] = 'standard';
|
||||
@@ -628,12 +590,10 @@ export class MediaRequest {
|
||||
seriesType === 'anime' && sonarrSettings.activeAnimeProfileId
|
||||
? sonarrSettings.activeAnimeProfileId
|
||||
: sonarrSettings.activeProfileId;
|
||||
|
||||
let languageProfile =
|
||||
seriesType === 'anime' && sonarrSettings.activeAnimeLanguageProfileId
|
||||
? sonarrSettings.activeAnimeLanguageProfileId
|
||||
: sonarrSettings.activeLanguageProfileId;
|
||||
|
||||
let tags =
|
||||
seriesType === 'anime'
|
||||
? sonarrSettings.animeTags
|
||||
@@ -647,14 +607,21 @@ export class MediaRequest {
|
||||
rootFolder = this.rootFolder;
|
||||
logger.info(`Request has an override root folder: ${rootFolder}`, {
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
}
|
||||
|
||||
if (this.profileId && this.profileId !== qualityProfile) {
|
||||
qualityProfile = this.profileId;
|
||||
logger.info(`Request has an override profile ID: ${qualityProfile}`, {
|
||||
label: 'Media Request',
|
||||
});
|
||||
logger.info(
|
||||
`Request has an override quality profile ID: ${qualityProfile}`,
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
@@ -663,9 +630,11 @@ export class MediaRequest {
|
||||
) {
|
||||
languageProfile = this.languageProfileId;
|
||||
logger.info(
|
||||
`Request has an override Language Profile: ${languageProfile}`,
|
||||
`Request has an override language profile ID: ${languageProfile}`,
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -674,25 +643,29 @@ export class MediaRequest {
|
||||
tags = this.tags;
|
||||
logger.info(`Request has override tags`, {
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
tagIds: tags,
|
||||
});
|
||||
}
|
||||
|
||||
const sonarrSeriesOptions: AddSeriesOptions = {
|
||||
profileId: qualityProfile,
|
||||
languageProfileId: languageProfile,
|
||||
rootFolderPath: rootFolder,
|
||||
title: series.name,
|
||||
tvdbid: tvdbId,
|
||||
seasons: this.seasons.map((season) => season.seasonNumber),
|
||||
seasonFolder: sonarrSettings.enableSeasonFolders,
|
||||
seriesType,
|
||||
tags,
|
||||
monitored: true,
|
||||
searchNow: !sonarrSettings.preventSearch,
|
||||
};
|
||||
|
||||
// Run this asynchronously so we don't wait for it on the UI side
|
||||
sonarr
|
||||
.addSeries({
|
||||
profileId: qualityProfile,
|
||||
languageProfileId: languageProfile,
|
||||
rootFolderPath: rootFolder,
|
||||
title: series.name,
|
||||
tvdbid: tvdbId,
|
||||
seasons: this.seasons.map((season) => season.seasonNumber),
|
||||
seasonFolder: sonarrSettings.enableSeasonFolders,
|
||||
seriesType,
|
||||
tags,
|
||||
monitored: true,
|
||||
searchNow: !sonarrSettings.preventSearch,
|
||||
})
|
||||
.addSeries(sonarrSeriesOptions)
|
||||
.then(async (sonarrSeries) => {
|
||||
// We grab media again here to make sure we have the latest version of it
|
||||
const media = await mediaRepository.findOne({
|
||||
@@ -701,7 +674,7 @@ export class MediaRequest {
|
||||
});
|
||||
|
||||
if (!media) {
|
||||
throw new Error('Media data is missing');
|
||||
throw new Error('Media data not found');
|
||||
}
|
||||
|
||||
media[this.is4k ? 'externalServiceId4k' : 'externalServiceId'] =
|
||||
@@ -715,45 +688,116 @@ export class MediaRequest {
|
||||
media[this.is4k ? 'status4k' : 'status'] = MediaStatus.UNKNOWN;
|
||||
await mediaRepository.save(media);
|
||||
logger.warn(
|
||||
'Newly added series request failed to add to Sonarr, marking as unknown',
|
||||
'Something went wrong sending series request to Sonarr, marking status as UNKNOWN',
|
||||
{
|
||||
label: 'Media Request',
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
sonarrSeriesOptions,
|
||||
}
|
||||
);
|
||||
|
||||
notificationManager.sendNotification(Notification.MEDIA_FAILED, {
|
||||
subject: `${series.name}${
|
||||
series.first_air_date
|
||||
? ` (${series.first_air_date.slice(0, 4)})`
|
||||
: ''
|
||||
}`,
|
||||
message: truncate(series.overview, {
|
||||
length: 500,
|
||||
separator: /\s/,
|
||||
omission: '…',
|
||||
}),
|
||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${series.poster_path}`,
|
||||
media,
|
||||
extra: [
|
||||
{
|
||||
name: 'Seasons',
|
||||
value: this.seasons
|
||||
.map((season) => season.seasonNumber)
|
||||
.join(', '),
|
||||
},
|
||||
],
|
||||
request: this,
|
||||
});
|
||||
this.sendNotification(media, Notification.MEDIA_FAILED);
|
||||
});
|
||||
logger.info('Sent request to Sonarr', { label: 'Media Request' });
|
||||
} catch (e) {
|
||||
const errorMessage = `Request failed to send to Sonarr: ${e.message}`;
|
||||
logger.error('Request failed to send to Sonarr', {
|
||||
logger.info('Sent request to Sonarr', {
|
||||
label: 'Media Request',
|
||||
errorMessage,
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
throw new Error(errorMessage);
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong sending request to Sonarr', {
|
||||
label: 'Media Request',
|
||||
errorMessage: e.message,
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
throw new Error(e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async sendNotification(media: Media, type: Notification) {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
try {
|
||||
const mediaType = this.type === MediaType.MOVIE ? 'Movie' : 'Series';
|
||||
let event: string | undefined;
|
||||
let notifyAdmin = true;
|
||||
|
||||
switch (type) {
|
||||
case Notification.MEDIA_APPROVED:
|
||||
event = `${this.is4k ? '4K ' : ''}${mediaType} Request Approved`;
|
||||
notifyAdmin = false;
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
event = `${this.is4k ? '4K ' : ''}${mediaType} Request Declined`;
|
||||
notifyAdmin = false;
|
||||
break;
|
||||
case Notification.MEDIA_PENDING:
|
||||
event = `New ${this.is4k ? '4K ' : ''}${mediaType} Request`;
|
||||
break;
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
event = `${
|
||||
this.is4k ? '4K ' : ''
|
||||
}${mediaType} Request Automatically Approved`;
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
event = `${this.is4k ? '4K ' : ''}${mediaType} Request Failed`;
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.type === MediaType.MOVIE) {
|
||||
const movie = await tmdb.getMovie({ movieId: media.tmdbId });
|
||||
notificationManager.sendNotification(type, {
|
||||
media,
|
||||
request: this,
|
||||
notifyAdmin,
|
||||
notifyUser: notifyAdmin ? undefined : this.requestedBy,
|
||||
event,
|
||||
subject: `${movie.title}${
|
||||
movie.release_date ? ` (${movie.release_date.slice(0, 4)})` : ''
|
||||
}`,
|
||||
message: truncate(movie.overview, {
|
||||
length: 500,
|
||||
separator: /\s/,
|
||||
omission: '…',
|
||||
}),
|
||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${movie.poster_path}`,
|
||||
});
|
||||
} else if (this.type === MediaType.TV) {
|
||||
const tv = await tmdb.getTvShow({ tvId: media.tmdbId });
|
||||
notificationManager.sendNotification(type, {
|
||||
media,
|
||||
request: this,
|
||||
notifyAdmin,
|
||||
notifyUser: notifyAdmin ? undefined : this.requestedBy,
|
||||
event,
|
||||
subject: `${tv.name}${
|
||||
tv.first_air_date ? ` (${tv.first_air_date.slice(0, 4)})` : ''
|
||||
}`,
|
||||
message: truncate(tv.overview, {
|
||||
length: 500,
|
||||
separator: /\s/,
|
||||
omission: '…',
|
||||
}),
|
||||
image: `https://image.tmdb.org/t/p/w600_and_h900_bestv2${tv.poster_path}`,
|
||||
extra: [
|
||||
{
|
||||
name: 'Requested Seasons',
|
||||
value: this.seasons
|
||||
.map((season) => season.seasonNumber)
|
||||
.join(', '),
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong sending media notification(s)', {
|
||||
label: 'Notifications',
|
||||
errorMessage: e.message,
|
||||
requestId: this.id,
|
||||
mediaId: this.media.id,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
} from '../lib/permissions';
|
||||
import { getSettings } from '../lib/settings';
|
||||
import logger from '../logger';
|
||||
import Issue from './Issue';
|
||||
import { MediaRequest } from './MediaRequest';
|
||||
import SeasonRequest from './SeasonRequest';
|
||||
import { UserPushSubscription } from './UserPushSubscription';
|
||||
@@ -115,6 +116,9 @@ export class User {
|
||||
@OneToMany(() => UserPushSubscription, (pushSub) => pushSub.user)
|
||||
public pushSubscriptions: UserPushSubscription[];
|
||||
|
||||
@OneToMany(() => Issue, (issue) => issue.createdBy, { cascade: true })
|
||||
public createdIssues: Issue[];
|
||||
|
||||
@CreateDateColumn()
|
||||
public createdAt: Date;
|
||||
|
||||
|
||||
@@ -42,6 +42,15 @@ export class UserSettings {
|
||||
@Column({ nullable: true })
|
||||
public discordId?: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
public pushbulletAccessToken?: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
public pushoverApplicationToken?: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
public pushoverUserKey?: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
public telegramChatId?: string;
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ import { startJobs } from './job/schedule';
|
||||
import notificationManager from './lib/notifications';
|
||||
import DiscordAgent from './lib/notifications/agents/discord';
|
||||
import EmailAgent from './lib/notifications/agents/email';
|
||||
import GotifyAgent from './lib/notifications/agents/gotify';
|
||||
import LunaSeaAgent from './lib/notifications/agents/lunasea';
|
||||
import PushbulletAgent from './lib/notifications/agents/pushbullet';
|
||||
import PushoverAgent from './lib/notifications/agents/pushover';
|
||||
@@ -63,11 +64,12 @@ app
|
||||
});
|
||||
|
||||
if (admin) {
|
||||
const plexapi = new PlexAPI({ plexToken: admin.plexToken });
|
||||
await plexapi.syncLibraries();
|
||||
logger.info('Migrating libraries to include media type', {
|
||||
logger.info('Migrating Plex libraries to include media type', {
|
||||
label: 'Settings',
|
||||
});
|
||||
|
||||
const plexapi = new PlexAPI({ plexToken: admin.plexToken });
|
||||
await plexapi.syncLibraries();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,6 +77,7 @@ app
|
||||
notificationManager.registerAgents([
|
||||
new DiscordAgent(),
|
||||
new EmailAgent(),
|
||||
new GotifyAgent(),
|
||||
new LunaSeaAgent(),
|
||||
new PushbulletAgent(),
|
||||
new PushoverAgent(),
|
||||
@@ -138,6 +141,9 @@ app
|
||||
saveUninitialized: false,
|
||||
cookie: {
|
||||
maxAge: 1000 * 60 * 60 * 24 * 30,
|
||||
httpOnly: true,
|
||||
sameSite: true,
|
||||
secure: 'auto',
|
||||
},
|
||||
store: new TypeormStore({
|
||||
cleanupLimit: 2,
|
||||
|
||||
6
server/interfaces/api/issueInterfaces.ts
Normal file
6
server/interfaces/api/issueInterfaces.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import Issue from '../../entity/Issue';
|
||||
import { PaginatedResponse } from './common';
|
||||
|
||||
export interface IssueResultsResponse extends PaginatedResponse {
|
||||
results: Issue[];
|
||||
}
|
||||
@@ -1,6 +1,22 @@
|
||||
import type Media from '../../entity/Media';
|
||||
import { User } from '../../entity/User';
|
||||
import { PaginatedResponse } from './common';
|
||||
|
||||
export interface MediaResultsResponse extends PaginatedResponse {
|
||||
results: Media[];
|
||||
}
|
||||
|
||||
export interface MediaWatchDataResponse {
|
||||
data?: {
|
||||
users: User[];
|
||||
playCount: number;
|
||||
playCount7Days: number;
|
||||
playCount30Days: number;
|
||||
};
|
||||
data4k?: {
|
||||
users: User[];
|
||||
playCount: number;
|
||||
playCount7Days: number;
|
||||
playCount30Days: number;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import type { PaginatedResponse } from './common';
|
||||
export type LogMessage = {
|
||||
timestamp: string;
|
||||
level: string;
|
||||
label: string;
|
||||
label?: string;
|
||||
message: string;
|
||||
data?: Record<string, unknown>;
|
||||
};
|
||||
@@ -17,6 +17,7 @@ export interface SettingsAboutResponse {
|
||||
totalRequests: number;
|
||||
totalMediaItems: number;
|
||||
tz?: string;
|
||||
appDataPath: string;
|
||||
}
|
||||
|
||||
export interface PublicSettingsResponse {
|
||||
@@ -35,6 +36,7 @@ export interface PublicSettingsResponse {
|
||||
enablePushRegistration: boolean;
|
||||
locale: string;
|
||||
emailEnabled: boolean;
|
||||
newPlexLogin: boolean;
|
||||
}
|
||||
|
||||
export interface CacheItem {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import Media from '../../entity/Media';
|
||||
import { MediaRequest } from '../../entity/MediaRequest';
|
||||
import type { User } from '../../entity/User';
|
||||
import { PaginatedResponse } from './common';
|
||||
@@ -22,3 +23,7 @@ export interface QuotaResponse {
|
||||
movie: QuotaStatus;
|
||||
tv: QuotaStatus;
|
||||
}
|
||||
export interface UserWatchDataResponse {
|
||||
recentlyWatched: Media[];
|
||||
playCount: number;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import { NotificationAgentKey } from '../../lib/settings';
|
||||
|
||||
export interface UserSettingsGeneralResponse {
|
||||
username?: string;
|
||||
discordId?: string;
|
||||
locale?: string;
|
||||
region?: string;
|
||||
originalLanguage?: string;
|
||||
@@ -22,6 +23,9 @@ export interface UserSettingsNotificationsResponse {
|
||||
discordEnabled?: boolean;
|
||||
discordEnabledTypes?: number;
|
||||
discordId?: string;
|
||||
pushbulletAccessToken?: string;
|
||||
pushoverApplicationToken?: string;
|
||||
pushoverUserKey?: string;
|
||||
telegramEnabled?: boolean;
|
||||
telegramBotUsername?: string;
|
||||
telegramChatId?: string;
|
||||
|
||||
@@ -40,7 +40,7 @@ class Cache {
|
||||
|
||||
class CacheManager {
|
||||
private availableCaches: Record<AvailableCacheIds, Cache> = {
|
||||
tmdb: new Cache('tmdb', 'TMDb API', {
|
||||
tmdb: new Cache('tmdb', 'The Movie Database API', {
|
||||
stdTtl: 21600,
|
||||
checkPeriod: 60 * 30,
|
||||
}),
|
||||
@@ -54,7 +54,7 @@ class CacheManager {
|
||||
stdTtl: 21600,
|
||||
checkPeriod: 60 * 30,
|
||||
}),
|
||||
plexguid: new Cache('plexguid', 'Plex GUID Cache', {
|
||||
plexguid: new Cache('plexguid', 'Plex GUID', {
|
||||
stdTtl: 86400 * 7, // 1 week cache
|
||||
checkPeriod: 60 * 30,
|
||||
}),
|
||||
|
||||
@@ -76,23 +76,32 @@ class DownloadTracker {
|
||||
url: RadarrAPI.buildUrl(server, '/api/v3'),
|
||||
});
|
||||
|
||||
const queueItems = await radarr.getQueue();
|
||||
try {
|
||||
const queueItems = await radarr.getQueue();
|
||||
|
||||
this.radarrServers[server.id] = queueItems.map((item) => ({
|
||||
externalId: item.movieId,
|
||||
estimatedCompletionTime: new Date(item.estimatedCompletionTime),
|
||||
mediaType: MediaType.MOVIE,
|
||||
size: item.size,
|
||||
sizeLeft: item.sizeleft,
|
||||
status: item.status,
|
||||
timeLeft: item.timeleft,
|
||||
title: item.title,
|
||||
}));
|
||||
this.radarrServers[server.id] = queueItems.map((item) => ({
|
||||
externalId: item.movieId,
|
||||
estimatedCompletionTime: new Date(item.estimatedCompletionTime),
|
||||
mediaType: MediaType.MOVIE,
|
||||
size: item.size,
|
||||
sizeLeft: item.sizeleft,
|
||||
status: item.status,
|
||||
timeLeft: item.timeleft,
|
||||
title: item.title,
|
||||
}));
|
||||
|
||||
if (queueItems.length > 0) {
|
||||
logger.debug(
|
||||
`Found ${queueItems.length} item(s) in progress on Radarr server: ${server.name}`,
|
||||
{ label: 'Download Tracker' }
|
||||
if (queueItems.length > 0) {
|
||||
logger.debug(
|
||||
`Found ${queueItems.length} item(s) in progress on Radarr server: ${server.name}`,
|
||||
{ label: 'Download Tracker' }
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
logger.error(
|
||||
`Unable to get queue from Radarr server: ${server.name}`,
|
||||
{
|
||||
label: 'Download Tracker',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,42 +143,51 @@ class DownloadTracker {
|
||||
);
|
||||
});
|
||||
|
||||
// Load downloads from Radarr servers
|
||||
// Load downloads from Sonarr servers
|
||||
Promise.all(
|
||||
filteredServers.map(async (server) => {
|
||||
if (server.syncEnabled) {
|
||||
const radarr = new SonarrAPI({
|
||||
const sonarr = new SonarrAPI({
|
||||
apiKey: server.apiKey,
|
||||
url: SonarrAPI.buildUrl(server, '/api/v3'),
|
||||
});
|
||||
|
||||
const queueItems = await radarr.getQueue();
|
||||
try {
|
||||
const queueItems = await sonarr.getQueue();
|
||||
|
||||
this.sonarrServers[server.id] = queueItems.map((item) => ({
|
||||
externalId: item.seriesId,
|
||||
estimatedCompletionTime: new Date(item.estimatedCompletionTime),
|
||||
mediaType: MediaType.TV,
|
||||
size: item.size,
|
||||
sizeLeft: item.sizeleft,
|
||||
status: item.status,
|
||||
timeLeft: item.timeleft,
|
||||
title: item.title,
|
||||
}));
|
||||
this.sonarrServers[server.id] = queueItems.map((item) => ({
|
||||
externalId: item.seriesId,
|
||||
estimatedCompletionTime: new Date(item.estimatedCompletionTime),
|
||||
mediaType: MediaType.TV,
|
||||
size: item.size,
|
||||
sizeLeft: item.sizeleft,
|
||||
status: item.status,
|
||||
timeLeft: item.timeleft,
|
||||
title: item.title,
|
||||
}));
|
||||
|
||||
if (queueItems.length > 0) {
|
||||
logger.debug(
|
||||
`Found ${queueItems.length} item(s) in progress on Sonarr server: ${server.name}`,
|
||||
{ label: 'Download Tracker' }
|
||||
if (queueItems.length > 0) {
|
||||
logger.debug(
|
||||
`Found ${queueItems.length} item(s) in progress on Sonarr server: ${server.name}`,
|
||||
{ label: 'Download Tracker' }
|
||||
);
|
||||
}
|
||||
} catch {
|
||||
logger.error(
|
||||
`Unable to get queue from Sonarr server: ${server.name}`,
|
||||
{
|
||||
label: 'Download Tracker',
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Duplicate this data to matching servers
|
||||
const matchingServers = settings.sonarr.filter(
|
||||
(rs) =>
|
||||
rs.hostname === server.hostname &&
|
||||
rs.port === server.port &&
|
||||
rs.baseUrl === server.baseUrl &&
|
||||
rs.id !== server.id
|
||||
(ss) =>
|
||||
ss.hostname === server.hostname &&
|
||||
ss.port === server.port &&
|
||||
ss.baseUrl === server.baseUrl &&
|
||||
ss.id !== server.id
|
||||
);
|
||||
|
||||
if (matchingServers.length > 0) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { randomBytes } from 'crypto';
|
||||
import * as openpgp from 'openpgp';
|
||||
import { Transform, TransformCallback } from 'stream';
|
||||
import logger from '../../logger';
|
||||
|
||||
interface EncryptorOptions {
|
||||
signingKey?: string;
|
||||
@@ -36,132 +37,149 @@ class PGPEncryptor extends Transform {
|
||||
|
||||
// Actually do stuff
|
||||
_flush = async (callback: TransformCallback): Promise<void> => {
|
||||
// Reconstruct message as buffer
|
||||
const message = Buffer.concat(this._messageChunks, this._messageLength);
|
||||
const validPublicKeys = await Promise.all(
|
||||
this._encryptionKeys.map((armoredKey) => openpgp.readKey({ armoredKey }))
|
||||
);
|
||||
let privateKey: openpgp.PrivateKey | undefined;
|
||||
|
||||
// Just return the message if there is no one to encrypt for
|
||||
if (!validPublicKeys.length) {
|
||||
this.push(message);
|
||||
return callback();
|
||||
}
|
||||
try {
|
||||
// Reconstruct message as buffer
|
||||
const validPublicKeys = await Promise.all(
|
||||
this._encryptionKeys.map((armoredKey) =>
|
||||
openpgp.readKey({ armoredKey })
|
||||
)
|
||||
);
|
||||
let privateKey: openpgp.PrivateKey | undefined;
|
||||
|
||||
// Only sign the message if private key and password exist
|
||||
if (this._signingKey && this._password) {
|
||||
privateKey = await openpgp.readPrivateKey({
|
||||
armoredKey: this._signingKey,
|
||||
// Just return the message if there is no one to encrypt for
|
||||
if (!validPublicKeys.length) {
|
||||
this.push(message);
|
||||
return callback();
|
||||
}
|
||||
|
||||
// Only sign the message if private key and password exist
|
||||
if (this._signingKey && this._password) {
|
||||
privateKey = await openpgp.decryptKey({
|
||||
privateKey: await openpgp.readPrivateKey({
|
||||
armoredKey: this._signingKey,
|
||||
}),
|
||||
passphrase: this._password,
|
||||
});
|
||||
}
|
||||
|
||||
const emailPartDelimiter = '\r\n\r\n';
|
||||
const messageParts = message.toString().split(emailPartDelimiter);
|
||||
|
||||
/**
|
||||
* In this loop original headers are split up into two parts,
|
||||
* one for the email that is sent
|
||||
* and one for the encrypted content
|
||||
*/
|
||||
const header = messageParts.shift() as string;
|
||||
const emailHeaders: string[][] = [];
|
||||
const contentHeaders: string[][] = [];
|
||||
const linesInHeader = header.split('\r\n');
|
||||
let previousHeader: string[] = [];
|
||||
for (let i = 0; i < linesInHeader.length; i++) {
|
||||
const line = linesInHeader[i];
|
||||
/**
|
||||
* If it is a multi-line header (current line starts with whitespace)
|
||||
* or it's the first line in the iteration
|
||||
* add the current line with previous header and move on
|
||||
*/
|
||||
if (/^\s/.test(line) || i === 0) {
|
||||
previousHeader.push(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is done to prevent the last header
|
||||
* from being missed
|
||||
*/
|
||||
if (i === linesInHeader.length - 1) {
|
||||
previousHeader.push(line);
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to seperate the actual content headers
|
||||
* so that we can add it as a header for the encrypted content
|
||||
* So that the content will be displayed properly after decryption
|
||||
*/
|
||||
if (
|
||||
/^(content-type|content-transfer-encoding):/i.test(previousHeader[0])
|
||||
) {
|
||||
contentHeaders.push(previousHeader);
|
||||
} else {
|
||||
emailHeaders.push(previousHeader);
|
||||
}
|
||||
previousHeader = [line];
|
||||
}
|
||||
|
||||
// Generate a new boundary for the email content
|
||||
const boundary = 'nm_' + randomBytes(14).toString('hex');
|
||||
/**
|
||||
* Concatenate everything into single strings
|
||||
* and add pgp headers to the email headers
|
||||
*/
|
||||
const emailHeadersRaw =
|
||||
emailHeaders.map((line) => line.join('\r\n')).join('\r\n') +
|
||||
'\r\n' +
|
||||
'Content-Type: multipart/encrypted; protocol="application/pgp-encrypted";' +
|
||||
'\r\n' +
|
||||
' boundary="' +
|
||||
boundary +
|
||||
'"' +
|
||||
'\r\n' +
|
||||
'Content-Description: OpenPGP encrypted message' +
|
||||
'\r\n' +
|
||||
'Content-Transfer-Encoding: 7bit';
|
||||
const contentHeadersRaw = contentHeaders
|
||||
.map((line) => line.join('\r\n'))
|
||||
.join('\r\n');
|
||||
|
||||
const encryptedMessage = await openpgp.encrypt({
|
||||
message: await openpgp.createMessage({
|
||||
text:
|
||||
contentHeadersRaw +
|
||||
emailPartDelimiter +
|
||||
messageParts.join(emailPartDelimiter),
|
||||
}),
|
||||
encryptionKeys: validPublicKeys,
|
||||
signingKeys: privateKey,
|
||||
});
|
||||
|
||||
await openpgp.decryptKey({ privateKey, passphrase: this._password });
|
||||
const body =
|
||||
'--' +
|
||||
boundary +
|
||||
'\r\n' +
|
||||
'Content-Type: application/pgp-encrypted\r\n' +
|
||||
'Content-Transfer-Encoding: 7bit\r\n' +
|
||||
'\r\n' +
|
||||
'Version: 1\r\n' +
|
||||
'\r\n' +
|
||||
'--' +
|
||||
boundary +
|
||||
'\r\n' +
|
||||
'Content-Type: application/octet-stream; name=encrypted.asc\r\n' +
|
||||
'Content-Disposition: inline; filename=encrypted.asc\r\n' +
|
||||
'Content-Transfer-Encoding: 7bit\r\n' +
|
||||
'\r\n' +
|
||||
encryptedMessage +
|
||||
'\r\n--' +
|
||||
boundary +
|
||||
'--\r\n';
|
||||
|
||||
this.push(Buffer.from(emailHeadersRaw + emailPartDelimiter + body));
|
||||
callback();
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
'Something went wrong while encrypting email message with OpenPGP. Sending email without encryption',
|
||||
{
|
||||
label: 'Notifications',
|
||||
errorMessage: e.message,
|
||||
}
|
||||
);
|
||||
|
||||
this.push(message);
|
||||
callback();
|
||||
}
|
||||
|
||||
const emailPartDelimiter = '\r\n\r\n';
|
||||
const messageParts = message.toString().split(emailPartDelimiter);
|
||||
|
||||
/**
|
||||
* In this loop original headers are split up into two parts,
|
||||
* one for the email that is sent
|
||||
* and one for the encrypted content
|
||||
*/
|
||||
const header = messageParts.shift() as string;
|
||||
const emailHeaders: string[][] = [];
|
||||
const contentHeaders: string[][] = [];
|
||||
const linesInHeader = header.split('\r\n');
|
||||
let previousHeader: string[] = [];
|
||||
for (let i = 0; i < linesInHeader.length; i++) {
|
||||
const line = linesInHeader[i];
|
||||
/**
|
||||
* If it is a multi-line header (current line starts with whitespace)
|
||||
* or it's the first line in the iteration
|
||||
* add the current line with previous header and move on
|
||||
*/
|
||||
if (/^\s/.test(line) || i === 0) {
|
||||
previousHeader.push(line);
|
||||
continue;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is done to prevent the last header
|
||||
* from being missed
|
||||
*/
|
||||
if (i === linesInHeader.length - 1) {
|
||||
previousHeader.push(line);
|
||||
}
|
||||
|
||||
/**
|
||||
* We need to seperate the actual content headers
|
||||
* so that we can add it as a header for the encrypted content
|
||||
* So that the content will be displayed properly after decryption
|
||||
*/
|
||||
if (
|
||||
/^(content-type|content-transfer-encoding):/i.test(previousHeader[0])
|
||||
) {
|
||||
contentHeaders.push(previousHeader);
|
||||
} else {
|
||||
emailHeaders.push(previousHeader);
|
||||
}
|
||||
previousHeader = [line];
|
||||
}
|
||||
|
||||
// Generate a new boundary for the email content
|
||||
const boundary = 'nm_' + randomBytes(14).toString('hex');
|
||||
/**
|
||||
* Concatenate everything into single strings
|
||||
* and add pgp headers to the email headers
|
||||
*/
|
||||
const emailHeadersRaw =
|
||||
emailHeaders.map((line) => line.join('\r\n')).join('\r\n') +
|
||||
'\r\n' +
|
||||
'Content-Type: multipart/encrypted; protocol="application/pgp-encrypted";' +
|
||||
'\r\n' +
|
||||
' boundary="' +
|
||||
boundary +
|
||||
'"' +
|
||||
'\r\n' +
|
||||
'Content-Description: OpenPGP encrypted message' +
|
||||
'\r\n' +
|
||||
'Content-Transfer-Encoding: 7bit';
|
||||
const contentHeadersRaw = contentHeaders
|
||||
.map((line) => line.join('\r\n'))
|
||||
.join('\r\n');
|
||||
|
||||
const encryptedMessage = await openpgp.encrypt({
|
||||
message: await openpgp.createMessage({
|
||||
text:
|
||||
contentHeadersRaw +
|
||||
emailPartDelimiter +
|
||||
messageParts.join(emailPartDelimiter),
|
||||
}),
|
||||
encryptionKeys: validPublicKeys,
|
||||
signingKeys: privateKey,
|
||||
});
|
||||
|
||||
const body =
|
||||
'--' +
|
||||
boundary +
|
||||
'\r\n' +
|
||||
'Content-Type: application/pgp-encrypted\r\n' +
|
||||
'Content-Transfer-Encoding: 7bit\r\n' +
|
||||
'\r\n' +
|
||||
'Version: 1\r\n' +
|
||||
'\r\n' +
|
||||
'--' +
|
||||
boundary +
|
||||
'\r\n' +
|
||||
'Content-Type: application/octet-stream; name=encrypted.asc\r\n' +
|
||||
'Content-Disposition: inline; filename=encrypted.asc\r\n' +
|
||||
'Content-Transfer-Encoding: 7bit\r\n' +
|
||||
'\r\n' +
|
||||
encryptedMessage +
|
||||
'\r\n--' +
|
||||
boundary +
|
||||
'--\r\n';
|
||||
|
||||
this.push(Buffer.from(emailHeadersRaw + emailPartDelimiter + body));
|
||||
callback();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,23 @@
|
||||
import { Notification } from '..';
|
||||
import type Issue from '../../../entity/Issue';
|
||||
import IssueComment from '../../../entity/IssueComment';
|
||||
import Media from '../../../entity/Media';
|
||||
import { MediaRequest } from '../../../entity/MediaRequest';
|
||||
import { User } from '../../../entity/User';
|
||||
import { NotificationAgentConfig } from '../../settings';
|
||||
|
||||
export interface NotificationPayload {
|
||||
event?: string;
|
||||
subject: string;
|
||||
notifyAdmin: boolean;
|
||||
notifyUser?: User;
|
||||
media?: Media;
|
||||
image?: string;
|
||||
message?: string;
|
||||
extra?: { name: string; value: string }[];
|
||||
request?: MediaRequest;
|
||||
issue?: Issue;
|
||||
comment?: IssueComment;
|
||||
}
|
||||
|
||||
export abstract class BaseAgent<T extends NotificationAgentConfig> {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import axios from 'axios';
|
||||
import { getRepository } from 'typeorm';
|
||||
import { hasNotificationType, Notification } from '..';
|
||||
import {
|
||||
hasNotificationType,
|
||||
Notification,
|
||||
shouldSendAdminNotification,
|
||||
} from '..';
|
||||
import { IssueStatus, IssueTypeName } from '../../../constants/issue';
|
||||
import { User } from '../../../entity/User';
|
||||
import logger from '../../../logger';
|
||||
import { Permission } from '../../permissions';
|
||||
import {
|
||||
getSettings,
|
||||
NotificationAgentDiscord,
|
||||
@@ -107,9 +111,9 @@ class DiscordAgent
|
||||
type: Notification,
|
||||
payload: NotificationPayload
|
||||
): DiscordRichEmbed {
|
||||
const settings = getSettings();
|
||||
let color = EmbedColors.DARK_PURPLE;
|
||||
const { applicationUrl } = getSettings().main;
|
||||
|
||||
let color = EmbedColors.DARK_PURPLE;
|
||||
const fields: Field[] = [];
|
||||
|
||||
if (payload.request) {
|
||||
@@ -118,56 +122,94 @@ class DiscordAgent
|
||||
value: payload.request.requestedBy.displayName,
|
||||
inline: true,
|
||||
});
|
||||
|
||||
let status = '';
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
color = EmbedColors.ORANGE;
|
||||
status = 'Pending Approval';
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
color = EmbedColors.PURPLE;
|
||||
status = 'Processing';
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
color = EmbedColors.GREEN;
|
||||
status = 'Available';
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
color = EmbedColors.RED;
|
||||
status = 'Declined';
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
color = EmbedColors.RED;
|
||||
status = 'Failed';
|
||||
break;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
fields.push({
|
||||
name: 'Request Status',
|
||||
value: status,
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
} else if (payload.comment) {
|
||||
fields.push({
|
||||
name: `Comment from ${payload.comment.user.displayName}`,
|
||||
value: payload.comment.message,
|
||||
inline: false,
|
||||
});
|
||||
} else if (payload.issue) {
|
||||
fields.push(
|
||||
{
|
||||
name: 'Reported By',
|
||||
value: payload.issue.createdBy.displayName,
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Issue Type',
|
||||
value: IssueTypeName[payload.issue.issueType],
|
||||
inline: true,
|
||||
},
|
||||
{
|
||||
name: 'Issue Status',
|
||||
value:
|
||||
payload.issue.status === IssueStatus.OPEN ? 'Open' : 'Resolved',
|
||||
inline: true,
|
||||
}
|
||||
);
|
||||
|
||||
switch (type) {
|
||||
case Notification.ISSUE_CREATED:
|
||||
case Notification.ISSUE_REOPENED:
|
||||
color = EmbedColors.RED;
|
||||
break;
|
||||
case Notification.ISSUE_COMMENT:
|
||||
color = EmbedColors.ORANGE;
|
||||
break;
|
||||
case Notification.ISSUE_RESOLVED:
|
||||
color = EmbedColors.GREEN;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
color = EmbedColors.ORANGE;
|
||||
fields.push({
|
||||
name: 'Status',
|
||||
value: 'Pending Approval',
|
||||
inline: true,
|
||||
});
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
color = EmbedColors.PURPLE;
|
||||
fields.push({
|
||||
name: 'Status',
|
||||
value: 'Processing',
|
||||
inline: true,
|
||||
});
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
color = EmbedColors.GREEN;
|
||||
fields.push({
|
||||
name: 'Status',
|
||||
value: 'Available',
|
||||
inline: true,
|
||||
});
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
color = EmbedColors.RED;
|
||||
fields.push({
|
||||
name: 'Status',
|
||||
value: 'Declined',
|
||||
inline: true,
|
||||
});
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
color = EmbedColors.RED;
|
||||
fields.push({
|
||||
name: 'Status',
|
||||
value: 'Failed',
|
||||
inline: true,
|
||||
});
|
||||
break;
|
||||
for (const extra of payload.extra ?? []) {
|
||||
fields.push({
|
||||
name: extra.name,
|
||||
value: extra.value,
|
||||
inline: true,
|
||||
});
|
||||
}
|
||||
|
||||
const url =
|
||||
settings.main.applicationUrl && payload.media
|
||||
? `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`
|
||||
: undefined;
|
||||
const url = applicationUrl
|
||||
? payload.issue
|
||||
? `${applicationUrl}/issues/${payload.issue.id}`
|
||||
: payload.media
|
||||
? `${applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`
|
||||
: undefined
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
title: payload.subject,
|
||||
@@ -175,18 +217,12 @@ class DiscordAgent
|
||||
description: payload.message,
|
||||
color,
|
||||
timestamp: new Date().toISOString(),
|
||||
author: {
|
||||
name: settings.main.applicationTitle,
|
||||
url: settings.main.applicationUrl,
|
||||
},
|
||||
fields: [
|
||||
...fields,
|
||||
// If we have extra data, map it to fields for discord notifications
|
||||
...(payload.extra ?? []).map((extra) => ({
|
||||
name: extra.name,
|
||||
value: extra.value,
|
||||
})),
|
||||
],
|
||||
author: payload.event
|
||||
? {
|
||||
name: payload.event,
|
||||
}
|
||||
: undefined,
|
||||
fields,
|
||||
thumbnail: {
|
||||
url: payload.image,
|
||||
},
|
||||
@@ -219,54 +255,55 @@ class DiscordAgent
|
||||
subject: payload.subject,
|
||||
});
|
||||
|
||||
let content = undefined;
|
||||
const userMentions: string[] = [];
|
||||
|
||||
try {
|
||||
if (payload.notifyUser) {
|
||||
// Mention user who submitted the request
|
||||
if (
|
||||
payload.notifyUser.settings?.hasNotificationType(
|
||||
NotificationAgentKey.DISCORD,
|
||||
type
|
||||
) &&
|
||||
payload.notifyUser.settings?.discordId
|
||||
) {
|
||||
content = `<@${payload.notifyUser.settings.discordId}>`;
|
||||
if (settings.options.enableMentions) {
|
||||
if (payload.notifyUser) {
|
||||
if (
|
||||
payload.notifyUser.settings?.hasNotificationType(
|
||||
NotificationAgentKey.DISCORD,
|
||||
type
|
||||
) &&
|
||||
payload.notifyUser.settings.discordId
|
||||
) {
|
||||
userMentions.push(`<@${payload.notifyUser.settings.discordId}>`);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Mention all users with the Manage Requests permission
|
||||
const userRepository = getRepository(User);
|
||||
const users = await userRepository.find();
|
||||
|
||||
content = users
|
||||
.filter(
|
||||
(user) =>
|
||||
user.hasPermission(Permission.MANAGE_REQUESTS) &&
|
||||
user.settings?.hasNotificationType(
|
||||
NotificationAgentKey.DISCORD,
|
||||
type
|
||||
) &&
|
||||
user.settings?.discordId &&
|
||||
// Check if it's the user's own auto-approved request
|
||||
(type !== Notification.MEDIA_AUTO_APPROVED ||
|
||||
user.id !== payload.request?.requestedBy.id)
|
||||
)
|
||||
.map((user) => `<@${user.settings?.discordId}>`)
|
||||
.join(' ');
|
||||
if (payload.notifyAdmin) {
|
||||
const userRepository = getRepository(User);
|
||||
const users = await userRepository.find();
|
||||
|
||||
userMentions.push(
|
||||
...users
|
||||
.filter(
|
||||
(user) =>
|
||||
user.settings?.hasNotificationType(
|
||||
NotificationAgentKey.DISCORD,
|
||||
type
|
||||
) &&
|
||||
user.settings.discordId &&
|
||||
shouldSendAdminNotification(type, user, payload)
|
||||
)
|
||||
.map((user) => `<@${user.settings?.discordId}>`)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
await axios.post(settings.options.webhookUrl, {
|
||||
username: settings.options.botUsername,
|
||||
username: settings.options.botUsername
|
||||
? settings.options.botUsername
|
||||
: getSettings().main.applicationTitle,
|
||||
avatar_url: settings.options.botAvatarUrl,
|
||||
embeds: [this.buildEmbed(type, payload)],
|
||||
content,
|
||||
content: userMentions.join(' '),
|
||||
} as DiscordWebhookPayload);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
logger.error('Error sending Discord notification', {
|
||||
label: 'Notifications',
|
||||
mentions: content,
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { EmailOptions } from 'email-templates';
|
||||
import path from 'path';
|
||||
import { getRepository } from 'typeorm';
|
||||
import { Notification } from '..';
|
||||
import { Notification, shouldSendAdminNotification } from '..';
|
||||
import { IssueType, IssueTypeName } from '../../../constants/issue';
|
||||
import { MediaType } from '../../../constants/media';
|
||||
import { User } from '../../../entity/User';
|
||||
import logger from '../../../logger';
|
||||
import PreparedEmail from '../../email';
|
||||
import { Permission } from '../../permissions';
|
||||
import {
|
||||
getSettings,
|
||||
NotificationAgentEmail,
|
||||
@@ -67,59 +67,47 @@ class EmailAgent
|
||||
};
|
||||
}
|
||||
|
||||
if (payload.media) {
|
||||
let requestType = '';
|
||||
const mediaType = payload.media
|
||||
? payload.media.mediaType === MediaType.MOVIE
|
||||
? 'movie'
|
||||
: 'series'
|
||||
: undefined;
|
||||
const is4k = payload.request?.is4k;
|
||||
|
||||
if (payload.request) {
|
||||
let body = '';
|
||||
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
requestType = `New ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request`;
|
||||
body = `A user has requested a new ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||
}!`;
|
||||
body = `A new request for the following ${mediaType} ${
|
||||
is4k ? 'in 4K ' : ''
|
||||
}is pending approval:`;
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
requestType = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Approved`;
|
||||
body = `Your request for the following ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||
} has been approved:`;
|
||||
body = `Your request for the following ${mediaType} ${
|
||||
is4k ? 'in 4K ' : ''
|
||||
}has been approved:`;
|
||||
break;
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
requestType = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Automatically Approved`;
|
||||
body = `A new request for the following ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||
} has been automatically approved:`;
|
||||
body = `A new request for the following ${mediaType} ${
|
||||
is4k ? 'in 4K ' : ''
|
||||
}has been automatically approved:`;
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
requestType = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Now Available`;
|
||||
body = `The following ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||
} you requested is now available!`;
|
||||
body = `Your request for the following ${mediaType} ${
|
||||
is4k ? 'in 4K ' : ''
|
||||
}is now available:`;
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
requestType = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Declined`;
|
||||
body = `Your request for the following ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||
} was declined:`;
|
||||
body = `Your request for the following ${mediaType} ${
|
||||
is4k ? 'in 4K ' : ''
|
||||
}was declined:`;
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
requestType = `Failed ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request`;
|
||||
body = `A new request for the following ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'series' : 'movie'
|
||||
} could not be added to ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Sonarr' : 'Radarr'
|
||||
body = `A request for the following ${mediaType} ${
|
||||
is4k ? 'in 4K ' : ''
|
||||
}failed to be added to ${
|
||||
payload.media?.mediaType === MediaType.MOVIE ? 'Radarr' : 'Sonarr'
|
||||
}:`;
|
||||
break;
|
||||
}
|
||||
@@ -133,14 +121,13 @@ class EmailAgent
|
||||
to: recipientEmail,
|
||||
},
|
||||
locals: {
|
||||
requestType,
|
||||
event: payload.event,
|
||||
body,
|
||||
mediaName: payload.subject,
|
||||
mediaPlot: payload.message,
|
||||
mediaExtra: payload.extra ?? [],
|
||||
imageUrl: payload.image,
|
||||
timestamp: new Date().toTimeString(),
|
||||
requestedBy: payload.request?.requestedBy.displayName,
|
||||
requestedBy: payload.request.requestedBy.displayName,
|
||||
actionUrl: applicationUrl
|
||||
? `${applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`
|
||||
: undefined,
|
||||
@@ -150,6 +137,52 @@ class EmailAgent
|
||||
recipientEmail,
|
||||
},
|
||||
};
|
||||
} else if (payload.issue) {
|
||||
const issueType =
|
||||
payload.issue && payload.issue.issueType !== IssueType.OTHER
|
||||
? `${IssueTypeName[payload.issue.issueType].toLowerCase()} issue`
|
||||
: 'issue';
|
||||
|
||||
let body = '';
|
||||
|
||||
switch (type) {
|
||||
case Notification.ISSUE_CREATED:
|
||||
body = `A new ${issueType} has been reported by ${payload.issue.createdBy.displayName} for the ${mediaType} ${payload.subject}:`;
|
||||
break;
|
||||
case Notification.ISSUE_COMMENT:
|
||||
body = `${payload.comment?.user.displayName} commented on the ${issueType} for the ${mediaType} ${payload.subject}:`;
|
||||
break;
|
||||
case Notification.ISSUE_RESOLVED:
|
||||
body = `The ${issueType} for the ${mediaType} ${payload.subject} was marked as resolved by ${payload.issue.modifiedBy?.displayName}!`;
|
||||
break;
|
||||
case Notification.ISSUE_REOPENED:
|
||||
body = `The ${issueType} for the ${mediaType} ${payload.subject} was reopened by ${payload.issue.modifiedBy?.displayName}.`;
|
||||
break;
|
||||
}
|
||||
|
||||
return {
|
||||
template: path.join(__dirname, '../../../templates/email/media-issue'),
|
||||
message: {
|
||||
to: recipientEmail,
|
||||
},
|
||||
locals: {
|
||||
event: payload.event,
|
||||
body,
|
||||
issueDescription: payload.message,
|
||||
issueComment: payload.comment?.message,
|
||||
mediaName: payload.subject,
|
||||
extra: payload.extra ?? [],
|
||||
imageUrl: payload.image,
|
||||
timestamp: new Date().toTimeString(),
|
||||
actionUrl: applicationUrl
|
||||
? `${applicationUrl}/issues/${payload.issue.id}`
|
||||
: undefined,
|
||||
applicationUrl,
|
||||
applicationTitle,
|
||||
recipientName,
|
||||
recipientEmail,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
@@ -160,7 +193,6 @@ class EmailAgent
|
||||
payload: NotificationPayload
|
||||
): Promise<boolean> {
|
||||
if (payload.notifyUser) {
|
||||
// Send notification to the user who submitted the request
|
||||
if (
|
||||
!payload.notifyUser.settings ||
|
||||
// Check if user has email notifications enabled and fallback to true if undefined
|
||||
@@ -203,8 +235,9 @@ class EmailAgent
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Send notifications to all users with the Manage Requests permission
|
||||
}
|
||||
|
||||
if (payload.notifyAdmin) {
|
||||
const userRepository = getRepository(User);
|
||||
const users = await userRepository.find();
|
||||
|
||||
@@ -212,7 +245,6 @@ class EmailAgent
|
||||
users
|
||||
.filter(
|
||||
(user) =>
|
||||
user.hasPermission(Permission.MANAGE_REQUESTS) &&
|
||||
(!user.settings ||
|
||||
// Check if user has email notifications enabled and fallback to true if undefined
|
||||
// since email should default to true
|
||||
@@ -221,9 +253,7 @@ class EmailAgent
|
||||
type
|
||||
) ??
|
||||
true)) &&
|
||||
// Check if it's the user's own auto-approved request
|
||||
(type !== Notification.MEDIA_AUTO_APPROVED ||
|
||||
user.id !== payload.request?.requestedBy.id)
|
||||
shouldSendAdminNotification(type, user, payload)
|
||||
)
|
||||
.map(async (user) => {
|
||||
logger.debug('Sending email notification', {
|
||||
|
||||
148
server/lib/notifications/agents/gotify.ts
Normal file
148
server/lib/notifications/agents/gotify.ts
Normal file
@@ -0,0 +1,148 @@
|
||||
import axios from 'axios';
|
||||
import { hasNotificationType, Notification } from '..';
|
||||
import { IssueStatus, IssueTypeName } from '../../../constants/issue';
|
||||
import logger from '../../../logger';
|
||||
import { getSettings, NotificationAgentGotify } from '../../settings';
|
||||
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
|
||||
|
||||
interface GotifyPayload {
|
||||
title: string;
|
||||
message: string;
|
||||
priority: number;
|
||||
extras: any;
|
||||
}
|
||||
|
||||
class GotifyAgent
|
||||
extends BaseAgent<NotificationAgentGotify>
|
||||
implements NotificationAgent
|
||||
{
|
||||
protected getSettings(): NotificationAgentGotify {
|
||||
if (this.settings) {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
const settings = getSettings();
|
||||
|
||||
return settings.notifications.agents.gotify;
|
||||
}
|
||||
|
||||
public shouldSend(): boolean {
|
||||
const settings = this.getSettings();
|
||||
|
||||
if (settings.enabled && settings.options.url && settings.options.token) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private getNotificationPayload(
|
||||
type: Notification,
|
||||
payload: NotificationPayload
|
||||
): GotifyPayload {
|
||||
const { applicationUrl, applicationTitle } = getSettings().main;
|
||||
let priority = 0;
|
||||
|
||||
const title = payload.event
|
||||
? `${payload.event} - ${payload.subject}`
|
||||
: payload.subject;
|
||||
let message = payload.message ?? '';
|
||||
|
||||
if (payload.request) {
|
||||
message += `\n\nRequested By: ${payload.request.requestedBy.displayName}`;
|
||||
|
||||
let status = '';
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
status = 'Pending Approval';
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
status = 'Processing';
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
status = 'Available';
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
status = 'Declined';
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
status = 'Failed';
|
||||
break;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
message += `\nRequest Status: ${status}`;
|
||||
}
|
||||
} else if (payload.comment) {
|
||||
message += `\nComment from ${payload.comment.user.displayName}:\n${payload.comment.message}`;
|
||||
} else if (payload.issue) {
|
||||
message += `\n\nReported By: ${payload.issue.createdBy.displayName}`;
|
||||
message += `\nIssue Type: ${IssueTypeName[payload.issue.issueType]}`;
|
||||
message += `\nIssue Status: ${
|
||||
payload.issue.status === IssueStatus.OPEN ? 'Open' : 'Resolved'
|
||||
}`;
|
||||
|
||||
if (type == Notification.ISSUE_CREATED) {
|
||||
priority = 1;
|
||||
}
|
||||
}
|
||||
|
||||
for (const extra of payload.extra ?? []) {
|
||||
message += `\n\n**${extra.name}**\n${extra.value}`;
|
||||
}
|
||||
|
||||
if (applicationUrl && payload.media) {
|
||||
const actionUrl = `${applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
|
||||
message += `\n\nOpen in ${applicationTitle}(${actionUrl})`;
|
||||
}
|
||||
|
||||
return {
|
||||
extras: {
|
||||
'client::display': {
|
||||
contentType: 'text/markdown',
|
||||
},
|
||||
},
|
||||
title,
|
||||
message,
|
||||
priority,
|
||||
};
|
||||
}
|
||||
|
||||
public async send(
|
||||
type: Notification,
|
||||
payload: NotificationPayload
|
||||
): Promise<boolean> {
|
||||
const settings = this.getSettings();
|
||||
|
||||
if (!hasNotificationType(type, settings.types ?? 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.debug('Sending Gotify notification', {
|
||||
label: 'Notifications',
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
});
|
||||
try {
|
||||
const endpoint = `${settings.options.url}/message?token=${settings.options.token}`;
|
||||
const notificationPayload = this.getNotificationPayload(type, payload);
|
||||
|
||||
await axios.post(endpoint, notificationPayload);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
logger.error('Error sending Gotify notification', {
|
||||
label: 'Notifications',
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
response: e.response?.data,
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default GotifyAgent;
|
||||
@@ -1,5 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import { hasNotificationType, Notification } from '..';
|
||||
import { IssueStatus, IssueType } from '../../../constants/issue';
|
||||
import { MediaStatus } from '../../../constants/media';
|
||||
import logger from '../../../logger';
|
||||
import { getSettings, NotificationAgentLunaSea } from '../../settings';
|
||||
@@ -22,17 +23,17 @@ class LunaSeaAgent
|
||||
private buildPayload(type: Notification, payload: NotificationPayload) {
|
||||
return {
|
||||
notification_type: Notification[type],
|
||||
event: payload.event,
|
||||
subject: payload.subject,
|
||||
message: payload.message,
|
||||
image: payload.image ?? null,
|
||||
email: payload.notifyUser?.email,
|
||||
username: payload.notifyUser?.username,
|
||||
username: payload.notifyUser?.displayName,
|
||||
avatar: payload.notifyUser?.avatar,
|
||||
media: payload.media
|
||||
? {
|
||||
media_type: payload.media.mediaType,
|
||||
tmdbId: payload.media.tmdbId,
|
||||
imdbId: payload.media.imdbId,
|
||||
tvdbId: payload.media.tvdbId,
|
||||
status: MediaStatus[payload.media.status],
|
||||
status4k: MediaStatus[payload.media.status4k],
|
||||
@@ -47,6 +48,24 @@ class LunaSeaAgent
|
||||
requestedBy_avatar: payload.request.requestedBy.avatar,
|
||||
}
|
||||
: null,
|
||||
issue: payload.issue
|
||||
? {
|
||||
issue_id: payload.issue.id,
|
||||
issue_type: IssueType[payload.issue.issueType],
|
||||
issue_status: IssueStatus[payload.issue.status],
|
||||
createdBy_email: payload.issue.createdBy.email,
|
||||
createdBy_username: payload.issue.createdBy.displayName,
|
||||
createdBy_avatar: payload.issue.createdBy.avatar,
|
||||
}
|
||||
: null,
|
||||
comment: payload.comment
|
||||
? {
|
||||
comment_message: payload.comment.message,
|
||||
commentedBy_email: payload.comment.user.email,
|
||||
commentedBy_username: payload.comment.user.displayName,
|
||||
commentedBy_avatar: payload.comment.user.avatar,
|
||||
}
|
||||
: null,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,25 @@
|
||||
import axios from 'axios';
|
||||
import { hasNotificationType, Notification } from '..';
|
||||
import { MediaType } from '../../../constants/media';
|
||||
import { getRepository } from 'typeorm';
|
||||
import {
|
||||
hasNotificationType,
|
||||
Notification,
|
||||
shouldSendAdminNotification,
|
||||
} from '..';
|
||||
import { IssueStatus, IssueTypeName } from '../../../constants/issue';
|
||||
import { User } from '../../../entity/User';
|
||||
import logger from '../../../logger';
|
||||
import { getSettings, NotificationAgentPushbullet } from '../../settings';
|
||||
import {
|
||||
getSettings,
|
||||
NotificationAgentKey,
|
||||
NotificationAgentPushbullet,
|
||||
} from '../../settings';
|
||||
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
|
||||
|
||||
interface PushbulletPayload {
|
||||
type: string;
|
||||
title: string;
|
||||
body: string;
|
||||
channel_tag?: string;
|
||||
}
|
||||
|
||||
class PushbulletAgent
|
||||
@@ -25,109 +37,62 @@ class PushbulletAgent
|
||||
}
|
||||
|
||||
public shouldSend(): boolean {
|
||||
const settings = this.getSettings();
|
||||
|
||||
if (settings.enabled && settings.options.accessToken) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private constructMessageDetails(
|
||||
private getNotificationPayload(
|
||||
type: Notification,
|
||||
payload: NotificationPayload
|
||||
): {
|
||||
title: string;
|
||||
body: string;
|
||||
} {
|
||||
let messageTitle = '';
|
||||
let message = '';
|
||||
): PushbulletPayload {
|
||||
const title = payload.event
|
||||
? `${payload.event} - ${payload.subject}`
|
||||
: payload.subject;
|
||||
let body = payload.message ?? '';
|
||||
|
||||
const title = payload.subject;
|
||||
const plot = payload.message;
|
||||
const username = payload.request?.requestedBy.displayName;
|
||||
if (payload.request) {
|
||||
body += `\n\nRequested By: ${payload.request.requestedBy.displayName}`;
|
||||
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
messageTitle = `New ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request`;
|
||||
message += `${title}`;
|
||||
if (plot) {
|
||||
message += `\n\n${plot}`;
|
||||
}
|
||||
message += `\n\nRequested By: ${username}`;
|
||||
message += `\nStatus: Pending Approval`;
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
messageTitle = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Approved`;
|
||||
message += `${title}`;
|
||||
if (plot) {
|
||||
message += `\n\n${plot}`;
|
||||
}
|
||||
message += `\n\nRequested By: ${username}`;
|
||||
message += `\nStatus: Processing`;
|
||||
break;
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
messageTitle = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Automatically Approved`;
|
||||
message += `${title}`;
|
||||
if (plot) {
|
||||
message += `\n\n${plot}`;
|
||||
}
|
||||
message += `\n\nRequested By: ${username}`;
|
||||
message += `\nStatus: Processing`;
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
messageTitle = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Now Available`;
|
||||
message += `${title}`;
|
||||
if (plot) {
|
||||
message += `\n\n${plot}`;
|
||||
}
|
||||
message += `\n\nRequested By: ${username}`;
|
||||
message += `\nStatus: Available`;
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
messageTitle = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Declined`;
|
||||
message += `${title}`;
|
||||
if (plot) {
|
||||
message += `\n\n${plot}`;
|
||||
}
|
||||
message += `\n\nRequested By: ${username}`;
|
||||
message += `\nStatus: Declined`;
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
messageTitle = `Failed ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request`;
|
||||
message += `${title}`;
|
||||
if (plot) {
|
||||
message += `\n\n${plot}`;
|
||||
}
|
||||
message += `\n\nRequested By: ${username}`;
|
||||
message += `\nStatus: Failed`;
|
||||
break;
|
||||
case Notification.TEST_NOTIFICATION:
|
||||
messageTitle = 'Test Notification';
|
||||
message += `${plot}`;
|
||||
break;
|
||||
let status = '';
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
status = 'Pending Approval';
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
status = 'Processing';
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
status = 'Available';
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
status = 'Declined';
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
status = 'Failed';
|
||||
break;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
body += `\nRequest Status: ${status}`;
|
||||
}
|
||||
} else if (payload.comment) {
|
||||
body += `\n\nComment from ${payload.comment.user.displayName}:\n${payload.comment.message}`;
|
||||
} else if (payload.issue) {
|
||||
body += `\n\nReported By: ${payload.issue.createdBy.displayName}`;
|
||||
body += `\nIssue Type: ${IssueTypeName[payload.issue.issueType]}`;
|
||||
body += `\nIssue Status: ${
|
||||
payload.issue.status === IssueStatus.OPEN ? 'Open' : 'Resolved'
|
||||
}`;
|
||||
}
|
||||
|
||||
for (const extra of payload.extra ?? []) {
|
||||
message += `\n${extra.name}: ${extra.value}`;
|
||||
body += `\n${extra.name}: ${extra.value}`;
|
||||
}
|
||||
|
||||
return {
|
||||
title: messageTitle,
|
||||
body: message,
|
||||
type: 'note',
|
||||
title,
|
||||
body,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -136,46 +101,133 @@ class PushbulletAgent
|
||||
payload: NotificationPayload
|
||||
): Promise<boolean> {
|
||||
const settings = this.getSettings();
|
||||
const endpoint = 'https://api.pushbullet.com/v2/pushes';
|
||||
const notificationPayload = this.getNotificationPayload(type, payload);
|
||||
|
||||
if (!hasNotificationType(type, settings.types ?? 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.debug('Sending Pushbullet notification', {
|
||||
label: 'Notifications',
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
});
|
||||
|
||||
try {
|
||||
const { title, body } = this.constructMessageDetails(type, payload);
|
||||
|
||||
await axios.post(
|
||||
'https://api.pushbullet.com/v2/pushes',
|
||||
{
|
||||
type: 'note',
|
||||
title: title,
|
||||
body: body,
|
||||
} as PushbulletPayload,
|
||||
{
|
||||
headers: {
|
||||
'Access-Token': settings.options.accessToken,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
logger.error('Error sending Pushbullet notification', {
|
||||
// Send system notification
|
||||
if (
|
||||
hasNotificationType(type, settings.types ?? 0) &&
|
||||
settings.enabled &&
|
||||
settings.options.accessToken
|
||||
) {
|
||||
logger.debug('Sending Pushbullet notification', {
|
||||
label: 'Notifications',
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
response: e.response?.data,
|
||||
});
|
||||
|
||||
return false;
|
||||
try {
|
||||
await axios.post(
|
||||
endpoint,
|
||||
{ ...notificationPayload, channel_tag: settings.options.channelTag },
|
||||
{
|
||||
headers: {
|
||||
'Access-Token': settings.options.accessToken,
|
||||
},
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
logger.error('Error sending Pushbullet notification', {
|
||||
label: 'Notifications',
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
response: e.response?.data,
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (payload.notifyUser) {
|
||||
if (
|
||||
payload.notifyUser.settings?.hasNotificationType(
|
||||
NotificationAgentKey.PUSHBULLET,
|
||||
type
|
||||
) &&
|
||||
payload.notifyUser.settings?.pushbulletAccessToken &&
|
||||
payload.notifyUser.settings.pushbulletAccessToken !==
|
||||
settings.options.accessToken
|
||||
) {
|
||||
logger.debug('Sending Pushbullet notification', {
|
||||
label: 'Notifications',
|
||||
recipient: payload.notifyUser.displayName,
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
});
|
||||
|
||||
try {
|
||||
await axios.post(endpoint, notificationPayload, {
|
||||
headers: {
|
||||
'Access-Token': payload.notifyUser.settings.pushbulletAccessToken,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error('Error sending Pushbullet notification', {
|
||||
label: 'Notifications',
|
||||
recipient: payload.notifyUser.displayName,
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
response: e.response?.data,
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (payload.notifyAdmin) {
|
||||
const userRepository = getRepository(User);
|
||||
const users = await userRepository.find();
|
||||
|
||||
await Promise.all(
|
||||
users
|
||||
.filter(
|
||||
(user) =>
|
||||
user.settings?.hasNotificationType(
|
||||
NotificationAgentKey.PUSHBULLET,
|
||||
type
|
||||
) && shouldSendAdminNotification(type, user, payload)
|
||||
)
|
||||
.map(async (user) => {
|
||||
if (
|
||||
user.settings?.pushbulletAccessToken &&
|
||||
(settings.options.channelTag ||
|
||||
user.settings.pushbulletAccessToken !==
|
||||
settings.options.accessToken)
|
||||
) {
|
||||
logger.debug('Sending Pushbullet notification', {
|
||||
label: 'Notifications',
|
||||
recipient: user.displayName,
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
});
|
||||
|
||||
try {
|
||||
await axios.post(endpoint, notificationPayload, {
|
||||
headers: {
|
||||
'Access-Token': user.settings.pushbulletAccessToken,
|
||||
},
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error('Error sending Pushbullet notification', {
|
||||
label: 'Notifications',
|
||||
recipient: user.displayName,
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
response: e.response?.data,
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
import axios from 'axios';
|
||||
import { hasNotificationType, Notification } from '..';
|
||||
import { MediaType } from '../../../constants/media';
|
||||
import { getRepository } from 'typeorm';
|
||||
import {
|
||||
hasNotificationType,
|
||||
Notification,
|
||||
shouldSendAdminNotification,
|
||||
} from '..';
|
||||
import { IssueStatus, IssueTypeName } from '../../../constants/issue';
|
||||
import { User } from '../../../entity/User';
|
||||
import logger from '../../../logger';
|
||||
import { getSettings, NotificationAgentPushover } from '../../settings';
|
||||
import {
|
||||
getSettings,
|
||||
NotificationAgentKey,
|
||||
NotificationAgentPushover,
|
||||
} from '../../settings';
|
||||
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
|
||||
|
||||
interface PushoverPayload {
|
||||
@@ -31,130 +41,89 @@ class PushoverAgent
|
||||
}
|
||||
|
||||
public shouldSend(): boolean {
|
||||
const settings = this.getSettings();
|
||||
|
||||
if (
|
||||
settings.enabled &&
|
||||
settings.options.accessToken &&
|
||||
settings.options.userToken
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private constructMessageDetails(
|
||||
private getNotificationPayload(
|
||||
type: Notification,
|
||||
payload: NotificationPayload
|
||||
): {
|
||||
title: string;
|
||||
message: string;
|
||||
url: string | undefined;
|
||||
url_title: string | undefined;
|
||||
priority: number;
|
||||
} {
|
||||
const settings = getSettings();
|
||||
let messageTitle = '';
|
||||
let message = '';
|
||||
let url: string | undefined;
|
||||
let url_title: string | undefined;
|
||||
): Partial<PushoverPayload> {
|
||||
const { applicationUrl, applicationTitle } = getSettings().main;
|
||||
|
||||
const title = payload.event ?? payload.subject;
|
||||
let message = payload.event ? `<b>${payload.subject}</b>` : '';
|
||||
let priority = 0;
|
||||
|
||||
const title = payload.subject;
|
||||
const plot = payload.message;
|
||||
const username = payload.request?.requestedBy.displayName;
|
||||
if (payload.message) {
|
||||
message += `<small>${message ? '\n' : ''}${payload.message}</small>`;
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
messageTitle = `New ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request`;
|
||||
message += `<b>${title}</b>`;
|
||||
if (plot) {
|
||||
message += `<small>\n${plot}</small>`;
|
||||
}
|
||||
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||
message += `<small>\n\n<b>Status</b>\nPending Approval</small>`;
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
messageTitle = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Approved`;
|
||||
message += `<b>${title}</b>`;
|
||||
if (plot) {
|
||||
message += `<small>\n${plot}</small>`;
|
||||
}
|
||||
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||
message += `<small>\n\n<b>Status</b>\nProcessing</small>`;
|
||||
break;
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
messageTitle = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Automatically Approved`;
|
||||
message += `<b>${title}</b>`;
|
||||
if (plot) {
|
||||
message += `<small>\n${plot}</small>`;
|
||||
}
|
||||
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||
message += `<small>\n\n<b>Status</b>\nProcessing</small>`;
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
messageTitle = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Now Available`;
|
||||
message += `<b>${title}</b>`;
|
||||
if (plot) {
|
||||
message += `<small>\n${plot}</small>`;
|
||||
}
|
||||
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||
message += `<small>\n\n<b>Status</b>\nAvailable</small>`;
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
messageTitle = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Declined`;
|
||||
message += `<b>${title}</b>`;
|
||||
if (plot) {
|
||||
message += `<small>\n${plot}</small>`;
|
||||
}
|
||||
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||
message += `<small>\n\n<b>Status</b>\nDeclined</small>`;
|
||||
if (payload.request) {
|
||||
message += `<small>\n\n<b>Requested By:</b> ${payload.request.requestedBy.displayName}</small>`;
|
||||
|
||||
let status = '';
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
status = 'Pending Approval';
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
status = 'Processing';
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
status = 'Available';
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
status = 'Declined';
|
||||
priority = 1;
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
status = 'Failed';
|
||||
priority = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
message += `<small>\n<b>Request Status:</b> ${status}</small>`;
|
||||
}
|
||||
} else if (payload.comment) {
|
||||
message += `<small>\n\n<b>Comment from ${payload.comment.user.displayName}:</b> ${payload.comment.message}</small>`;
|
||||
} else if (payload.issue) {
|
||||
message += `<small>\n\n<b>Reported By:</b> ${payload.issue.createdBy.displayName}</small>`;
|
||||
message += `<small>\n<b>Issue Type:</b> ${
|
||||
IssueTypeName[payload.issue.issueType]
|
||||
}</small>`;
|
||||
message += `<small>\n<b>Issue Status:</b> ${
|
||||
payload.issue.status === IssueStatus.OPEN ? 'Open' : 'Resolved'
|
||||
}</small>`;
|
||||
|
||||
if (type === Notification.ISSUE_CREATED) {
|
||||
priority = 1;
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
messageTitle = `Failed ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request`;
|
||||
message += `<b>${title}</b>`;
|
||||
if (plot) {
|
||||
message += `<small>\n${plot}</small>`;
|
||||
}
|
||||
message += `<small>\n\n<b>Requested By</b>\n${username}</small>`;
|
||||
message += `<small>\n\n<b>Status</b>\nFailed</small>`;
|
||||
priority = 1;
|
||||
break;
|
||||
case Notification.TEST_NOTIFICATION:
|
||||
messageTitle = 'Test Notification';
|
||||
message += `<small>${plot}</small>`;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (const extra of payload.extra ?? []) {
|
||||
message += `<small>\n\n<b>${extra.name}</b>\n${extra.value}</small>`;
|
||||
message += `<small>\n<b>${extra.name}:</b> ${extra.value}</small>`;
|
||||
}
|
||||
|
||||
if (settings.main.applicationUrl && payload.media) {
|
||||
url = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
|
||||
url_title = `Open in ${settings.main.applicationTitle}`;
|
||||
}
|
||||
const url = applicationUrl
|
||||
? payload.issue
|
||||
? `${applicationUrl}/issues/${payload.issue.id}`
|
||||
: payload.media
|
||||
? `${applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`
|
||||
: undefined
|
||||
: undefined;
|
||||
const url_title = url
|
||||
? `View ${payload.issue ? 'Issue' : 'Media'} in ${applicationTitle}`
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
title: messageTitle,
|
||||
title,
|
||||
message,
|
||||
url,
|
||||
url_title,
|
||||
priority,
|
||||
html: 1,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -163,45 +132,134 @@ class PushoverAgent
|
||||
payload: NotificationPayload
|
||||
): Promise<boolean> {
|
||||
const settings = this.getSettings();
|
||||
const endpoint = 'https://api.pushover.net/1/messages.json';
|
||||
const notificationPayload = this.getNotificationPayload(type, payload);
|
||||
|
||||
if (!hasNotificationType(type, settings.types ?? 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
logger.debug('Sending Pushover notification', {
|
||||
label: 'Notifications',
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
});
|
||||
try {
|
||||
const endpoint = 'https://api.pushover.net/1/messages.json';
|
||||
|
||||
const { title, message, url, url_title, priority } =
|
||||
this.constructMessageDetails(type, payload);
|
||||
|
||||
await axios.post(endpoint, {
|
||||
token: settings.options.accessToken,
|
||||
user: settings.options.userToken,
|
||||
title: title,
|
||||
message: message,
|
||||
url: url,
|
||||
url_title: url_title,
|
||||
priority: priority,
|
||||
html: 1,
|
||||
} as PushoverPayload);
|
||||
|
||||
return true;
|
||||
} catch (e) {
|
||||
logger.error('Error sending Pushover notification', {
|
||||
// Send system notification
|
||||
if (
|
||||
hasNotificationType(type, settings.types ?? 0) &&
|
||||
settings.enabled &&
|
||||
settings.options.accessToken &&
|
||||
settings.options.userToken
|
||||
) {
|
||||
logger.debug('Sending Pushover notification', {
|
||||
label: 'Notifications',
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
response: e.response?.data,
|
||||
});
|
||||
|
||||
return false;
|
||||
try {
|
||||
await axios.post(endpoint, {
|
||||
...notificationPayload,
|
||||
token: settings.options.accessToken,
|
||||
user: settings.options.userToken,
|
||||
} as PushoverPayload);
|
||||
} catch (e) {
|
||||
logger.error('Error sending Pushover notification', {
|
||||
label: 'Notifications',
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
response: e.response?.data,
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (payload.notifyUser) {
|
||||
if (
|
||||
payload.notifyUser.settings?.hasNotificationType(
|
||||
NotificationAgentKey.PUSHOVER,
|
||||
type
|
||||
) &&
|
||||
payload.notifyUser.settings.pushoverApplicationToken &&
|
||||
payload.notifyUser.settings.pushoverUserKey &&
|
||||
(payload.notifyUser.settings.pushoverApplicationToken !==
|
||||
settings.options.accessToken ||
|
||||
payload.notifyUser.settings.pushoverUserKey !==
|
||||
settings.options.userToken)
|
||||
) {
|
||||
logger.debug('Sending Pushover notification', {
|
||||
label: 'Notifications',
|
||||
recipient: payload.notifyUser.displayName,
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
});
|
||||
|
||||
try {
|
||||
await axios.post(endpoint, {
|
||||
...notificationPayload,
|
||||
token: payload.notifyUser.settings.pushoverApplicationToken,
|
||||
user: payload.notifyUser.settings.pushoverUserKey,
|
||||
} as PushoverPayload);
|
||||
} catch (e) {
|
||||
logger.error('Error sending Pushover notification', {
|
||||
label: 'Notifications',
|
||||
recipient: payload.notifyUser.displayName,
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
response: e.response?.data,
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (payload.notifyAdmin) {
|
||||
const userRepository = getRepository(User);
|
||||
const users = await userRepository.find();
|
||||
|
||||
await Promise.all(
|
||||
users
|
||||
.filter(
|
||||
(user) =>
|
||||
user.settings?.hasNotificationType(
|
||||
NotificationAgentKey.PUSHOVER,
|
||||
type
|
||||
) && shouldSendAdminNotification(type, user, payload)
|
||||
)
|
||||
.map(async (user) => {
|
||||
if (
|
||||
user.settings?.pushoverApplicationToken &&
|
||||
user.settings?.pushoverUserKey &&
|
||||
user.settings.pushoverApplicationToken !==
|
||||
settings.options.accessToken &&
|
||||
user.settings.pushoverUserKey !== settings.options.userToken
|
||||
) {
|
||||
logger.debug('Sending Pushover notification', {
|
||||
label: 'Notifications',
|
||||
recipient: user.displayName,
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
});
|
||||
|
||||
try {
|
||||
await axios.post(endpoint, {
|
||||
...notificationPayload,
|
||||
token: user.settings.pushoverApplicationToken,
|
||||
user: user.settings.pushoverUserKey,
|
||||
} as PushoverPayload);
|
||||
} catch (e) {
|
||||
logger.error('Error sending Pushover notification', {
|
||||
label: 'Notifications',
|
||||
recipient: user.displayName,
|
||||
type: Notification[type],
|
||||
subject: payload.subject,
|
||||
errorMessage: e.message,
|
||||
response: e.response?.data,
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import axios from 'axios';
|
||||
import { hasNotificationType, Notification } from '..';
|
||||
import { MediaType } from '../../../constants/media';
|
||||
import { IssueStatus, IssueTypeName } from '../../../constants/issue';
|
||||
import logger from '../../../logger';
|
||||
import { getSettings, NotificationAgentSlack } from '../../settings';
|
||||
import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
|
||||
@@ -19,9 +19,10 @@ interface TextItem {
|
||||
interface Element {
|
||||
type: 'button';
|
||||
text?: TextItem;
|
||||
value: string;
|
||||
url: string;
|
||||
action_id: 'button-action';
|
||||
action_id: string;
|
||||
url?: string;
|
||||
value?: string;
|
||||
style?: 'primary' | 'danger';
|
||||
}
|
||||
|
||||
interface EmbedBlock {
|
||||
@@ -34,10 +35,11 @@ interface EmbedBlock {
|
||||
image_url: string;
|
||||
alt_text: string;
|
||||
};
|
||||
elements?: Element[];
|
||||
elements?: (Element | TextItem)[];
|
||||
}
|
||||
|
||||
interface SlackBlockEmbed {
|
||||
text: string;
|
||||
blocks: EmbedBlock[];
|
||||
}
|
||||
|
||||
@@ -59,9 +61,7 @@ class SlackAgent
|
||||
type: Notification,
|
||||
payload: NotificationPayload
|
||||
): SlackBlockEmbed {
|
||||
const settings = getSettings();
|
||||
let header = '';
|
||||
let actionUrl: string | undefined;
|
||||
const { applicationUrl, applicationTitle } = getSettings().main;
|
||||
|
||||
const fields: EmbedField[] = [];
|
||||
|
||||
@@ -70,66 +70,55 @@ class SlackAgent
|
||||
type: 'mrkdwn',
|
||||
text: `*Requested By*\n${payload.request.requestedBy.displayName}`,
|
||||
});
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
header = `New ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request`;
|
||||
let status = '';
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
status = 'Pending Approval';
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
status = 'Processing';
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
status = 'Available';
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
status = 'Declined';
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
status = 'Failed';
|
||||
break;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
fields.push({
|
||||
type: 'mrkdwn',
|
||||
text: '*Status*\nPending Approval',
|
||||
text: `*Request Status*\n${status}`,
|
||||
});
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
header = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Approved`;
|
||||
fields.push({
|
||||
}
|
||||
} else if (payload.comment) {
|
||||
fields.push({
|
||||
type: 'mrkdwn',
|
||||
text: `*Comment from ${payload.comment.user.displayName}*\n${payload.comment.message}`,
|
||||
});
|
||||
} else if (payload.issue) {
|
||||
fields.push(
|
||||
{
|
||||
type: 'mrkdwn',
|
||||
text: '*Status*\nProcessing',
|
||||
});
|
||||
break;
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
header = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Automatically Approved`;
|
||||
fields.push({
|
||||
text: `*Reported By*\n${payload.issue.createdBy.displayName}`,
|
||||
},
|
||||
{
|
||||
type: 'mrkdwn',
|
||||
text: '*Status*\nProcessing',
|
||||
});
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
header = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Now Available`;
|
||||
fields.push({
|
||||
text: `*Issue Type*\n${IssueTypeName[payload.issue.issueType]}`,
|
||||
},
|
||||
{
|
||||
type: 'mrkdwn',
|
||||
text: '*Status*\nAvailable',
|
||||
});
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
header = `${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Declined`;
|
||||
fields.push({
|
||||
type: 'mrkdwn',
|
||||
text: '*Status*\nDeclined',
|
||||
});
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
header = `Failed ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request`;
|
||||
fields.push({
|
||||
type: 'mrkdwn',
|
||||
text: '*Status*\nFailed',
|
||||
});
|
||||
break;
|
||||
case Notification.TEST_NOTIFICATION:
|
||||
header = 'Test Notification';
|
||||
break;
|
||||
text: `*Issue Status*\n${
|
||||
payload.issue.status === IssueStatus.OPEN ? 'Open' : 'Resolved'
|
||||
}`,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
for (const extra of payload.extra ?? []) {
|
||||
@@ -139,30 +128,28 @@ class SlackAgent
|
||||
});
|
||||
}
|
||||
|
||||
if (settings.main.applicationUrl && payload.media) {
|
||||
actionUrl = `${settings.main.applicationUrl}/${payload.media?.mediaType}/${payload.media?.tmdbId}`;
|
||||
}
|
||||
const blocks: EmbedBlock[] = [];
|
||||
|
||||
const blocks: EmbedBlock[] = [
|
||||
{
|
||||
type: 'header',
|
||||
text: {
|
||||
type: 'plain_text',
|
||||
text: header,
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
if (type !== Notification.TEST_NOTIFICATION) {
|
||||
if (payload.event) {
|
||||
blocks.push({
|
||||
type: 'section',
|
||||
text: {
|
||||
type: 'mrkdwn',
|
||||
text: `*${payload.subject}*`,
|
||||
},
|
||||
type: 'context',
|
||||
elements: [
|
||||
{
|
||||
type: 'mrkdwn',
|
||||
text: `*${payload.event}*`,
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
blocks.push({
|
||||
type: 'header',
|
||||
text: {
|
||||
type: 'plain_text',
|
||||
text: payload.subject,
|
||||
},
|
||||
});
|
||||
|
||||
if (payload.message) {
|
||||
blocks.push({
|
||||
type: 'section',
|
||||
@@ -183,30 +170,31 @@ class SlackAgent
|
||||
if (fields.length > 0) {
|
||||
blocks.push({
|
||||
type: 'section',
|
||||
fields: [
|
||||
...fields,
|
||||
...(payload.extra ?? []).map(
|
||||
(extra): EmbedField => ({
|
||||
type: 'mrkdwn',
|
||||
text: `*${extra.name}*\n${extra.value}`,
|
||||
})
|
||||
),
|
||||
],
|
||||
fields,
|
||||
});
|
||||
}
|
||||
|
||||
if (actionUrl) {
|
||||
const url = applicationUrl
|
||||
? payload.issue
|
||||
? `${applicationUrl}/issues/${payload.issue.id}`
|
||||
: payload.media
|
||||
? `${applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`
|
||||
: undefined
|
||||
: undefined;
|
||||
|
||||
if (url) {
|
||||
blocks.push({
|
||||
type: 'actions',
|
||||
elements: [
|
||||
{
|
||||
action_id: 'button-action',
|
||||
action_id: 'open-in-overseerr',
|
||||
type: 'button',
|
||||
url: actionUrl,
|
||||
value: 'open_overseerr',
|
||||
url,
|
||||
text: {
|
||||
type: 'plain_text',
|
||||
text: `Open in ${settings.main.applicationTitle}`,
|
||||
text: `View ${
|
||||
payload.issue ? 'Issue' : 'Media'
|
||||
} in ${applicationTitle}`,
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -214,6 +202,7 @@ class SlackAgent
|
||||
}
|
||||
|
||||
return {
|
||||
text: payload.event ?? payload.subject,
|
||||
blocks,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
import axios from 'axios';
|
||||
import { getRepository } from 'typeorm';
|
||||
import { hasNotificationType, Notification } from '..';
|
||||
import { MediaType } from '../../../constants/media';
|
||||
import {
|
||||
hasNotificationType,
|
||||
Notification,
|
||||
shouldSendAdminNotification,
|
||||
} from '..';
|
||||
import { IssueStatus, IssueTypeName } from '../../../constants/issue';
|
||||
import { User } from '../../../entity/User';
|
||||
import logger from '../../../logger';
|
||||
import { Permission } from '../../permissions';
|
||||
import {
|
||||
getSettings,
|
||||
NotificationAgentKey,
|
||||
@@ -46,11 +49,7 @@ class TelegramAgent
|
||||
public shouldSend(): boolean {
|
||||
const settings = this.getSettings();
|
||||
|
||||
if (
|
||||
settings.enabled &&
|
||||
settings.options.botAPI &&
|
||||
settings.options.chatId
|
||||
) {
|
||||
if (settings.enabled && settings.options.botAPI) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -61,118 +60,91 @@ class TelegramAgent
|
||||
return text ? text.replace(/[_*[\]()~>#+=|{}.!-]/gi, (x) => '\\' + x) : '';
|
||||
}
|
||||
|
||||
private buildMessage(
|
||||
private getNotificationPayload(
|
||||
type: Notification,
|
||||
payload: NotificationPayload,
|
||||
chatId: string,
|
||||
sendSilently: boolean
|
||||
): TelegramMessagePayload | TelegramPhotoPayload {
|
||||
const settings = getSettings();
|
||||
let message = '';
|
||||
|
||||
const title = this.escapeText(payload.subject);
|
||||
const plot = this.escapeText(payload.message);
|
||||
const user = this.escapeText(payload.request?.requestedBy.displayName);
|
||||
const applicationTitle = this.escapeText(settings.main.applicationTitle);
|
||||
payload: NotificationPayload
|
||||
): Partial<TelegramMessagePayload | TelegramPhotoPayload> {
|
||||
const { applicationUrl, applicationTitle } = getSettings().main;
|
||||
|
||||
/* eslint-disable no-useless-escape */
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
message += `\*New ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request\*`;
|
||||
message += `\n\n\*${title}\*`;
|
||||
if (plot) {
|
||||
message += `\n${plot}`;
|
||||
}
|
||||
message += `\n\n\*Requested By\*\n${user}`;
|
||||
message += `\n\n\*Status\*\nPending Approval`;
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
message += `\*${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Approved\*`;
|
||||
message += `\n\n\*${title}\*`;
|
||||
if (plot) {
|
||||
message += `\n${plot}`;
|
||||
}
|
||||
message += `\n\n\*Requested By\*\n${user}`;
|
||||
message += `\n\n\*Status\*\nProcessing`;
|
||||
break;
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
message += `\*${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Automatically Approved\*`;
|
||||
message += `\n\n\*${title}\*`;
|
||||
if (plot) {
|
||||
message += `\n${plot}`;
|
||||
}
|
||||
message += `\n\n\*Requested By\*\n${user}`;
|
||||
message += `\n\n\*Status\*\nProcessing`;
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
message += `\*${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Now Available\*`;
|
||||
message += `\n\n\*${title}\*`;
|
||||
if (plot) {
|
||||
message += `\n${plot}`;
|
||||
}
|
||||
message += `\n\n\*Requested By\*\n${user}`;
|
||||
message += `\n\n\*Status\*\nAvailable`;
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
message += `\*${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request Declined\*`;
|
||||
message += `\n\n\*${title}\*`;
|
||||
if (plot) {
|
||||
message += `\n${plot}`;
|
||||
}
|
||||
message += `\n\n\*Requested By\*\n${user}`;
|
||||
message += `\n\n\*Status\*\nDeclined`;
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
message += `\*Failed ${
|
||||
payload.media?.mediaType === MediaType.TV ? 'Series' : 'Movie'
|
||||
} Request\*`;
|
||||
message += `\n\n\*${title}\*`;
|
||||
if (plot) {
|
||||
message += `\n${plot}`;
|
||||
}
|
||||
message += `\n\n\*Requested By\*\n${user}`;
|
||||
message += `\n\n\*Status\*\nFailed`;
|
||||
break;
|
||||
case Notification.TEST_NOTIFICATION:
|
||||
message += `\*Test Notification\*`;
|
||||
message += `\n\n${plot}`;
|
||||
break;
|
||||
let message = `\*${this.escapeText(
|
||||
payload.event ? `${payload.event} - ${payload.subject}` : payload.subject
|
||||
)}\*`;
|
||||
if (payload.message) {
|
||||
message += `\n${this.escapeText(payload.message)}`;
|
||||
}
|
||||
|
||||
if (payload.request) {
|
||||
message += `\n\n\*Requested By:\* ${this.escapeText(
|
||||
payload.request?.requestedBy.displayName
|
||||
)}`;
|
||||
|
||||
let status = '';
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
status = 'Pending Approval';
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
status = 'Processing';
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
status = 'Available';
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
status = 'Declined';
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
status = 'Failed';
|
||||
break;
|
||||
}
|
||||
|
||||
if (status) {
|
||||
message += `\n\*Request Status:\* ${status}`;
|
||||
}
|
||||
} else if (payload.comment) {
|
||||
message += `\n\n\*Comment from ${this.escapeText(
|
||||
payload.comment.user.displayName
|
||||
)}:\* ${this.escapeText(payload.comment.message)}`;
|
||||
} else if (payload.issue) {
|
||||
message += `\n\n\*Reported By:\* ${this.escapeText(
|
||||
payload.issue.createdBy.displayName
|
||||
)}`;
|
||||
message += `\n\*Issue Type:\* ${IssueTypeName[payload.issue.issueType]}`;
|
||||
message += `\n\*Issue Status:\* ${
|
||||
payload.issue.status === IssueStatus.OPEN ? 'Open' : 'Resolved'
|
||||
}`;
|
||||
}
|
||||
|
||||
for (const extra of payload.extra ?? []) {
|
||||
message += `\n\n\*${extra.name}\*\n${extra.value}`;
|
||||
message += `\n\*${extra.name}:\* ${extra.value}`;
|
||||
}
|
||||
|
||||
if (settings.main.applicationUrl && payload.media) {
|
||||
const actionUrl = `${settings.main.applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`;
|
||||
message += `\n\n\[Open in ${applicationTitle}\]\(${actionUrl}\)`;
|
||||
const url = applicationUrl
|
||||
? payload.issue
|
||||
? `${applicationUrl}/issues/${payload.issue.id}`
|
||||
: payload.media
|
||||
? `${applicationUrl}/${payload.media.mediaType}/${payload.media.tmdbId}`
|
||||
: undefined
|
||||
: undefined;
|
||||
|
||||
if (url) {
|
||||
message += `\n\n\[View ${
|
||||
payload.issue ? 'Issue' : 'Media'
|
||||
} in ${this.escapeText(applicationTitle)}\]\(${url}\)`;
|
||||
}
|
||||
/* eslint-enable */
|
||||
|
||||
return payload.image
|
||||
? ({
|
||||
? {
|
||||
photo: payload.image,
|
||||
caption: message,
|
||||
parse_mode: 'MarkdownV2',
|
||||
chat_id: chatId,
|
||||
disable_notification: !!sendSilently,
|
||||
} as TelegramPhotoPayload)
|
||||
: ({
|
||||
}
|
||||
: {
|
||||
text: message,
|
||||
parse_mode: 'MarkdownV2',
|
||||
chat_id: chatId,
|
||||
disable_notification: !!sendSilently,
|
||||
} as TelegramMessagePayload);
|
||||
};
|
||||
}
|
||||
|
||||
public async send(
|
||||
@@ -180,13 +152,16 @@ class TelegramAgent
|
||||
payload: NotificationPayload
|
||||
): Promise<boolean> {
|
||||
const settings = this.getSettings();
|
||||
|
||||
const endpoint = `${this.baseUrl}bot${settings.options.botAPI}/${
|
||||
payload.image ? 'sendPhoto' : 'sendMessage'
|
||||
}`;
|
||||
const notificationPayload = this.getNotificationPayload(type, payload);
|
||||
|
||||
// Send system notification
|
||||
if (hasNotificationType(type, settings.types ?? 0)) {
|
||||
if (
|
||||
hasNotificationType(type, settings.types ?? 0) &&
|
||||
settings.options.chatId
|
||||
) {
|
||||
logger.debug('Sending Telegram notification', {
|
||||
label: 'Notifications',
|
||||
type: Notification[type],
|
||||
@@ -194,15 +169,11 @@ class TelegramAgent
|
||||
});
|
||||
|
||||
try {
|
||||
await axios.post(
|
||||
endpoint,
|
||||
this.buildMessage(
|
||||
type,
|
||||
payload,
|
||||
settings.options.chatId,
|
||||
settings.options.sendSilently
|
||||
)
|
||||
);
|
||||
await axios.post(endpoint, {
|
||||
...notificationPayload,
|
||||
chat_id: settings.options.chatId,
|
||||
disable_notification: !!settings.options.sendSilently,
|
||||
} as TelegramMessagePayload | TelegramPhotoPayload);
|
||||
} catch (e) {
|
||||
logger.error('Error sending Telegram notification', {
|
||||
label: 'Notifications',
|
||||
@@ -217,14 +188,13 @@ class TelegramAgent
|
||||
}
|
||||
|
||||
if (payload.notifyUser) {
|
||||
// Send notification to the user who submitted the request
|
||||
if (
|
||||
payload.notifyUser.settings?.hasNotificationType(
|
||||
NotificationAgentKey.TELEGRAM,
|
||||
type
|
||||
) &&
|
||||
payload.notifyUser.settings?.telegramChatId &&
|
||||
payload.notifyUser.settings?.telegramChatId !== settings.options.chatId
|
||||
payload.notifyUser.settings.telegramChatId !== settings.options.chatId
|
||||
) {
|
||||
logger.debug('Sending Telegram notification', {
|
||||
label: 'Notifications',
|
||||
@@ -234,15 +204,12 @@ class TelegramAgent
|
||||
});
|
||||
|
||||
try {
|
||||
await axios.post(
|
||||
endpoint,
|
||||
this.buildMessage(
|
||||
type,
|
||||
payload,
|
||||
payload.notifyUser.settings.telegramChatId,
|
||||
!!payload.notifyUser.settings.telegramSendSilently
|
||||
)
|
||||
);
|
||||
await axios.post(endpoint, {
|
||||
...notificationPayload,
|
||||
chat_id: payload.notifyUser.settings.telegramChatId,
|
||||
disable_notification:
|
||||
!!payload.notifyUser.settings.telegramSendSilently,
|
||||
} as TelegramMessagePayload | TelegramPhotoPayload);
|
||||
} catch (e) {
|
||||
logger.error('Error sending Telegram notification', {
|
||||
label: 'Notifications',
|
||||
@@ -256,8 +223,9 @@ class TelegramAgent
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Send notifications to all users with the Manage Requests permission
|
||||
}
|
||||
|
||||
if (payload.notifyAdmin) {
|
||||
const userRepository = getRepository(User);
|
||||
const users = await userRepository.find();
|
||||
|
||||
@@ -265,14 +233,10 @@ class TelegramAgent
|
||||
users
|
||||
.filter(
|
||||
(user) =>
|
||||
user.hasPermission(Permission.MANAGE_REQUESTS) &&
|
||||
user.settings?.hasNotificationType(
|
||||
NotificationAgentKey.TELEGRAM,
|
||||
type
|
||||
) &&
|
||||
// Check if it's the user's own auto-approved request
|
||||
(type !== Notification.MEDIA_AUTO_APPROVED ||
|
||||
user.id !== payload.request?.requestedBy.id)
|
||||
) && shouldSendAdminNotification(type, user, payload)
|
||||
)
|
||||
.map(async (user) => {
|
||||
if (
|
||||
@@ -287,15 +251,11 @@ class TelegramAgent
|
||||
});
|
||||
|
||||
try {
|
||||
await axios.post(
|
||||
endpoint,
|
||||
this.buildMessage(
|
||||
type,
|
||||
payload,
|
||||
user.settings.telegramChatId,
|
||||
!!user.settings?.telegramSendSilently
|
||||
)
|
||||
);
|
||||
await axios.post(endpoint, {
|
||||
...notificationPayload,
|
||||
chat_id: user.settings.telegramChatId,
|
||||
disable_notification: !!user.settings?.telegramSendSilently,
|
||||
} as TelegramMessagePayload | TelegramPhotoPayload);
|
||||
} catch (e) {
|
||||
logger.error('Error sending Telegram notification', {
|
||||
label: 'Notifications',
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import axios from 'axios';
|
||||
import { get } from 'lodash';
|
||||
import { hasNotificationType, Notification } from '..';
|
||||
import { IssueStatus, IssueType } from '../../../constants/issue';
|
||||
import { MediaStatus } from '../../../constants/media';
|
||||
import logger from '../../../logger';
|
||||
import { getSettings, NotificationAgentWebhook } from '../../settings';
|
||||
@@ -13,6 +14,7 @@ type KeyMapFunction = (
|
||||
|
||||
const KeyMap: Record<string, string | KeyMapFunction> = {
|
||||
notification_type: (_payload, type) => Notification[type],
|
||||
event: 'event',
|
||||
subject: 'subject',
|
||||
message: 'message',
|
||||
image: 'image',
|
||||
@@ -22,13 +24,12 @@ const KeyMap: Record<string, string | KeyMapFunction> = {
|
||||
notifyuser_settings_discordId: 'notifyUser.settings.discordId',
|
||||
notifyuser_settings_telegramChatId: 'notifyUser.settings.telegramChatId',
|
||||
media_tmdbid: 'media.tmdbId',
|
||||
media_imdbid: 'media.imdbId',
|
||||
media_tvdbid: 'media.tvdbId',
|
||||
media_type: 'media.mediaType',
|
||||
media_status: (payload) =>
|
||||
payload.media?.status ? MediaStatus[payload.media?.status] : '',
|
||||
payload.media ? MediaStatus[payload.media.status] : '',
|
||||
media_status4k: (payload) =>
|
||||
payload.media?.status ? MediaStatus[payload.media?.status4k] : '',
|
||||
payload.media ? MediaStatus[payload.media.status4k] : '',
|
||||
request_id: 'request.id',
|
||||
requestedBy_username: 'request.requestedBy.displayName',
|
||||
requestedBy_email: 'request.requestedBy.email',
|
||||
@@ -36,6 +37,22 @@ const KeyMap: Record<string, string | KeyMapFunction> = {
|
||||
requestedBy_settings_discordId: 'request.requestedBy.settings.discordId',
|
||||
requestedBy_settings_telegramChatId:
|
||||
'request.requestedBy.settings.telegramChatId',
|
||||
issue_id: 'issue.id',
|
||||
issue_type: (payload) =>
|
||||
payload.issue ? IssueType[payload.issue.issueType] : '',
|
||||
issue_status: (payload) =>
|
||||
payload.issue ? IssueStatus[payload.issue.status] : '',
|
||||
reportedBy_username: 'issue.createdBy.displayName',
|
||||
reportedBy_email: 'issue.createdBy.email',
|
||||
reportedBy_avatar: 'issue.createdBy.avatar',
|
||||
reportedBy_settings_discordId: 'issue.createdBy.settings.discordId',
|
||||
reportedBy_settings_telegramChatId: 'issue.createdBy.settings.telegramChatId',
|
||||
comment_message: 'comment.message',
|
||||
commentedBy_username: 'comment.user.displayName',
|
||||
commentedBy_email: 'comment.user.email',
|
||||
commentedBy_avatar: 'comment.user.avatar',
|
||||
commentedBy_settings_discordId: 'comment.user.settings.discordId',
|
||||
commentedBy_settings_telegramChatId: 'comment.user.settings.telegramChatId',
|
||||
};
|
||||
|
||||
class WebhookAgent
|
||||
@@ -78,6 +95,22 @@ class WebhookAgent
|
||||
}
|
||||
delete finalPayload[key];
|
||||
key = 'request';
|
||||
} else if (key === '{{issue}}') {
|
||||
if (payload.issue) {
|
||||
finalPayload.issue = finalPayload[key];
|
||||
} else {
|
||||
finalPayload.issue = null;
|
||||
}
|
||||
delete finalPayload[key];
|
||||
key = 'issue';
|
||||
} else if (key === '{{comment}}') {
|
||||
if (payload.comment) {
|
||||
finalPayload.comment = finalPayload[key];
|
||||
} else {
|
||||
finalPayload.comment = null;
|
||||
}
|
||||
delete finalPayload[key];
|
||||
key = 'comment';
|
||||
}
|
||||
|
||||
if (typeof finalPayload[key] === 'string') {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { getRepository } from 'typeorm';
|
||||
import webpush from 'web-push';
|
||||
import { Notification } from '..';
|
||||
import { Notification, shouldSendAdminNotification } from '..';
|
||||
import { IssueType, IssueTypeName } from '../../../constants/issue';
|
||||
import { MediaType } from '../../../constants/media';
|
||||
import { User } from '../../../entity/User';
|
||||
import { UserPushSubscription } from '../../../entity/UserPushSubscription';
|
||||
import logger from '../../../logger';
|
||||
import { Permission } from '../../permissions';
|
||||
import {
|
||||
getSettings,
|
||||
NotificationAgentConfig,
|
||||
@@ -15,12 +15,11 @@ import { BaseAgent, NotificationAgent, NotificationPayload } from './agent';
|
||||
|
||||
interface PushNotificationPayload {
|
||||
notificationType: string;
|
||||
mediaType?: 'movie' | 'tv';
|
||||
tmdbId?: number;
|
||||
subject: string;
|
||||
message?: string;
|
||||
image?: string;
|
||||
actionUrl?: string;
|
||||
actionUrlTitle?: string;
|
||||
requestId?: number;
|
||||
}
|
||||
|
||||
@@ -42,97 +41,92 @@ class WebPushAgent
|
||||
type: Notification,
|
||||
payload: NotificationPayload
|
||||
): PushNotificationPayload {
|
||||
const mediaType = payload.media
|
||||
? payload.media.mediaType === MediaType.MOVIE
|
||||
? 'movie'
|
||||
: 'series'
|
||||
: undefined;
|
||||
const is4k = payload.request?.is4k;
|
||||
|
||||
const issueType = payload.issue
|
||||
? payload.issue.issueType !== IssueType.OTHER
|
||||
? `${IssueTypeName[payload.issue.issueType].toLowerCase()} issue`
|
||||
: 'issue'
|
||||
: undefined;
|
||||
|
||||
let message: string | undefined;
|
||||
switch (type) {
|
||||
case Notification.NONE:
|
||||
case Notification.TEST_NOTIFICATION:
|
||||
message = payload.message;
|
||||
break;
|
||||
case Notification.MEDIA_APPROVED:
|
||||
message = `Your ${
|
||||
is4k ? '4K ' : ''
|
||||
}${mediaType} request has been approved.`;
|
||||
break;
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
message = `Automatically approved a new ${
|
||||
is4k ? '4K ' : ''
|
||||
}${mediaType} request from ${
|
||||
payload.request?.requestedBy.displayName
|
||||
}.`;
|
||||
break;
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
message = `Your ${
|
||||
is4k ? '4K ' : ''
|
||||
}${mediaType} request is now available!`;
|
||||
break;
|
||||
case Notification.MEDIA_DECLINED:
|
||||
message = `Your ${is4k ? '4K ' : ''}${mediaType} request was declined.`;
|
||||
break;
|
||||
case Notification.MEDIA_FAILED:
|
||||
message = `Failed to process ${is4k ? '4K ' : ''}${mediaType} request.`;
|
||||
break;
|
||||
case Notification.MEDIA_PENDING:
|
||||
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}.`;
|
||||
break;
|
||||
case Notification.ISSUE_COMMENT:
|
||||
message = `${payload.comment?.user.displayName} commented on the ${issueType}.`;
|
||||
break;
|
||||
case Notification.ISSUE_RESOLVED:
|
||||
message = `The ${issueType} was marked as resolved by ${payload.issue?.modifiedBy?.displayName}!`;
|
||||
break;
|
||||
case Notification.ISSUE_REOPENED:
|
||||
message = `The ${issueType} was reopened by ${payload.issue?.modifiedBy?.displayName}.`;
|
||||
break;
|
||||
default:
|
||||
return {
|
||||
notificationType: Notification[type],
|
||||
subject: 'Unknown',
|
||||
};
|
||||
case Notification.TEST_NOTIFICATION:
|
||||
return {
|
||||
notificationType: Notification[type],
|
||||
subject: payload.subject,
|
||||
message: payload.message,
|
||||
};
|
||||
case Notification.MEDIA_APPROVED:
|
||||
return {
|
||||
notificationType: Notification[type],
|
||||
subject: payload.subject,
|
||||
message: `Your ${
|
||||
payload.media?.mediaType === MediaType.MOVIE ? 'movie' : 'series'
|
||||
} request has been approved.`,
|
||||
image: payload.image,
|
||||
mediaType: payload.media?.mediaType,
|
||||
tmdbId: payload.media?.tmdbId,
|
||||
requestId: payload.request?.id,
|
||||
actionUrl: `/${payload.media?.mediaType}/${payload.media?.tmdbId}`,
|
||||
};
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
return {
|
||||
notificationType: Notification[type],
|
||||
subject: payload.subject,
|
||||
message: `Automatically approved a new ${
|
||||
payload.media?.mediaType === MediaType.MOVIE ? 'movie' : 'series'
|
||||
} request from ${payload.request?.requestedBy.displayName}.`,
|
||||
image: payload.image,
|
||||
mediaType: payload.media?.mediaType,
|
||||
tmdbId: payload.media?.tmdbId,
|
||||
requestId: payload.request?.id,
|
||||
actionUrl: `/${payload.media?.mediaType}/${payload.media?.tmdbId}`,
|
||||
};
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
return {
|
||||
notificationType: Notification[type],
|
||||
subject: payload.subject,
|
||||
message: `Your ${
|
||||
payload.media?.mediaType === MediaType.MOVIE ? 'movie' : 'series'
|
||||
} request is now available!`,
|
||||
image: payload.image,
|
||||
mediaType: payload.media?.mediaType,
|
||||
tmdbId: payload.media?.tmdbId,
|
||||
requestId: payload.request?.id,
|
||||
actionUrl: `/${payload.media?.mediaType}/${payload.media?.tmdbId}`,
|
||||
};
|
||||
case Notification.MEDIA_DECLINED:
|
||||
return {
|
||||
notificationType: Notification[type],
|
||||
subject: payload.subject,
|
||||
message: `Your ${
|
||||
payload.media?.mediaType === MediaType.MOVIE ? 'movie' : 'series'
|
||||
} request was declined.`,
|
||||
image: payload.image,
|
||||
mediaType: payload.media?.mediaType,
|
||||
tmdbId: payload.media?.tmdbId,
|
||||
requestId: payload.request?.id,
|
||||
actionUrl: `/${payload.media?.mediaType}/${payload.media?.tmdbId}`,
|
||||
};
|
||||
case Notification.MEDIA_FAILED:
|
||||
return {
|
||||
notificationType: Notification[type],
|
||||
subject: payload.subject,
|
||||
message: `Failed to process ${
|
||||
payload.media?.mediaType === MediaType.MOVIE ? 'movie' : 'series'
|
||||
} request.`,
|
||||
image: payload.image,
|
||||
mediaType: payload.media?.mediaType,
|
||||
tmdbId: payload.media?.tmdbId,
|
||||
requestId: payload.request?.id,
|
||||
actionUrl: `/${payload.media?.mediaType}/${payload.media?.tmdbId}`,
|
||||
};
|
||||
case Notification.MEDIA_PENDING:
|
||||
return {
|
||||
notificationType: Notification[type],
|
||||
subject: payload.subject,
|
||||
message: `Approval required for new ${
|
||||
payload.media?.mediaType === MediaType.MOVIE ? 'movie' : 'series'
|
||||
} request from ${payload.request?.requestedBy.displayName}.`,
|
||||
image: payload.image,
|
||||
mediaType: payload.media?.mediaType,
|
||||
tmdbId: payload.media?.tmdbId,
|
||||
requestId: payload.request?.id,
|
||||
actionUrl: `/${payload.media?.mediaType}/${payload.media?.tmdbId}`,
|
||||
};
|
||||
}
|
||||
|
||||
const actionUrl = payload.issue
|
||||
? `/issues/${payload.issue.id}`
|
||||
: payload.media
|
||||
? `/${payload.media.mediaType}/${payload.media.tmdbId}`
|
||||
: undefined;
|
||||
|
||||
const actionUrlTitle = actionUrl
|
||||
? `View ${payload.issue ? 'Issue' : 'Media'}`
|
||||
: undefined;
|
||||
|
||||
return {
|
||||
notificationType: Notification[type],
|
||||
subject: payload.subject,
|
||||
message,
|
||||
image: payload.image,
|
||||
requestId: payload.request?.id,
|
||||
actionUrl,
|
||||
actionUrlTitle,
|
||||
};
|
||||
}
|
||||
|
||||
public shouldSend(): boolean {
|
||||
@@ -151,7 +145,7 @@ class WebPushAgent
|
||||
const userPushSubRepository = getRepository(UserPushSubscription);
|
||||
const settings = getSettings();
|
||||
|
||||
let pushSubs: UserPushSubscription[] = [];
|
||||
const pushSubs: UserPushSubscription[] = [];
|
||||
|
||||
const mainUser = await userRepository.findOne({ where: { id: 1 } });
|
||||
|
||||
@@ -169,13 +163,14 @@ class WebPushAgent
|
||||
where: { user: payload.notifyUser.id },
|
||||
});
|
||||
|
||||
pushSubs = notifySubs;
|
||||
} else if (!payload.notifyUser) {
|
||||
pushSubs.push(...notifySubs);
|
||||
}
|
||||
|
||||
if (payload.notifyAdmin) {
|
||||
const users = await userRepository.find();
|
||||
|
||||
const manageUsers = users.filter(
|
||||
(user) =>
|
||||
user.hasPermission(Permission.MANAGE_REQUESTS) &&
|
||||
// Check if user has webpush notifications enabled and fallback to true if undefined
|
||||
// since web push should default to true
|
||||
(user.settings?.hasNotificationType(
|
||||
@@ -183,9 +178,7 @@ class WebPushAgent
|
||||
type
|
||||
) ??
|
||||
true) &&
|
||||
// Check if it's the user's own auto-approved request
|
||||
(type !== Notification.MEDIA_AUTO_APPROVED ||
|
||||
user.id !== payload.request?.requestedBy.id)
|
||||
shouldSendAdminNotification(type, user, payload)
|
||||
);
|
||||
|
||||
const allSubs = await userPushSubRepository
|
||||
@@ -196,7 +189,7 @@ class WebPushAgent
|
||||
})
|
||||
.getMany();
|
||||
|
||||
pushSubs = allSubs;
|
||||
pushSubs.push(...allSubs);
|
||||
}
|
||||
|
||||
if (mainUser && pushSubs.length > 0) {
|
||||
@@ -206,6 +199,11 @@ class WebPushAgent
|
||||
settings.vapidPrivate
|
||||
);
|
||||
|
||||
const notificationPayload = Buffer.from(
|
||||
JSON.stringify(this.getNotificationPayload(type, payload)),
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
await Promise.all(
|
||||
pushSubs.map(async (sub) => {
|
||||
logger.debug('Sending web push notification', {
|
||||
@@ -224,10 +222,7 @@ class WebPushAgent
|
||||
p256dh: sub.p256dh,
|
||||
},
|
||||
},
|
||||
Buffer.from(
|
||||
JSON.stringify(this.getNotificationPayload(type, payload)),
|
||||
'utf-8'
|
||||
)
|
||||
notificationPayload
|
||||
);
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { User } from '../../entity/User';
|
||||
import logger from '../../logger';
|
||||
import { Permission } from '../permissions';
|
||||
import type { NotificationAgent, NotificationPayload } from './agents/agent';
|
||||
|
||||
export enum Notification {
|
||||
@@ -10,6 +12,10 @@ export enum Notification {
|
||||
TEST_NOTIFICATION = 32,
|
||||
MEDIA_DECLINED = 64,
|
||||
MEDIA_AUTO_APPROVED = 128,
|
||||
ISSUE_CREATED = 256,
|
||||
ISSUE_COMMENT = 512,
|
||||
ISSUE_RESOLVED = 1024,
|
||||
ISSUE_REOPENED = 2048,
|
||||
}
|
||||
|
||||
export const hasNotificationType = (
|
||||
@@ -38,6 +44,50 @@ export const hasNotificationType = (
|
||||
return !!(value & total);
|
||||
};
|
||||
|
||||
export const getAdminPermission = (type: Notification): Permission => {
|
||||
switch (type) {
|
||||
case Notification.MEDIA_PENDING:
|
||||
case Notification.MEDIA_APPROVED:
|
||||
case Notification.MEDIA_AVAILABLE:
|
||||
case Notification.MEDIA_FAILED:
|
||||
case Notification.MEDIA_DECLINED:
|
||||
case Notification.MEDIA_AUTO_APPROVED:
|
||||
return Permission.MANAGE_REQUESTS;
|
||||
case Notification.ISSUE_CREATED:
|
||||
case Notification.ISSUE_COMMENT:
|
||||
case Notification.ISSUE_RESOLVED:
|
||||
case Notification.ISSUE_REOPENED:
|
||||
return Permission.MANAGE_ISSUES;
|
||||
default:
|
||||
return Permission.ADMIN;
|
||||
}
|
||||
};
|
||||
|
||||
export const shouldSendAdminNotification = (
|
||||
type: Notification,
|
||||
user: User,
|
||||
payload: NotificationPayload
|
||||
): boolean => {
|
||||
return (
|
||||
user.id !== payload.notifyUser?.id &&
|
||||
user.hasPermission(getAdminPermission(type)) &&
|
||||
// Check if the user submitted this request (on behalf of themself OR another user)
|
||||
(type !== Notification.MEDIA_AUTO_APPROVED ||
|
||||
user.id !==
|
||||
(payload.request?.modifiedBy ?? payload.request?.requestedBy)?.id) &&
|
||||
// Check if the user created this issue
|
||||
(type !== Notification.ISSUE_CREATED ||
|
||||
user.id !== payload.issue?.createdBy.id) &&
|
||||
// Check if the user submitted this issue comment
|
||||
(type !== Notification.ISSUE_COMMENT ||
|
||||
user.id !== payload.comment?.user.id) &&
|
||||
// Check if the user resolved/reopened this issue
|
||||
((type !== Notification.ISSUE_RESOLVED &&
|
||||
type !== Notification.ISSUE_REOPENED) ||
|
||||
user.id !== payload.issue?.modifiedBy?.id)
|
||||
);
|
||||
};
|
||||
|
||||
class NotificationManager {
|
||||
private activeAgents: NotificationAgent[] = [];
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@ export enum Permission {
|
||||
AUTO_APPROVE_4K_TV = 131072,
|
||||
REQUEST_MOVIE = 262144,
|
||||
REQUEST_TV = 524288,
|
||||
MANAGE_ISSUES = 1048576,
|
||||
VIEW_ISSUES = 2097152,
|
||||
CREATE_ISSUES = 4194304,
|
||||
}
|
||||
|
||||
export interface PermissionCheckOptions {
|
||||
|
||||
@@ -371,10 +371,10 @@ class PlexScanner
|
||||
|
||||
// If we got an IMDb ID, but no TMDb ID, lookup the TMDb ID with the IMDb ID
|
||||
if (mediaIds.imdbId && !mediaIds.tmdbId) {
|
||||
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
||||
const tmdbMedia = await this.tmdb.getMediaByImdbId({
|
||||
imdbId: mediaIds.imdbId,
|
||||
});
|
||||
mediaIds.tmdbId = tmdbMovie.id;
|
||||
mediaIds.tmdbId = tmdbMedia.id;
|
||||
}
|
||||
|
||||
// Cache GUIDs
|
||||
@@ -385,10 +385,10 @@ class PlexScanner
|
||||
const imdbMatch = plexitem.guid.match(imdbRegex);
|
||||
if (imdbMatch) {
|
||||
mediaIds.imdbId = imdbMatch[1];
|
||||
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
||||
const tmdbMedia = await this.tmdb.getMediaByImdbId({
|
||||
imdbId: mediaIds.imdbId,
|
||||
});
|
||||
mediaIds.tmdbId = tmdbMovie.id;
|
||||
mediaIds.tmdbId = tmdbMedia.id;
|
||||
}
|
||||
// Check if the agent is TMDb
|
||||
} else if (plexitem.guid.match(tmdbRegex)) {
|
||||
@@ -473,7 +473,7 @@ class PlexScanner
|
||||
mediaIds.tmdbId = result.tmdbId;
|
||||
mediaIds.imdbId = result?.imdbId;
|
||||
} else if (result?.imdbId) {
|
||||
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
||||
const tmdbMovie = await this.tmdb.getMediaByImdbId({
|
||||
imdbId: result.imdbId,
|
||||
});
|
||||
mediaIds.tmdbId = tmdbMovie.id;
|
||||
@@ -522,7 +522,7 @@ class PlexScanner
|
||||
if (special.tmdbId) {
|
||||
await this.processPlexMovieByTmdbId(episode, special.tmdbId);
|
||||
} else if (special.imdbId) {
|
||||
const tmdbMovie = await this.tmdb.getMovieByImdbId({
|
||||
const tmdbMovie = await this.tmdb.getMediaByImdbId({
|
||||
imdbId: special.imdbId,
|
||||
});
|
||||
await this.processPlexMovieByTmdbId(episode, tmdbMovie.id);
|
||||
|
||||
@@ -73,7 +73,7 @@ class RadarrScanner
|
||||
}
|
||||
|
||||
private async processRadarrMovie(radarrMovie: RadarrMovie): Promise<void> {
|
||||
if (!radarrMovie.monitored && !radarrMovie.downloaded) {
|
||||
if (!radarrMovie.monitored && !radarrMovie.hasFile) {
|
||||
this.log(
|
||||
'Title is unmonitored and has not been downloaded. Skipping item.',
|
||||
'debug',
|
||||
@@ -92,7 +92,7 @@ class RadarrScanner
|
||||
externalServiceId: radarrMovie.id,
|
||||
externalServiceSlug: radarrMovie.titleSlug,
|
||||
title: radarrMovie.title,
|
||||
processing: !radarrMovie.downloaded,
|
||||
processing: !radarrMovie.hasFile,
|
||||
});
|
||||
} catch (e) {
|
||||
this.log('Failed to process Radarr media', 'error', {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { uniqWith } from 'lodash';
|
||||
import { getRepository } from 'typeorm';
|
||||
import SonarrAPI, { SonarrSeries } from '../../../api/servarr/sonarr';
|
||||
import { TmdbTvDetails } from '../../../api/themoviedb/interfaces';
|
||||
import Media from '../../../entity/Media';
|
||||
import { getSettings, SonarrSettings } from '../../settings';
|
||||
import BaseScanner, {
|
||||
@@ -83,24 +84,26 @@ class SonarrScanner
|
||||
const mediaRepository = getRepository(Media);
|
||||
const server4k = this.enable4kShow && this.currentServer.is4k;
|
||||
const processableSeasons: ProcessableSeason[] = [];
|
||||
let tmdbId: number;
|
||||
let tvShow: TmdbTvDetails;
|
||||
|
||||
const media = await mediaRepository.findOne({
|
||||
where: { tvdbId: sonarrSeries.tvdbId },
|
||||
});
|
||||
|
||||
if (!media || !media.tmdbId) {
|
||||
const tvShow = await this.tmdb.getShowByTvdbId({
|
||||
tvShow = await this.tmdb.getShowByTvdbId({
|
||||
tvdbId: sonarrSeries.tvdbId,
|
||||
});
|
||||
|
||||
tmdbId = tvShow.id;
|
||||
} else {
|
||||
tmdbId = media.tmdbId;
|
||||
tvShow = await this.tmdb.getTvShow({ tvId: media.tmdbId });
|
||||
}
|
||||
|
||||
const tmdbId = tvShow.id;
|
||||
|
||||
const filteredSeasons = sonarrSeries.seasons.filter(
|
||||
(sn) => sn.seasonNumber !== 0
|
||||
(sn) =>
|
||||
sn.seasonNumber !== 0 &&
|
||||
tvShow.seasons.find((s) => s.season_number === sn.seasonNumber)
|
||||
);
|
||||
|
||||
for (const season of filteredSeasons) {
|
||||
|
||||
212
server/lib/search.ts
Normal file
212
server/lib/search.ts
Normal file
@@ -0,0 +1,212 @@
|
||||
import TheMovieDb from '../api/themoviedb';
|
||||
import {
|
||||
TmdbMovieDetails,
|
||||
TmdbMovieResult,
|
||||
TmdbPersonDetails,
|
||||
TmdbPersonResult,
|
||||
TmdbSearchMovieResponse,
|
||||
TmdbSearchMultiResponse,
|
||||
TmdbSearchTvResponse,
|
||||
TmdbTvDetails,
|
||||
TmdbTvResult,
|
||||
} from '../api/themoviedb/interfaces';
|
||||
import {
|
||||
mapMovieDetailsToResult,
|
||||
mapPersonDetailsToResult,
|
||||
mapTvDetailsToResult,
|
||||
} from '../models/Search';
|
||||
import { isMovie, isMovieDetails, isTvDetails } from '../utils/typeHelpers';
|
||||
|
||||
interface SearchProvider {
|
||||
pattern: RegExp;
|
||||
search: ({
|
||||
id,
|
||||
language,
|
||||
query,
|
||||
}: {
|
||||
id: string;
|
||||
language?: string;
|
||||
query?: string;
|
||||
}) => Promise<TmdbSearchMultiResponse>;
|
||||
}
|
||||
|
||||
const searchProviders: SearchProvider[] = [];
|
||||
|
||||
export const findSearchProvider = (
|
||||
query: string
|
||||
): SearchProvider | undefined => {
|
||||
return searchProviders.find((provider) => provider.pattern.test(query));
|
||||
};
|
||||
|
||||
searchProviders.push({
|
||||
pattern: new RegExp(/(?<=tmdb:)\d+/),
|
||||
search: async ({ id, language }) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const moviePromise = tmdb.getMovie({ movieId: parseInt(id), language });
|
||||
const tvShowPromise = tmdb.getTvShow({ tvId: parseInt(id), language });
|
||||
const personPromise = tmdb.getPerson({ personId: parseInt(id), language });
|
||||
|
||||
const responses = await Promise.allSettled([
|
||||
moviePromise,
|
||||
tvShowPromise,
|
||||
personPromise,
|
||||
]);
|
||||
|
||||
const successfulResponses = responses.filter(
|
||||
(r) => r.status === 'fulfilled'
|
||||
) as
|
||||
| (
|
||||
| PromiseFulfilledResult<TmdbMovieDetails>
|
||||
| PromiseFulfilledResult<TmdbTvDetails>
|
||||
| PromiseFulfilledResult<TmdbPersonDetails>
|
||||
)[];
|
||||
|
||||
const results: (TmdbMovieResult | TmdbTvResult | TmdbPersonResult)[] = [];
|
||||
|
||||
if (successfulResponses.length) {
|
||||
results.push(
|
||||
...successfulResponses.map((r) => {
|
||||
if (isMovieDetails(r.value)) {
|
||||
return mapMovieDetailsToResult(r.value);
|
||||
} else if (isTvDetails(r.value)) {
|
||||
return mapTvDetailsToResult(r.value);
|
||||
} else {
|
||||
return mapPersonDetailsToResult(r.value);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
page: 1,
|
||||
total_pages: 1,
|
||||
total_results: results.length,
|
||||
results,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
searchProviders.push({
|
||||
pattern: new RegExp(/(?<=imdb:)(tt|nm)\d+/),
|
||||
search: async ({ id, language }) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const responses = await tmdb.getByExternalId({
|
||||
externalId: id,
|
||||
type: 'imdb',
|
||||
language,
|
||||
});
|
||||
|
||||
const results: (TmdbMovieResult | TmdbTvResult | TmdbPersonResult)[] = [];
|
||||
|
||||
// set the media_type here since searching by external id doesn't return it
|
||||
results.push(
|
||||
...(responses.movie_results.map((movie) => ({
|
||||
...movie,
|
||||
media_type: 'movie',
|
||||
})) as TmdbMovieResult[]),
|
||||
...(responses.tv_results.map((tv) => ({
|
||||
...tv,
|
||||
media_type: 'tv',
|
||||
})) as TmdbTvResult[]),
|
||||
...(responses.person_results.map((person) => ({
|
||||
...person,
|
||||
media_type: 'person',
|
||||
})) as TmdbPersonResult[])
|
||||
);
|
||||
|
||||
return {
|
||||
page: 1,
|
||||
total_pages: 1,
|
||||
total_results: results.length,
|
||||
results,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
searchProviders.push({
|
||||
pattern: new RegExp(/(?<=tvdb:)\d+/),
|
||||
search: async ({ id, language }) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const responses = await tmdb.getByExternalId({
|
||||
externalId: parseInt(id),
|
||||
type: 'tvdb',
|
||||
language,
|
||||
});
|
||||
|
||||
const results: (TmdbMovieResult | TmdbTvResult | TmdbPersonResult)[] = [];
|
||||
|
||||
// set the media_type here since searching by external id doesn't return it
|
||||
results.push(
|
||||
...(responses.movie_results.map((movie) => ({
|
||||
...movie,
|
||||
media_type: 'movie',
|
||||
})) as TmdbMovieResult[]),
|
||||
...(responses.tv_results.map((tv) => ({
|
||||
...tv,
|
||||
media_type: 'tv',
|
||||
})) as TmdbTvResult[]),
|
||||
...(responses.person_results.map((person) => ({
|
||||
...person,
|
||||
media_type: 'person',
|
||||
})) as TmdbPersonResult[])
|
||||
);
|
||||
|
||||
return {
|
||||
page: 1,
|
||||
total_pages: 1,
|
||||
total_results: results.length,
|
||||
results,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
searchProviders.push({
|
||||
pattern: new RegExp(/(?<=year:)\d{4}/),
|
||||
search: async ({ id: year, query }) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const moviesPromise = tmdb.searchMovies({
|
||||
query: query?.replace(new RegExp(/year:\d{4}/), '') ?? '',
|
||||
year: parseInt(year),
|
||||
});
|
||||
const tvShowsPromise = tmdb.searchTvShows({
|
||||
query: query?.replace(new RegExp(/year:\d{4}/), '') ?? '',
|
||||
year: parseInt(year),
|
||||
});
|
||||
|
||||
const responses = await Promise.allSettled([moviesPromise, tvShowsPromise]);
|
||||
|
||||
const successfulResponses = responses.filter(
|
||||
(r) => r.status === 'fulfilled'
|
||||
) as
|
||||
| (
|
||||
| PromiseFulfilledResult<TmdbSearchMovieResponse>
|
||||
| PromiseFulfilledResult<TmdbSearchTvResponse>
|
||||
)[];
|
||||
|
||||
const results: (TmdbMovieResult | TmdbTvResult)[] = [];
|
||||
|
||||
if (successfulResponses.length) {
|
||||
successfulResponses.forEach((response) => {
|
||||
response.value.results.forEach((result) =>
|
||||
// set the media_type here since the search endpoints don't return it
|
||||
results.push(
|
||||
isMovie(result)
|
||||
? { ...result, media_type: 'movie' }
|
||||
: { ...result, media_type: 'tv' }
|
||||
)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
page: 1,
|
||||
total_pages: 1,
|
||||
total_results: results.length,
|
||||
results,
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -35,6 +35,15 @@ export interface PlexSettings {
|
||||
webAppUrl?: string;
|
||||
}
|
||||
|
||||
export interface TautulliSettings {
|
||||
hostname?: string;
|
||||
port?: number;
|
||||
useSsl?: boolean;
|
||||
urlBase?: string;
|
||||
apiKey?: string;
|
||||
externalUrl?: string;
|
||||
}
|
||||
|
||||
export interface DVRSettings {
|
||||
id: number;
|
||||
name: string;
|
||||
@@ -113,6 +122,7 @@ interface FullPublicSettings extends PublicSettings {
|
||||
enablePushRegistration: boolean;
|
||||
locale: string;
|
||||
emailEnabled: boolean;
|
||||
newPlexLogin: boolean;
|
||||
}
|
||||
|
||||
export interface NotificationAgentConfig {
|
||||
@@ -125,6 +135,7 @@ export interface NotificationAgentDiscord extends NotificationAgentConfig {
|
||||
botUsername?: string;
|
||||
botAvatarUrl?: string;
|
||||
webhookUrl: string;
|
||||
enableMentions: boolean;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -170,6 +181,7 @@ export interface NotificationAgentTelegram extends NotificationAgentConfig {
|
||||
export interface NotificationAgentPushbullet extends NotificationAgentConfig {
|
||||
options: {
|
||||
accessToken: string;
|
||||
channelTag?: string;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -188,9 +200,17 @@ export interface NotificationAgentWebhook extends NotificationAgentConfig {
|
||||
};
|
||||
}
|
||||
|
||||
export interface NotificationAgentGotify extends NotificationAgentConfig {
|
||||
options: {
|
||||
url: string;
|
||||
token: string;
|
||||
};
|
||||
}
|
||||
|
||||
export enum NotificationAgentKey {
|
||||
DISCORD = 'discord',
|
||||
EMAIL = 'email',
|
||||
GOTIFY = 'gotify',
|
||||
PUSHBULLET = 'pushbullet',
|
||||
PUSHOVER = 'pushover',
|
||||
SLACK = 'slack',
|
||||
@@ -202,6 +222,7 @@ export enum NotificationAgentKey {
|
||||
interface NotificationAgents {
|
||||
discord: NotificationAgentDiscord;
|
||||
email: NotificationAgentEmail;
|
||||
gotify: NotificationAgentGotify;
|
||||
lunasea: NotificationAgentLunaSea;
|
||||
pushbullet: NotificationAgentPushbullet;
|
||||
pushover: NotificationAgentPushover;
|
||||
@@ -233,6 +254,7 @@ interface AllSettings {
|
||||
vapidPrivate: string;
|
||||
main: MainSettings;
|
||||
plex: PlexSettings;
|
||||
tautulli: TautulliSettings;
|
||||
radarr: RadarrSettings[];
|
||||
sonarr: SonarrSettings[];
|
||||
public: PublicSettings;
|
||||
@@ -279,6 +301,7 @@ class Settings {
|
||||
useSsl: false,
|
||||
libraries: [],
|
||||
},
|
||||
tautulli: {},
|
||||
radarr: [],
|
||||
sonarr: [],
|
||||
public: {
|
||||
@@ -304,6 +327,7 @@ class Settings {
|
||||
types: 0,
|
||||
options: {
|
||||
webhookUrl: '',
|
||||
enableMentions: true,
|
||||
},
|
||||
},
|
||||
lunasea: {
|
||||
@@ -350,13 +374,21 @@ class Settings {
|
||||
options: {
|
||||
webhookUrl: '',
|
||||
jsonPayload:
|
||||
'IntcbiAgICBcIm5vdGlmaWNhdGlvbl90eXBlXCI6IFwie3tub3RpZmljYXRpb25fdHlwZX19XCIsXG4gICAgXCJzdWJqZWN0XCI6IFwie3tzdWJqZWN0fX1cIixcbiAgICBcIm1lc3NhZ2VcIjogXCJ7e21lc3NhZ2V9fVwiLFxuICAgIFwiaW1hZ2VcIjogXCJ7e2ltYWdlfX1cIixcbiAgICBcImVtYWlsXCI6IFwie3tub3RpZnl1c2VyX2VtYWlsfX1cIixcbiAgICBcInVzZXJuYW1lXCI6IFwie3tub3RpZnl1c2VyX3VzZXJuYW1lfX1cIixcbiAgICBcImF2YXRhclwiOiBcInt7bm90aWZ5dXNlcl9hdmF0YXJ9fVwiLFxuICAgIFwie3ttZWRpYX19XCI6IHtcbiAgICAgICAgXCJtZWRpYV90eXBlXCI6IFwie3ttZWRpYV90eXBlfX1cIixcbiAgICAgICAgXCJ0bWRiSWRcIjogXCJ7e21lZGlhX3RtZGJpZH19XCIsXG4gICAgICAgIFwiaW1kYklkXCI6IFwie3ttZWRpYV9pbWRiaWR9fVwiLFxuICAgICAgICBcInR2ZGJJZFwiOiBcInt7bWVkaWFfdHZkYmlkfX1cIixcbiAgICAgICAgXCJzdGF0dXNcIjogXCJ7e21lZGlhX3N0YXR1c319XCIsXG4gICAgICAgIFwic3RhdHVzNGtcIjogXCJ7e21lZGlhX3N0YXR1czRrfX1cIlxuICAgIH0sXG4gICAgXCJ7e2V4dHJhfX1cIjogW10sXG4gICAgXCJ7e3JlcXVlc3R9fVwiOiB7XG4gICAgICAgIFwicmVxdWVzdF9pZFwiOiBcInt7cmVxdWVzdF9pZH19XCIsXG4gICAgICAgIFwicmVxdWVzdGVkQnlfZW1haWxcIjogXCJ7e3JlcXVlc3RlZEJ5X2VtYWlsfX1cIixcbiAgICAgICAgXCJyZXF1ZXN0ZWRCeV91c2VybmFtZVwiOiBcInt7cmVxdWVzdGVkQnlfdXNlcm5hbWV9fVwiLFxuICAgICAgICBcInJlcXVlc3RlZEJ5X2F2YXRhclwiOiBcInt7cmVxdWVzdGVkQnlfYXZhdGFyfX1cIlxuICAgIH1cbn0i',
|
||||
'IntcbiAgICBcIm5vdGlmaWNhdGlvbl90eXBlXCI6IFwie3tub3RpZmljYXRpb25fdHlwZX19XCIsXG4gICAgXCJldmVudFwiOiBcInt7ZXZlbnR9fVwiLFxuICAgIFwic3ViamVjdFwiOiBcInt7c3ViamVjdH19XCIsXG4gICAgXCJtZXNzYWdlXCI6IFwie3ttZXNzYWdlfX1cIixcbiAgICBcImltYWdlXCI6IFwie3tpbWFnZX19XCIsXG4gICAgXCJ7e21lZGlhfX1cIjoge1xuICAgICAgICBcIm1lZGlhX3R5cGVcIjogXCJ7e21lZGlhX3R5cGV9fVwiLFxuICAgICAgICBcInRtZGJJZFwiOiBcInt7bWVkaWFfdG1kYmlkfX1cIixcbiAgICAgICAgXCJ0dmRiSWRcIjogXCJ7e21lZGlhX3R2ZGJpZH19XCIsXG4gICAgICAgIFwic3RhdHVzXCI6IFwie3ttZWRpYV9zdGF0dXN9fVwiLFxuICAgICAgICBcInN0YXR1czRrXCI6IFwie3ttZWRpYV9zdGF0dXM0a319XCJcbiAgICB9LFxuICAgIFwie3tyZXF1ZXN0fX1cIjoge1xuICAgICAgICBcInJlcXVlc3RfaWRcIjogXCJ7e3JlcXVlc3RfaWR9fVwiLFxuICAgICAgICBcInJlcXVlc3RlZEJ5X2VtYWlsXCI6IFwie3tyZXF1ZXN0ZWRCeV9lbWFpbH19XCIsXG4gICAgICAgIFwicmVxdWVzdGVkQnlfdXNlcm5hbWVcIjogXCJ7e3JlcXVlc3RlZEJ5X3VzZXJuYW1lfX1cIixcbiAgICAgICAgXCJyZXF1ZXN0ZWRCeV9hdmF0YXJcIjogXCJ7e3JlcXVlc3RlZEJ5X2F2YXRhcn19XCJcbiAgICB9LFxuICAgIFwie3tpc3N1ZX19XCI6IHtcbiAgICAgICAgXCJpc3N1ZV9pZFwiOiBcInt7aXNzdWVfaWR9fVwiLFxuICAgICAgICBcImlzc3VlX3R5cGVcIjogXCJ7e2lzc3VlX3R5cGV9fVwiLFxuICAgICAgICBcImlzc3VlX3N0YXR1c1wiOiBcInt7aXNzdWVfc3RhdHVzfX1cIixcbiAgICAgICAgXCJyZXBvcnRlZEJ5X2VtYWlsXCI6IFwie3tyZXBvcnRlZEJ5X2VtYWlsfX1cIixcbiAgICAgICAgXCJyZXBvcnRlZEJ5X3VzZXJuYW1lXCI6IFwie3tyZXBvcnRlZEJ5X3VzZXJuYW1lfX1cIixcbiAgICAgICAgXCJyZXBvcnRlZEJ5X2F2YXRhclwiOiBcInt7cmVwb3J0ZWRCeV9hdmF0YXJ9fVwiXG4gICAgfSxcbiAgICBcInt7Y29tbWVudH19XCI6IHtcbiAgICAgICAgXCJjb21tZW50X21lc3NhZ2VcIjogXCJ7e2NvbW1lbnRfbWVzc2FnZX19XCIsXG4gICAgICAgIFwiY29tbWVudGVkQnlfZW1haWxcIjogXCJ7e2NvbW1lbnRlZEJ5X2VtYWlsfX1cIixcbiAgICAgICAgXCJjb21tZW50ZWRCeV91c2VybmFtZVwiOiBcInt7Y29tbWVudGVkQnlfdXNlcm5hbWV9fVwiLFxuICAgICAgICBcImNvbW1lbnRlZEJ5X2F2YXRhclwiOiBcInt7Y29tbWVudGVkQnlfYXZhdGFyfX1cIlxuICAgIH0sXG4gICAgXCJ7e2V4dHJhfX1cIjogW11cbn0i',
|
||||
},
|
||||
},
|
||||
webpush: {
|
||||
enabled: false,
|
||||
options: {},
|
||||
},
|
||||
gotify: {
|
||||
enabled: false,
|
||||
types: 0,
|
||||
options: {
|
||||
url: '',
|
||||
token: '',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
jobs: {
|
||||
@@ -405,6 +437,14 @@ class Settings {
|
||||
this.data.plex = data;
|
||||
}
|
||||
|
||||
get tautulli(): TautulliSettings {
|
||||
return this.data.tautulli;
|
||||
}
|
||||
|
||||
set tautulli(data: TautulliSettings) {
|
||||
this.data.tautulli = data;
|
||||
}
|
||||
|
||||
get radarr(): RadarrSettings[] {
|
||||
return this.data.radarr;
|
||||
}
|
||||
@@ -450,6 +490,7 @@ class Settings {
|
||||
enablePushRegistration: this.data.notifications.agents.webpush.enabled,
|
||||
locale: this.data.main.locale,
|
||||
emailEnabled: this.data.notifications.agents.email.enabled,
|
||||
newPlexLogin: this.data.main.newPlexLogin,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import * as winston from 'winston';
|
||||
import 'winston-daily-rotate-file';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
|
||||
// Migrate away from old log
|
||||
const OLD_LOG_FILE = path.join(__dirname, '../config/logs/overseerr.log');
|
||||
@@ -52,6 +52,22 @@ const logger = winston.createLogger({
|
||||
createSymlink: true,
|
||||
symlinkName: 'overseerr.log',
|
||||
}),
|
||||
new winston.transports.DailyRotateFile({
|
||||
filename: process.env.CONFIG_DIRECTORY
|
||||
? `${process.env.CONFIG_DIRECTORY}/logs/.machinelogs-%DATE%.json`
|
||||
: path.join(__dirname, '../config/logs/.machinelogs-%DATE%.json'),
|
||||
datePattern: 'YYYY-MM-DD',
|
||||
zippedArchive: true,
|
||||
maxSize: '20m',
|
||||
maxFiles: '1d',
|
||||
createSymlink: true,
|
||||
symlinkName: '.machinelogs.json',
|
||||
format: winston.format.combine(
|
||||
winston.format.splat(),
|
||||
winston.format.timestamp(),
|
||||
winston.format.json()
|
||||
),
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
|
||||
55
server/migration/1634904083966-AddIssues.ts
Normal file
55
server/migration/1634904083966-AddIssues.ts
Normal file
@@ -0,0 +1,55 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddIssues1634904083966 implements MigrationInterface {
|
||||
name = 'AddIssues1634904083966';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "issue" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "issueType" integer NOT NULL, "status" integer NOT NULL DEFAULT (1), "problemSeason" integer NOT NULL DEFAULT (0), "problemEpisode" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "mediaId" integer, "createdById" integer, "modifiedById" integer)`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "issue_comment" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "message" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "userId" integer, "issueId" integer)`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "temporary_issue" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "issueType" integer NOT NULL, "status" integer NOT NULL DEFAULT (1), "problemSeason" integer NOT NULL DEFAULT (0), "problemEpisode" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "mediaId" integer, "createdById" integer, "modifiedById" integer, CONSTRAINT "FK_276e20d053f3cff1645803c95d8" FOREIGN KEY ("mediaId") REFERENCES "media" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_10b17b49d1ee77e7184216001e0" FOREIGN KEY ("createdById") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_da88a1019c850d1a7b143ca02e5" FOREIGN KEY ("modifiedById") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "temporary_issue"("id", "issueType", "status", "problemSeason", "problemEpisode", "createdAt", "updatedAt", "mediaId", "createdById", "modifiedById") SELECT "id", "issueType", "status", "problemSeason", "problemEpisode", "createdAt", "updatedAt", "mediaId", "createdById", "modifiedById" FROM "issue"`
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "issue"`);
|
||||
await queryRunner.query(`ALTER TABLE "temporary_issue" RENAME TO "issue"`);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "temporary_issue_comment" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "message" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "userId" integer, "issueId" integer, CONSTRAINT "FK_707b033c2d0653f75213614789d" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_180710fead1c94ca499c57a7d42" FOREIGN KEY ("issueId") REFERENCES "issue" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "temporary_issue_comment"("id", "message", "createdAt", "updatedAt", "userId", "issueId") SELECT "id", "message", "createdAt", "updatedAt", "userId", "issueId" FROM "issue_comment"`
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "issue_comment"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "temporary_issue_comment" RENAME TO "issue_comment"`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "issue_comment" RENAME TO "temporary_issue_comment"`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "issue_comment" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "message" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "userId" integer, "issueId" integer)`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "issue_comment"("id", "message", "createdAt", "updatedAt", "userId", "issueId") SELECT "id", "message", "createdAt", "updatedAt", "userId", "issueId" FROM "temporary_issue_comment"`
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "temporary_issue_comment"`);
|
||||
await queryRunner.query(`ALTER TABLE "issue" RENAME TO "temporary_issue"`);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "issue" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "issueType" integer NOT NULL, "status" integer NOT NULL DEFAULT (1), "problemSeason" integer NOT NULL DEFAULT (0), "problemEpisode" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "mediaId" integer, "createdById" integer, "modifiedById" integer)`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "issue"("id", "issueType", "status", "problemSeason", "problemEpisode", "createdAt", "updatedAt", "mediaId", "createdById", "modifiedById") SELECT "id", "issueType", "status", "problemSeason", "problemEpisode", "createdAt", "updatedAt", "mediaId", "createdById", "modifiedById" FROM "temporary_issue"`
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "temporary_issue"`);
|
||||
await queryRunner.query(`DROP TABLE "issue_comment"`);
|
||||
await queryRunner.query(`DROP TABLE "issue"`);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
import { MigrationInterface, QueryRunner } from 'typeorm';
|
||||
|
||||
export class AddPushbulletPushoverUserSettings1635079863457
|
||||
implements MigrationInterface
|
||||
{
|
||||
name = 'AddPushbulletPushoverUserSettings1635079863457';
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "temporary_user_settings" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "notificationTypes" text, "discordId" varchar, "userId" integer, "region" varchar, "originalLanguage" varchar, "telegramChatId" varchar, "telegramSendSilently" boolean, "pgpKey" varchar, "locale" varchar NOT NULL DEFAULT (''), "pushbulletAccessToken" varchar, "pushoverApplicationToken" varchar, "pushoverUserKey" varchar, CONSTRAINT "UQ_986a2b6d3c05eb4091bb8066f78" UNIQUE ("userId"), CONSTRAINT "FK_986a2b6d3c05eb4091bb8066f78" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "temporary_user_settings"("id", "notificationTypes", "discordId", "userId", "region", "originalLanguage", "telegramChatId", "telegramSendSilently", "pgpKey", "locale") SELECT "id", "notificationTypes", "discordId", "userId", "region", "originalLanguage", "telegramChatId", "telegramSendSilently", "pgpKey", "locale" FROM "user_settings"`
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "user_settings"`);
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "temporary_user_settings" RENAME TO "user_settings"`
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(
|
||||
`ALTER TABLE "user_settings" RENAME TO "temporary_user_settings"`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`CREATE TABLE "user_settings" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "notificationTypes" text, "discordId" varchar, "userId" integer, "region" varchar, "originalLanguage" varchar, "telegramChatId" varchar, "telegramSendSilently" boolean, "pgpKey" varchar, "locale" varchar NOT NULL DEFAULT (''), CONSTRAINT "UQ_986a2b6d3c05eb4091bb8066f78" UNIQUE ("userId"), CONSTRAINT "FK_986a2b6d3c05eb4091bb8066f78" FOREIGN KEY ("userId") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`
|
||||
);
|
||||
await queryRunner.query(
|
||||
`INSERT INTO "user_settings"("id", "notificationTypes", "discordId", "userId", "region", "originalLanguage", "telegramChatId", "telegramSendSilently", "pgpKey", "locale") SELECT "id", "notificationTypes", "discordId", "userId", "region", "originalLanguage", "telegramChatId", "telegramSendSilently", "pgpKey", "locale" FROM "temporary_user_settings"`
|
||||
);
|
||||
await queryRunner.query(`DROP TABLE "temporary_user_settings"`);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import { sortBy } from 'lodash';
|
||||
import type { TmdbCollection } from '../api/themoviedb/interfaces';
|
||||
import { MediaType } from '../constants/media';
|
||||
import Media from '../entity/Media';
|
||||
@@ -21,7 +22,7 @@ export const mapCollection = (
|
||||
overview: collection.overview,
|
||||
posterPath: collection.poster_path,
|
||||
backdropPath: collection.backdrop_path,
|
||||
parts: collection.parts.map((part) =>
|
||||
parts: sortBy(collection.parts, 'release_date').map((part) =>
|
||||
mapMovieResult(
|
||||
part,
|
||||
media?.find(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type {
|
||||
TmdbPersonCreditCast,
|
||||
TmdbPersonCreditCrew,
|
||||
TmdbPersonDetail,
|
||||
TmdbPersonDetails,
|
||||
} from '../api/themoviedb/interfaces';
|
||||
import Media from '../entity/Media';
|
||||
|
||||
export interface PersonDetail {
|
||||
export interface PersonDetails {
|
||||
id: number;
|
||||
name: string;
|
||||
birthday: string;
|
||||
@@ -14,7 +14,7 @@ export interface PersonDetail {
|
||||
alsoKnownAs?: string[];
|
||||
gender: number;
|
||||
biography: string;
|
||||
popularity: string;
|
||||
popularity: number;
|
||||
placeOfBirth?: string;
|
||||
profilePath?: string;
|
||||
adult: boolean;
|
||||
@@ -62,7 +62,7 @@ export interface CombinedCredit {
|
||||
crew: PersonCreditCrew[];
|
||||
}
|
||||
|
||||
export const mapPersonDetails = (person: TmdbPersonDetail): PersonDetail => ({
|
||||
export const mapPersonDetails = (person: TmdbPersonDetails): PersonDetails => ({
|
||||
id: person.id,
|
||||
name: person.name,
|
||||
birthday: person.birthday,
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import type {
|
||||
TmdbMovieDetails,
|
||||
TmdbMovieResult,
|
||||
TmdbPersonDetails,
|
||||
TmdbPersonResult,
|
||||
TmdbTvDetails,
|
||||
TmdbTvResult,
|
||||
} from '../api/themoviedb/interfaces';
|
||||
import { MediaType as MainMediaType } from '../constants/media';
|
||||
@@ -140,3 +143,54 @@ export const mapSearchResults = (
|
||||
return mapPersonResult(result);
|
||||
}
|
||||
});
|
||||
|
||||
export const mapMovieDetailsToResult = (
|
||||
movieDetails: TmdbMovieDetails
|
||||
): TmdbMovieResult => ({
|
||||
id: movieDetails.id,
|
||||
media_type: 'movie',
|
||||
adult: movieDetails.adult,
|
||||
genre_ids: movieDetails.genres.map((genre) => genre.id),
|
||||
original_language: movieDetails.original_language,
|
||||
original_title: movieDetails.original_title,
|
||||
overview: movieDetails.overview ?? '',
|
||||
popularity: movieDetails.popularity,
|
||||
release_date: movieDetails.release_date,
|
||||
title: movieDetails.title,
|
||||
video: movieDetails.video,
|
||||
vote_average: movieDetails.vote_average,
|
||||
vote_count: movieDetails.vote_count,
|
||||
backdrop_path: movieDetails.backdrop_path,
|
||||
poster_path: movieDetails.poster_path,
|
||||
});
|
||||
|
||||
export const mapTvDetailsToResult = (
|
||||
tvDetails: TmdbTvDetails
|
||||
): TmdbTvResult => ({
|
||||
id: tvDetails.id,
|
||||
media_type: 'tv',
|
||||
first_air_date: tvDetails.first_air_date,
|
||||
genre_ids: tvDetails.genres.map((genre) => genre.id),
|
||||
name: tvDetails.name,
|
||||
origin_country: tvDetails.origin_country,
|
||||
original_language: tvDetails.original_language,
|
||||
original_name: tvDetails.original_name,
|
||||
overview: tvDetails.overview,
|
||||
popularity: tvDetails.popularity,
|
||||
vote_average: tvDetails.vote_average,
|
||||
vote_count: tvDetails.vote_count,
|
||||
backdrop_path: tvDetails.backdrop_path,
|
||||
poster_path: tvDetails.poster_path,
|
||||
});
|
||||
|
||||
export const mapPersonDetailsToResult = (
|
||||
personDetails: TmdbPersonDetails
|
||||
): TmdbPersonResult => ({
|
||||
id: personDetails.id,
|
||||
media_type: 'person',
|
||||
name: personDetails.name,
|
||||
popularity: personDetails.popularity,
|
||||
adult: personDetails.adult,
|
||||
profile_path: personDetails.profile_path,
|
||||
known_for: [],
|
||||
});
|
||||
|
||||
@@ -90,6 +90,10 @@ export interface TvDetails {
|
||||
overview: string;
|
||||
popularity: number;
|
||||
productionCompanies: ProductionCompany[];
|
||||
productionCountries: {
|
||||
iso_3166_1: string;
|
||||
name: string;
|
||||
}[];
|
||||
spokenLanguages: SpokenLanguage[];
|
||||
seasons: Season[];
|
||||
status: string;
|
||||
@@ -187,6 +191,7 @@ export const mapTvDetails = (
|
||||
originCountry: company.origin_country,
|
||||
logoPath: company.logo_path,
|
||||
})),
|
||||
productionCountries: show.production_countries,
|
||||
contentRatings: show.content_ratings,
|
||||
spokenLanguages: show.spoken_languages.map((language) => ({
|
||||
englishName: language.english_name,
|
||||
|
||||
@@ -15,8 +15,7 @@ authRoutes.get('/me', isAuthenticated(), async (req, res) => {
|
||||
if (!req.user) {
|
||||
return res.status(500).json({
|
||||
status: 500,
|
||||
error:
|
||||
'Requested user endpoint without valid authenticated user in session',
|
||||
error: 'Please sign in.',
|
||||
});
|
||||
}
|
||||
const user = await userRepository.findOneOrFail({
|
||||
@@ -32,10 +31,13 @@ authRoutes.post('/plex', async (req, res, next) => {
|
||||
const body = req.body as { authToken?: string };
|
||||
|
||||
if (!body.authToken) {
|
||||
return res.status(500).json({ error: 'You must provide an auth token' });
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Authentication token required.',
|
||||
});
|
||||
}
|
||||
try {
|
||||
// First we need to use this auth token to get the users email from plex.tv
|
||||
// First we need to use this auth token to get the user's email from plex.tv
|
||||
const plextv = new PlexTvAPI(body.authToken);
|
||||
const account = await plextv.getUser();
|
||||
|
||||
@@ -48,71 +50,78 @@ authRoutes.post('/plex', async (req, res, next) => {
|
||||
})
|
||||
.getOne();
|
||||
|
||||
if (user) {
|
||||
// Let's check if their Plex token is up-to-date
|
||||
if (user.plexToken !== body.authToken) {
|
||||
user.plexToken = body.authToken;
|
||||
}
|
||||
|
||||
// Update the user's avatar with their Plex thumbnail, in case it changed
|
||||
user.avatar = account.thumb;
|
||||
user.email = account.email;
|
||||
user.plexUsername = account.username;
|
||||
|
||||
// In case the user was previously a local account
|
||||
if (user.userType === UserType.LOCAL) {
|
||||
user.userType = UserType.PLEX;
|
||||
user.plexId = account.id;
|
||||
}
|
||||
if (!user && !(await userRepository.count())) {
|
||||
user = new User({
|
||||
email: account.email,
|
||||
plexUsername: account.username,
|
||||
plexId: account.id,
|
||||
plexToken: account.authToken,
|
||||
permissions: Permission.ADMIN,
|
||||
avatar: account.thumb,
|
||||
userType: UserType.PLEX,
|
||||
});
|
||||
|
||||
await userRepository.save(user);
|
||||
} else {
|
||||
// Here we check if it's the first user. If it is, we create the user with no check
|
||||
// and give them admin permissions
|
||||
const totalUsers = await userRepository.count();
|
||||
const mainUser = await userRepository.findOneOrFail({
|
||||
select: ['id', 'plexToken', 'plexId'],
|
||||
order: { id: 'ASC' },
|
||||
});
|
||||
const mainPlexTv = new PlexTvAPI(mainUser.plexToken ?? '');
|
||||
|
||||
if (totalUsers === 0) {
|
||||
user = new User({
|
||||
email: account.email,
|
||||
plexUsername: account.username,
|
||||
plexId: account.id,
|
||||
plexToken: account.authToken,
|
||||
permissions: Permission.ADMIN,
|
||||
avatar: account.thumb,
|
||||
userType: UserType.PLEX,
|
||||
});
|
||||
await userRepository.save(user);
|
||||
}
|
||||
if (
|
||||
account.id === mainUser.plexId ||
|
||||
(await mainPlexTv.checkUserAccess(account.id))
|
||||
) {
|
||||
if (user) {
|
||||
if (!user.plexId) {
|
||||
logger.info(
|
||||
'Found matching Plex user; updating user with Plex data',
|
||||
{
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
email: user.email,
|
||||
userId: user.id,
|
||||
plexId: account.id,
|
||||
plexUsername: account.username,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Double check that we didn't create the first admin user before running this
|
||||
if (!user) {
|
||||
if (!settings.main.newPlexLogin) {
|
||||
logger.info(
|
||||
'Failed sign-in attempt from user who has not been imported to Overseerr.',
|
||||
user.plexToken = body.authToken;
|
||||
user.plexId = account.id;
|
||||
user.avatar = account.thumb;
|
||||
user.email = account.email;
|
||||
user.plexUsername = account.username;
|
||||
user.userType = UserType.PLEX;
|
||||
|
||||
await userRepository.save(user);
|
||||
} else if (!settings.main.newPlexLogin) {
|
||||
logger.warn(
|
||||
'Failed sign-in attempt by unimported Plex user with access to the media server',
|
||||
{
|
||||
label: 'Auth',
|
||||
account: {
|
||||
...account,
|
||||
authentication_token: '__REDACTED__',
|
||||
authToken: '__REDACTED__',
|
||||
},
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
email: account.email,
|
||||
plexId: account.id,
|
||||
plexUsername: account.username,
|
||||
}
|
||||
);
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'Access denied.',
|
||||
});
|
||||
}
|
||||
|
||||
// If we get to this point, the user does not already exist so we need to create the
|
||||
// user _assuming_ they have access to the Plex server
|
||||
const mainUser = await userRepository.findOneOrFail({
|
||||
select: ['id', 'plexToken'],
|
||||
order: { id: 'ASC' },
|
||||
});
|
||||
const mainPlexTv = new PlexTvAPI(mainUser.plexToken ?? '');
|
||||
|
||||
if (await mainPlexTv.checkUserAccess(account.id)) {
|
||||
} else {
|
||||
logger.info(
|
||||
'Sign-in attempt from Plex user with access to the media server; creating new Overseerr user',
|
||||
{
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
email: account.email,
|
||||
plexId: account.id,
|
||||
plexUsername: account.username,
|
||||
}
|
||||
);
|
||||
user = new User({
|
||||
email: account.email,
|
||||
plexUsername: account.username,
|
||||
@@ -122,24 +131,24 @@ authRoutes.post('/plex', async (req, res, next) => {
|
||||
avatar: account.thumb,
|
||||
userType: UserType.PLEX,
|
||||
});
|
||||
|
||||
await userRepository.save(user);
|
||||
} else {
|
||||
logger.info(
|
||||
'Failed sign-in attempt from user without access to the Plex server.',
|
||||
{
|
||||
label: 'Auth',
|
||||
account: {
|
||||
...account,
|
||||
authentication_token: '__REDACTED__',
|
||||
authToken: '__REDACTED__',
|
||||
},
|
||||
}
|
||||
);
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'Access denied.',
|
||||
});
|
||||
}
|
||||
} else {
|
||||
logger.warn(
|
||||
'Failed sign-in attempt by Plex user without access to the media server',
|
||||
{
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
email: account.email,
|
||||
plexId: account.id,
|
||||
plexUsername: account.username,
|
||||
}
|
||||
);
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'Access denied.',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,10 +159,14 @@ authRoutes.post('/plex', async (req, res, next) => {
|
||||
|
||||
return res.status(200).json(user?.filter() ?? {});
|
||||
} catch (e) {
|
||||
logger.error(e.message, { label: 'Auth' });
|
||||
logger.error('Something went wrong authenticating with Plex account', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
ip: req.ip,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Something went wrong.',
|
||||
message: 'Unable to authenticate.',
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -164,7 +177,7 @@ authRoutes.post('/local', async (req, res, next) => {
|
||||
const body = req.body as { email?: string; password?: string };
|
||||
|
||||
if (!settings.main.localLogin) {
|
||||
return res.status(500).json({ error: 'Local user sign-in is disabled.' });
|
||||
return res.status(500).json({ error: 'Password sign-in is disabled.' });
|
||||
} else if (!body.email || !body.password) {
|
||||
return res.status(500).json({
|
||||
error: 'You must provide both an email address and a password.',
|
||||
@@ -173,28 +186,77 @@ authRoutes.post('/local', async (req, res, next) => {
|
||||
try {
|
||||
const user = await userRepository
|
||||
.createQueryBuilder('user')
|
||||
.select(['user.id', 'user.password'])
|
||||
.select(['user.id', 'user.email', 'user.password', 'user.plexId'])
|
||||
.where('user.email = :email', { email: body.email.toLowerCase() })
|
||||
.getOne();
|
||||
|
||||
const isCorrectCredentials = await user?.passwordMatch(body.password);
|
||||
if (!user || !(await user.passwordMatch(body.password))) {
|
||||
logger.warn('Failed sign-in attempt using invalid Overseerr password', {
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
email: body.email,
|
||||
userId: user?.id,
|
||||
});
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'Access denied.',
|
||||
});
|
||||
}
|
||||
|
||||
// User doesn't exist or credentials are incorrect
|
||||
if (!isCorrectCredentials) {
|
||||
logger.info(
|
||||
'Failed sign-in attempt from user with incorrect credentials.',
|
||||
const mainUser = await userRepository.findOneOrFail({
|
||||
select: ['id', 'plexToken', 'plexId'],
|
||||
order: { id: 'ASC' },
|
||||
});
|
||||
const mainPlexTv = new PlexTvAPI(mainUser.plexToken ?? '');
|
||||
|
||||
if (!user.plexId) {
|
||||
const plexUsersResponse = await mainPlexTv.getUsers();
|
||||
const account = plexUsersResponse.MediaContainer.User.find(
|
||||
(account) =>
|
||||
account.$.email &&
|
||||
account.$.email.toLowerCase() === user.email.toLowerCase()
|
||||
)?.$;
|
||||
|
||||
if (account) {
|
||||
logger.info('Found matching Plex user; updating user with Plex data', {
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
email: body.email,
|
||||
userId: user.id,
|
||||
plexId: account.id,
|
||||
plexUsername: account.username,
|
||||
});
|
||||
|
||||
user.plexId = parseInt(account.id);
|
||||
user.avatar = account.thumb;
|
||||
user.email = account.email;
|
||||
user.plexUsername = account.username;
|
||||
user.userType = UserType.PLEX;
|
||||
|
||||
await userRepository.save(user);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
user.plexId &&
|
||||
user.plexId !== mainUser.plexId &&
|
||||
!(await mainPlexTv.checkUserAccess(user.plexId))
|
||||
) {
|
||||
logger.warn(
|
||||
'Failed sign-in attempt from Plex user without access to the media server',
|
||||
{
|
||||
label: 'Auth',
|
||||
label: 'API',
|
||||
account: {
|
||||
ip: req.ip,
|
||||
email: body.email,
|
||||
password: '__REDACTED__',
|
||||
userId: user.id,
|
||||
plexId: user.plexId,
|
||||
},
|
||||
}
|
||||
);
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'Your sign-in credentials are incorrect.',
|
||||
message: 'Access denied.',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -205,13 +267,18 @@ authRoutes.post('/local', async (req, res, next) => {
|
||||
|
||||
return res.status(200).json(user?.filter() ?? {});
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong while attempting to authenticate.', {
|
||||
label: 'Auth',
|
||||
error: e.message,
|
||||
});
|
||||
logger.error(
|
||||
'Something went wrong authenticating with Overseerr password',
|
||||
{
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
ip: req.ip,
|
||||
email: body.email,
|
||||
}
|
||||
);
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Something went wrong.',
|
||||
message: 'Unable to authenticate.',
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -221,7 +288,7 @@ authRoutes.post('/logout', (req, res, next) => {
|
||||
if (err) {
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Something went wrong while attempting to sign out.',
|
||||
message: 'Something went wrong.',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -229,14 +296,15 @@ authRoutes.post('/logout', (req, res, next) => {
|
||||
});
|
||||
});
|
||||
|
||||
authRoutes.post('/reset-password', async (req, res) => {
|
||||
authRoutes.post('/reset-password', async (req, res, next) => {
|
||||
const userRepository = getRepository(User);
|
||||
const body = req.body as { email?: string };
|
||||
|
||||
if (!body.email) {
|
||||
return res
|
||||
.status(500)
|
||||
.json({ error: 'You must provide an email address.' });
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Email address required.',
|
||||
});
|
||||
}
|
||||
|
||||
const user = await userRepository
|
||||
@@ -247,14 +315,16 @@ authRoutes.post('/reset-password', async (req, res) => {
|
||||
if (user) {
|
||||
await user.resetPassword();
|
||||
userRepository.save(user);
|
||||
logger.info('Successful request made for recovery link.', {
|
||||
label: 'User Management',
|
||||
context: { ip: req.ip, email: body.email },
|
||||
logger.info('Successfully sent password reset link', {
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
email: body.email,
|
||||
});
|
||||
} else {
|
||||
logger.info('Failed request made to reset a password.', {
|
||||
label: 'User Management',
|
||||
context: { ip: req.ip, email: body.email },
|
||||
logger.error('Something went wrong sending password reset link', {
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
email: body.email,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -264,48 +334,61 @@ authRoutes.post('/reset-password', async (req, res) => {
|
||||
authRoutes.post('/reset-password/:guid', async (req, res, next) => {
|
||||
const userRepository = getRepository(User);
|
||||
|
||||
try {
|
||||
if (!req.body.password || req.body.password?.length < 8) {
|
||||
const message =
|
||||
'Failed to reset password. Password must be at least 8 characters long.';
|
||||
logger.info(message, {
|
||||
label: 'User Management',
|
||||
context: { ip: req.ip, guid: req.params.guid },
|
||||
});
|
||||
return next({ status: 500, message: message });
|
||||
}
|
||||
|
||||
const user = await userRepository.findOne({
|
||||
where: { resetPasswordGuid: req.params.guid },
|
||||
if (!req.body.password || req.body.password?.length < 8) {
|
||||
logger.warn('Failed password reset attempt using invalid new password', {
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
guid: req.params.guid,
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
throw new Error('Guid invalid.');
|
||||
}
|
||||
|
||||
if (
|
||||
!user.recoveryLinkExpirationDate ||
|
||||
user.recoveryLinkExpirationDate <= new Date()
|
||||
) {
|
||||
throw new Error('Recovery link expired.');
|
||||
}
|
||||
|
||||
await user.setPassword(req.body.password);
|
||||
user.recoveryLinkExpirationDate = null;
|
||||
userRepository.save(user);
|
||||
logger.info(`Successfully reset password`, {
|
||||
label: 'User Management',
|
||||
context: { ip: req.ip, guid: req.params.guid, email: user.email },
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Password must be at least 8 characters long.',
|
||||
});
|
||||
|
||||
return res.status(200).json({ status: 'ok' });
|
||||
} catch (e) {
|
||||
logger.info(`Failed to reset password. ${e.message}`, {
|
||||
label: 'User Management',
|
||||
context: { ip: req.ip, guid: req.params.guid },
|
||||
});
|
||||
return res.status(200).json({ status: 'ok' });
|
||||
}
|
||||
|
||||
const user = await userRepository.findOne({
|
||||
where: { resetPasswordGuid: req.params.guid },
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
logger.warn('Failed password reset attempt using invalid recovery link', {
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
guid: req.params.guid,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Invalid password reset link.',
|
||||
});
|
||||
}
|
||||
|
||||
if (
|
||||
!user.recoveryLinkExpirationDate ||
|
||||
user.recoveryLinkExpirationDate <= new Date()
|
||||
) {
|
||||
logger.warn('Failed password reset attempt using expired recovery link', {
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
guid: req.params.guid,
|
||||
email: user.email,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Invalid password reset link.',
|
||||
});
|
||||
}
|
||||
|
||||
await user.setPassword(req.body.password);
|
||||
user.recoveryLinkExpirationDate = null;
|
||||
userRepository.save(user);
|
||||
logger.info('Successfully reset password', {
|
||||
label: 'API',
|
||||
ip: req.ip,
|
||||
guid: req.params.guid,
|
||||
email: user.email,
|
||||
});
|
||||
|
||||
return res.status(200).json({ status: 'ok' });
|
||||
});
|
||||
|
||||
export default authRoutes;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Router } from 'express';
|
||||
import TheMovieDb from '../api/themoviedb';
|
||||
import Media from '../entity/Media';
|
||||
import logger from '../logger';
|
||||
import { mapCollection } from '../models/Collection';
|
||||
|
||||
const collectionRoutes = Router();
|
||||
@@ -20,7 +21,15 @@ collectionRoutes.get<{ id: string }>('/:id', async (req, res, next) => {
|
||||
|
||||
return res.status(200).json(mapCollection(collection, media));
|
||||
} catch (e) {
|
||||
return next({ status: 404, message: 'Collection does not exist' });
|
||||
logger.debug('Something went wrong retrieving collection', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
collectionId: req.params.id,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve collection.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -37,54 +37,15 @@ export const createTmdbWithRegionLanguage = (user?: User): TheMovieDb => {
|
||||
|
||||
const discoverRoutes = Router();
|
||||
|
||||
discoverRoutes.get('/movies', async (req, res) => {
|
||||
discoverRoutes.get('/movies', async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
const data = await tmdb.getDiscoverMovies({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
genre: req.query.genre ? Number(req.query.genre) : undefined,
|
||||
studio: req.query.studio ? Number(req.query.studio) : undefined,
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
results: data.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(req) => req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
discoverRoutes.get<{ language: string }>(
|
||||
'/movies/language/:language',
|
||||
async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
const languages = await tmdb.getLanguages();
|
||||
|
||||
const language = languages.find(
|
||||
(lang) => lang.iso_639_1 === req.params.language
|
||||
);
|
||||
|
||||
if (!language) {
|
||||
return next({ status: 404, message: 'Unable to retrieve language' });
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await tmdb.getDiscoverMovies({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
originalLanguage: req.params.language,
|
||||
genre: req.query.genre ? Number(req.query.genre) : undefined,
|
||||
studio: req.query.studio ? Number(req.query.studio) : undefined,
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
@@ -95,7 +56,6 @@ discoverRoutes.get<{ language: string }>(
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
language,
|
||||
results: data.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
@@ -106,6 +66,70 @@ discoverRoutes.get<{ language: string }>(
|
||||
)
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving popular movies', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve popular movies.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
discoverRoutes.get<{ language: string }>(
|
||||
'/movies/language/:language',
|
||||
async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
try {
|
||||
const languages = await tmdb.getLanguages();
|
||||
|
||||
const language = languages.find(
|
||||
(lang) => lang.iso_639_1 === req.params.language
|
||||
);
|
||||
|
||||
if (!language) {
|
||||
return next({ status: 404, message: 'Language not found.' });
|
||||
}
|
||||
|
||||
const data = await tmdb.getDiscoverMovies({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
originalLanguage: req.params.language,
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
language,
|
||||
results: data.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(req) =>
|
||||
req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving movies by language', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
language: req.params.language,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve movies by language.',
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -114,43 +138,55 @@ discoverRoutes.get<{ genreId: string }>(
|
||||
async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
const genres = await tmdb.getMovieGenres({
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
try {
|
||||
const genres = await tmdb.getMovieGenres({
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
|
||||
const genre = genres.find(
|
||||
(genre) => genre.id === Number(req.params.genreId)
|
||||
);
|
||||
const genre = genres.find(
|
||||
(genre) => genre.id === Number(req.params.genreId)
|
||||
);
|
||||
|
||||
if (!genre) {
|
||||
return next({ status: 404, message: 'Unable to retrieve genre' });
|
||||
}
|
||||
if (!genre) {
|
||||
return next({ status: 404, message: 'Genre not found.' });
|
||||
}
|
||||
|
||||
const data = await tmdb.getDiscoverMovies({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
genre: Number(req.params.genreId),
|
||||
});
|
||||
const data = await tmdb.getDiscoverMovies({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
genre: Number(req.params.genreId),
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
genre,
|
||||
results: data.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(req) =>
|
||||
req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
genre,
|
||||
results: data.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(req) =>
|
||||
req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving movies by genre', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
genreId: req.params.genreId,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve movies by genre.',
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -188,12 +224,20 @@ discoverRoutes.get<{ studioId: string }>(
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
return next({ status: 404, message: 'Unable to retrieve studio' });
|
||||
logger.debug('Something went wrong retrieving movies by studio', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
studioId: req.params.studioId,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve movies by studio.',
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
discoverRoutes.get('/movies/upcoming', async (req, res) => {
|
||||
discoverRoutes.get('/movies/upcoming', async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
const now = new Date();
|
||||
@@ -202,79 +246,52 @@ discoverRoutes.get('/movies/upcoming', async (req, res) => {
|
||||
.toISOString()
|
||||
.split('T')[0];
|
||||
|
||||
const data = await tmdb.getDiscoverMovies({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
primaryReleaseDateGte: date,
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
results: data.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) => med.tmdbId === result.id && med.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
discoverRoutes.get('/tv', async (req, res) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
const data = await tmdb.getDiscoverTv({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
genre: req.query.genre ? Number(req.query.genre) : undefined,
|
||||
network: req.query.network ? Number(req.query.network) : undefined,
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
results: data.results.map((result) =>
|
||||
mapTvResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) => med.tmdbId === result.id && med.mediaType === MediaType.TV
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
discoverRoutes.get<{ language: string }>(
|
||||
'/tv/language/:language',
|
||||
async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
const languages = await tmdb.getLanguages();
|
||||
|
||||
const language = languages.find(
|
||||
(lang) => lang.iso_639_1 === req.params.language
|
||||
);
|
||||
|
||||
if (!language) {
|
||||
return next({ status: 404, message: 'Unable to retrieve language' });
|
||||
}
|
||||
|
||||
const data = await tmdb.getDiscoverTv({
|
||||
try {
|
||||
const data = await tmdb.getDiscoverMovies({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
originalLanguage: req.params.language,
|
||||
primaryReleaseDateGte: date,
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
results: data.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving upcoming movies', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve upcoming movies.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
discoverRoutes.get('/tv', async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
try {
|
||||
const data = await tmdb.getDiscoverTv({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
genre: req.query.genre ? Number(req.query.genre) : undefined,
|
||||
network: req.query.network ? Number(req.query.network) : undefined,
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
@@ -285,7 +302,6 @@ discoverRoutes.get<{ language: string }>(
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
language,
|
||||
results: data.results.map((result) =>
|
||||
mapTvResult(
|
||||
result,
|
||||
@@ -295,6 +311,70 @@ discoverRoutes.get<{ language: string }>(
|
||||
)
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving popular series', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve popular series.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
discoverRoutes.get<{ language: string }>(
|
||||
'/tv/language/:language',
|
||||
async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
try {
|
||||
const languages = await tmdb.getLanguages();
|
||||
|
||||
const language = languages.find(
|
||||
(lang) => lang.iso_639_1 === req.params.language
|
||||
);
|
||||
|
||||
if (!language) {
|
||||
return next({ status: 404, message: 'Language not found.' });
|
||||
}
|
||||
|
||||
const data = await tmdb.getDiscoverTv({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
originalLanguage: req.params.language,
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
language,
|
||||
results: data.results.map((result) =>
|
||||
mapTvResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === MediaType.TV
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving series by language', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
language: req.params.language,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve series by language.',
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -303,42 +383,55 @@ discoverRoutes.get<{ genreId: string }>(
|
||||
async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
const genres = await tmdb.getTvGenres({
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
try {
|
||||
const genres = await tmdb.getTvGenres({
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
|
||||
const genre = genres.find(
|
||||
(genre) => genre.id === Number(req.params.genreId)
|
||||
);
|
||||
const genre = genres.find(
|
||||
(genre) => genre.id === Number(req.params.genreId)
|
||||
);
|
||||
|
||||
if (!genre) {
|
||||
return next({ status: 404, message: 'Unable to retrieve genre' });
|
||||
}
|
||||
if (!genre) {
|
||||
return next({ status: 404, message: 'Genre not found.' });
|
||||
}
|
||||
|
||||
const data = await tmdb.getDiscoverTv({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
genre: Number(req.params.genreId),
|
||||
});
|
||||
const data = await tmdb.getDiscoverTv({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
genre: Number(req.params.genreId),
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
genre,
|
||||
results: data.results.map((result) =>
|
||||
mapTvResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) => med.tmdbId === result.id && med.mediaType === MediaType.TV
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
genre,
|
||||
results: data.results.map((result) =>
|
||||
mapTvResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === MediaType.TV
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving series by genre', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
genreId: req.params.genreId,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve series by genre.',
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -376,12 +469,20 @@ discoverRoutes.get<{ networkId: string }>(
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
return next({ status: 404, message: 'Unable to retrieve network' });
|
||||
logger.debug('Something went wrong retrieving series by network', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
networkId: req.params.networkId,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve series by network.',
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
discoverRoutes.get('/tv/upcoming', async (req, res) => {
|
||||
discoverRoutes.get('/tv/upcoming', async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
const now = new Date();
|
||||
@@ -390,76 +491,47 @@ discoverRoutes.get('/tv/upcoming', async (req, res) => {
|
||||
.toISOString()
|
||||
.split('T')[0];
|
||||
|
||||
const data = await tmdb.getDiscoverTv({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
firstAirDateGte: date,
|
||||
});
|
||||
try {
|
||||
const data = await tmdb.getDiscoverTv({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
firstAirDateGte: date,
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
results: data.results.map((result) =>
|
||||
mapTvResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) => med.tmdbId === result.id && med.mediaType === MediaType.TV
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
results: data.results.map((result) =>
|
||||
mapTvResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) => med.tmdbId === result.id && med.mediaType === MediaType.TV
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving upcoming series', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve upcoming series.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
discoverRoutes.get('/trending', async (req, res) => {
|
||||
discoverRoutes.get('/trending', async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage(req.user);
|
||||
|
||||
const data = await tmdb.getAllTrending({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
results: data.results.map((result) =>
|
||||
isMovie(result)
|
||||
? mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
: isPerson(result)
|
||||
? mapPersonResult(result)
|
||||
: mapTvResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === MediaType.TV
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
});
|
||||
|
||||
discoverRoutes.get<{ keywordId: string }>(
|
||||
'/keyword/:keywordId/movies',
|
||||
async (req, res) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const data = await tmdb.getMoviesByKeyword({
|
||||
keywordId: Number(req.params.keywordId),
|
||||
try {
|
||||
const data = await tmdb.getAllTrending({
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
@@ -473,15 +545,78 @@ discoverRoutes.get<{ keywordId: string }>(
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
results: data.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
isMovie(result)
|
||||
? mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
: isPerson(result)
|
||||
? mapPersonResult(result)
|
||||
: mapTvResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === MediaType.TV
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving trending items', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve trending items.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
discoverRoutes.get<{ keywordId: string }>(
|
||||
'/keyword/:keywordId/movies',
|
||||
async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
try {
|
||||
const data = await tmdb.getMoviesByKeyword({
|
||||
keywordId: Number(req.params.keywordId),
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
data.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: data.page,
|
||||
totalPages: data.total_pages,
|
||||
totalResults: data.total_results,
|
||||
results: data.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving movies by keyword', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
keywordId: req.params.keywordId,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve movies by keyword.',
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -515,7 +650,8 @@ discoverRoutes.get<{ language: string }, GenreSliderItem[]>(
|
||||
|
||||
return res.status(200).json(sortedData);
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong retrieving the movie genre slider', {
|
||||
logger.debug('Something went wrong retrieving the movie genre slider', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
@@ -556,12 +692,13 @@ discoverRoutes.get<{ language: string }, GenreSliderItem[]>(
|
||||
|
||||
return res.status(200).json(sortedData);
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong retrieving the tv genre slider', {
|
||||
logger.debug('Something went wrong retrieving the series genre slider', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve tv genre slider.',
|
||||
message: 'Unable to retrieve series genre slider.',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import { TmdbMovieResult, TmdbTvResult } from '../api/themoviedb/interfaces';
|
||||
import { StatusResponse } from '../interfaces/api/settingsInterfaces';
|
||||
import { Permission } from '../lib/permissions';
|
||||
import { getSettings } from '../lib/settings';
|
||||
import logger from '../logger';
|
||||
import { checkUser, isAuthenticated } from '../middleware/auth';
|
||||
import { mapProductionCompany } from '../models/Movie';
|
||||
import { mapNetwork } from '../models/Tv';
|
||||
@@ -14,6 +15,8 @@ import { isPerson } from '../utils/typeHelpers';
|
||||
import authRoutes from './auth';
|
||||
import collectionRoutes from './collection';
|
||||
import discoverRoutes, { createTmdbWithRegionLanguage } from './discover';
|
||||
import issueRoutes from './issue';
|
||||
import issueCommentRoutes from './issueComment';
|
||||
import mediaRoutes from './media';
|
||||
import movieRoutes from './movie';
|
||||
import personRoutes from './person';
|
||||
@@ -108,80 +111,161 @@ router.use('/media', isAuthenticated(), mediaRoutes);
|
||||
router.use('/person', isAuthenticated(), personRoutes);
|
||||
router.use('/collection', isAuthenticated(), collectionRoutes);
|
||||
router.use('/service', isAuthenticated(), serviceRoutes);
|
||||
router.use('/issue', isAuthenticated(), issueRoutes);
|
||||
router.use('/issueComment', isAuthenticated(), issueCommentRoutes);
|
||||
router.use('/auth', authRoutes);
|
||||
|
||||
router.get('/regions', isAuthenticated(), async (req, res) => {
|
||||
router.get('/regions', isAuthenticated(), async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const regions = await tmdb.getRegions();
|
||||
try {
|
||||
const regions = await tmdb.getRegions();
|
||||
|
||||
return res.status(200).json(regions);
|
||||
return res.status(200).json(regions);
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving regions', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve regions.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/languages', isAuthenticated(), async (req, res) => {
|
||||
router.get('/languages', isAuthenticated(), async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const languages = await tmdb.getLanguages();
|
||||
try {
|
||||
const languages = await tmdb.getLanguages();
|
||||
|
||||
return res.status(200).json(languages);
|
||||
return res.status(200).json(languages);
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving languages', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve languages.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get<{ id: string }>('/studio/:id', async (req, res) => {
|
||||
router.get<{ id: string }>('/studio/:id', async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const studio = await tmdb.getStudio(Number(req.params.id));
|
||||
try {
|
||||
const studio = await tmdb.getStudio(Number(req.params.id));
|
||||
|
||||
return res.status(200).json(mapProductionCompany(studio));
|
||||
return res.status(200).json(mapProductionCompany(studio));
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving studio', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
studioId: req.params.id,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve studio.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get<{ id: string }>('/network/:id', async (req, res) => {
|
||||
router.get<{ id: string }>('/network/:id', async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const network = await tmdb.getNetwork(Number(req.params.id));
|
||||
try {
|
||||
const network = await tmdb.getNetwork(Number(req.params.id));
|
||||
|
||||
return res.status(200).json(mapNetwork(network));
|
||||
return res.status(200).json(mapNetwork(network));
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving network', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
networkId: req.params.id,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve network.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/genres/movie', isAuthenticated(), async (req, res) => {
|
||||
router.get('/genres/movie', isAuthenticated(), async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const genres = await tmdb.getMovieGenres({
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
try {
|
||||
const genres = await tmdb.getMovieGenres({
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
|
||||
return res.status(200).json(genres);
|
||||
return res.status(200).json(genres);
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving movie genres', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve movie genres.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/genres/tv', isAuthenticated(), async (req, res) => {
|
||||
router.get('/genres/tv', isAuthenticated(), async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const genres = await tmdb.getTvGenres({
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
try {
|
||||
const genres = await tmdb.getTvGenres({
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
|
||||
return res.status(200).json(genres);
|
||||
return res.status(200).json(genres);
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving series genres', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve series genres.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/backdrops', async (req, res) => {
|
||||
router.get('/backdrops', async (req, res, next) => {
|
||||
const tmdb = createTmdbWithRegionLanguage();
|
||||
|
||||
const data = (
|
||||
await tmdb.getAllTrending({
|
||||
page: 1,
|
||||
timeWindow: 'week',
|
||||
})
|
||||
).results.filter((result) => !isPerson(result)) as (
|
||||
| TmdbMovieResult
|
||||
| TmdbTvResult
|
||||
)[];
|
||||
try {
|
||||
const data = (
|
||||
await tmdb.getAllTrending({
|
||||
page: 1,
|
||||
timeWindow: 'week',
|
||||
})
|
||||
).results.filter((result) => !isPerson(result)) as (
|
||||
| TmdbMovieResult
|
||||
| TmdbTvResult
|
||||
)[];
|
||||
|
||||
return res
|
||||
.status(200)
|
||||
.json(
|
||||
data
|
||||
.map((result) => result.backdrop_path)
|
||||
.filter((backdropPath) => !!backdropPath)
|
||||
);
|
||||
return res
|
||||
.status(200)
|
||||
.json(
|
||||
data
|
||||
.map((result) => result.backdrop_path)
|
||||
.filter((backdropPath) => !!backdropPath)
|
||||
);
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving backdrops', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve backdrops.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/', (_req, res) => {
|
||||
|
||||
332
server/routes/issue.ts
Normal file
332
server/routes/issue.ts
Normal file
@@ -0,0 +1,332 @@
|
||||
import { Router } from 'express';
|
||||
import { getRepository } from 'typeorm';
|
||||
import { IssueStatus } from '../constants/issue';
|
||||
import Issue from '../entity/Issue';
|
||||
import IssueComment from '../entity/IssueComment';
|
||||
import Media from '../entity/Media';
|
||||
import { IssueResultsResponse } from '../interfaces/api/issueInterfaces';
|
||||
import { Permission } from '../lib/permissions';
|
||||
import logger from '../logger';
|
||||
import { isAuthenticated } from '../middleware/auth';
|
||||
|
||||
const issueRoutes = Router();
|
||||
|
||||
issueRoutes.get<Record<string, string>, IssueResultsResponse>(
|
||||
'/',
|
||||
isAuthenticated(
|
||||
[
|
||||
Permission.MANAGE_ISSUES,
|
||||
Permission.VIEW_ISSUES,
|
||||
Permission.CREATE_ISSUES,
|
||||
],
|
||||
{ type: 'or' }
|
||||
),
|
||||
async (req, res, next) => {
|
||||
const pageSize = req.query.take ? Number(req.query.take) : 10;
|
||||
const skip = req.query.skip ? Number(req.query.skip) : 0;
|
||||
const createdBy = req.query.createdBy ? Number(req.query.createdBy) : null;
|
||||
|
||||
let sortFilter: string;
|
||||
|
||||
switch (req.query.sort) {
|
||||
case 'modified':
|
||||
sortFilter = 'issue.updatedAt';
|
||||
break;
|
||||
default:
|
||||
sortFilter = 'issue.createdAt';
|
||||
}
|
||||
|
||||
let statusFilter: IssueStatus[];
|
||||
|
||||
switch (req.query.filter) {
|
||||
case 'open':
|
||||
statusFilter = [IssueStatus.OPEN];
|
||||
break;
|
||||
case 'resolved':
|
||||
statusFilter = [IssueStatus.RESOLVED];
|
||||
break;
|
||||
default:
|
||||
statusFilter = [IssueStatus.OPEN, IssueStatus.RESOLVED];
|
||||
}
|
||||
|
||||
let query = getRepository(Issue)
|
||||
.createQueryBuilder('issue')
|
||||
.leftJoinAndSelect('issue.createdBy', 'createdBy')
|
||||
.leftJoinAndSelect('issue.media', 'media')
|
||||
.leftJoinAndSelect('issue.modifiedBy', 'modifiedBy')
|
||||
.where('issue.status IN (:...issueStatus)', {
|
||||
issueStatus: statusFilter,
|
||||
});
|
||||
|
||||
if (
|
||||
!req.user?.hasPermission(
|
||||
[Permission.MANAGE_ISSUES, Permission.VIEW_ISSUES],
|
||||
{ type: 'or' }
|
||||
)
|
||||
) {
|
||||
if (createdBy && createdBy !== req.user?.id) {
|
||||
return next({
|
||||
status: 403,
|
||||
message:
|
||||
'You do not have permission to view issues reported by other users',
|
||||
});
|
||||
}
|
||||
query = query.andWhere('createdBy.id = :id', { id: req.user?.id });
|
||||
} else if (createdBy) {
|
||||
query = query.andWhere('createdBy.id = :id', { id: createdBy });
|
||||
}
|
||||
|
||||
const [issues, issueCount] = await query
|
||||
.orderBy(sortFilter, 'DESC')
|
||||
.take(pageSize)
|
||||
.skip(skip)
|
||||
.getManyAndCount();
|
||||
|
||||
return res.status(200).json({
|
||||
pageInfo: {
|
||||
pages: Math.ceil(issueCount / pageSize),
|
||||
pageSize,
|
||||
results: issueCount,
|
||||
page: Math.ceil(skip / pageSize) + 1,
|
||||
},
|
||||
results: issues,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
issueRoutes.post<
|
||||
Record<string, string>,
|
||||
Issue,
|
||||
{
|
||||
message: string;
|
||||
mediaId: number;
|
||||
issueType: number;
|
||||
problemSeason: number;
|
||||
problemEpisode: number;
|
||||
}
|
||||
>(
|
||||
'/',
|
||||
isAuthenticated([Permission.MANAGE_ISSUES, Permission.CREATE_ISSUES], {
|
||||
type: 'or',
|
||||
}),
|
||||
async (req, res, next) => {
|
||||
// Satisfy typescript here. User is set, we assure you!
|
||||
if (!req.user) {
|
||||
return next({ status: 500, message: 'User missing from request.' });
|
||||
}
|
||||
|
||||
const issueRepository = getRepository(Issue);
|
||||
const mediaRepository = getRepository(Media);
|
||||
|
||||
const media = await mediaRepository.findOne({
|
||||
where: { id: req.body.mediaId },
|
||||
});
|
||||
|
||||
if (!media) {
|
||||
return next({ status: 404, message: 'Media does not exist.' });
|
||||
}
|
||||
|
||||
const issue = new Issue({
|
||||
createdBy: req.user,
|
||||
issueType: req.body.issueType,
|
||||
problemSeason: req.body.problemSeason,
|
||||
problemEpisode: req.body.problemEpisode,
|
||||
media,
|
||||
comments: [
|
||||
new IssueComment({
|
||||
user: req.user,
|
||||
message: req.body.message,
|
||||
}),
|
||||
],
|
||||
});
|
||||
|
||||
const newIssue = await issueRepository.save(issue);
|
||||
|
||||
return res.status(200).json(newIssue);
|
||||
}
|
||||
);
|
||||
|
||||
issueRoutes.get<{ issueId: string }>(
|
||||
'/:issueId',
|
||||
isAuthenticated(
|
||||
[
|
||||
Permission.MANAGE_ISSUES,
|
||||
Permission.VIEW_ISSUES,
|
||||
Permission.CREATE_ISSUES,
|
||||
],
|
||||
{ type: 'or' }
|
||||
),
|
||||
async (req, res, next) => {
|
||||
const issueRepository = getRepository(Issue);
|
||||
// Satisfy typescript here. User is set, we assure you!
|
||||
if (!req.user) {
|
||||
return next({ status: 500, message: 'User missing from request.' });
|
||||
}
|
||||
|
||||
try {
|
||||
const issue = await issueRepository
|
||||
.createQueryBuilder('issue')
|
||||
.leftJoinAndSelect('issue.comments', 'comments')
|
||||
.leftJoinAndSelect('issue.createdBy', 'createdBy')
|
||||
.leftJoinAndSelect('comments.user', 'user')
|
||||
.leftJoinAndSelect('issue.media', 'media')
|
||||
.where('issue.id = :issueId', { issueId: Number(req.params.issueId) })
|
||||
.getOneOrFail();
|
||||
|
||||
if (
|
||||
issue.createdBy.id !== req.user.id &&
|
||||
!req.user.hasPermission(
|
||||
[Permission.MANAGE_ISSUES, Permission.VIEW_ISSUES],
|
||||
{ type: 'or' }
|
||||
)
|
||||
) {
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'You do not have permission to view this issue.',
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json(issue);
|
||||
} catch (e) {
|
||||
logger.debug('Failed to retrieve issue.', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 500, message: 'Issue not found.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
issueRoutes.post<{ issueId: string }, Issue, { message: string }>(
|
||||
'/:issueId/comment',
|
||||
isAuthenticated([Permission.MANAGE_ISSUES, Permission.CREATE_ISSUES], {
|
||||
type: 'or',
|
||||
}),
|
||||
async (req, res, next) => {
|
||||
const issueRepository = getRepository(Issue);
|
||||
// Satisfy typescript here. User is set, we assure you!
|
||||
if (!req.user) {
|
||||
return next({ status: 500, message: 'User missing from request.' });
|
||||
}
|
||||
|
||||
try {
|
||||
const issue = await issueRepository.findOneOrFail({
|
||||
where: { id: Number(req.params.issueId) },
|
||||
});
|
||||
|
||||
if (
|
||||
issue.createdBy.id !== req.user.id &&
|
||||
!req.user.hasPermission(Permission.MANAGE_ISSUES)
|
||||
) {
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'You do not have permission to comment on this issue.',
|
||||
});
|
||||
}
|
||||
|
||||
const comment = new IssueComment({
|
||||
message: req.body.message,
|
||||
user: req.user,
|
||||
});
|
||||
|
||||
issue.comments = [...issue.comments, comment];
|
||||
|
||||
await issueRepository.save(issue);
|
||||
|
||||
return res.status(200).json(issue);
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong creating an issue comment.', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 500, message: 'Issue not found.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
issueRoutes.post<{ issueId: string; status: string }, Issue>(
|
||||
'/:issueId/:status',
|
||||
isAuthenticated(Permission.MANAGE_ISSUES),
|
||||
async (req, res, next) => {
|
||||
const issueRepository = getRepository(Issue);
|
||||
// Satisfy typescript here. User is set, we assure you!
|
||||
if (!req.user) {
|
||||
return next({ status: 500, message: 'User missing from request.' });
|
||||
}
|
||||
|
||||
try {
|
||||
const issue = await issueRepository.findOneOrFail({
|
||||
where: { id: Number(req.params.issueId) },
|
||||
});
|
||||
|
||||
let newStatus: IssueStatus | undefined;
|
||||
|
||||
switch (req.params.status) {
|
||||
case 'resolved':
|
||||
newStatus = IssueStatus.RESOLVED;
|
||||
break;
|
||||
case 'open':
|
||||
newStatus = IssueStatus.OPEN;
|
||||
}
|
||||
|
||||
if (!newStatus) {
|
||||
return next({
|
||||
status: 400,
|
||||
message: 'You must provide a valid status',
|
||||
});
|
||||
}
|
||||
|
||||
issue.status = newStatus;
|
||||
issue.modifiedBy = req.user;
|
||||
|
||||
await issueRepository.save(issue);
|
||||
|
||||
return res.status(200).json(issue);
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong creating an issue comment.', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 500, message: 'Issue not found.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
issueRoutes.delete(
|
||||
'/:issueId',
|
||||
isAuthenticated([Permission.MANAGE_ISSUES, Permission.CREATE_ISSUES], {
|
||||
type: 'or',
|
||||
}),
|
||||
async (req, res, next) => {
|
||||
const issueRepository = getRepository(Issue);
|
||||
|
||||
try {
|
||||
const issue = await issueRepository.findOneOrFail({
|
||||
where: { id: Number(req.params.issueId) },
|
||||
relations: ['createdBy'],
|
||||
});
|
||||
|
||||
if (
|
||||
!req.user?.hasPermission(Permission.MANAGE_ISSUES) &&
|
||||
(issue.createdBy.id !== req.user?.id || issue.comments.length > 1)
|
||||
) {
|
||||
return next({
|
||||
status: 401,
|
||||
message: 'You do not have permission to delete this issue.',
|
||||
});
|
||||
}
|
||||
|
||||
await issueRepository.remove(issue);
|
||||
|
||||
return res.status(204).send();
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong deleting an issue.', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 404, message: 'Issue not found.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export default issueRoutes;
|
||||
129
server/routes/issueComment.ts
Normal file
129
server/routes/issueComment.ts
Normal file
@@ -0,0 +1,129 @@
|
||||
import { Router } from 'express';
|
||||
import { getRepository } from 'typeorm';
|
||||
import IssueComment from '../entity/IssueComment';
|
||||
import { Permission } from '../lib/permissions';
|
||||
import logger from '../logger';
|
||||
import { isAuthenticated } from '../middleware/auth';
|
||||
|
||||
const issueCommentRoutes = Router();
|
||||
|
||||
issueCommentRoutes.get<{ commentId: string }, IssueComment>(
|
||||
'/:commentId',
|
||||
isAuthenticated(
|
||||
[
|
||||
Permission.MANAGE_ISSUES,
|
||||
Permission.VIEW_ISSUES,
|
||||
Permission.CREATE_ISSUES,
|
||||
],
|
||||
{
|
||||
type: 'or',
|
||||
}
|
||||
),
|
||||
async (req, res, next) => {
|
||||
const issueCommentRepository = getRepository(IssueComment);
|
||||
|
||||
try {
|
||||
const comment = await issueCommentRepository.findOneOrFail({
|
||||
where: { id: Number(req.params.commentId) },
|
||||
});
|
||||
|
||||
if (
|
||||
!req.user?.hasPermission(
|
||||
[Permission.MANAGE_ISSUES, Permission.VIEW_ISSUES],
|
||||
{ type: 'or' }
|
||||
) &&
|
||||
comment.user.id !== req.user?.id
|
||||
) {
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'You do not have permission to view this comment.',
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json(comment);
|
||||
} catch (e) {
|
||||
logger.debug('Request for unknown issue comment failed', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 404, message: 'Issue comment not found.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
issueCommentRoutes.put<
|
||||
{ commentId: string },
|
||||
IssueComment,
|
||||
{ message: string }
|
||||
>(
|
||||
'/:commentId',
|
||||
isAuthenticated([Permission.MANAGE_ISSUES, Permission.CREATE_ISSUES], {
|
||||
type: 'or',
|
||||
}),
|
||||
async (req, res, next) => {
|
||||
const issueCommentRepository = getRepository(IssueComment);
|
||||
|
||||
try {
|
||||
const comment = await issueCommentRepository.findOneOrFail({
|
||||
where: { id: Number(req.params.commentId) },
|
||||
});
|
||||
|
||||
if (comment.user.id !== req.user?.id) {
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'You can only edit your own comments.',
|
||||
});
|
||||
}
|
||||
|
||||
comment.message = req.body.message;
|
||||
|
||||
await issueCommentRepository.save(comment);
|
||||
|
||||
return res.status(200).json(comment);
|
||||
} catch (e) {
|
||||
logger.debug('Put request for issue comment failed', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 404, message: 'Issue comment not found.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
issueCommentRoutes.delete<{ commentId: string }, IssueComment>(
|
||||
'/:commentId',
|
||||
isAuthenticated([Permission.MANAGE_ISSUES, Permission.CREATE_ISSUES], {
|
||||
type: 'or',
|
||||
}),
|
||||
async (req, res, next) => {
|
||||
const issueCommentRepository = getRepository(IssueComment);
|
||||
|
||||
try {
|
||||
const comment = await issueCommentRepository.findOneOrFail({
|
||||
where: { id: Number(req.params.commentId) },
|
||||
});
|
||||
|
||||
if (
|
||||
!req.user?.hasPermission([Permission.MANAGE_ISSUES], { type: 'or' }) &&
|
||||
comment.user.id !== req.user?.id
|
||||
) {
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'You do not have permission to delete this comment.',
|
||||
});
|
||||
}
|
||||
|
||||
await issueCommentRepository.remove(comment);
|
||||
|
||||
return res.status(204).send();
|
||||
} catch (e) {
|
||||
logger.debug('Delete request for issue comment failed', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 404, message: 'Issue comment not found.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export default issueCommentRoutes;
|
||||
@@ -1,11 +1,17 @@
|
||||
import { Router } from 'express';
|
||||
import { getRepository, FindOperator, FindOneOptions, In } from 'typeorm';
|
||||
import Media from '../entity/Media';
|
||||
import { FindOneOptions, FindOperator, getRepository, In } from 'typeorm';
|
||||
import TautulliAPI from '../api/tautulli';
|
||||
import { MediaStatus, MediaType } from '../constants/media';
|
||||
import Media from '../entity/Media';
|
||||
import { User } from '../entity/User';
|
||||
import {
|
||||
MediaResultsResponse,
|
||||
MediaWatchDataResponse,
|
||||
} from '../interfaces/api/mediaInterfaces';
|
||||
import { Permission } from '../lib/permissions';
|
||||
import { getSettings } from '../lib/settings';
|
||||
import logger from '../logger';
|
||||
import { isAuthenticated } from '../middleware/auth';
|
||||
import { Permission } from '../lib/permissions';
|
||||
import { MediaResultsResponse } from '../interfaces/api/mediaInterfaces';
|
||||
|
||||
const mediaRoutes = Router();
|
||||
|
||||
@@ -161,4 +167,103 @@ mediaRoutes.delete(
|
||||
}
|
||||
);
|
||||
|
||||
mediaRoutes.get<{ id: string }, MediaWatchDataResponse>(
|
||||
'/:id/watch_data',
|
||||
isAuthenticated(Permission.ADMIN),
|
||||
async (req, res, next) => {
|
||||
const settings = getSettings().tautulli;
|
||||
|
||||
if (!settings.hostname || !settings.port || !settings.apiKey) {
|
||||
return next({
|
||||
status: 404,
|
||||
message: 'Tautulli API not configured.',
|
||||
});
|
||||
}
|
||||
|
||||
const media = await getRepository(Media).findOne({
|
||||
where: { id: Number(req.params.id) },
|
||||
});
|
||||
|
||||
if (!media) {
|
||||
return next({ status: 404, message: 'Media does not exist.' });
|
||||
}
|
||||
|
||||
try {
|
||||
const tautulli = new TautulliAPI(settings);
|
||||
const userRepository = getRepository(User);
|
||||
|
||||
const response: MediaWatchDataResponse = {};
|
||||
|
||||
if (media.ratingKey) {
|
||||
const watchStats = await tautulli.getMediaWatchStats(media.ratingKey);
|
||||
const watchUsers = await tautulli.getMediaWatchUsers(media.ratingKey);
|
||||
|
||||
const users = await userRepository
|
||||
.createQueryBuilder('user')
|
||||
.where('user.plexId IN (:...plexIds)', {
|
||||
plexIds: watchUsers.map((u) => u.user_id),
|
||||
})
|
||||
.getMany();
|
||||
|
||||
const playCount =
|
||||
watchStats.find((i) => i.query_days == 0)?.total_plays ?? 0;
|
||||
|
||||
const playCount7Days =
|
||||
watchStats.find((i) => i.query_days == 7)?.total_plays ?? 0;
|
||||
|
||||
const playCount30Days =
|
||||
watchStats.find((i) => i.query_days == 30)?.total_plays ?? 0;
|
||||
|
||||
response.data = {
|
||||
users: users,
|
||||
playCount,
|
||||
playCount7Days,
|
||||
playCount30Days,
|
||||
};
|
||||
}
|
||||
|
||||
if (media.ratingKey4k) {
|
||||
const watchStats4k = await tautulli.getMediaWatchStats(
|
||||
media.ratingKey4k
|
||||
);
|
||||
const watchUsers4k = await tautulli.getMediaWatchUsers(
|
||||
media.ratingKey4k
|
||||
);
|
||||
|
||||
const users = await userRepository
|
||||
.createQueryBuilder('user')
|
||||
.where('user.plexId IN (:...plexIds)', {
|
||||
plexIds: watchUsers4k.map((u) => u.user_id),
|
||||
})
|
||||
.getMany();
|
||||
|
||||
const playCount =
|
||||
watchStats4k.find((i) => i.query_days == 0)?.total_plays ?? 0;
|
||||
|
||||
const playCount7Days =
|
||||
watchStats4k.find((i) => i.query_days == 7)?.total_plays ?? 0;
|
||||
|
||||
const playCount30Days =
|
||||
watchStats4k.find((i) => i.query_days == 30)?.total_plays ?? 0;
|
||||
|
||||
response.data4k = {
|
||||
users,
|
||||
playCount,
|
||||
playCount7Days,
|
||||
playCount30Days,
|
||||
};
|
||||
}
|
||||
|
||||
return res.status(200).json(response);
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong fetching media watch data', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
mediaId: req.params.id,
|
||||
});
|
||||
next({ status: 500, message: 'Failed to fetch watch data.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
export default mediaRoutes;
|
||||
|
||||
@@ -22,75 +22,105 @@ movieRoutes.get('/:id', async (req, res, next) => {
|
||||
|
||||
return res.status(200).json(mapMovieDetails(tmdbMovie, media));
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong getting movie', {
|
||||
label: 'Movie',
|
||||
message: e.message,
|
||||
logger.debug('Something went wrong retrieving movie', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
movieId: req.params.id,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve movie.',
|
||||
});
|
||||
return next({ status: 404, message: 'Movie does not exist' });
|
||||
}
|
||||
});
|
||||
|
||||
movieRoutes.get('/:id/recommendations', async (req, res) => {
|
||||
movieRoutes.get('/:id/recommendations', async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const results = await tmdb.getMovieRecommendations({
|
||||
movieId: Number(req.params.id),
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
try {
|
||||
const results = await tmdb.getMovieRecommendations({
|
||||
movieId: Number(req.params.id),
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
results.results.map((result) => result.id)
|
||||
);
|
||||
const media = await Media.getRelatedMedia(
|
||||
results.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: results.page,
|
||||
totalPages: results.total_pages,
|
||||
totalResults: results.total_results,
|
||||
results: results.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(req) => req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
|
||||
return res.status(200).json({
|
||||
page: results.page,
|
||||
totalPages: results.total_pages,
|
||||
totalResults: results.total_results,
|
||||
results: results.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(req) =>
|
||||
req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving movie recommendations', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
movieId: req.params.id,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve movie recommendations.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
movieRoutes.get('/:id/similar', async (req, res) => {
|
||||
movieRoutes.get('/:id/similar', async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const results = await tmdb.getMovieSimilar({
|
||||
movieId: Number(req.params.id),
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
try {
|
||||
const results = await tmdb.getMovieSimilar({
|
||||
movieId: Number(req.params.id),
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
results.results.map((result) => result.id)
|
||||
);
|
||||
const media = await Media.getRelatedMedia(
|
||||
results.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: results.page,
|
||||
totalPages: results.total_pages,
|
||||
totalResults: results.total_results,
|
||||
results: results.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(req) => req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
|
||||
return res.status(200).json({
|
||||
page: results.page,
|
||||
totalPages: results.total_pages,
|
||||
totalResults: results.total_results,
|
||||
results: results.results.map((result) =>
|
||||
mapMovieResult(
|
||||
result,
|
||||
media.find(
|
||||
(req) =>
|
||||
req.tmdbId === result.id && req.mediaType === MediaType.MOVIE
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
});
|
||||
),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving similar movies', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
movieId: req.params.id,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve similar movies.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
movieRoutes.get('/:id/ratings', async (req, res, next) => {
|
||||
try {
|
||||
const tmdb = new TheMovieDb();
|
||||
const rtapi = new RottenTomatoes();
|
||||
const tmdb = new TheMovieDb();
|
||||
const rtapi = new RottenTomatoes();
|
||||
|
||||
try {
|
||||
const movie = await tmdb.getMovie({
|
||||
movieId: Number(req.params.id),
|
||||
});
|
||||
@@ -101,12 +131,23 @@ movieRoutes.get('/:id/ratings', async (req, res, next) => {
|
||||
);
|
||||
|
||||
if (!rtratings) {
|
||||
return next({ status: 404, message: 'Unable to retrieve ratings' });
|
||||
return next({
|
||||
status: 404,
|
||||
message: 'Rotten Tomatoes ratings not found.',
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json(rtratings);
|
||||
} catch (e) {
|
||||
return next({ status: 404, message: 'Movie does not exist' });
|
||||
logger.debug('Something went wrong retrieving movie ratings', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
movieId: req.params.id,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve movie ratings.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -20,52 +20,71 @@ personRoutes.get('/:id', async (req, res, next) => {
|
||||
});
|
||||
return res.status(200).json(mapPersonDetails(person));
|
||||
} catch (e) {
|
||||
logger.error(e.message);
|
||||
next({ status: 404, message: 'Person not found' });
|
||||
logger.debug('Something went wrong retrieving person', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
personId: req.params.id,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve person.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
personRoutes.get('/:id/combined_credits', async (req, res) => {
|
||||
personRoutes.get('/:id/combined_credits', async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const combinedCredits = await tmdb.getPersonCombinedCredits({
|
||||
personId: Number(req.params.id),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
try {
|
||||
const combinedCredits = await tmdb.getPersonCombinedCredits({
|
||||
personId: Number(req.params.id),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
|
||||
const castMedia = await Media.getRelatedMedia(
|
||||
combinedCredits.cast.map((result) => result.id)
|
||||
);
|
||||
const castMedia = await Media.getRelatedMedia(
|
||||
combinedCredits.cast.map((result) => result.id)
|
||||
);
|
||||
|
||||
const crewMedia = await Media.getRelatedMedia(
|
||||
combinedCredits.crew.map((result) => result.id)
|
||||
);
|
||||
const crewMedia = await Media.getRelatedMedia(
|
||||
combinedCredits.crew.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
cast: combinedCredits.cast
|
||||
.map((result) =>
|
||||
mapCastCredits(
|
||||
result,
|
||||
castMedia.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === result.media_type
|
||||
return res.status(200).json({
|
||||
cast: combinedCredits.cast
|
||||
.map((result) =>
|
||||
mapCastCredits(
|
||||
result,
|
||||
castMedia.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === result.media_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.filter((item) => !item.adult),
|
||||
crew: combinedCredits.crew
|
||||
.map((result) =>
|
||||
mapCrewCredits(
|
||||
result,
|
||||
crewMedia.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === result.media_type
|
||||
.filter((item) => !item.adult),
|
||||
crew: combinedCredits.crew
|
||||
.map((result) =>
|
||||
mapCrewCredits(
|
||||
result,
|
||||
crewMedia.find(
|
||||
(med) =>
|
||||
med.tmdbId === result.id && med.mediaType === result.media_type
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
.filter((item) => !item.adult),
|
||||
id: combinedCredits.id,
|
||||
});
|
||||
.filter((item) => !item.adult),
|
||||
id: combinedCredits.id,
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving combined credits', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
personId: req.params.id,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve combined credits.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export default personRoutes;
|
||||
|
||||
@@ -13,131 +13,134 @@ import { isAuthenticated } from '../middleware/auth';
|
||||
|
||||
const requestRoutes = Router();
|
||||
|
||||
requestRoutes.get('/', async (req, res, next) => {
|
||||
try {
|
||||
const pageSize = req.query.take ? Number(req.query.take) : 10;
|
||||
const skip = req.query.skip ? Number(req.query.skip) : 0;
|
||||
const requestedBy = req.query.requestedBy
|
||||
? Number(req.query.requestedBy)
|
||||
: null;
|
||||
requestRoutes.get<Record<string, unknown>, RequestResultsResponse>(
|
||||
'/',
|
||||
async (req, res, next) => {
|
||||
try {
|
||||
const pageSize = req.query.take ? Number(req.query.take) : 10;
|
||||
const skip = req.query.skip ? Number(req.query.skip) : 0;
|
||||
const requestedBy = req.query.requestedBy
|
||||
? Number(req.query.requestedBy)
|
||||
: null;
|
||||
|
||||
let statusFilter: MediaRequestStatus[];
|
||||
let statusFilter: MediaRequestStatus[];
|
||||
|
||||
switch (req.query.filter) {
|
||||
case 'approved':
|
||||
case 'processing':
|
||||
case 'available':
|
||||
statusFilter = [MediaRequestStatus.APPROVED];
|
||||
break;
|
||||
case 'pending':
|
||||
statusFilter = [MediaRequestStatus.PENDING];
|
||||
break;
|
||||
case 'unavailable':
|
||||
statusFilter = [
|
||||
MediaRequestStatus.PENDING,
|
||||
MediaRequestStatus.APPROVED,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
statusFilter = [
|
||||
MediaRequestStatus.PENDING,
|
||||
MediaRequestStatus.APPROVED,
|
||||
MediaRequestStatus.DECLINED,
|
||||
];
|
||||
}
|
||||
switch (req.query.filter) {
|
||||
case 'approved':
|
||||
case 'processing':
|
||||
case 'available':
|
||||
statusFilter = [MediaRequestStatus.APPROVED];
|
||||
break;
|
||||
case 'pending':
|
||||
statusFilter = [MediaRequestStatus.PENDING];
|
||||
break;
|
||||
case 'unavailable':
|
||||
statusFilter = [
|
||||
MediaRequestStatus.PENDING,
|
||||
MediaRequestStatus.APPROVED,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
statusFilter = [
|
||||
MediaRequestStatus.PENDING,
|
||||
MediaRequestStatus.APPROVED,
|
||||
MediaRequestStatus.DECLINED,
|
||||
];
|
||||
}
|
||||
|
||||
let mediaStatusFilter: MediaStatus[];
|
||||
let mediaStatusFilter: MediaStatus[];
|
||||
|
||||
switch (req.query.filter) {
|
||||
case 'available':
|
||||
mediaStatusFilter = [MediaStatus.AVAILABLE];
|
||||
break;
|
||||
case 'processing':
|
||||
case 'unavailable':
|
||||
mediaStatusFilter = [
|
||||
MediaStatus.UNKNOWN,
|
||||
MediaStatus.PENDING,
|
||||
MediaStatus.PROCESSING,
|
||||
MediaStatus.PARTIALLY_AVAILABLE,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
mediaStatusFilter = [
|
||||
MediaStatus.UNKNOWN,
|
||||
MediaStatus.PENDING,
|
||||
MediaStatus.PROCESSING,
|
||||
MediaStatus.PARTIALLY_AVAILABLE,
|
||||
MediaStatus.AVAILABLE,
|
||||
];
|
||||
}
|
||||
switch (req.query.filter) {
|
||||
case 'available':
|
||||
mediaStatusFilter = [MediaStatus.AVAILABLE];
|
||||
break;
|
||||
case 'processing':
|
||||
case 'unavailable':
|
||||
mediaStatusFilter = [
|
||||
MediaStatus.UNKNOWN,
|
||||
MediaStatus.PENDING,
|
||||
MediaStatus.PROCESSING,
|
||||
MediaStatus.PARTIALLY_AVAILABLE,
|
||||
];
|
||||
break;
|
||||
default:
|
||||
mediaStatusFilter = [
|
||||
MediaStatus.UNKNOWN,
|
||||
MediaStatus.PENDING,
|
||||
MediaStatus.PROCESSING,
|
||||
MediaStatus.PARTIALLY_AVAILABLE,
|
||||
MediaStatus.AVAILABLE,
|
||||
];
|
||||
}
|
||||
|
||||
let sortFilter: string;
|
||||
let sortFilter: string;
|
||||
|
||||
switch (req.query.sort) {
|
||||
case 'modified':
|
||||
sortFilter = 'request.updatedAt';
|
||||
break;
|
||||
default:
|
||||
sortFilter = 'request.id';
|
||||
}
|
||||
switch (req.query.sort) {
|
||||
case 'modified':
|
||||
sortFilter = 'request.updatedAt';
|
||||
break;
|
||||
default:
|
||||
sortFilter = 'request.id';
|
||||
}
|
||||
|
||||
let query = getRepository(MediaRequest)
|
||||
.createQueryBuilder('request')
|
||||
.leftJoinAndSelect('request.media', 'media')
|
||||
.leftJoinAndSelect('request.seasons', 'seasons')
|
||||
.leftJoinAndSelect('request.modifiedBy', 'modifiedBy')
|
||||
.leftJoinAndSelect('request.requestedBy', 'requestedBy')
|
||||
.where('request.status IN (:...requestStatus)', {
|
||||
requestStatus: statusFilter,
|
||||
})
|
||||
.andWhere(
|
||||
'((request.is4k = 0 AND media.status IN (:...mediaStatus)) OR (request.is4k = 1 AND media.status4k IN (:...mediaStatus)))',
|
||||
{
|
||||
mediaStatus: mediaStatusFilter,
|
||||
let query = getRepository(MediaRequest)
|
||||
.createQueryBuilder('request')
|
||||
.leftJoinAndSelect('request.media', 'media')
|
||||
.leftJoinAndSelect('request.seasons', 'seasons')
|
||||
.leftJoinAndSelect('request.modifiedBy', 'modifiedBy')
|
||||
.leftJoinAndSelect('request.requestedBy', 'requestedBy')
|
||||
.where('request.status IN (:...requestStatus)', {
|
||||
requestStatus: statusFilter,
|
||||
})
|
||||
.andWhere(
|
||||
'((request.is4k = 0 AND media.status IN (:...mediaStatus)) OR (request.is4k = 1 AND media.status4k IN (:...mediaStatus)))',
|
||||
{
|
||||
mediaStatus: mediaStatusFilter,
|
||||
}
|
||||
);
|
||||
|
||||
if (
|
||||
!req.user?.hasPermission(
|
||||
[Permission.MANAGE_REQUESTS, Permission.REQUEST_VIEW],
|
||||
{ type: 'or' }
|
||||
)
|
||||
) {
|
||||
if (requestedBy && requestedBy !== req.user?.id) {
|
||||
return next({
|
||||
status: 403,
|
||||
message: "You do not have permission to view this user's requests.",
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
if (
|
||||
!req.user?.hasPermission(
|
||||
[Permission.MANAGE_REQUESTS, Permission.REQUEST_VIEW],
|
||||
{ type: 'or' }
|
||||
)
|
||||
) {
|
||||
if (requestedBy && requestedBy !== req.user?.id) {
|
||||
return next({
|
||||
status: 403,
|
||||
message: "You do not have permission to view this user's requests.",
|
||||
query = query.andWhere('requestedBy.id = :id', {
|
||||
id: req.user?.id,
|
||||
});
|
||||
} else if (requestedBy) {
|
||||
query = query.andWhere('requestedBy.id = :id', {
|
||||
id: requestedBy,
|
||||
});
|
||||
}
|
||||
|
||||
query = query.andWhere('requestedBy.id = :id', {
|
||||
id: req.user?.id,
|
||||
});
|
||||
} else if (requestedBy) {
|
||||
query = query.andWhere('requestedBy.id = :id', {
|
||||
id: requestedBy,
|
||||
const [requests, requestCount] = await query
|
||||
.orderBy(sortFilter, 'DESC')
|
||||
.take(pageSize)
|
||||
.skip(skip)
|
||||
.getManyAndCount();
|
||||
|
||||
return res.status(200).json({
|
||||
pageInfo: {
|
||||
pages: Math.ceil(requestCount / pageSize),
|
||||
pageSize,
|
||||
results: requestCount,
|
||||
page: Math.ceil(skip / pageSize) + 1,
|
||||
},
|
||||
results: requests,
|
||||
});
|
||||
} catch (e) {
|
||||
next({ status: 500, message: e.message });
|
||||
}
|
||||
|
||||
const [requests, requestCount] = await query
|
||||
.orderBy(sortFilter, 'DESC')
|
||||
.take(pageSize)
|
||||
.skip(skip)
|
||||
.getManyAndCount();
|
||||
|
||||
return res.status(200).json({
|
||||
pageInfo: {
|
||||
pages: Math.ceil(requestCount / pageSize),
|
||||
pageSize,
|
||||
results: requestCount,
|
||||
page: Math.ceil(skip / pageSize) + 1,
|
||||
},
|
||||
results: requests,
|
||||
} as RequestResultsResponse);
|
||||
} catch (e) {
|
||||
next({ status: 500, message: e.message });
|
||||
}
|
||||
});
|
||||
);
|
||||
|
||||
requestRoutes.post('/', async (req, res, next) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
@@ -256,6 +259,9 @@ requestRoutes.post('/', async (req, res, next) => {
|
||||
.leftJoin('request.media', 'media')
|
||||
.where('request.is4k = :is4k', { is4k: req.body.is4k })
|
||||
.andWhere('media.tmdbId = :tmdbId', { tmdbId: tmdbMedia.id })
|
||||
.andWhere('media.mediaType = :mediaType', {
|
||||
mediaType: MediaType.MOVIE,
|
||||
})
|
||||
.andWhere('request.status != :requestStatus', {
|
||||
requestStatus: MediaRequestStatus.DECLINED,
|
||||
})
|
||||
@@ -441,6 +447,20 @@ requestRoutes.get('/count', async (_req, res, next) => {
|
||||
.createQueryBuilder('request')
|
||||
.leftJoinAndSelect('request.media', 'media');
|
||||
|
||||
const totalCount = await query.getCount();
|
||||
|
||||
const movieCount = await query
|
||||
.where('request.type = :requestType', {
|
||||
requestType: MediaType.MOVIE,
|
||||
})
|
||||
.getCount();
|
||||
|
||||
const tvCount = await query
|
||||
.where('request.type = :requestType', {
|
||||
requestType: MediaType.TV,
|
||||
})
|
||||
.getCount();
|
||||
|
||||
const pendingCount = await query
|
||||
.where('request.status = :requestStatus', {
|
||||
requestStatus: MediaRequestStatus.PENDING,
|
||||
@@ -453,12 +473,18 @@ requestRoutes.get('/count', async (_req, res, next) => {
|
||||
})
|
||||
.getCount();
|
||||
|
||||
const declinedCount = await query
|
||||
.where('request.status = :requestStatus', {
|
||||
requestStatus: MediaRequestStatus.DECLINED,
|
||||
})
|
||||
.getCount();
|
||||
|
||||
const processingCount = await query
|
||||
.where('request.status = :requestStatus', {
|
||||
requestStatus: MediaRequestStatus.APPROVED,
|
||||
})
|
||||
.andWhere(
|
||||
'(request.is4k = false AND media.status != :availableStatus) OR (request.is4k = true AND media.status4k != :availableStatus)',
|
||||
'((request.is4k = false AND media.status != :availableStatus) OR (request.is4k = true AND media.status4k != :availableStatus))',
|
||||
{
|
||||
availableStatus: MediaStatus.AVAILABLE,
|
||||
}
|
||||
@@ -470,7 +496,7 @@ requestRoutes.get('/count', async (_req, res, next) => {
|
||||
requestStatus: MediaRequestStatus.APPROVED,
|
||||
})
|
||||
.andWhere(
|
||||
'(request.is4k = false AND media.status = :availableStatus) OR (request.is4k = true AND media.status4k = :availableStatus)',
|
||||
'((request.is4k = false AND media.status = :availableStatus) OR (request.is4k = true AND media.status4k = :availableStatus))',
|
||||
{
|
||||
availableStatus: MediaStatus.AVAILABLE,
|
||||
}
|
||||
@@ -478,13 +504,21 @@ requestRoutes.get('/count', async (_req, res, next) => {
|
||||
.getCount();
|
||||
|
||||
return res.status(200).json({
|
||||
total: totalCount,
|
||||
movie: movieCount,
|
||||
tv: tvCount,
|
||||
pending: pendingCount,
|
||||
approved: approvedCount,
|
||||
declined: declinedCount,
|
||||
processing: processingCount,
|
||||
available: availableCount,
|
||||
});
|
||||
} catch (e) {
|
||||
next({ status: 500, message: e.message });
|
||||
logger.error('Something went wrong retrieving request counts', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 500, message: 'Unable to retrieve request counts.' });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -497,9 +531,26 @@ requestRoutes.get('/:requestId', async (req, res, next) => {
|
||||
relations: ['requestedBy', 'modifiedBy'],
|
||||
});
|
||||
|
||||
if (
|
||||
request.requestedBy.id !== req.user?.id &&
|
||||
!req.user?.hasPermission(
|
||||
[Permission.MANAGE_REQUESTS, Permission.REQUEST_VIEW],
|
||||
{ type: 'or' }
|
||||
)
|
||||
) {
|
||||
return next({
|
||||
status: 403,
|
||||
message: 'You do not have permission to view this request.',
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json(request);
|
||||
} catch (e) {
|
||||
next({ status: 404, message: 'Request not found' });
|
||||
logger.debug('Failed to retrieve request.', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 404, message: 'Request not found.' });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -529,11 +580,11 @@ requestRoutes.put<{ requestId: string }>(
|
||||
});
|
||||
}
|
||||
|
||||
let requestUser = req.user;
|
||||
let requestUser = request.requestedBy;
|
||||
|
||||
if (
|
||||
req.body.userId &&
|
||||
req.body.userId !== req.user?.id &&
|
||||
req.body.userId !== request.requestedBy.id &&
|
||||
!req.user?.hasPermission([
|
||||
Permission.MANAGE_USERS,
|
||||
Permission.MANAGE_REQUESTS,
|
||||
@@ -665,7 +716,10 @@ requestRoutes.delete('/:requestId', async (req, res, next) => {
|
||||
|
||||
return res.status(204).send();
|
||||
} catch (e) {
|
||||
logger.error(e.message);
|
||||
logger.error('Something went wrong deleting a request.', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({ status: 404, message: 'Request not found.' });
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,29 +1,59 @@
|
||||
import { Router } from 'express';
|
||||
import TheMovieDb from '../api/themoviedb';
|
||||
import { TmdbSearchMultiResponse } from '../api/themoviedb/interfaces';
|
||||
import Media from '../entity/Media';
|
||||
import { findSearchProvider } from '../lib/search';
|
||||
import logger from '../logger';
|
||||
import { mapSearchResults } from '../models/Search';
|
||||
|
||||
const searchRoutes = Router();
|
||||
|
||||
searchRoutes.get('/', async (req, res) => {
|
||||
const tmdb = new TheMovieDb();
|
||||
searchRoutes.get('/', async (req, res, next) => {
|
||||
const queryString = req.query.query as string;
|
||||
const searchProvider = findSearchProvider(queryString.toLowerCase());
|
||||
let results: TmdbSearchMultiResponse;
|
||||
|
||||
const results = await tmdb.searchMulti({
|
||||
query: req.query.query as string,
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
try {
|
||||
if (searchProvider) {
|
||||
const [id] = queryString
|
||||
.toLowerCase()
|
||||
.match(searchProvider.pattern) as RegExpMatchArray;
|
||||
results = await searchProvider.search({
|
||||
id,
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
query: queryString,
|
||||
});
|
||||
} else {
|
||||
const tmdb = new TheMovieDb();
|
||||
|
||||
const media = await Media.getRelatedMedia(
|
||||
results.results.map((result) => result.id)
|
||||
);
|
||||
results = await tmdb.searchMulti({
|
||||
query: queryString,
|
||||
page: Number(req.query.page),
|
||||
language: req.locale ?? (req.query.language as string),
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json({
|
||||
page: results.page,
|
||||
totalPages: results.total_pages,
|
||||
totalResults: results.total_results,
|
||||
results: mapSearchResults(results.results, media),
|
||||
});
|
||||
const media = await Media.getRelatedMedia(
|
||||
results.results.map((result) => result.id)
|
||||
);
|
||||
|
||||
return res.status(200).json({
|
||||
page: results.page,
|
||||
totalPages: results.total_pages,
|
||||
totalResults: results.total_results,
|
||||
results: mapSearchResults(results.results, media),
|
||||
});
|
||||
} catch (e) {
|
||||
logger.debug('Something went wrong retrieving search results', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
query: req.query.query,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve search results.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export default searchRoutes;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { Router } from 'express';
|
||||
import rateLimit from 'express-rate-limit';
|
||||
import fs from 'fs';
|
||||
import { merge, omit } from 'lodash';
|
||||
import { merge, omit, set, sortBy } from 'lodash';
|
||||
import { rescheduleJob } from 'node-schedule';
|
||||
import path from 'path';
|
||||
import semver from 'semver';
|
||||
import { getRepository } from 'typeorm';
|
||||
import { URL } from 'url';
|
||||
import PlexAPI from '../../api/plexapi';
|
||||
import PlexTvAPI from '../../api/plextv';
|
||||
import TautulliAPI from '../../api/tautulli';
|
||||
import Media from '../../entity/Media';
|
||||
import { MediaRequest } from '../../entity/MediaRequest';
|
||||
import { User } from '../../entity/User';
|
||||
@@ -24,6 +26,7 @@ import { plexFullScanner } from '../../lib/scanners/plex';
|
||||
import { getSettings, MainSettings } from '../../lib/settings';
|
||||
import logger from '../../logger';
|
||||
import { isAuthenticated } from '../../middleware/auth';
|
||||
import { appDataPath } from '../../utils/appDataVolume';
|
||||
import { getAppVersion } from '../../utils/appVersion';
|
||||
import notificationRoutes from './notifications';
|
||||
import radarrRoutes from './radarr';
|
||||
@@ -50,7 +53,7 @@ settingsRoutes.get('/main', (req, res, next) => {
|
||||
const settings = getSettings();
|
||||
|
||||
if (!req.user) {
|
||||
return next({ status: 400, message: 'User missing from request' });
|
||||
return next({ status: 400, message: 'User missing from request.' });
|
||||
}
|
||||
|
||||
res.status(200).json(filteredMainSettings(req.user, settings.main));
|
||||
@@ -71,7 +74,7 @@ settingsRoutes.post('/main/regenerate', (req, res, next) => {
|
||||
const main = settings.regenerateApiKey();
|
||||
|
||||
if (!req.user) {
|
||||
return next({ status: 500, message: 'User missing from request' });
|
||||
return next({ status: 500, message: 'User missing from request.' });
|
||||
}
|
||||
|
||||
return res.status(200).json(filteredMainSettings(req.user, main));
|
||||
@@ -98,16 +101,22 @@ settingsRoutes.post('/plex', async (req, res, next) => {
|
||||
|
||||
const result = await plexClient.getStatus();
|
||||
|
||||
if (result?.MediaContainer?.machineIdentifier) {
|
||||
settings.plex.machineId = result.MediaContainer.machineIdentifier;
|
||||
settings.plex.name = result.MediaContainer.friendlyName;
|
||||
|
||||
settings.save();
|
||||
if (!result?.MediaContainer?.machineIdentifier) {
|
||||
throw new Error('Server not found');
|
||||
}
|
||||
|
||||
settings.plex.machineId = result.MediaContainer.machineIdentifier;
|
||||
settings.plex.name = result.MediaContainer.friendlyName;
|
||||
|
||||
settings.save();
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong testing Plex connection', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: `Failed to connect to Plex: ${e.message}`,
|
||||
message: 'Unable to connect to Plex.',
|
||||
});
|
||||
}
|
||||
|
||||
@@ -180,9 +189,13 @@ settingsRoutes.get('/plex/devices/servers', async (req, res, next) => {
|
||||
}
|
||||
return res.status(200).json(devices);
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong retrieving Plex server list', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: `Failed to connect to Plex: ${e.message}`,
|
||||
message: 'Unable to retrieve Plex server list.',
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -225,6 +238,104 @@ settingsRoutes.post('/plex/sync', (req, res) => {
|
||||
return res.status(200).json(plexFullScanner.status());
|
||||
});
|
||||
|
||||
settingsRoutes.get('/tautulli', (_req, res) => {
|
||||
const settings = getSettings();
|
||||
|
||||
res.status(200).json(settings.tautulli);
|
||||
});
|
||||
|
||||
settingsRoutes.post('/tautulli', async (req, res, next) => {
|
||||
const settings = getSettings();
|
||||
|
||||
Object.assign(settings.tautulli, req.body);
|
||||
|
||||
try {
|
||||
const tautulliClient = new TautulliAPI(settings.tautulli);
|
||||
|
||||
const result = await tautulliClient.getInfo();
|
||||
|
||||
if (!semver.gte(semver.coerce(result?.tautulli_version) ?? '', '2.9.0')) {
|
||||
throw new Error('Tautulli version not supported');
|
||||
}
|
||||
|
||||
settings.save();
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong testing Tautulli connection', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Unable to connect to Tautulli.',
|
||||
});
|
||||
}
|
||||
|
||||
return res.status(200).json(settings.tautulli);
|
||||
});
|
||||
|
||||
settingsRoutes.get(
|
||||
'/plex/users',
|
||||
isAuthenticated(Permission.MANAGE_USERS),
|
||||
async (req, res, next) => {
|
||||
const userRepository = getRepository(User);
|
||||
const qb = userRepository.createQueryBuilder('user');
|
||||
|
||||
try {
|
||||
const admin = await userRepository.findOneOrFail({
|
||||
select: ['id', 'plexToken'],
|
||||
order: { id: 'ASC' },
|
||||
});
|
||||
const plexApi = new PlexTvAPI(admin.plexToken ?? '');
|
||||
const plexUsers = (await plexApi.getUsers()).MediaContainer.User.map(
|
||||
(user) => user.$
|
||||
).filter((user) => user.email);
|
||||
|
||||
const unimportedPlexUsers: {
|
||||
id: string;
|
||||
title: string;
|
||||
username: string;
|
||||
email: string;
|
||||
thumb: string;
|
||||
}[] = [];
|
||||
|
||||
const existingUsers = await qb
|
||||
.where('user.plexId IN (:...plexIds)', {
|
||||
plexIds: plexUsers.map((plexUser) => plexUser.id),
|
||||
})
|
||||
.orWhere('user.email IN (:...plexEmails)', {
|
||||
plexEmails: plexUsers.map((plexUser) => plexUser.email.toLowerCase()),
|
||||
})
|
||||
.getMany();
|
||||
|
||||
await Promise.all(
|
||||
plexUsers.map(async (plexUser) => {
|
||||
if (
|
||||
!existingUsers.find(
|
||||
(user) =>
|
||||
user.plexId === parseInt(plexUser.id) ||
|
||||
user.email === plexUser.email.toLowerCase()
|
||||
) &&
|
||||
(await plexApi.checkUserAccess(parseInt(plexUser.id)))
|
||||
) {
|
||||
unimportedPlexUsers.push(plexUser);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
return res.status(200).json(sortBy(unimportedPlexUsers, 'username'));
|
||||
} catch (e) {
|
||||
logger.error('Something went wrong getting unimported Plex users', {
|
||||
label: 'API',
|
||||
errorMessage: e.message,
|
||||
});
|
||||
next({
|
||||
status: 500,
|
||||
message: 'Unable to retrieve unimported Plex users.',
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
settingsRoutes.get(
|
||||
'/logs',
|
||||
rateLimit({ windowMs: 60 * 1000, max: 50 }),
|
||||
@@ -251,34 +362,42 @@ settingsRoutes.get(
|
||||
}
|
||||
|
||||
const logFile = process.env.CONFIG_DIRECTORY
|
||||
? `${process.env.CONFIG_DIRECTORY}/logs/overseerr.log`
|
||||
: path.join(__dirname, '../../../config/logs/overseerr.log');
|
||||
? `${process.env.CONFIG_DIRECTORY}/logs/.machinelogs.json`
|
||||
: path.join(__dirname, '../../../config/logs/.machinelogs.json');
|
||||
const logs: LogMessage[] = [];
|
||||
const logMessageProperties = [
|
||||
'timestamp',
|
||||
'level',
|
||||
'label',
|
||||
'message',
|
||||
'data',
|
||||
];
|
||||
|
||||
try {
|
||||
fs.readFileSync(logFile)
|
||||
.toString()
|
||||
fs.readFileSync(logFile, 'utf-8')
|
||||
.split('\n')
|
||||
.forEach((line) => {
|
||||
if (!line.length) return;
|
||||
|
||||
const timestamp = line.match(new RegExp(/^.{24}/)) || [];
|
||||
const level = line.match(new RegExp(/\s\[\w+\]/)) || [];
|
||||
const label = line.match(new RegExp(/\]\[.+?\]/)) || [];
|
||||
const message = line.match(new RegExp(/:\s([^{}]+)({.*})?/)) || [];
|
||||
const logMessage = JSON.parse(line);
|
||||
|
||||
if (level.length && filter.includes(level[0].slice(2, -1))) {
|
||||
logs.push({
|
||||
timestamp: timestamp[0],
|
||||
level: level.length ? level[0].slice(2, -1) : '',
|
||||
label: label.length ? label[0].slice(2, -1) : '',
|
||||
message: message.length && message[1] ? message[1] : '',
|
||||
data:
|
||||
message.length && message[2]
|
||||
? JSON.parse(message[2])
|
||||
: undefined,
|
||||
});
|
||||
if (!filter.includes(logMessage.level)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!Object.keys(logMessage).every((key) =>
|
||||
logMessageProperties.includes(key)
|
||||
)
|
||||
) {
|
||||
Object.keys(logMessage)
|
||||
.filter((prop) => !logMessageProperties.includes(prop))
|
||||
.forEach((prop) => {
|
||||
set(logMessage, `data.${prop}`, logMessage[prop]);
|
||||
});
|
||||
}
|
||||
|
||||
logs.push(logMessage);
|
||||
});
|
||||
|
||||
const displayedLogs = logs.reverse().slice(skip, skip + pageSize);
|
||||
@@ -293,13 +412,13 @@ settingsRoutes.get(
|
||||
results: displayedLogs,
|
||||
} as LogsResultsResponse);
|
||||
} catch (error) {
|
||||
logger.error('Something went wrong while fetching the logs', {
|
||||
logger.error('Something went wrong while retrieving logs', {
|
||||
label: 'Logs',
|
||||
errorMessage: error.message,
|
||||
});
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Something went wrong while fetching the logs',
|
||||
message: 'Unable to retrieve logs.',
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -322,7 +441,7 @@ settingsRoutes.post<{ jobId: string }>('/jobs/:jobId/run', (req, res, next) => {
|
||||
const scheduledJob = scheduledJobs.find((job) => job.id === req.params.jobId);
|
||||
|
||||
if (!scheduledJob) {
|
||||
return next({ status: 404, message: 'Job not found' });
|
||||
return next({ status: 404, message: 'Job not found.' });
|
||||
}
|
||||
|
||||
scheduledJob.job.invoke();
|
||||
@@ -345,7 +464,7 @@ settingsRoutes.post<{ jobId: string }>(
|
||||
);
|
||||
|
||||
if (!scheduledJob) {
|
||||
return next({ status: 404, message: 'Job not found' });
|
||||
return next({ status: 404, message: 'Job not found.' });
|
||||
}
|
||||
|
||||
if (scheduledJob.cancelFn) {
|
||||
@@ -371,7 +490,7 @@ settingsRoutes.post<{ jobId: string }>(
|
||||
);
|
||||
|
||||
if (!scheduledJob) {
|
||||
return next({ status: 404, message: 'Job not found' });
|
||||
return next({ status: 404, message: 'Job not found.' });
|
||||
}
|
||||
|
||||
const result = rescheduleJob(scheduledJob.job, req.body.schedule);
|
||||
@@ -390,7 +509,7 @@ settingsRoutes.post<{ jobId: string }>(
|
||||
running: scheduledJob.running ? scheduledJob.running() : false,
|
||||
});
|
||||
} else {
|
||||
return next({ status: 400, message: 'Invalid job schedule' });
|
||||
return next({ status: 400, message: 'Invalid job schedule.' });
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -417,7 +536,7 @@ settingsRoutes.post<{ cacheId: AvailableCacheIds }>(
|
||||
return res.status(204).send();
|
||||
}
|
||||
|
||||
next({ status: 404, message: 'Cache does not exist.' });
|
||||
next({ status: 404, message: 'Cache not found.' });
|
||||
}
|
||||
);
|
||||
|
||||
@@ -446,6 +565,7 @@ settingsRoutes.get('/about', async (req, res) => {
|
||||
totalMediaItems,
|
||||
totalRequests,
|
||||
tz: process.env.TZ,
|
||||
appDataPath: appDataPath(),
|
||||
} as SettingsAboutResponse);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import { Router } from 'express';
|
||||
import { User } from '../../entity/User';
|
||||
import { Notification } from '../../lib/notifications';
|
||||
import { NotificationAgent } from '../../lib/notifications/agents/agent';
|
||||
import DiscordAgent from '../../lib/notifications/agents/discord';
|
||||
import EmailAgent from '../../lib/notifications/agents/email';
|
||||
import GotifyAgent from '../../lib/notifications/agents/gotify';
|
||||
import LunaSeaAgent from '../../lib/notifications/agents/lunasea';
|
||||
import PushbulletAgent from '../../lib/notifications/agents/pushbullet';
|
||||
import PushoverAgent from '../../lib/notifications/agents/pushover';
|
||||
@@ -13,6 +16,14 @@ import { getSettings } from '../../lib/settings';
|
||||
|
||||
const notificationRoutes = Router();
|
||||
|
||||
const sendTestNotification = async (agent: NotificationAgent, user: User) =>
|
||||
await agent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyAdmin: false,
|
||||
notifyUser: user,
|
||||
subject: 'Test Notification',
|
||||
message: 'Check check, 1, 2, 3. Are we coming in clear?',
|
||||
});
|
||||
|
||||
notificationRoutes.get('/discord', (_req, res) => {
|
||||
const settings = getSettings();
|
||||
|
||||
@@ -37,14 +48,7 @@ notificationRoutes.post('/discord/test', async (req, res, next) => {
|
||||
}
|
||||
|
||||
const discordAgent = new DiscordAgent(req.body);
|
||||
if (
|
||||
await discordAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
if (await sendTestNotification(discordAgent, req.user)) {
|
||||
return res.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
@@ -78,14 +82,7 @@ notificationRoutes.post('/slack/test', async (req, res, next) => {
|
||||
}
|
||||
|
||||
const slackAgent = new SlackAgent(req.body);
|
||||
if (
|
||||
await slackAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
if (await sendTestNotification(slackAgent, req.user)) {
|
||||
return res.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
@@ -119,14 +116,7 @@ notificationRoutes.post('/telegram/test', async (req, res, next) => {
|
||||
}
|
||||
|
||||
const telegramAgent = new TelegramAgent(req.body);
|
||||
if (
|
||||
await telegramAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
if (await sendTestNotification(telegramAgent, req.user)) {
|
||||
return res.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
@@ -160,14 +150,7 @@ notificationRoutes.post('/pushbullet/test', async (req, res, next) => {
|
||||
}
|
||||
|
||||
const pushbulletAgent = new PushbulletAgent(req.body);
|
||||
if (
|
||||
await pushbulletAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
if (await sendTestNotification(pushbulletAgent, req.user)) {
|
||||
return res.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
@@ -201,14 +184,7 @@ notificationRoutes.post('/pushover/test', async (req, res, next) => {
|
||||
}
|
||||
|
||||
const pushoverAgent = new PushoverAgent(req.body);
|
||||
if (
|
||||
await pushoverAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
if (await sendTestNotification(pushoverAgent, req.user)) {
|
||||
return res.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
@@ -242,14 +218,7 @@ notificationRoutes.post('/email/test', async (req, res, next) => {
|
||||
}
|
||||
|
||||
const emailAgent = new EmailAgent(req.body);
|
||||
if (
|
||||
await emailAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
if (await sendTestNotification(emailAgent, req.user)) {
|
||||
return res.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
@@ -283,14 +252,7 @@ notificationRoutes.post('/webpush/test', async (req, res, next) => {
|
||||
}
|
||||
|
||||
const webpushAgent = new WebPushAgent(req.body);
|
||||
if (
|
||||
await webpushAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
if (await sendTestNotification(webpushAgent, req.user)) {
|
||||
return res.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
@@ -369,14 +331,7 @@ notificationRoutes.post('/webhook/test', async (req, res, next) => {
|
||||
};
|
||||
|
||||
const webhookAgent = new WebhookAgent(testBody);
|
||||
if (
|
||||
await webhookAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
if (await sendTestNotification(webhookAgent, req.user)) {
|
||||
return res.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
@@ -413,14 +368,7 @@ notificationRoutes.post('/lunasea/test', async (req, res, next) => {
|
||||
}
|
||||
|
||||
const lunaseaAgent = new LunaSeaAgent(req.body);
|
||||
if (
|
||||
await lunaseaAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
if (await sendTestNotification(lunaseaAgent, req.user)) {
|
||||
return res.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
@@ -430,4 +378,46 @@ notificationRoutes.post('/lunasea/test', async (req, res, next) => {
|
||||
}
|
||||
});
|
||||
|
||||
notificationRoutes.get('/gotify', (_req, res) => {
|
||||
const settings = getSettings();
|
||||
|
||||
res.status(200).json(settings.notifications.agents.gotify);
|
||||
});
|
||||
|
||||
notificationRoutes.post('/gotify', (req, rest) => {
|
||||
const settings = getSettings();
|
||||
|
||||
settings.notifications.agents.gotify = req.body;
|
||||
settings.save();
|
||||
|
||||
rest.status(200).json(settings.notifications.agents.gotify);
|
||||
});
|
||||
|
||||
notificationRoutes.post('/gotify/test', async (req, rest, next) => {
|
||||
if (!req.user) {
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'User information is missing from request',
|
||||
});
|
||||
}
|
||||
|
||||
const gotifyAgent = new GotifyAgent(req.body);
|
||||
if (
|
||||
await gotifyAgent.send(Notification.TEST_NOTIFICATION, {
|
||||
notifyAdmin: false,
|
||||
notifyUser: req.user,
|
||||
subject: 'Test Notification',
|
||||
message:
|
||||
'This is a test notification! Check check, 1, 2, 3. Are we coming in clear?',
|
||||
})
|
||||
) {
|
||||
return rest.status(204).send();
|
||||
} else {
|
||||
return next({
|
||||
status: 500,
|
||||
message: 'Failed to send Gotify notification.',
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export default notificationRoutes;
|
||||
|
||||
@@ -46,7 +46,10 @@ radarrRoutes.post<
|
||||
url: RadarrAPI.buildUrl(req.body, '/api/v3'),
|
||||
});
|
||||
|
||||
const { urlBase } = await radarr.getSystemStatus();
|
||||
const urlBase = await radarr
|
||||
.getSystemStatus()
|
||||
.then((value) => value.urlBase)
|
||||
.catch(() => req.body.baseUrl);
|
||||
const profiles = await radarr.getProfiles();
|
||||
const folders = await radarr.getRootFolders();
|
||||
const tags = await radarr.getTags();
|
||||
@@ -58,10 +61,7 @@ radarrRoutes.post<
|
||||
path: folder.path,
|
||||
})),
|
||||
tags,
|
||||
urlBase:
|
||||
req.body.baseUrl && req.body.baseUrl !== '/'
|
||||
? req.body.baseUrl
|
||||
: urlBase,
|
||||
urlBase,
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error('Failed to test Radarr', {
|
||||
|
||||
@@ -42,7 +42,10 @@ sonarrRoutes.post('/test', async (req, res, next) => {
|
||||
url: SonarrAPI.buildUrl(req.body, '/api/v3'),
|
||||
});
|
||||
|
||||
const { urlBase } = await sonarr.getSystemStatus();
|
||||
const urlBase = await sonarr
|
||||
.getSystemStatus()
|
||||
.then((value) => value.urlBase)
|
||||
.catch(() => req.body.baseUrl);
|
||||
const profiles = await sonarr.getProfiles();
|
||||
const folders = await sonarr.getRootFolders();
|
||||
const languageProfiles = await sonarr.getLanguageProfiles();
|
||||
@@ -56,10 +59,7 @@ sonarrRoutes.post('/test', async (req, res, next) => {
|
||||
})),
|
||||
languageProfiles,
|
||||
tags,
|
||||
urlBase:
|
||||
req.body.baseUrl && req.body.baseUrl !== '/'
|
||||
? req.body.baseUrl
|
||||
: urlBase,
|
||||
urlBase,
|
||||
});
|
||||
} catch (e) {
|
||||
logger.error('Failed to test Sonarr', {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user