Add URL property to video
This commit is contained in:
parent
dd765cecbf
commit
3dbaf01e34
|
@ -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),
|
||||
|
||||
|
|
|
@ -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'
|
||||
},
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 }
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
export interface IndexableDoc {
|
||||
elasticSearchId: string
|
||||
host: string
|
||||
url: string
|
||||
}
|
||||
|
|
|
@ -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 }
|
||||
|
|
Loading…
Reference in New Issue