Add logs for refresh functions
This commit is contained in:
parent
7ffa92d6e4
commit
9de33c6bd9
|
@ -1,4 +1,4 @@
|
|||
import { logger } from '@server/helpers/logger'
|
||||
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
||||
import { PeerTubeRequestError } from '@server/helpers/requests'
|
||||
import { ActorLoadByUrlType } from '@server/lib/model-loaders'
|
||||
import { ActorModel } from '@server/models/actor/actor'
|
||||
|
@ -19,6 +19,10 @@ async function refreshActorIfNeeded <T extends MActorFull | MActorAccountChannel
|
|||
? actorArg as MActorFull
|
||||
: await ActorModel.loadByUrlAndPopulateAccountAndChannel(actorArg.url)
|
||||
|
||||
const lTags = loggerTagsFactory('ap', 'actor', 'refresh', actor.url)
|
||||
|
||||
logger.info('Refreshing actor %s.', actor.url, lTags())
|
||||
|
||||
try {
|
||||
const actorUrl = await getActorUrl(actor)
|
||||
const { actorObject } = await fetchRemoteActor(actorUrl)
|
||||
|
@ -34,7 +38,7 @@ async function refreshActorIfNeeded <T extends MActorFull | MActorAccountChannel
|
|||
return { refreshed: true, actor }
|
||||
} catch (err) {
|
||||
if ((err as PeerTubeRequestError).statusCode === HttpStatusCode.NOT_FOUND_404) {
|
||||
logger.info('Deleting actor %s because there is a 404 in refresh actor.', actor.url)
|
||||
logger.info('Deleting actor %s because there is a 404 in refresh actor.', actor.url, lTags())
|
||||
|
||||
actor.Account
|
||||
? await actor.Account.destroy()
|
||||
|
@ -43,7 +47,7 @@ async function refreshActorIfNeeded <T extends MActorFull | MActorAccountChannel
|
|||
return { actor: undefined, refreshed: false }
|
||||
}
|
||||
|
||||
logger.warn('Cannot refresh actor %s.', actor.url, { err })
|
||||
logger.warn('Cannot refresh actor %s.', actor.url, { err, ...lTags() })
|
||||
return { actor, refreshed: false }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@ async function refreshVideoPlaylistIfNeeded (videoPlaylist: MVideoPlaylistOwner)
|
|||
|
||||
const lTags = loggerTagsFactory('ap', 'video-playlist', 'refresh', videoPlaylist.uuid, videoPlaylist.url)
|
||||
|
||||
logger.info('Refreshing playlist %s.', videoPlaylist.url, lTags())
|
||||
|
||||
try {
|
||||
const { playlistObject } = await fetchRemoteVideoPlaylist(videoPlaylist.url)
|
||||
|
||||
|
|
|
@ -22,6 +22,8 @@ async function refreshVideoIfNeeded (options: {
|
|||
|
||||
const lTags = loggerTagsFactory('ap', 'video', 'refresh', video.uuid, video.url)
|
||||
|
||||
logger.info('Refreshing video %s.', video.url, lTags())
|
||||
|
||||
try {
|
||||
const { videoObject } = await fetchRemoteVideo(video.url)
|
||||
|
||||
|
|
|
@ -215,7 +215,7 @@ describe('Test blocklist', function () {
|
|||
|
||||
const threads: VideoComment[] = resThreads.body.data
|
||||
expect(threads).to.have.lengthOf(1)
|
||||
expect(threads[0].totalReplies).to.equal(0)
|
||||
expect(threads[0].totalReplies).to.equal(1)
|
||||
|
||||
const t = threads.find(t => t.text === 'comment user 1')
|
||||
expect(t).to.be.undefined
|
||||
|
@ -565,7 +565,7 @@ describe('Test blocklist', function () {
|
|||
threads = threads.filter(t => t.isDeleted === false)
|
||||
|
||||
expect(threads).to.have.lengthOf(1)
|
||||
expect(threads[0].totalReplies).to.equal(0)
|
||||
expect(threads[0].totalReplies).to.equal(1)
|
||||
|
||||
const t = threads.find(t => t.text === 'comment user 1')
|
||||
expect(t).to.be.undefined
|
||||
|
|
|
@ -519,7 +519,7 @@ describe('Test follows', function () {
|
|||
expect(deletedComment.text).to.equal('')
|
||||
expect(deletedComment.inReplyToCommentId).to.be.null
|
||||
expect(deletedComment.account).to.be.null
|
||||
expect(deletedComment.totalReplies).to.equal(3)
|
||||
expect(deletedComment.totalReplies).to.equal(2)
|
||||
expect(dateIsValid(deletedComment.deletedAt as string)).to.be.true
|
||||
|
||||
const res2 = await getVideoThreadComments(servers[0].url, video4.id, deletedComment.threadId)
|
||||
|
|
Loading…
Reference in New Issue