]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/custom-validators/activitypub/actor.ts
Merge branch 'release/3.1.0' into develop
[github/Chocobozzz/PeerTube.git] / server / helpers / custom-validators / activitypub / actor.ts
index fec67823d721b273c9d814f4e4a8d87d293bcac1..87734515750ba812b9d8dcab552ef0d95f60d4d4 100644 (file)
@@ -28,7 +28,7 @@ function isActorPublicKeyValid (publicKey: string) {
   return exists(publicKey) &&
     typeof publicKey === 'string' &&
     publicKey.startsWith('-----BEGIN PUBLIC KEY-----') &&
-    publicKey.indexOf('-----END PUBLIC KEY-----') !== -1 &&
+    publicKey.includes('-----END PUBLIC KEY-----') &&
     validator.isLength(publicKey, CONSTRAINTS_FIELDS.ACTORS.PUBLIC_KEY)
 }
 
@@ -43,7 +43,7 @@ function isActorPrivateKeyValid (privateKey: string) {
     typeof privateKey === 'string' &&
     privateKey.startsWith('-----BEGIN RSA PRIVATE KEY-----') &&
     // Sometimes there is a \n at the end, so just assert the string contains the end mark
-    privateKey.indexOf('-----END RSA PRIVATE KEY-----') !== -1 &&
+    privateKey.includes('-----END RSA PRIVATE KEY-----') &&
     validator.isLength(privateKey, CONSTRAINTS_FIELDS.ACTORS.PRIVATE_KEY)
 }
 
@@ -62,6 +62,7 @@ function isActorObjectValid (actor: any) {
     (!actor.followers || isActivityPubUrlValid(actor.followers)) &&
 
     setValidAttributedTo(actor) &&
+    setValidDescription(actor) &&
     // If this is a group (a channel), it should be attributed to an account
     // In PeerTube we use this to attach a video channel to a specific account
     (actor.type !== 'Group' || actor.attributedTo.length !== 0)
@@ -116,6 +117,12 @@ function areValidActorHandles (handles: string[]) {
   return isArray(handles) && handles.every(h => isValidActorHandle(h))
 }
 
+function setValidDescription (obj: any) {
+  if (!obj.summary) obj.summary = null
+
+  return true
+}
+
 // ---------------------------------------------------------------------------
 
 export {