aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
Diffstat (limited to 'server')
-rw-r--r--server/helpers/custom-validators/activitypub/actor.ts6
-rw-r--r--server/models/video/video-comment.ts10
-rw-r--r--server/tests/api/videos/video-comments.ts16
3 files changed, 21 insertions, 11 deletions
diff --git a/server/helpers/custom-validators/activitypub/actor.ts b/server/helpers/custom-validators/activitypub/actor.ts
index 8820bb2a4..e1a4b5b8f 100644
--- a/server/helpers/custom-validators/activitypub/actor.ts
+++ b/server/helpers/custom-validators/activitypub/actor.ts
@@ -1,8 +1,6 @@
1import * as validator from 'validator' 1import * as validator from 'validator'
2import { CONSTRAINTS_FIELDS } from '../../../initializers' 2import { CONSTRAINTS_FIELDS } from '../../../initializers'
3import { isAccountNameValid } from '../accounts'
4import { exists } from '../misc' 3import { exists } from '../misc'
5import { isVideoChannelNameValid } from '../video-channels'
6import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc' 4import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc'
7 5
8function isActorEndpointsObjectValid (endpointObject: any) { 6function isActorEndpointsObjectValid (endpointObject: any) {
@@ -32,10 +30,6 @@ function isActorPreferredUsernameValid (preferredUsername: string) {
32 return exists(preferredUsername) && validator.matches(preferredUsername, actorNameRegExp) 30 return exists(preferredUsername) && validator.matches(preferredUsername, actorNameRegExp)
33} 31}
34 32
35function isActorNameValid (name: string) {
36 return isAccountNameValid(name) || isVideoChannelNameValid(name)
37}
38
39function isActorPrivateKeyValid (privateKey: string) { 33function isActorPrivateKeyValid (privateKey: string) {
40 return exists(privateKey) && 34 return exists(privateKey) &&
41 typeof privateKey === 'string' && 35 typeof privateKey === 'string' &&
diff --git a/server/models/video/video-comment.ts b/server/models/video/video-comment.ts
index 63675c20b..d2d8945c3 100644
--- a/server/models/video/video-comment.ts
+++ b/server/models/video/video-comment.ts
@@ -9,6 +9,7 @@ import { isActivityPubUrlValid } from '../../helpers/custom-validators/activityp
9import { CONSTRAINTS_FIELDS } from '../../initializers' 9import { CONSTRAINTS_FIELDS } from '../../initializers'
10import { AccountModel } from '../account/account' 10import { AccountModel } from '../account/account'
11import { ActorModel } from '../activitypub/actor' 11import { ActorModel } from '../activitypub/actor'
12import { AvatarModel } from '../avatar/avatar'
12import { ServerModel } from '../server/server' 13import { ServerModel } from '../server/server'
13import { getSort, throwIfNotValid } from '../utils' 14import { getSort, throwIfNotValid } from '../utils'
14import { VideoModel } from './video' 15import { VideoModel } from './video'
@@ -46,6 +47,10 @@ enum ScopeNames {
46 { 47 {
47 model: () => ServerModel, 48 model: () => ServerModel,
48 required: false 49 required: false
50 },
51 {
52 model: () => AvatarModel,
53 required: false
49 } 54 }
50 ] 55 ]
51 } 56 }
@@ -243,10 +248,7 @@ export class VideoCommentModel extends Model<VideoCommentModel> {
243 createdAt: this.createdAt, 248 createdAt: this.createdAt,
244 updatedAt: this.updatedAt, 249 updatedAt: this.updatedAt,
245 totalReplies: this.get('totalReplies') || 0, 250 totalReplies: this.get('totalReplies') || 0,
246 account: { 251 account: this.Account.toFormattedJSON()
247 name: this.Account.name,
248 host: this.Account.Actor.getHost()
249 }
250 } as VideoComment 252 } as VideoComment
251 } 253 }
252 254
diff --git a/server/tests/api/videos/video-comments.ts b/server/tests/api/videos/video-comments.ts
index 3b6578f04..604a3027d 100644
--- a/server/tests/api/videos/video-comments.ts
+++ b/server/tests/api/videos/video-comments.ts
@@ -3,7 +3,11 @@
3import * as chai from 'chai' 3import * as chai from 'chai'
4import 'mocha' 4import 'mocha'
5import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model' 5import { VideoComment, VideoCommentThreadTree } from '../../../../shared/models/videos/video-comment.model'
6import { dateIsValid, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, uploadVideo } from '../../utils/index' 6import { testVideoImage } from '../../utils'
7import {
8 dateIsValid, flushTests, killallServers, runServer, ServerInfo, setAccessTokensToServers, updateMyAvatar,
9 uploadVideo
10} from '../../utils/index'
7import { 11import {
8 addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads, 12 addVideoCommentReply, addVideoCommentThread, getVideoCommentThreads,
9 getVideoThreadComments 13 getVideoThreadComments
@@ -29,6 +33,12 @@ describe('Test video comments', function () {
29 const res = await uploadVideo(server.url, server.accessToken, {}) 33 const res = await uploadVideo(server.url, server.accessToken, {})
30 videoUUID = res.body.video.uuid 34 videoUUID = res.body.video.uuid
31 videoId = res.body.video.id 35 videoId = res.body.video.id
36
37 await updateMyAvatar({
38 url: server.url,
39 accessToken: server.accessToken,
40 fixture: 'avatar.png'
41 })
32 }) 42 })
33 43
34 it('Should not have threads on this video', async function () { 44 it('Should not have threads on this video', async function () {
@@ -70,6 +80,10 @@ describe('Test video comments', function () {
70 expect(comment.id).to.equal(comment.threadId) 80 expect(comment.id).to.equal(comment.threadId)
71 expect(comment.account.name).to.equal('root') 81 expect(comment.account.name).to.equal('root')
72 expect(comment.account.host).to.equal('localhost:9001') 82 expect(comment.account.host).to.equal('localhost:9001')
83
84 const test = await testVideoImage(server.url, 'avatar-resized', comment.account.avatar.path, '.png')
85 expect(test).to.equal(true)
86
73 expect(comment.totalReplies).to.equal(0) 87 expect(comment.totalReplies).to.equal(0)
74 expect(dateIsValid(comment.createdAt as string)).to.be.true 88 expect(dateIsValid(comment.createdAt as string)).to.be.true
75 expect(dateIsValid(comment.updatedAt as string)).to.be.true 89 expect(dateIsValid(comment.updatedAt as string)).to.be.true