diff options
author | Chocobozzz <me@florianbigard.com> | 2021-02-11 10:23:52 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-02-11 10:23:52 +0100 |
commit | 6559da2821cfa37717fb6f607f76a505d549cc74 (patch) | |
tree | 5e522cbb4b683eafa1baa64e5564327ad9867e06 | |
parent | d93e43164a716d98cf1c84aa993824ff6d1496ff (diff) | |
download | PeerTube-6559da2821cfa37717fb6f607f76a505d549cc74.tar.gz PeerTube-6559da2821cfa37717fb6f607f76a505d549cc74.tar.zst PeerTube-6559da2821cfa37717fb6f607f76a505d549cc74.zip |
Allow plugins to load a video by id
-rw-r--r-- | client/.browserslistrc | 14 | ||||
-rw-r--r-- | server/lib/plugins/plugin-helpers-builder.ts | 4 | ||||
-rw-r--r-- | server/tests/fixtures/peertube-plugin-test-four/main.js | 9 | ||||
-rw-r--r-- | server/types/plugins/register-server-option.model.ts | 1 |
4 files changed, 22 insertions, 6 deletions
diff --git a/client/.browserslistrc b/client/.browserslistrc index 80848532e..0ccadaf32 100644 --- a/client/.browserslistrc +++ b/client/.browserslistrc | |||
@@ -2,11 +2,17 @@ | |||
2 | # For additional information regarding the format and rule options, please see: | 2 | # For additional information regarding the format and rule options, please see: |
3 | # https://github.com/browserslist/browserslist#queries | 3 | # https://github.com/browserslist/browserslist#queries |
4 | 4 | ||
5 | # For the full list of supported browsers by the Angular framework, please see: | ||
6 | # https://angular.io/guide/browser-support | ||
7 | |||
5 | # You can see what browsers were selected by your queries by running: | 8 | # You can see what browsers were selected by your queries by running: |
6 | # npx browserslist | 9 | # npx browserslist |
7 | 10 | ||
8 | > 0.5% | 11 | last 1 Chrome version |
9 | last 2 versions | 12 | last 1 Firefox version |
13 | last 2 Edge major versions | ||
14 | last 2 Safari major versions | ||
15 | last 2 iOS major versions | ||
10 | Firefox ESR | 16 | Firefox ESR |
11 | not dead | 17 | not IE 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line. |
12 | not IE 9-11 # For IE 9-11 support, remove 'not'. \ No newline at end of file | 18 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. |
diff --git a/server/lib/plugins/plugin-helpers-builder.ts b/server/lib/plugins/plugin-helpers-builder.ts index 39773f693..dac6b3185 100644 --- a/server/lib/plugins/plugin-helpers-builder.ts +++ b/server/lib/plugins/plugin-helpers-builder.ts | |||
@@ -63,6 +63,10 @@ function buildVideosHelpers () { | |||
63 | return VideoModel.loadByUrl(url) | 63 | return VideoModel.loadByUrl(url) |
64 | }, | 64 | }, |
65 | 65 | ||
66 | loadByIdOrUUID: (id: number | string) => { | ||
67 | return VideoModel.load(id) | ||
68 | }, | ||
69 | |||
66 | removeVideo: (id: number) => { | 70 | removeVideo: (id: number) => { |
67 | return sequelizeTypescript.transaction(async t => { | 71 | return sequelizeTypescript.transaction(async t => { |
68 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t) | 72 | const video = await VideoModel.loadAndPopulateAccountAndServerAndTags(id, t) |
diff --git a/server/tests/fixtures/peertube-plugin-test-four/main.js b/server/tests/fixtures/peertube-plugin-test-four/main.js index 067c3fe15..8df456c8a 100644 --- a/server/tests/fixtures/peertube-plugin-test-four/main.js +++ b/server/tests/fixtures/peertube-plugin-test-four/main.js | |||
@@ -24,8 +24,13 @@ async function register ({ | |||
24 | registerHook({ | 24 | registerHook({ |
25 | target: 'action:api.video.viewed', | 25 | target: 'action:api.video.viewed', |
26 | handler: async ({ video }) => { | 26 | handler: async ({ video }) => { |
27 | const videoFromDB = await peertubeHelpers.videos.loadByUrl(video.url) | 27 | const videoFromDB1 = await peertubeHelpers.videos.loadByUrl(video.url) |
28 | logger.info('video from DB uuid is %s.', videoFromDB.uuid) | 28 | const videoFromDB2 = await peertubeHelpers.videos.loadByIdOrUUID(video.id) |
29 | const videoFromDB3 = await peertubeHelpers.videos.loadByIdOrUUID(video.uuid) | ||
30 | |||
31 | if (videoFromDB1.uuid !== videoFromDB2.uuid || videoFromDB2.uuid !== videoFromDB3.uuid) return | ||
32 | |||
33 | logger.info('video from DB uuid is %s.', videoFromDB1.uuid) | ||
29 | 34 | ||
30 | await peertubeHelpers.videos.removeVideo(video.id) | 35 | await peertubeHelpers.videos.removeVideo(video.id) |
31 | 36 | ||
diff --git a/server/types/plugins/register-server-option.model.ts b/server/types/plugins/register-server-option.model.ts index ccd5a060d..1ca17e4ab 100644 --- a/server/types/plugins/register-server-option.model.ts +++ b/server/types/plugins/register-server-option.model.ts | |||
@@ -30,6 +30,7 @@ export type PeerTubeHelpers = { | |||
30 | 30 | ||
31 | videos: { | 31 | videos: { |
32 | loadByUrl: (url: string) => Promise<MVideoThumbnail> | 32 | loadByUrl: (url: string) => Promise<MVideoThumbnail> |
33 | loadByIdOrUUID: (id: number | string) => Promise<MVideoThumbnail> | ||
33 | 34 | ||
34 | removeVideo: (videoId: number) => Promise<void> | 35 | removeVideo: (videoId: number) => Promise<void> |
35 | } | 36 | } |