]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/lib/activitypub/actor.ts
emails: remove hardcoded PeerTube names
[github/Chocobozzz/PeerTube.git] / server / lib / activitypub / actor.ts
index 63975021c920fc53cf02db83cde4dbce2cb0308b..52547536cfe7db29e4f2450bb3234b55ddce87d4 100644 (file)
@@ -36,6 +36,7 @@ import {
 } from '../../types/models'
 import { extname } from 'path'
 import { getServerActor } from '@server/models/application/application'
+import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
 
 // Set account keys, this could be long so process after the account creation and do not block the client
 function setAsyncActorKeys <T extends MActor> (actor: T) {
@@ -277,7 +278,7 @@ async function refreshActorIfNeeded <T extends MActorFull | MActorAccountChannel
 
     const { result, statusCode } = await fetchRemoteActor(actorUrl)
 
-    if (statusCode === 404) {
+    if (statusCode === HttpStatusCode.NOT_FOUND_404) {
       logger.info('Deleting actor %s because there is a 404 in refresh actor.', actor.url)
       actor.Account
         ? await actor.Account.destroy()
@@ -403,7 +404,7 @@ function saveActorAndServerAndModelIfNotExist (
     // Try to fix non HTTPS accounts of remote instances that fixed their URL afterwards
     if (created !== true && actorCreated.url !== actor.url) {
       // Only fix http://example.com/account/djidane to https://example.com/account/djidane
-      if (actorCreated.url.replace('http://', '') !== actor.url.replace('https://', '')) {
+      if (actorCreated.url.replace(/^http:\/\//, '') !== actor.url.replace(/^https:\/\//, '')) {
         throw new Error(`Actor from DB with URL ${actorCreated.url} does not correspond to actor ${actor.url}`)
       }