<noscript>
<p>You are blocking Javascript, and we totally get that. However this endpoint uses Angular, so the front end is in full JavaScript and won't work without it.
- </br></br>
+
+ <br /><br />
There will be other non JS-based clients to access PeerTube, but for now none is available. Be sure we will update this page with a list once alternative clients are developed. You can certainly develop you own in the meantime as our code is open source and libre software under GNU AGPLv3.0.
- </br></br>
+
+ <br /><br />
There might be numerous reasons you refuse to use JavaScript. If it has just to do with security (or lack thereof) of JavaScript-based webapps, then depending on your threat menace you might want to go through the code running on the node you are trying to access, and look for security audits.
</p>
</noscript>
import { ActorModel } from '../../../models/activitypub/actor'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
import { addFetchOutboxJob } from '../actor'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processAcceptActivity (activity: ActivityAccept, targetActor: ActorModel, inboxActor?: ActorModel) {
+async function processAcceptActivity (options: APProcessorOptions<ActivityAccept>) {
+ const { byActor: targetActor, inboxActor } = options
if (inboxActor === undefined) throw new Error('Need to accept on explicit inbox.')
return processAccept(inboxActor, targetActor)
import { Notifier } from '../../notifier'
import { VideoModel } from '../../../models/video/video'
import { logger } from '../../../helpers/logger'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processAnnounceActivity (activity: ActivityAnnounce, actorAnnouncer: ActorModel) {
- return retryTransactionWrapper(processVideoShare, actorAnnouncer, activity)
+async function processAnnounceActivity (options: APProcessorOptions<ActivityAnnounce>) {
+ const { activity, byActor: actorAnnouncer } = options
+ // Only notify if it is not from a fetcher job
+ const notify = options.fromFetch !== true
+
+ return retryTransactionWrapper(processVideoShare, actorAnnouncer, activity, notify)
}
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
-async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce) {
+async function processVideoShare (actorAnnouncer: ActorModel, activity: ActivityAnnounce, notify: boolean) {
const objectUri = typeof activity.object === 'string' ? activity.object : activity.object.id
let video: VideoModel
return undefined
})
- if (videoCreated) Notifier.Instance.notifyOnNewVideoIfNeeded(video)
+ if (videoCreated && notify) Notifier.Instance.notifyOnNewVideoIfNeeded(video)
}
import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
import { createOrUpdateVideoPlaylist } from '../playlist'
import { VideoModel } from '../../../models/video/video'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processCreateActivity (activity: ActivityCreate, byActor: ActorModel) {
+async function processCreateActivity (options: APProcessorOptions<ActivityCreate>) {
+ const { activity, byActor } = options
+
+ // Only notify if it is not from a fetcher job
+ const notify = options.fromFetch !== true
const activityObject = activity.object
const activityType = activityObject.type
if (activityType === 'Video') {
- return processCreateVideo(activity)
+ return processCreateVideo(activity, notify)
}
if (activityType === 'Note') {
- return retryTransactionWrapper(processCreateVideoComment, activity, byActor)
+ return retryTransactionWrapper(processCreateVideoComment, activity, byActor, notify)
}
if (activityType === 'CacheFile') {
// ---------------------------------------------------------------------------
-async function processCreateVideo (activity: ActivityCreate) {
+async function processCreateVideo (activity: ActivityCreate, notify: boolean) {
const videoToCreateData = activity.object as VideoTorrentObject
const { video, created } = await getOrCreateVideoAndAccountAndChannel({ videoObject: videoToCreateData })
- if (created) Notifier.Instance.notifyOnNewVideoIfNeeded(video)
+ if (created && notify) Notifier.Instance.notifyOnNewVideoIfNeeded(video)
return video
}
}
}
-async function processCreateVideoComment (activity: ActivityCreate, byActor: ActorModel) {
+async function processCreateVideoComment (activity: ActivityCreate, byActor: ActorModel, notify: boolean) {
const commentObject = activity.object as VideoCommentObject
const byAccount = byActor.Account
await forwardVideoRelatedActivity(activity, undefined, exceptions, video)
}
- if (created === true) Notifier.Instance.notifyOnNewComment(comment)
+ if (created && notify) Notifier.Instance.notifyOnNewComment(comment)
}
async function processCreatePlaylist (activity: ActivityCreate, byActor: ActorModel) {
import { VideoCommentModel } from '../../../models/video/video-comment'
import { forwardVideoRelatedActivity } from '../send/utils'
import { VideoPlaylistModel } from '../../../models/video/video-playlist'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
+
+async function processDeleteActivity (options: APProcessorOptions<ActivityDelete>) {
+ const { activity, byActor } = options
-async function processDeleteActivity (activity: ActivityDelete, byActor: ActorModel) {
const objectUrl = typeof activity.object === 'string' ? activity.object : activity.object.id
if (activity.actor === objectUrl) {
import { getOrCreateVideoAndAccountAndChannel } from '../videos'
import { forwardVideoRelatedActivity } from '../send/utils'
import { getVideoDislikeActivityPubUrl } from '../url'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processDislikeActivity (activity: ActivityCreate | ActivityDislike, byActor: ActorModel) {
+async function processDislikeActivity (options: APProcessorOptions<ActivityCreate | ActivityDislike>) {
+ const { activity, byActor } = options
return retryTransactionWrapper(processDislike, activity, byActor)
}
import { getOrCreateVideoAndAccountAndChannel } from '../videos'
import { Notifier } from '../../notifier'
import { getAPId } from '../../../helpers/activitypub'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processFlagActivity (activity: ActivityCreate | ActivityFlag, byActor: ActorModel) {
+async function processFlagActivity (options: APProcessorOptions<ActivityCreate | ActivityFlag>) {
+ const { activity, byActor } = options
return retryTransactionWrapper(processCreateVideoAbuse, activity, byActor)
}
import { getAPId } from '../../../helpers/activitypub'
import { getServerActor } from '../../../helpers/utils'
import { CONFIG } from '../../../initializers/config'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processFollowActivity (activity: ActivityFollow, byActor: ActorModel) {
+async function processFollowActivity (options: APProcessorOptions<ActivityFollow>) {
+ const { activity, byActor } = options
const activityObject = getAPId(activity.object)
return retryTransactionWrapper(processFollow, byActor, activityObject)
import { getOrCreateVideoAndAccountAndChannel } from '../videos'
import { getVideoLikeActivityPubUrl } from '../url'
import { getAPId } from '../../../helpers/activitypub'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processLikeActivity (activity: ActivityLike, byActor: ActorModel) {
+async function processLikeActivity (options: APProcessorOptions<ActivityLike>) {
+ const { activity, byActor } = options
return retryTransactionWrapper(processLikeVideo, byActor, activity)
}
import { sequelizeTypescript } from '../../../initializers'
import { ActorModel } from '../../../models/activitypub/actor'
import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processRejectActivity (activity: ActivityReject, targetActor: ActorModel, inboxActor?: ActorModel) {
+async function processRejectActivity (options: APProcessorOptions<ActivityReject>) {
+ const { byActor: targetActor, inboxActor } = options
if (inboxActor === undefined) throw new Error('Need to reject on explicit inbox.')
return processReject(inboxActor, targetActor)
import { getOrCreateVideoAndAccountAndChannel } from '../videos'
import { VideoShareModel } from '../../../models/video/video-share'
import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processUndoActivity (activity: ActivityUndo, byActor: ActorModel) {
+async function processUndoActivity (options: APProcessorOptions<ActivityUndo>) {
+ const { activity, byActor } = options
const activityToUndo = activity.object
if (activityToUndo.type === 'Like') {
import { forwardVideoRelatedActivity } from '../send/utils'
import { PlaylistObject } from '../../../../shared/models/activitypub/objects/playlist-object'
import { createOrUpdateVideoPlaylist } from '../playlist'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
+
+async function processUpdateActivity (options: APProcessorOptions<ActivityUpdate>) {
+ const { activity, byActor } = options
-async function processUpdateActivity (activity: ActivityUpdate, byActor: ActorModel) {
const objectType = activity.object.type
if (objectType === 'Video') {
import { forwardVideoRelatedActivity } from '../send/utils'
import { Redis } from '../../redis'
import { ActivityCreate, ActivityView, ViewObject } from '../../../../shared/models/activitypub'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-async function processViewActivity (activity: ActivityView | ActivityCreate, byActor: ActorModel) {
+async function processViewActivity (options: APProcessorOptions<ActivityCreate | ActivityView>) {
+ const { activity, byActor } = options
return processCreateView(activity, byActor)
}
import { processDislikeActivity } from './process-dislike'
import { processFlagActivity } from './process-flag'
import { processViewActivity } from './process-view'
+import { APProcessorOptions } from '../../../typings/activitypub-processor.model'
-const processActivity: { [ P in ActivityType ]: (activity: Activity, byActor: ActorModel, inboxActor?: ActorModel) => Promise<any> } = {
+const processActivity: { [ P in ActivityType ]: (options: APProcessorOptions<Activity>) => Promise<any> } = {
Create: processCreateActivity,
Update: processUpdateActivity,
Delete: processDeleteActivity,
signatureActor?: ActorModel
inboxActor?: ActorModel
outboxUrl?: string
- } = {}) {
+ fromFetch?: boolean
+ } = {}
+) {
+ const { outboxUrl, signatureActor, inboxActor, fromFetch = false } = options
+
const actorsCache: { [ url: string ]: ActorModel } = {}
for (const activity of activities) {
- if (!options.signatureActor && [ 'Create', 'Announce', 'Like' ].includes(activity.type) === false) {
+ if (!signatureActor && [ 'Create', 'Announce', 'Like' ].includes(activity.type) === false) {
logger.error('Cannot process activity %s (type: %s) without the actor signature.', activity.id, activity.type)
continue
}
const actorUrl = getAPId(activity.actor)
// When we fetch remote data, we don't have signature
- if (options.signatureActor && actorUrl !== options.signatureActor.url) {
- logger.warn('Signature mismatch between %s and %s, skipping.', actorUrl, options.signatureActor.url)
+ if (signatureActor && actorUrl !== signatureActor.url) {
+ logger.warn('Signature mismatch between %s and %s, skipping.', actorUrl, signatureActor.url)
continue
}
- if (options.outboxUrl && checkUrlsSameHost(options.outboxUrl, actorUrl) !== true) {
- logger.warn('Host mismatch between outbox URL %s and actor URL %s, skipping.', options.outboxUrl, actorUrl)
+ if (outboxUrl && checkUrlsSameHost(outboxUrl, actorUrl) !== true) {
+ logger.warn('Host mismatch between outbox URL %s and actor URL %s, skipping.', outboxUrl, actorUrl)
continue
}
- const byActor = options.signatureActor || actorsCache[actorUrl] || await getOrCreateActorAndServerAndModel(actorUrl)
+ const byActor = signatureActor || actorsCache[actorUrl] || await getOrCreateActorAndServerAndModel(actorUrl)
actorsCache[actorUrl] = byActor
const activityProcessor = processActivity[activity.type]
}
try {
- await activityProcessor(activity, byActor, options.inboxActor)
+ await activityProcessor({ activity, byActor, inboxActor: inboxActor, fromFetch })
} catch (err) {
logger.warn('Cannot process activity %s.', activity.type, { err })
}
if (payload.accountId) account = await AccountModel.load(payload.accountId)
const fetcherType: { [ id in FetchType ]: (items: any[]) => Promise<any> } = {
- 'activity': items => processActivities(items, { outboxUrl: payload.uri }),
+ 'activity': items => processActivities(items, { outboxUrl: payload.uri, fromFetch: true }),
'video-likes': items => createRates(items, video, 'like'),
'video-dislikes': items => createRates(items, video, 'dislike'),
'video-shares': items => addVideoShares(items, video),
private async regeneratePluginGlobalCSS () {
await this.resetCSSGlobalFile()
- for (const key of Object.keys(this.getRegisteredPlugins())) {
- const plugin = this.registeredPlugins[key]
-
+ for (const plugin of this.getRegisteredPlugins()) {
await this.addCSSToGlobalFile(plugin.path, plugin.css)
}
}
--- /dev/null
+import { Activity } from '../../shared/models/activitypub'
+import { ActorModel } from '../models/activitypub/actor'
+
+export type APProcessorOptions<T extends Activity> = {
+ activity: T
+ byActor: ActorModel
+ inboxActor?: ActorModel
+ fromFetch?: boolean
+}