Add URL property to video

This commit is contained in:
Chocobozzz 2020-06-05 14:37:39 +02:00
parent dd765cecbf
commit 3dbaf01e34
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
6 changed files with 21 additions and 3 deletions

View File

@ -154,9 +154,9 @@ function formatChannelForDB (c: IndexableChannel): DBChannel {
return {
id: c.id,
url: c.url,
name: c.name,
host: c.host,
url: c.url,
avatar: formatAvatarForDB(c),

View File

@ -325,6 +325,7 @@ function formatVideoForDB (v: IndexableVideo | IndexableVideoDetails): DBVideo |
nsfw: v.nsfw,
host: v.host,
url: v.url,
tags: (v as IndexableVideoDetails).tags ? (v as IndexableVideoDetails).tags : undefined,
@ -394,6 +395,8 @@ function formatVideoForAPI (v: DBVideo, fromHost?: string): any {
embedPath: v.embedPath,
embedUrl: buildUrl(v.host, v.embedPath),
url: v.url,
isLocal: fromHost && fromHost === v.host,
views: v.views,
@ -563,6 +566,10 @@ function buildVideosMapping () {
type: 'keyword'
},
url: {
type: 'keyword'
},
views: {
type: 'long'
},

View File

@ -45,11 +45,19 @@ async function getVideos (host: string, start: number): Promise<IndexableVideo[]
}
function prepareVideoForDB <T extends Video> (video: T, host: string): T & IndexableDoc {
return Object.assign(video, { elasticSearchId: host + video.id, host })
return Object.assign(video, {
elasticSearchId: host + video.id,
host,
url: 'https://' + host + '/videos/watch/' + video.uuid
})
}
function prepareChannelForDB <T extends VideoChannel> (channel: T, host: string): T & IndexableDoc {
return Object.assign(channel, { elasticSearchId: host + channel.id, host })
return Object.assign(channel, {
elasticSearchId: host + channel.id,
host,
url: 'https://' + host + '/video-channels/' + channel.name
})
}
export {

View File

@ -11,6 +11,7 @@ export interface IndexableChannel extends VideoChannel, IndexableDoc {
export interface DBChannel extends Omit<VideoChannel, 'isLocal'> {
indexedAt: Date
handle: string
url: string
ownerAccount?: Account & { handle: string }
}

View File

@ -1,4 +1,5 @@
export interface IndexableDoc {
elasticSearchId: string
host: string
url: string
}

View File

@ -20,6 +20,7 @@ export interface DBVideoDetails extends Omit<VideoDetails, 'isLocal'> {
export interface DBVideo extends Omit<Video, 'isLocal'> {
indexedAt: Date
host: string
url: string
account: AccountSummary & { handle: string }
channel: VideoChannelSummary & { handle: string }