aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--server/lib/activitypub/process/process-undo.ts8
-rw-r--r--server/lib/activitypub/send/send-undo.ts9
-rw-r--r--server/tests/api/follows.ts65
-rw-r--r--server/tests/api/multiple-servers.ts2
4 files changed, 73 insertions, 11 deletions
diff --git a/server/lib/activitypub/process/process-undo.ts b/server/lib/activitypub/process/process-undo.ts
index caa835714..9fe066c01 100644
--- a/server/lib/activitypub/process/process-undo.ts
+++ b/server/lib/activitypub/process/process-undo.ts
@@ -1,10 +1,10 @@
1import { ActivityCreate, ActivityFollow, ActivityLike, ActivityUndo } from '../../../../shared/models/activitypub/activity' 1import { ActivityFollow, ActivityLike, ActivityUndo } from '../../../../shared/models/activitypub/activity'
2import { DislikeObject } from '../../../../shared/models/activitypub/objects/dislike-object'
3import { retryTransactionWrapper } from '../../../helpers/database-utils'
2import { logger } from '../../../helpers/logger' 4import { logger } from '../../../helpers/logger'
3import { database as db } from '../../../initializers' 5import { database as db } from '../../../initializers'
4import { retryTransactionWrapper } from '../../../helpers/database-utils'
5import { DislikeObject } from '../../../../shared/models/activitypub/objects/dislike-object'
6import { sendUndoLikeToVideoFollowers } from '../send/send-undo'
7import { sendUndoDislikeToVideoFollowers } from '../index' 6import { sendUndoDislikeToVideoFollowers } from '../index'
7import { sendUndoLikeToVideoFollowers } from '../send/send-undo'
8 8
9async function processUndoActivity (activity: ActivityUndo) { 9async function processUndoActivity (activity: ActivityUndo) {
10 const activityToUndo = activity.object 10 const activityToUndo = activity.object
diff --git a/server/lib/activitypub/send/send-undo.ts b/server/lib/activitypub/send/send-undo.ts
index 53fddd0cb..8f46a051e 100644
--- a/server/lib/activitypub/send/send-undo.ts
+++ b/server/lib/activitypub/send/send-undo.ts
@@ -1,14 +1,14 @@
1import { Transaction } from 'sequelize' 1import { Transaction } from 'sequelize'
2import { ActivityCreate, ActivityFollow, ActivityLike, ActivityUndo } from '../../../../shared/models/activitypub/activity' 2import { ActivityCreate, ActivityFollow, ActivityLike, ActivityUndo } from '../../../../shared/models/activitypub/activity'
3import { getServerAccount } from '../../../helpers/utils'
3import { AccountInstance } from '../../../models' 4import { AccountInstance } from '../../../models'
4import { AccountFollowInstance } from '../../../models/account/account-follow-interface' 5import { AccountFollowInstance } from '../../../models/account/account-follow-interface'
6import { VideoInstance } from '../../../models/video/video-interface'
7import { getAccountFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url'
5import { broadcastToFollowers, getAccountsToForwardVideoAction, unicastTo } from './misc' 8import { broadcastToFollowers, getAccountsToForwardVideoAction, unicastTo } from './misc'
9import { createActivityData, createDislikeActivityData } from './send-create'
6import { followActivityData } from './send-follow' 10import { followActivityData } from './send-follow'
7import { getAccountFollowActivityPubUrl, getUndoActivityPubUrl, getVideoDislikeActivityPubUrl, getVideoLikeActivityPubUrl } from '../url'
8import { VideoInstance } from '../../../models/video/video-interface'
9import { likeActivityData } from './send-like' 11import { likeActivityData } from './send-like'
10import { createActivityData, createDislikeActivityData } from './send-create'
11import { getServerAccount } from '../../../helpers/utils'
12 12
13async function sendUndoFollow (accountFollow: AccountFollowInstance, t: Transaction) { 13async function sendUndoFollow (accountFollow: AccountFollowInstance, t: Transaction) {
14 const me = accountFollow.AccountFollower 14 const me = accountFollow.AccountFollower
@@ -75,7 +75,6 @@ async function sendUndoDislikeToVideoFollowers (byAccount: AccountInstance, vide
75 return broadcastToFollowers(data, serverAccount, accountsToForwardView, t, followersException) 75 return broadcastToFollowers(data, serverAccount, accountsToForwardView, t, followersException)
76} 76}
77 77
78
79// --------------------------------------------------------------------------- 78// ---------------------------------------------------------------------------
80 79
81export { 80export {
diff --git a/server/tests/api/follows.ts b/server/tests/api/follows.ts
index 875d814a7..aadae3cce 100644
--- a/server/tests/api/follows.ts
+++ b/server/tests/api/follows.ts
@@ -14,6 +14,10 @@ import {
14 wait 14 wait
15} from '../utils' 15} from '../utils'
16import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../utils/follows' 16import { follow, getFollowersListPaginationAndSort, getFollowingListPaginationAndSort, unfollow } from '../utils/follows'
17import { getUserAccessToken } from '../utils/login'
18import { dateIsValid, webtorrentAdd } from '../utils/miscs'
19import { createUser } from '../utils/users'
20import { getVideo, rateVideo, testVideoImage } from '../utils/videos'
17 21
18const expect = chai.expect 22const expect = chai.expect
19 23
@@ -166,12 +170,32 @@ describe('Test follows', function () {
166 it('Should propagate previous uploaded videos on a new following', async function () { 170 it('Should propagate previous uploaded videos on a new following', async function () {
167 this.timeout(20000) 171 this.timeout(20000)
168 172
173 const video4Attributes = {
174 name: 'server3-4',
175 category: 2,
176 nsfw: true,
177 licence: 6,
178 tags: [ 'tag1', 'tag2', 'tag3' ]
179 }
180
169 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-2' }) 181 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-2' })
170 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-3' }) 182 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-3' })
171 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-4' }) 183 await uploadVideo(servers[2].url, servers[2].accessToken, video4Attributes)
172 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-5' }) 184 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-5' })
173 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-6' }) 185 await uploadVideo(servers[2].url, servers[2].accessToken, { name: 'server3-6' })
174 186
187 {
188 const user = { username: 'captain', password: 'password' }
189 await createUser(servers[2].url, servers[2].accessToken, user.username, user.password)
190 const userAccessToken = await getUserAccessToken(servers[2], user)
191
192 const res = await getVideosList(servers[2].url)
193 const video4 = res.body.data.find(v => v.name === 'server3-4')
194
195 await rateVideo(servers[2].url, servers[2].accessToken, video4.id, 'like')
196 await rateVideo(servers[2].url, userAccessToken, video4.id, 'dislike')
197 }
198
175 await wait(5000) 199 await wait(5000)
176 200
177 // Server 1 follows server 3 201 // Server 1 follows server 3
@@ -189,6 +213,45 @@ describe('Test follows', function () {
189 expect(video2).to.not.be.undefined 213 expect(video2).to.not.be.undefined
190 expect(video4).to.not.be.undefined 214 expect(video4).to.not.be.undefined
191 expect(video6).to.not.be.undefined 215 expect(video6).to.not.be.undefined
216
217 const res2 = await getVideo(servers[0].url, video4.id)
218 const videoDetails = res2.body
219
220 expect(videoDetails.name).to.equal('server3-4')
221 expect(videoDetails.category).to.equal(2)
222 expect(videoDetails.categoryLabel).to.equal('Films')
223 expect(videoDetails.licence).to.equal(6)
224 expect(videoDetails.licenceLabel).to.equal('Attribution - Non Commercial - No Derivatives')
225 expect(videoDetails.language).to.equal(3)
226 expect(videoDetails.languageLabel).to.equal('Mandarin')
227 expect(videoDetails.nsfw).to.be.ok
228 expect(videoDetails.description).to.equal('my super description')
229 expect(videoDetails.serverHost).to.equal('localhost:9003')
230 expect(videoDetails.account).to.equal('root')
231 expect(videoDetails.likes).to.equal(1)
232 expect(videoDetails.dislikes).to.equal(1)
233 expect(videoDetails.isLocal).to.be.false
234 expect(videoDetails.tags).to.deep.equal([ 'tag1', 'tag2', 'tag3' ])
235 expect(dateIsValid(videoDetails.createdAt)).to.be.true
236 expect(dateIsValid(videoDetails.updatedAt)).to.be.true
237 expect(videoDetails.files).to.have.lengthOf(1)
238
239 const file = videoDetails.files[0]
240 const magnetUri = file.magnetUri
241 expect(file.magnetUri).to.have.lengthOf.above(2)
242 expect(file.torrentUrl).to.equal(`${servers[2].url}/static/torrents/${videoDetails.uuid}-${file.resolution}.torrent`)
243 expect(file.fileUrl).to.equal(`${servers[2].url}/static/webseed/${videoDetails.uuid}-${file.resolution}.webm`)
244 expect(file.resolution).to.equal(720)
245 expect(file.resolutionLabel).to.equal('720p')
246 expect(file.size).to.equal(218910)
247
248 const test = await testVideoImage(servers[2].url, 'video_short.webm', videoDetails.thumbnailPath)
249 expect(test).to.equal(true)
250
251 const torrent = await webtorrentAdd(magnetUri)
252 expect(torrent.files).to.be.an('array')
253 expect(torrent.files.length).to.equal(1)
254 expect(torrent.files[0].path).to.exist.and.to.not.equal('')
192 }) 255 })
193 256
194 after(async function () { 257 after(async function () {
diff --git a/server/tests/api/multiple-servers.ts b/server/tests/api/multiple-servers.ts
index 405dcf625..601e5f39a 100644
--- a/server/tests/api/multiple-servers.ts
+++ b/server/tests/api/multiple-servers.ts
@@ -175,7 +175,7 @@ describe('Test multiple servers', function () {
175 await uploadVideo(servers[1].url, userAccessToken, videoAttributes) 175 await uploadVideo(servers[1].url, userAccessToken, videoAttributes)
176 176
177 // Transcoding 177 // Transcoding
178 await wait(15000) 178 await wait(25000)
179 179
180 // All servers should have this video 180 // All servers should have this video
181 for (const server of servers) { 181 for (const server of servers) {