mirror of
https://git.joinsharkey.org/Sharkey/Sharkey.git
synced 2024-11-23 09:33:09 +02:00
upd: remove debug lines, fix header not being detected
This commit is contained in:
parent
d942d4d0d0
commit
c88fbe843a
1 changed files with 5 additions and 4 deletions
|
@ -258,27 +258,27 @@ export class MastodonApiServerService {
|
||||||
try {
|
try {
|
||||||
if (_request.files.length > 0 && accessTokens) {
|
if (_request.files.length > 0 && accessTokens) {
|
||||||
const tokeninfo = await this.accessTokensRepository.findOneBy({ token: accessTokens.replace('Bearer ', '') });
|
const tokeninfo = await this.accessTokensRepository.findOneBy({ token: accessTokens.replace('Bearer ', '') });
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const avatar = (_request.files as any).find((obj: any) => {
|
const avatar = (_request.files as any).find((obj: any) => {
|
||||||
return obj.fieldname === 'avatar';
|
return obj.fieldname === 'avatar';
|
||||||
});
|
});
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const header = (_request.files as any).find((obj: any) => {
|
const header = (_request.files as any).find((obj: any) => {
|
||||||
return obj.fieldname === 'header';
|
return obj.fieldname === 'header';
|
||||||
});
|
});
|
||||||
|
|
||||||
if (tokeninfo && avatar) {
|
if (tokeninfo && avatar) {
|
||||||
console.error('avatar');
|
|
||||||
const upload = await this.driveService.addFile({
|
const upload = await this.driveService.addFile({
|
||||||
user: { id: tokeninfo.userId, host: null },
|
user: { id: tokeninfo.userId, host: null },
|
||||||
path: avatar.path,
|
path: avatar.path,
|
||||||
name: avatar.originalname !== null && avatar.originalname !== 'file' ? avatar.originalname : undefined,
|
name: avatar.originalname !== null && avatar.originalname !== 'file' ? avatar.originalname : undefined,
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
});
|
});
|
||||||
console.error(upload);
|
|
||||||
if (upload.type.startsWith('image/')) {
|
if (upload.type.startsWith('image/')) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(_request.body as any).avatar = upload.id;
|
(_request.body as any).avatar = upload.id;
|
||||||
}
|
}
|
||||||
}
|
} else if (tokeninfo && header) {
|
||||||
if (tokeninfo && (_request.files as any)['header']) {
|
|
||||||
const upload = await this.driveService.addFile({
|
const upload = await this.driveService.addFile({
|
||||||
user: { id: tokeninfo.userId, host: null },
|
user: { id: tokeninfo.userId, host: null },
|
||||||
path: header.path,
|
path: header.path,
|
||||||
|
@ -286,6 +286,7 @@ export class MastodonApiServerService {
|
||||||
sensitive: false,
|
sensitive: false,
|
||||||
});
|
});
|
||||||
if (upload.type.startsWith('image/')) {
|
if (upload.type.startsWith('image/')) {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
(_request.body as any).header = upload.id;
|
(_request.body as any).header = upload.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue