Skip to content

Commit

Permalink
fix(api-aco): ensure correct tenant and locale is used in ACO storage (
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel910 committed Sep 18, 2023
1 parent e06f999 commit 30d6f95
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions packages/api-aco/src/apps/AcoApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,28 +29,32 @@ export class AcoApp implements IAcoApp {
public get search(): AcoSearchRecordCrudBase {
return {
create: async <TData>(data: CreateSearchRecordParams<TData>) => {
return this.context.aco.search.create<TData>(this.model, data);
return this.context.aco.search.create<TData>(this.getModel(), data);
},
update: async <TData>(id: string, data: SearchRecord<TData>) => {
/**
* Required to have as any atm as TS is breaking on the return type.
*/
return (await this.context.aco.search.update<TData>(this.model, id, data)) as any;
return (await this.context.aco.search.update<TData>(
this.getModel(),
id,
data
)) as any;
},
move: async (id: string, folderId?: string) => {
return this.context.aco.search.move(this.model, id, folderId);
return this.context.aco.search.move(this.getModel(), id, folderId);
},
get: async <TData>(id: string) => {
return this.context.aco.search.get<TData>(this.model, id);
return this.context.aco.search.get<TData>(this.getModel(), id);
},
list: async <TData>(params: ListSearchRecordsParams) => {
return this.context.aco.search.list<TData>(this.model, params);
return this.context.aco.search.list<TData>(this.getModel(), params);
},
delete: async (id: string): Promise<Boolean> => {
return this.context.aco.search.delete(this.model, id);
return this.context.aco.search.delete(this.getModel(), id);
},
listTags: async (params: ListSearchRecordTagsParams) => {
return this.context.aco.search.listTags(this.model, params);
return this.context.aco.search.listTags(this.getModel(), params);
}
};
}
Expand All @@ -59,6 +63,13 @@ export class AcoApp implements IAcoApp {
return this.context.aco.folder;
}

private getModel() {
const tenant = this.context.tenancy.getCurrentTenant().id;
const locale = this.context.i18n.getContentLocale()!.code;

return { ...this.model, tenant, locale };
}

private constructor(context: AcoContext, params: IAcoAppParams) {
this.context = context;
this.name = params.name;
Expand Down

0 comments on commit 30d6f95

Please sign in to comment.