Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(core): Fixed missing customField input for assets (#844) #845

Merged
merged 1 commit into from
Apr 26, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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