// Speed up things and resolve directly the thread
if (commentFromDatabase.InReplyToVideoComment) {
const data = await VideoCommentModel.listThreadParentComments(commentFromDatabase, undefined, 'DESC')
- console.log(data)
parentComments = parentComments.concat(data)
}
import { getServerActor } from '../../../helpers/utils'
import { ACTIVITY_PUB } from '../../../initializers'
import { ActorModel } from '../../../models/activitypub/actor'
+import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { JobHandler, JobScheduler } from '../job-scheduler'
import * as activitypubHttpBroadcastHandler from './activitypub-http-broadcast-handler'
if (attemptNumber < ACTIVITY_PUB.MAX_HTTP_ATTEMPT) {
logger.debug('Retrying request to %s (attempt %d/%d).', uri, attemptNumber, ACTIVITY_PUB.MAX_HTTP_ATTEMPT, err)
+ const actor = await ActorFollowModel.loadByFollowerInbox(uri, undefined)
+ if (!actor) {
+ logger.debug('Actor %s is not a follower, do not retry the request.', uri)
+ return false
+ }
+
const newPayload = Object.assign(payload, {
uris: [ uri ],
attemptNumber
async function process (payload: ActivityPubHttpPayload, jobId: number) {
logger.info('Processing ActivityPub unicast in job %d.', jobId)
+ const uri = payload.uris[0]
+
const body = await computeBody(payload)
const httpSignatureOptions = await buildSignedRequestOptions(payload)
- const uri = payload.uris[0]
const options = {
method: 'POST',
uri,
function executeIfActivityPub (fun: RequestHandler | RequestHandler[]) {
return (req: Request, res: Response, next: NextFunction) => {
const accepted = req.accepts(ACCEPT_HEADERS)
- console.log(accepted)
if (accepted === false || ACTIVITY_PUB.POTENTIAL_ACCEPT_HEADERS.indexOf(accepted) === -1) {
return next()
}
return ActorFollowModel.findOne(query)
}
+ static loadByFollowerInbox (url: string, t?: Sequelize.Transaction) {
+ const query = {
+ where: {
+ state: 'accepted'
+ },
+ include: [
+ {
+ model: ActorModel,
+ required: true,
+ as: 'ActorFollower',
+ where: {
+ [Sequelize.Op.or]: [
+ {
+ inboxUrl: url
+ },
+ {
+ sharedInboxUrl: url
+ }
+ ]
+ }
+ }
+ ],
+ transaction: t
+ } as any // FIXME: typings does not work
+
+ return ActorFollowModel.findOne(query)
+ }
+
static listFollowingForApi (id: number, start: number, count: number, sort: string) {
const query = {
distinct: true,
{
fields: [ 'preferredUsername', 'serverId' ],
unique: true
+ },
+ {
+ fields: [ 'inboxUrl', 'sharedInboxUrl' ]
}
]
})
videos.push(resVideo.body.video)
}
+ await wait(2000)
+
+ await uploadVideo(servers[ 0 ].url, servers[ 0 ].accessToken, videoAttributes)
+
// Add comments to video 2
{
const text = 'thread 1'