Skip to content

Commit

Permalink
fix(core): Fix missing customField input for Assets
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Mattutat <[email protected]>

Fixes #844
  • Loading branch information
Draykee authored Apr 26, 2021
1 parent eb80758 commit 772bd8d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/core/src/service/services/asset.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { AssetEvent } from '../../event-bus/events/asset-event';
import { ListQueryBuilder } from '../helpers/list-query-builder/list-query-builder';
import { patchEntity } from '../helpers/utils/patch-entity';
import { TransactionalConnection } from '../transaction/transactional-connection';
import { CustomFieldRelationService } from '../helpers/custom-field-relation/custom-field-relation.service';

import { ChannelService } from './channel.service';
import { RoleService } from './role.service';
Expand Down Expand Up @@ -69,6 +70,7 @@ export class AssetService {
private tagService: TagService,
private channelService: ChannelService,
private roleService: RoleService,
private customFieldRelationService: CustomFieldRelationService,
) {
this.permittedMimeTypes = this.configService.assetOptions.permittedFileTypes
.map(val => (/\.[\w]+/.test(val) ? mime.lookup(val) || undefined : val))
Expand Down Expand Up @@ -235,10 +237,11 @@ export class AssetService {
async create(ctx: RequestContext, input: CreateAssetInput): Promise<CreateAssetResult> {
const { createReadStream, filename, mimetype } = await input.file;
const stream = createReadStream();
const result = await this.createAssetInternal(ctx, stream, filename, mimetype);
const result = await this.createAssetInternal(ctx, stream, filename, mimetype, input.customFields);
if (isGraphQlErrorResult(result)) {
return result;
}
await this.customFieldRelationService.updateRelations(ctx, Asset, input, result);
if (input.tags) {
const tags = await this.tagService.valuesToTags(ctx, input.tags);
result.tags = tags;
Expand Down Expand Up @@ -419,6 +422,7 @@ export class AssetService {
stream: Stream,
filename: string,
mimetype: string,
customFields?: { [key: string]: any }
): Promise<Asset | MimeTypeError> {
const { assetOptions } = this.configService;
if (!this.validateMimeType(mimetype)) {
Expand Down Expand Up @@ -454,6 +458,7 @@ export class AssetService {
source: sourceFileIdentifier,
preview: previewFileIdentifier,
focalPoint: null,
customFields
});
this.channelService.assignToCurrentChannel(asset, ctx);
return this.connection.getRepository(ctx, Asset).save(asset);
Expand Down

0 comments on commit 772bd8d

Please sign in to comment.