diff options
Diffstat (limited to 'server/helpers/utils.ts')
-rw-r--r-- | server/helpers/utils.ts | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/server/helpers/utils.ts b/server/helpers/utils.ts index 6228fec04..049c3f8bc 100644 --- a/server/helpers/utils.ts +++ b/server/helpers/utils.ts | |||
@@ -40,7 +40,10 @@ const getServerActor = memoizee(async function () { | |||
40 | const application = await ApplicationModel.load() | 40 | const application = await ApplicationModel.load() |
41 | if (!application) throw Error('Could not load Application from database.') | 41 | if (!application) throw Error('Could not load Application from database.') |
42 | 42 | ||
43 | return application.Account.Actor | 43 | const actor = application.Account.Actor |
44 | actor.Account = application.Account | ||
45 | |||
46 | return actor | ||
44 | }) | 47 | }) |
45 | 48 | ||
46 | function generateVideoTmpPath (target: string | ParseTorrent) { | 49 | function generateVideoTmpPath (target: string | ParseTorrent) { |
@@ -77,6 +80,20 @@ async function getVersion () { | |||
77 | return require('../../../package.json').version | 80 | return require('../../../package.json').version |
78 | } | 81 | } |
79 | 82 | ||
83 | /** | ||
84 | * From a filename like "ede4cba5-742b-46fa-a388-9a6eb3a3aeb3.mp4", returns | ||
85 | * only the "ede4cba5-742b-46fa-a388-9a6eb3a3aeb3" part. If the filename does | ||
86 | * not contain a UUID, returns null. | ||
87 | */ | ||
88 | function getUUIDFromFilename (filename: string) { | ||
89 | const regex = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/ | ||
90 | const result = filename.match(regex) | ||
91 | |||
92 | if (!result || Array.isArray(result) === false) return null | ||
93 | |||
94 | return result[0] | ||
95 | } | ||
96 | |||
80 | // --------------------------------------------------------------------------- | 97 | // --------------------------------------------------------------------------- |
81 | 98 | ||
82 | export { | 99 | export { |
@@ -86,5 +103,6 @@ export { | |||
86 | getSecureTorrentName, | 103 | getSecureTorrentName, |
87 | getServerActor, | 104 | getServerActor, |
88 | getVersion, | 105 | getVersion, |
89 | generateVideoTmpPath | 106 | generateVideoTmpPath, |
107 | getUUIDFromFilename | ||
90 | } | 108 | } |