import { MIMETYPES } from '../../../initializers/constants'
import { sequelizeTypescript } from '../../../initializers/database'
import { sendUpdateActor } from '../../../lib/activitypub/send'
-import { deleteActorAvatarFile, updateActorAvatarFile } from '../../../lib/avatar'
+import { deleteLocalActorAvatarFile, updateLocalActorAvatarFile } from '../../../lib/avatar'
import { getOriginalVideoFileTotalDailyFromUser, getOriginalVideoFileTotalFromUser, sendVerifyUserEmail } from '../../../lib/user'
import {
asyncMiddleware,
const userAccount = await AccountModel.load(user.Account.id)
- const avatar = await updateActorAvatarFile(userAccount, avatarPhysicalFile)
+ const avatar = await updateLocalActorAvatarFile(userAccount, avatarPhysicalFile)
return res.json({ avatar: avatar.toFormattedJSON() })
}
const user = res.locals.oauth.token.user
const userAccount = await AccountModel.load(user.Account.id)
- await deleteActorAvatarFile(userAccount)
+ await deleteLocalActorAvatarFile(userAccount)
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
}
import { sequelizeTypescript } from '../../initializers/database'
import { setAsyncActorKeys } from '../../lib/activitypub/actor'
import { sendUpdateActor } from '../../lib/activitypub/send'
-import { deleteActorAvatarFile, updateActorAvatarFile } from '../../lib/avatar'
+import { deleteLocalActorAvatarFile, updateLocalActorAvatarFile } from '../../lib/avatar'
import { JobQueue } from '../../lib/job-queue'
import { createLocalVideoChannel, federateAllVideosOfChannel } from '../../lib/video-channel'
import {
const videoChannel = res.locals.videoChannel
const oldVideoChannelAuditKeys = new VideoChannelAuditView(videoChannel.toFormattedJSON())
- const avatar = await updateActorAvatarFile(videoChannel, avatarPhysicalFile)
+ const avatar = await updateLocalActorAvatarFile(videoChannel, avatarPhysicalFile)
auditLogger.update(getAuditIdFromRes(res), new VideoChannelAuditView(videoChannel.toFormattedJSON()), oldVideoChannelAuditKeys)
async function deleteVideoChannelAvatar (req: express.Request, res: express.Response) {
const videoChannel = res.locals.videoChannel
- await deleteActorAvatarFile(videoChannel)
+ await deleteLocalActorAvatarFile(videoChannel)
return res.sendStatus(HttpStatusCode.NO_CONTENT_204)
}
DESCRIPTION: { min: 3, max: 10000 }, // Length
SUPPORT: { min: 3, max: 1000 }, // Length
IMAGE: {
- EXTNAME: [ '.jpg', '.jpeg' ],
+ EXTNAME: [ '.png', '.jpg', '.jpeg', '.webp' ],
FILE_SIZE: {
max: 2 * 1024 * 1024 // 2MB
}
PRIVATE_KEY: { min: 10, max: 5000 }, // Length
URL: { min: 3, max: 2000 }, // Length
AVATAR: {
- EXTNAME: [ '.png', '.jpeg', '.jpg', '.gif' ],
+ EXTNAME: [ '.png', '.jpeg', '.jpg', '.gif', '.webp' ],
FILE_SIZE: {
max: 2 * 1024 * 1024 // 2MB
}
import { downloadImage } from '../helpers/requests'
import { MAccountDefault, MChannelDefault } from '../types/models'
-async function updateActorAvatarFile (
+async function updateLocalActorAvatarFile (
accountOrChannel: MAccountDefault | MChannelDefault,
avatarPhysicalFile: Express.Multer.File
) {
const extension = extname(avatarPhysicalFile.filename)
+
const avatarName = uuidv4() + extension
const destination = join(CONFIG.STORAGE.AVATARS_DIR, avatarName)
await processImage(avatarPhysicalFile.path, destination, AVATARS_SIZE)
})
}
-async function deleteActorAvatarFile (
+async function deleteLocalActorAvatarFile (
accountOrChannel: MAccountDefault | MChannelDefault
) {
return retryTransactionWrapper(() => {
export {
avatarPathUnsafeCache,
- updateActorAvatarFile,
- deleteActorAvatarFile,
+ updateLocalActorAvatarFile,
+ deleteLocalActorAvatarFile,
pushAvatarProcessInQueue
}