mirror of
https://github.com/Chocobozzz/PeerTube.git
synced 2025-10-05 19:42:24 +02:00
Fix remote actor creation date
This commit is contained in:
parent
64df4b65ae
commit
a66c2e3252
10 changed files with 80 additions and 42 deletions
|
@ -1,6 +1,6 @@
|
|||
import validator from 'validator'
|
||||
import { CONSTRAINTS_FIELDS } from '../../../initializers/constants'
|
||||
import { exists, isArray } from '../misc'
|
||||
import { exists, isArray, isDateValid } from '../misc'
|
||||
import { isActivityPubUrlValid, isBaseActivityValid, setValidAttributedTo } from './misc'
|
||||
import { isHostValid } from '../servers'
|
||||
import { peertubeTruncate } from '@server/helpers/core-utils'
|
||||
|
@ -47,7 +47,21 @@ function isActorPrivateKeyValid (privateKey: string) {
|
|||
validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY)
|
||||
}
|
||||
|
||||
function isActorObjectValid (actor: any) {
|
||||
function isActorFollowingCountValid (value: string) {
|
||||
return exists(value) && validator.isInt('' + value, { min: 0 })
|
||||
}
|
||||
|
||||
function isActorFollowersCountValid (value: string) {
|
||||
return exists(value) && validator.isInt('' + value, { min: 0 })
|
||||
}
|
||||
|
||||
function isActorDeleteActivityValid (activity: any) {
|
||||
return isBaseActivityValid(activity, 'Delete')
|
||||
}
|
||||
|
||||
function sanitizeAndCheckActorObject (actor: any) {
|
||||
normalizeActor(actor)
|
||||
|
||||
return exists(actor) &&
|
||||
isActivityPubUrlValid(actor.id) &&
|
||||
isActorTypeValid(actor.type) &&
|
||||
|
@ -68,24 +82,6 @@ function isActorObjectValid (actor: any) {
|
|||
(actor.type !== 'Group' || actor.attributedTo.length !== 0)
|
||||
}
|
||||
|
||||
function isActorFollowingCountValid (value: string) {
|
||||
return exists(value) && validator.isInt('' + value, { min: 0 })
|
||||
}
|
||||
|
||||
function isActorFollowersCountValid (value: string) {
|
||||
return exists(value) && validator.isInt('' + value, { min: 0 })
|
||||
}
|
||||
|
||||
function isActorDeleteActivityValid (activity: any) {
|
||||
return isBaseActivityValid(activity, 'Delete')
|
||||
}
|
||||
|
||||
function sanitizeAndCheckActorObject (object: any) {
|
||||
normalizeActor(object)
|
||||
|
||||
return isActorObjectValid(object)
|
||||
}
|
||||
|
||||
function normalizeActor (actor: any) {
|
||||
if (!actor) return
|
||||
|
||||
|
@ -95,6 +91,8 @@ function normalizeActor (actor: any) {
|
|||
actor.url = actor.url.href || actor.url.url
|
||||
}
|
||||
|
||||
if (!isDateValid(actor.published)) actor.published = undefined
|
||||
|
||||
if (actor.summary && typeof actor.summary === 'string') {
|
||||
actor.summary = peertubeTruncate(actor.summary, { length: CONSTRAINTS_FIELDS.USERS.DESCRIPTION.max })
|
||||
|
||||
|
@ -135,7 +133,6 @@ export {
|
|||
isActorPublicKeyValid,
|
||||
isActorPreferredUsernameValid,
|
||||
isActorPrivateKeyValid,
|
||||
isActorObjectValid,
|
||||
isActorFollowingCountValid,
|
||||
isActorFollowersCountValid,
|
||||
isActorDeleteActivityValid,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue