} 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) {
const recurseIfNeeded = false
ownerActor = await getOrCreateActorAndServerAndModel(accountAttributedTo.id, 'all', recurseIfNeeded)
} catch (err) {
- logger.error('Cannot get or create account attributed to video channel ' + actor.url)
+ logger.error('Cannot get or create account attributed to video channel ' + actorUrl)
throw new Error(err)
}
}
return actor
}
+async function deleteActorAvatarInstance (actor: MActorDefault, t: Transaction) {
+ try {
+ await actor.Avatar.destroy({ transaction: t })
+ } catch (err) {
+ logger.error('Cannot remove old avatar of actor %s.', actor.url, { err })
+ }
+
+ actor.avatarId = null
+ actor.Avatar = null
+
+ return actor
+}
+
async function fetchActorTotalItems (url: string) {
const options = {
uri: url,
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()
fetchActorTotalItems,
getAvatarInfoIfExists,
updateActorInstance,
+ deleteActorAvatarInstance,
refreshActorIfNeeded,
updateActorAvatarInstance,
addFetchOutboxJob