mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-02-25 18:55:32 -06:00
Add avatar in comments
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
import * as validator from 'validator'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers'
|
||||
import { isAccountNameValid } from '../accounts'
|
||||
import { exists } from '../misc'
|
||||
import { isVideoChannelNameValid } from '../video-channels'
|
||||
import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc'
|
||||
|
||||
function isActorEndpointsObjectValid (endpointObject: any) {
|
||||
@@ -32,10 +30,6 @@ function isActorPreferredUsernameValid (preferredUsername: string) {
|
||||
return exists(preferredUsername) && validator.matches(preferredUsername, actorNameRegExp)
|
||||
}
|
||||
|
||||
function isActorNameValid (name: string) {
|
||||
return isAccountNameValid(name) || isVideoChannelNameValid(name)
|
||||
}
|
||||
|
||||
function isActorPrivateKeyValid (privateKey: string) {
|
||||
return exists(privateKey) &&
|
||||
typeof privateKey === 'string' &&
|
||||
|
||||
@@ -9,6 +9,7 @@ import { isActivityPubUrlValid } from '../../helpers/custom-validators/activityp
|
||||
import { CONSTRAINTS_FIELDS } from '../../initializers'
|
||||
import { AccountModel } from '../account/account'
|
||||
import { ActorModel } from '../activitypub/actor'
|
||||
import { AvatarModel } from '../avatar/avatar'
|
||||
import { ServerModel } from '../server/server'
|
||||
import { getSort, throwIfNotValid } from '../utils'
|
||||
import { VideoModel } from './video'
|
||||
@@ -46,6 +47,10 @@ enum ScopeNames {
|
||||
{
|
||||
model: () => ServerModel,
|
||||
required: false
|
||||
},
|
||||
{
|
||||
model: () => AvatarModel,
|
||||
required: false
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -243,10 +248,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
|
||||
createdAt: this.createdAt,
|
||||
updatedAt: this.updatedAt,
|
||||
totalReplies: this.get('totalReplies') || 0,
|
||||
account: {
|
||||
name: this.Account.name,
|
||||
host: this.Account.Actor.getHost()
|
||||
}
|
||||
account: this.Account.toFormattedJSON()
|
||||
} as VideoComment
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,11 @@
|
||||
import * as chai from 'chai'
|
||||
import 'mocha'
|
||||
import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
|
||||
import { dateIsValid, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index'
|
||||
import { testVideoImage } from '../../utils'
|
||||
import {
|
||||
dateIsValid, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, updateMyAvatar,
|
||||
uploadVideo
|
||||
} from '../../utils/index'
|
||||
import {
|
||||
addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
|
||||
getVideoThreadComments
|
||||
@@ -29,6 +33,12 @@ describe('Test video comments', function () {
|
||||
const res = await uploadVideo(server.url, server.accessToken, {})
|
||||
videoUUID = res.body.video.uuid
|
||||
videoId = res.body.video.id
|
||||
|
||||
await updateMyAvatar({
|
||||
url: server.url,
|
||||
accessToken: server.accessToken,
|
||||
fixture: 'avatar.png'
|
||||
})
|
||||
})
|
||||
|
||||
it('Should not have threads on this video', async function () {
|
||||
@@ -70,6 +80,10 @@ describe('Test video comments', function () {
|
||||
expect(comment.id).to.equal(comment.threadId)
|
||||
expect(comment.account.name).to.equal('root')
|
||||
expect(comment.account.host).to.equal('localhost:9001')
|
||||
|
||||
const test = await testVideoImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png')
|
||||
expect(test).to.equal(true)
|
||||
|
||||
expect(comment.totalReplies).to.equal(0)
|
||||
expect(dateIsValid(comment.createdAt as string)).to.be.true
|
||||
expect(dateIsValid(comment.updatedAt as string)).to.be.true
|
||||
|
||||
Reference in New Issue
Block a user