Add url to avatar

This commit is contained in:
Chocobozzz 2020-06-09 14:29:20 +02:00
parent 8d2fd71f61
commit 5ff8df46c6
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 19 additions and 9 deletions

View File

@ -16,7 +16,7 @@
"tsc": "tsc",
"eslint": "eslint",
"lint": "eslint --ext .ts \"server/**/*.ts\"",
"build": "tsc",
"build": "rm -r dist && tsc",
"start": "node dist/server.js"
},
"dependencies": {

View File

@ -1,10 +1,12 @@
import { Avatar } from '@shared/models'
import { buildUrl } from '../helpers/utils'
function formatAvatarForAPI (obj: { avatar?: Avatar }) {
function formatAvatarForAPI (obj: { avatar?: Avatar & { url: string } }) {
if (!obj.avatar) return null
return {
url: obj.avatar.url,
path: obj.avatar.path,
createdAt: obj.avatar.createdAt,
updatedAt: obj.avatar.updatedAt

View File

@ -194,7 +194,7 @@ function formatChannelForDB (c: IndexableChannel): DBChannel {
}
}
function formatChannelForAPI (c: DBChannel, fromHost?: string): VideoChannel {
function formatChannelForAPI (c: DBChannel, fromHost?: string): any {
return {
id: c.id,

View File

@ -1,5 +1,5 @@
import { IndexableDoc } from './elastic-search.model'
import { VideoChannel, VideoChannelSummary } from '@shared/models'
import { VideoChannel, VideoChannelSummary, Avatar } from '@shared/models'
import { Account } from '@shared/models/actors/account.model'
export interface IndexableChannelSummary extends VideoChannelSummary, IndexableDoc {
@ -13,7 +13,9 @@ export interface DBChannel extends Omit<VideoChannel, 'isLocal'> {
handle: string
url: string
ownerAccount?: Account & { handle: string }
ownerAccount?: Account & { handle: string, avatar: Avatar & { url: string } }
avatar?: Avatar & { url: string }
}
export interface DBChannelSummary extends VideoChannelSummary {

View File

@ -2,6 +2,12 @@ import { VideoChannel, VideoChannelSummary } from '@shared/models/videos/channel
import { Account, AccountSummary } from '@shared/models/actors/account.model'
import { Video, VideoDetails } from '@shared/models/videos/video.model'
import { IndexableDoc } from './elastic-search.model'
import { Avatar } from '@shared/models'
type ActorExtended = {
handle: string
avatar: Avatar & { url: string }
}
export interface IndexableVideo extends Video, IndexableDoc {
}
@ -13,8 +19,8 @@ export interface DBVideoDetails extends Omit<VideoDetails, 'isLocal'> {
indexedAt: Date
host: string
account: Account & { handle: string }
channel: VideoChannel & { handle: string }
account: Account & ActorExtended
channel: VideoChannel & ActorExtended
}
export interface DBVideo extends Omit<Video, 'isLocal'> {
@ -22,6 +28,6 @@ export interface DBVideo extends Omit<Video, 'isLocal'> {
host: string
url: string
account: AccountSummary & { handle: string }
channel: VideoChannelSummary & { handle: string }
account: AccountSummary & ActorExtended
channel: VideoChannelSummary & ActorExtended
}