Remove activitypub helper
Put functions in lib/activitypub instead
This commit is contained in:
parent
5302f77d09
commit
7e98a7df7d
31 changed files with 155 additions and 136 deletions
|
@ -1,10 +1,11 @@
|
|||
import cors from 'cors'
|
||||
import express from 'express'
|
||||
import { activityPubCollectionPagination } from '@server/lib/activitypub/collection'
|
||||
import { activityPubContextify } from '@server/lib/activitypub/context'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { MAccountId, MActorId, MChannelId, MVideoId } from '@server/types/models'
|
||||
import { VideoPrivacy, VideoRateType } from '../../../shared/models/videos'
|
||||
import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
|
||||
import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
|
||||
import { ROUTE_CACHE_LIFETIME, WEBSERVER } from '../../initializers/constants'
|
||||
import { audiencify, getAudience } from '../../lib/activitypub/audience'
|
||||
import { buildAnnounceWithVideoAudience, buildLikeActivity } from '../../lib/activitypub/send'
|
||||
|
@ -400,7 +401,7 @@ function videoPlaylistElementController (req: express.Request, res: express.Resp
|
|||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
async function actorFollowing (req: express.Request, actor: MActorId) {
|
||||
function actorFollowing (req: express.Request, actor: MActorId) {
|
||||
const handler = (start: number, count: number) => {
|
||||
return ActorFollowModel.listAcceptedFollowingUrlsForApi([ actor.id ], undefined, start, count)
|
||||
}
|
||||
|
@ -408,7 +409,7 @@ async function actorFollowing (req: express.Request, actor: MActorId) {
|
|||
return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
|
||||
}
|
||||
|
||||
async function actorFollowers (req: express.Request, actor: MActorId) {
|
||||
function actorFollowers (req: express.Request, actor: MActorId) {
|
||||
const handler = (start: number, count: number) => {
|
||||
return ActorFollowModel.listAcceptedFollowerUrlsForAP([ actor.id ], undefined, start, count)
|
||||
}
|
||||
|
@ -416,7 +417,7 @@ async function actorFollowers (req: express.Request, actor: MActorId) {
|
|||
return activityPubCollectionPagination(WEBSERVER.URL + req.path, handler, req.query.page)
|
||||
}
|
||||
|
||||
async function actorPlaylists (req: express.Request, options: { account: MAccountId } | { channel: MChannelId }) {
|
||||
function actorPlaylists (req: express.Request, options: { account: MAccountId } | { channel: MChannelId }) {
|
||||
const handler = (start: number, count: number) => {
|
||||
return VideoPlaylistModel.listPublicUrlsOfForAP(options, start, count)
|
||||
}
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import express from 'express'
|
||||
import { activityPubCollectionPagination } from '@server/lib/activitypub/collection'
|
||||
import { activityPubContextify } from '@server/lib/activitypub/context'
|
||||
import { MActorLight } from '@server/types/models'
|
||||
import { Activity } from '../../../shared/models/activitypub/activity'
|
||||
import { VideoPrivacy } from '../../../shared/models/videos'
|
||||
import { activityPubCollectionPagination, activityPubContextify } from '../../helpers/activitypub'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { buildAudience } from '../../lib/activitypub/audience'
|
||||
import { buildAnnounceActivity, buildCreateActivity } from '../../lib/activitypub/send'
|
||||
|
|
21
server/lib/activitypub/activity.ts
Normal file
21
server/lib/activitypub/activity.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { signJsonLDObject } from '@server/helpers/peertube-crypto'
|
||||
import { MActor } from '@server/types/models'
|
||||
import { ContextType } from '@shared/models'
|
||||
import { activityPubContextify } from './context'
|
||||
|
||||
function buildSignedActivity <T> (byActor: MActor, data: T, contextType?: ContextType) {
|
||||
const activity = activityPubContextify(data, contextType)
|
||||
|
||||
return signJsonLDObject(byActor, activity)
|
||||
}
|
||||
|
||||
function getAPId (object: string | { id: string }) {
|
||||
if (typeof object === 'string') return object
|
||||
|
||||
return object.id
|
||||
}
|
||||
|
||||
export {
|
||||
buildSignedActivity,
|
||||
getAPId
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
import { checkUrlsSameHost, getAPId } from '@server/helpers/activitypub'
|
||||
import { retryTransactionWrapper } from '@server/helpers/database-utils'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { JobQueue } from '@server/lib/job-queue'
|
||||
import { ActorLoadByUrlType, loadActorByUrl } from '@server/lib/model-loaders'
|
||||
import { MActor, MActorAccountChannelId, MActorAccountChannelIdActor, MActorAccountId, MActorFullActor } from '@server/types/models'
|
||||
import { ActivityPubActor } from '@shared/models'
|
||||
import { getAPId } from '../activity'
|
||||
import { checkUrlsSameHost } from '../url'
|
||||
import { refreshActorIfNeeded } from './refresh'
|
||||
import { APActorCreator, fetchRemoteActor } from './shared'
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
import { checkUrlsSameHost } from '@server/helpers/activitypub'
|
||||
import { sanitizeAndCheckActorObject } from '@server/helpers/custom-validators/activitypub/actor'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { doJSONRequest } from '@server/helpers/requests'
|
||||
import { ActivityPubActor, ActivityPubOrderedCollection } from '@shared/models'
|
||||
import { checkUrlsSameHost } from '../../url'
|
||||
|
||||
async function fetchRemoteActor (actorUrl: string): Promise<{ statusCode: number, actorObject: ActivityPubActor }> {
|
||||
logger.info('Fetching remote actor %s.', actorUrl)
|
||||
|
|
62
server/lib/activitypub/collection.ts
Normal file
62
server/lib/activitypub/collection.ts
Normal file
|
@ -0,0 +1,62 @@
|
|||
import Bluebird from 'bluebird'
|
||||
import validator from 'validator'
|
||||
import { pageToStartAndCount } from '@server/helpers/core-utils'
|
||||
import { ACTIVITY_PUB } from '@server/initializers/constants'
|
||||
import { ResultList } from '@shared/models'
|
||||
|
||||
type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird<ResultList<any>> | Promise<ResultList<any>>
|
||||
|
||||
async function activityPubCollectionPagination (
|
||||
baseUrl: string,
|
||||
handler: ActivityPubCollectionPaginationHandler,
|
||||
page?: any,
|
||||
size = ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE
|
||||
) {
|
||||
if (!page || !validator.isInt(page)) {
|
||||
// We just display the first page URL, we only need the total items
|
||||
const result = await handler(0, 1)
|
||||
|
||||
return {
|
||||
id: baseUrl,
|
||||
type: 'OrderedCollectionPage',
|
||||
totalItems: result.total,
|
||||
first: result.data.length === 0
|
||||
? undefined
|
||||
: baseUrl + '?page=1'
|
||||
}
|
||||
}
|
||||
|
||||
const { start, count } = pageToStartAndCount(page, size)
|
||||
const result = await handler(start, count)
|
||||
|
||||
let next: string | undefined
|
||||
let prev: string | undefined
|
||||
|
||||
// Assert page is a number
|
||||
page = parseInt(page, 10)
|
||||
|
||||
// There are more results
|
||||
if (result.total > page * size) {
|
||||
next = baseUrl + '?page=' + (page + 1)
|
||||
}
|
||||
|
||||
if (page > 1) {
|
||||
prev = baseUrl + '?page=' + (page - 1)
|
||||
}
|
||||
|
||||
return {
|
||||
id: baseUrl + '?page=' + page,
|
||||
type: 'OrderedCollectionPage',
|
||||
prev,
|
||||
next,
|
||||
partOf: baseUrl,
|
||||
orderedItems: result.data,
|
||||
totalItems: result.total
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
activityPubCollectionPagination
|
||||
}
|
|
@ -1,12 +1,4 @@
|
|||
import Bluebird from 'bluebird'
|
||||
import { URL } from 'url'
|
||||
import validator from 'validator'
|
||||
import { ContextType } from '@shared/models/activitypub/context'
|
||||
import { ResultList } from '../../shared/models'
|
||||
import { ACTIVITY_PUB, REMOTE_SCHEME } from '../initializers/constants'
|
||||
import { MActor, MVideoWithHost } from '../types/models'
|
||||
import { pageToStartAndCount } from './core-utils'
|
||||
import { signJsonLDObject } from './peertube-crypto'
|
||||
import { ContextType } from '@shared/models'
|
||||
|
||||
function getContextData (type: ContextType) {
|
||||
const context: any[] = [
|
||||
|
@ -139,91 +131,7 @@ function activityPubContextify <T> (data: T, type: ContextType = 'All') {
|
|||
return Object.assign({}, data, getContextData(type))
|
||||
}
|
||||
|
||||
type ActivityPubCollectionPaginationHandler = (start: number, count: number) => Bluebird<ResultList<any>> | Promise<ResultList<any>>
|
||||
async function activityPubCollectionPagination (
|
||||
baseUrl: string,
|
||||
handler: ActivityPubCollectionPaginationHandler,
|
||||
page?: any,
|
||||
size = ACTIVITY_PUB.COLLECTION_ITEMS_PER_PAGE
|
||||
) {
|
||||
if (!page || !validator.isInt(page)) {
|
||||
// We just display the first page URL, we only need the total items
|
||||
const result = await handler(0, 1)
|
||||
|
||||
return {
|
||||
id: baseUrl,
|
||||
type: 'OrderedCollectionPage',
|
||||
totalItems: result.total,
|
||||
first: result.data.length === 0
|
||||
? undefined
|
||||
: baseUrl + '?page=1'
|
||||
}
|
||||
}
|
||||
|
||||
const { start, count } = pageToStartAndCount(page, size)
|
||||
const result = await handler(start, count)
|
||||
|
||||
let next: string | undefined
|
||||
let prev: string | undefined
|
||||
|
||||
// Assert page is a number
|
||||
page = parseInt(page, 10)
|
||||
|
||||
// There are more results
|
||||
if (result.total > page * size) {
|
||||
next = baseUrl + '?page=' + (page + 1)
|
||||
}
|
||||
|
||||
if (page > 1) {
|
||||
prev = baseUrl + '?page=' + (page - 1)
|
||||
}
|
||||
|
||||
return {
|
||||
id: baseUrl + '?page=' + page,
|
||||
type: 'OrderedCollectionPage',
|
||||
prev,
|
||||
next,
|
||||
partOf: baseUrl,
|
||||
orderedItems: result.data,
|
||||
totalItems: result.total
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function buildSignedActivity <T> (byActor: MActor, data: T, contextType?: ContextType) {
|
||||
const activity = activityPubContextify(data, contextType)
|
||||
|
||||
return signJsonLDObject(byActor, activity)
|
||||
}
|
||||
|
||||
function getAPId (object: string | { id: string }) {
|
||||
if (typeof object === 'string') return object
|
||||
|
||||
return object.id
|
||||
}
|
||||
|
||||
function checkUrlsSameHost (url1: string, url2: string) {
|
||||
const idHost = new URL(url1).host
|
||||
const actorHost = new URL(url2).host
|
||||
|
||||
return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase()
|
||||
}
|
||||
|
||||
function buildRemoteVideoBaseUrl (video: MVideoWithHost, path: string, scheme?: string) {
|
||||
if (!scheme) scheme = REMOTE_SCHEME.HTTP
|
||||
|
||||
const host = video.VideoChannel.Actor.Server.host
|
||||
|
||||
return scheme + '://' + host + path
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
checkUrlsSameHost,
|
||||
getAPId,
|
||||
activityPubContextify,
|
||||
activityPubCollectionPagination,
|
||||
buildSignedActivity,
|
||||
buildRemoteVideoBaseUrl
|
||||
getContextData,
|
||||
activityPubContextify
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
import { map } from 'bluebird'
|
||||
import { getAPId } from '@server/helpers/activitypub'
|
||||
import { isArray } from '@server/helpers/custom-validators/misc'
|
||||
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
||||
import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants'
|
||||
|
@ -9,8 +8,9 @@ import { VideoPlaylistModel } from '@server/models/video/video-playlist'
|
|||
import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'
|
||||
import { FilteredModelAttributes } from '@server/types'
|
||||
import { MThumbnail, MVideoPlaylist, MVideoPlaylistFull, MVideoPlaylistVideosLength } from '@server/types/models'
|
||||
import { AttributesOnly } from '@shared/typescript-utils'
|
||||
import { PlaylistObject } from '@shared/models'
|
||||
import { AttributesOnly } from '@shared/typescript-utils'
|
||||
import { getAPId } from '../activity'
|
||||
import { getOrCreateAPActor } from '../actors'
|
||||
import { crawlCollectionPage } from '../crawl'
|
||||
import { getOrCreateAPVideo } from '../videos'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { getAPId } from '@server/helpers/activitypub'
|
||||
import { VideoPlaylistModel } from '@server/models/video/video-playlist'
|
||||
import { MVideoPlaylistFullSummary } from '@server/types/models'
|
||||
import { APObject } from '@shared/models'
|
||||
import { getAPId } from '../activity'
|
||||
import { createOrUpdateVideoPlaylist } from './create-update'
|
||||
import { scheduleRefreshIfNeeded } from './refresh'
|
||||
import { fetchRemoteVideoPlaylist } from './shared'
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { isArray } from 'lodash'
|
||||
import { checkUrlsSameHost } from '@server/helpers/activitypub'
|
||||
import { isPlaylistElementObjectValid, isPlaylistObjectValid } from '@server/helpers/custom-validators/activitypub/playlist'
|
||||
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
||||
import { doJSONRequest } from '@server/helpers/requests'
|
||||
import { PlaylistElementObject, PlaylistObject } from '@shared/models'
|
||||
import { checkUrlsSameHost } from '../../url'
|
||||
|
||||
async function fetchRemoteVideoPlaylist (playlistUrl: string): Promise<{ statusCode: number, playlistObject: PlaylistObject }> {
|
||||
const lTags = loggerTagsFactory('ap', 'video-playlist', playlistUrl)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
import { getAPId } from '@server/lib/activitypub/activity'
|
||||
import { ActivityAnnounce } from '../../../../shared/models/activitypub'
|
||||
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { VideoShareModel } from '../../../models/video/video-share'
|
||||
import { forwardVideoRelatedActivity } from '../send/shared/send-utils'
|
||||
import { getOrCreateAPVideo } from '../videos'
|
||||
import { Notifier } from '../../notifier'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
|
||||
import { MActorSignature, MVideoAccountLightBlacklistAllFiles } from '../../../types/models'
|
||||
import { getAPId } from '@server/helpers/activitypub'
|
||||
import { Notifier } from '../../notifier'
|
||||
import { forwardVideoRelatedActivity } from '../send/shared/send-utils'
|
||||
import { getOrCreateAPVideo } from '../videos'
|
||||
|
||||
async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) {
|
||||
const { activity, byActor: actorAnnouncer } = options
|
||||
|
|
|
@ -4,10 +4,10 @@ import { VideoModel } from '@server/models/video/video'
|
|||
import { VideoCommentModel } from '@server/models/video/video-comment'
|
||||
import { abusePredefinedReasonsMap } from '@shared/core-utils/abuse'
|
||||
import { AbuseObject, AbuseState, ActivityCreate, ActivityFlag } from '@shared/models'
|
||||
import { getAPId } from '../../../helpers/activitypub'
|
||||
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { getAPId } from '../../../lib/activitypub/activity'
|
||||
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
|
||||
import { MAccountDefault, MActorSignature, MCommentOwnerVideo } from '../../../types/models'
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
import { getServerActor } from '@server/models/application/application'
|
||||
import { ActivityFollow } from '../../../../shared/models/activitypub'
|
||||
import { getAPId } from '../../../helpers/activitypub'
|
||||
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { CONFIG } from '../../../initializers/config'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { getAPId } from '../../../lib/activitypub/activity'
|
||||
import { ActorModel } from '../../../models/actor/actor'
|
||||
import { ActorFollowModel } from '../../../models/actor/actor-follow'
|
||||
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { VideoModel } from '@server/models/video/video'
|
||||
import { ActivityLike } from '../../../../shared/models/activitypub'
|
||||
import { getAPId } from '../../../helpers/activitypub'
|
||||
import { retryTransactionWrapper } from '../../../helpers/database-utils'
|
||||
import { sequelizeTypescript } from '../../../initializers/database'
|
||||
import { getAPId } from '../../../lib/activitypub/activity'
|
||||
import { AccountVideoRateModel } from '../../../models/account/account-video-rate'
|
||||
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
|
||||
import { MActorSignature } from '../../../types/models'
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
import { StatsManager } from '@server/lib/stat-manager'
|
||||
import { Activity, ActivityType } from '../../../../shared/models/activitypub'
|
||||
import { checkUrlsSameHost, getAPId } from '../../../helpers/activitypub'
|
||||
import { logger } from '../../../helpers/logger'
|
||||
import { APProcessorOptions } from '../../../types/activitypub-processor.model'
|
||||
import { MActorDefault, MActorSignature } from '../../../types/models'
|
||||
import { getAPId } from '../activity'
|
||||
import { getOrCreateAPActor } from '../actors'
|
||||
import { checkUrlsSameHost } from '../url'
|
||||
import { processAcceptActivity } from './process-accept'
|
||||
import { processAnnounceActivity } from './process-announce'
|
||||
import { processCreateActivity } from './process-create'
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
import { map } from 'bluebird'
|
||||
import { Transaction } from 'sequelize'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { checkUrlsSameHost, getAPId } from '../../helpers/activitypub'
|
||||
import { logger, loggerTagsFactory } from '../../helpers/logger'
|
||||
import { doJSONRequest } from '../../helpers/requests'
|
||||
import { CRAWL_REQUEST_CONCURRENCY } from '../../initializers/constants'
|
||||
import { VideoShareModel } from '../../models/video/video-share'
|
||||
import { MChannelActorLight, MVideo, MVideoAccountLight, MVideoId } from '../../types/models/video'
|
||||
import { getAPId } from './activity'
|
||||
import { getOrCreateAPActor } from './actors'
|
||||
import { sendUndoAnnounce, sendVideoAnnounce } from './send'
|
||||
import { getLocalVideoAnnounceActivityPubUrl } from './url'
|
||||
import { checkUrlsSameHost, getLocalVideoAnnounceActivityPubUrl } from './url'
|
||||
|
||||
const lTags = loggerTagsFactory('share')
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { WEBSERVER } from '../../initializers/constants'
|
||||
import { REMOTE_SCHEME, WEBSERVER } from '../../initializers/constants'
|
||||
import {
|
||||
MAbuseFull,
|
||||
MAbuseId,
|
||||
|
@ -10,7 +10,8 @@ import {
|
|||
MVideoId,
|
||||
MVideoPlaylistElement,
|
||||
MVideoUrl,
|
||||
MVideoUUID
|
||||
MVideoUUID,
|
||||
MVideoWithHost
|
||||
} from '../../types/models'
|
||||
import { MVideoFileVideoUUID } from '../../types/models/video/video-file'
|
||||
import { MVideoPlaylist, MVideoPlaylistUUID } from '../../types/models/video/video-playlist'
|
||||
|
@ -121,6 +122,27 @@ function getAbuseTargetUrl (abuse: MAbuseFull) {
|
|||
abuse.FlaggedAccount.Actor.url
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function buildRemoteVideoBaseUrl (video: MVideoWithHost, path: string, scheme?: string) {
|
||||
if (!scheme) scheme = REMOTE_SCHEME.HTTP
|
||||
|
||||
const host = video.VideoChannel.Actor.Server.host
|
||||
|
||||
return scheme + '://' + host + path
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
function checkUrlsSameHost (url1: string, url2: string) {
|
||||
const idHost = new URL(url1).host
|
||||
const actorHost = new URL(url2).host
|
||||
|
||||
return idHost && actorHost && idHost.toLowerCase() === actorHost.toLowerCase()
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export {
|
||||
getLocalVideoActivityPubUrl,
|
||||
getLocalVideoPlaylistActivityPubUrl,
|
||||
|
@ -145,5 +167,8 @@ export {
|
|||
getLocalVideoCommentsActivityPubUrl,
|
||||
getLocalVideoLikesActivityPubUrl,
|
||||
getLocalVideoDislikesActivityPubUrl,
|
||||
getAbuseTargetUrl
|
||||
|
||||
getAbuseTargetUrl,
|
||||
checkUrlsSameHost,
|
||||
buildRemoteVideoBaseUrl
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { map } from 'bluebird'
|
||||
import { checkUrlsSameHost } from '../../helpers/activitypub'
|
||||
import { sanitizeAndCheckVideoCommentObject } from '../../helpers/custom-validators/activitypub/video-comments'
|
||||
import { logger } from '../../helpers/logger'
|
||||
import { doJSONRequest } from '../../helpers/requests'
|
||||
|
@ -7,6 +6,7 @@ import { ACTIVITY_PUB, CRAWL_REQUEST_CONCURRENCY } from '../../initializers/cons
|
|||
import { VideoCommentModel } from '../../models/video/video-comment'
|
||||
import { MCommentOwner, MCommentOwnerVideo, MVideoAccountLightBlacklistAllFiles } from '../../types/models/video'
|
||||
import { getOrCreateAPActor } from './actors'
|
||||
import { checkUrlsSameHost } from './url'
|
||||
import { getOrCreateAPVideo } from './videos'
|
||||
|
||||
type ResolveThreadParams = {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { getAPId } from '@server/helpers/activitypub'
|
||||
import { retryTransactionWrapper } from '@server/helpers/database-utils'
|
||||
import { JobQueue } from '@server/lib/job-queue'
|
||||
import { loadVideoByUrl, VideoLoadByUrlType } from '@server/lib/model-loaders'
|
||||
import { MVideoAccountLightBlacklistAllFiles, MVideoImmutable, MVideoThumbnail } from '@server/types/models'
|
||||
import { APObject } from '@shared/models'
|
||||
import { getAPId } from '../activity'
|
||||
import { refreshVideoIfNeeded } from './refresh'
|
||||
import { APVideoCreator, fetchRemoteVideo, SyncParam, syncVideoExternalAttributes } from './shared'
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { Transaction } from 'sequelize/types'
|
||||
import { checkUrlsSameHost } from '@server/helpers/activitypub'
|
||||
import { deleteAllModels, filterNonExistingModels } from '@server/helpers/database-utils'
|
||||
import { logger, LoggerTagsFn } from '@server/helpers/logger'
|
||||
import { updatePlaceholderThumbnail, updateVideoMiniatureFromUrl } from '@server/lib/thumbnail'
|
||||
|
@ -11,6 +10,7 @@ import { VideoStreamingPlaylistModel } from '@server/models/video/video-streamin
|
|||
import { MStreamingPlaylistFilesVideo, MThumbnail, MVideoCaption, MVideoFile, MVideoFullLight, MVideoThumbnail } from '@server/types/models'
|
||||
import { ActivityTagObject, ThumbnailType, VideoObject, VideoStreamingPlaylistType } from '@shared/models'
|
||||
import { getOrCreateAPActor } from '../../actors'
|
||||
import { checkUrlsSameHost } from '../../url'
|
||||
import {
|
||||
getCaptionAttributesFromObject,
|
||||
getFileAttributesFromUrl,
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { Transaction } from 'sequelize/types'
|
||||
import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub'
|
||||
import { isAPVideoTrackerUrlObject } from '@server/helpers/custom-validators/activitypub/videos'
|
||||
import { isArray } from '@server/helpers/custom-validators/misc'
|
||||
import { REMOTE_SCHEME } from '@server/initializers/constants'
|
||||
import { TrackerModel } from '@server/models/server/tracker'
|
||||
import { MVideo, MVideoWithHost } from '@server/types/models'
|
||||
import { ActivityTrackerUrlObject, VideoObject } from '@shared/models'
|
||||
import { buildRemoteVideoBaseUrl } from '../../url'
|
||||
|
||||
function getTrackerUrls (object: VideoObject, video: MVideoWithHost) {
|
||||
let wsFound = false
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { checkUrlsSameHost } from '@server/helpers/activitypub'
|
||||
import { sanitizeAndCheckVideoTorrentObject } from '@server/helpers/custom-validators/activitypub/videos'
|
||||
import { logger, loggerTagsFactory } from '@server/helpers/logger'
|
||||
import { doJSONRequest } from '@server/helpers/requests'
|
||||
import { VideoObject } from '@shared/models'
|
||||
import { checkUrlsSameHost } from '../../url'
|
||||
|
||||
const lTags = loggerTagsFactory('ap', 'video')
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { map } from 'bluebird'
|
||||
import { Job } from 'bull'
|
||||
import { checkUrlsSameHost } from '@server/helpers/activitypub'
|
||||
import {
|
||||
isAnnounceActivityValid,
|
||||
isDislikeActivityValid,
|
||||
|
@ -9,6 +8,7 @@ import {
|
|||
import { sanitizeAndCheckVideoCommentObject } from '@server/helpers/custom-validators/activitypub/video-comments'
|
||||
import { doJSONRequest, PeerTubeRequestError } from '@server/helpers/requests'
|
||||
import { AP_CLEANER } from '@server/initializers/constants'
|
||||
import { checkUrlsSameHost } from '@server/lib/activitypub/url'
|
||||
import { Redis } from '@server/lib/redis'
|
||||
import { VideoModel } from '@server/models/video/video'
|
||||
import { VideoCommentModel } from '@server/models/video/video-comment'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { buildDigest } from '@server/helpers/peertube-crypto'
|
||||
import { buildSignedActivity } from '@server/lib/activitypub/activity'
|
||||
import { getServerActor } from '@server/models/application/application'
|
||||
import { ContextType } from '@shared/models/activitypub/context'
|
||||
import { buildSignedActivity } from '../../../../helpers/activitypub'
|
||||
import { ACTIVITY_PUB, HTTP_SIGNATURE } from '../../../../initializers/constants'
|
||||
import { ActorModel } from '../../../../models/actor/actor'
|
||||
import { MActor } from '../../../../types/models'
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { NextFunction, Request, Response } from 'express'
|
||||
import { getAPId } from '@server/helpers/activitypub'
|
||||
import { isActorDeleteActivityValid } from '@server/helpers/custom-validators/activitypub/actor'
|
||||
import { getAPId } from '@server/lib/activitypub/activity'
|
||||
import { ActivityDelete, ActivityPubSignature, HttpStatusCode } from '@shared/models'
|
||||
import { logger } from '../helpers/logger'
|
||||
import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../helpers/peertube-crypto'
|
||||
|
|
|
@ -16,12 +16,12 @@ import {
|
|||
Table,
|
||||
UpdatedAt
|
||||
} from 'sequelize-typescript'
|
||||
import { activityPubContextify } from '@server/lib/activitypub/context'
|
||||
import { getBiggestActorImage } from '@server/lib/actor-image'
|
||||
import { ModelCache } from '@server/models/model-cache'
|
||||
import { getLowercaseExtension } from '@shared/core-utils'
|
||||
import { ActivityIconObject, ActivityPubActorType, ActorImageType } from '@shared/models'
|
||||
import { AttributesOnly } from '@shared/typescript-utils'
|
||||
import { activityPubContextify } from '../../helpers/activitypub'
|
||||
import {
|
||||
isActorFollowersCountValid,
|
||||
isActorFollowingCountValid,
|
||||
|
|
|
@ -19,9 +19,9 @@ import {
|
|||
UpdatedAt
|
||||
} from 'sequelize-typescript'
|
||||
import validator from 'validator'
|
||||
import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub'
|
||||
import { logger } from '@server/helpers/logger'
|
||||
import { extractVideo } from '@server/helpers/video'
|
||||
import { buildRemoteVideoBaseUrl } from '@server/lib/activitypub/url'
|
||||
import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from '@server/lib/object-storage'
|
||||
import { getFSTorrentFilePath } from '@server/lib/paths'
|
||||
import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models'
|
||||
|
|
|
@ -17,6 +17,7 @@ import {
|
|||
Table,
|
||||
UpdatedAt
|
||||
} from 'sequelize-typescript'
|
||||
import { activityPubCollectionPagination } from '@server/lib/activitypub/collection'
|
||||
import { MAccountId, MChannelId } from '@server/types/models'
|
||||
import { buildPlaylistEmbedPath, buildPlaylistWatchPath, pick } from '@shared/core-utils'
|
||||
import { buildUUID, uuidToShort } from '@shared/extra-utils'
|
||||
|
@ -26,7 +27,6 @@ import { PlaylistObject } from '../../../shared/models/activitypub/objects/playl
|
|||
import { VideoPlaylistPrivacy } from '../../../shared/models/videos/playlist/video-playlist-privacy.model'
|
||||
import { VideoPlaylistType } from '../../../shared/models/videos/playlist/video-playlist-type.model'
|
||||
import { VideoPlaylist } from '../../../shared/models/videos/playlist/video-playlist.model'
|
||||
import { activityPubCollectionPagination } from '../../helpers/activitypub'
|
||||
import { isActivityPubUrlValid } from '../../helpers/custom-validators/activitypub/misc'
|
||||
import {
|
||||
isVideoPlaylistDescriptionValid,
|
||||
|
|
|
@ -5,8 +5,8 @@ import { expect } from 'chai'
|
|||
import { cloneDeep } from 'lodash'
|
||||
import { buildRequestStub } from '@server/tests/shared'
|
||||
import { buildAbsoluteFixturePath } from '@shared/core-utils'
|
||||
import { buildSignedActivity } from '../../../helpers/activitypub'
|
||||
import { isHTTPSignatureVerified, isJsonLDSignatureVerified, parseHTTPSignature } from '../../../helpers/peertube-crypto'
|
||||
import { buildSignedActivity } from '../../../lib/activitypub/activity'
|
||||
|
||||
describe('Test activity pub helpers', function () {
|
||||
describe('When checking the Linked Signature', function () {
|
||||
|
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
import 'mocha'
|
||||
import * as chai from 'chai'
|
||||
import { activityPubContextify, buildSignedActivity } from '@server/helpers/activitypub'
|
||||
import { buildDigest } from '@server/helpers/peertube-crypto'
|
||||
import { HTTP_SIGNATURE } from '@server/initializers/constants'
|
||||
import { buildSignedActivity } from '@server/lib/activitypub/activity'
|
||||
import { activityPubContextify } from '@server/lib/activitypub/context'
|
||||
import { buildGlobalHeaders } from '@server/lib/job-queue/handlers/utils/activitypub-http-utils'
|
||||
import { makeFollowRequest, makePOSTAPRequest } from '@server/tests/shared'
|
||||
import { buildAbsoluteFixturePath, wait } from '@shared/core-utils'
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { activityPubContextify } from '@server/helpers/activitypub'
|
||||
import { buildDigest } from '@server/helpers/peertube-crypto'
|
||||
import { doRequest } from '@server/helpers/requests'
|
||||
import { ACTIVITY_PUB, HTTP_SIGNATURE } from '@server/initializers/constants'
|
||||
import { activityPubContextify } from '@server/lib/activitypub/context'
|
||||
|
||||
export function makePOSTAPRequest (url: string, body: any, httpSignature: any, headers: any) {
|
||||
const options = {
|
||||
|
|
Loading…
Reference in a new issue