Skip to content
Merged
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions quickstart-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ services:
hostname: notifications
image: alkemio/notifications:v0.19.0
platform: linux/x86_64
depends_on:
- rabbitmq
environment:
- RABBITMQ_HOST
- RABBITMQ_USER
Expand Down Expand Up @@ -236,6 +238,8 @@ services:
hostname: matrix-adapter
image: alkemio/matrix-adapter:v0.4.5
platform: linux/x86_64
depends_on:
- rabbitmq
environment:
- RABBITMQ_HOST
- RABBITMQ_USER
Expand Down Expand Up @@ -274,6 +278,8 @@ services:
hostname: whiteboard-collaboration
image: alkemio/whiteboard-collaboration-service:v0.3.1
platform: linux/x86_64
depends_on:
- rabbitmq
environment:
- RABBITMQ_HOST
- RABBITMQ_USER
Expand All @@ -292,6 +298,8 @@ services:
hostname: file-service
image: alkemio/file-service:v0.1.2
platform: linux/x86_64
depends_on:
- rabbitmq
environment:
- RABBITMQ_HOST
- RABBITMQ_USER
Expand Down
24 changes: 10 additions & 14 deletions src/domain/common/tagset/tagset.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { some } from 'lodash';
import { Inject, Injectable, LoggerService } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

Expand All @@ -7,11 +6,7 @@ import { Tagset } from './tagset.entity';
import { ITagset } from './tagset.interface';
import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
import { LogContext } from '@common/enums';
import {
EntityNotFoundException,
RelationshipNotFoundException,
ValidationException,
} from '@common/exceptions';
import { EntityNotFoundException, RelationshipNotFoundException, ValidationException } from '@common/exceptions';
import { CreateTagsetInput } from '@domain/common/tagset/dto/tagset.dto.create';
import { UpdateTagsetInput } from '@domain/common/tagset/dto/tagset.dto.update';
import { AuthorizationPolicy } from '@domain/common/authorization-policy';
Expand All @@ -30,13 +25,14 @@ export class TagsetService {
@Inject(WINSTON_MODULE_NEST_PROVIDER) private readonly logger: LoggerService
) {}

async createTagset(tagsetData: CreateTagsetInput): Promise<ITagset> {
if (!tagsetData.type) tagsetData.type = TagsetType.FREEFORM;
const tagset: ITagset = Tagset.create({ ...tagsetData });
tagset.authorization = new AuthorizationPolicy();
if (!tagset.tags) tagset.tags = [];
tagset.tagsetTemplate = tagsetData.tagsetTemplate;
return await this.tagsetRepository.save(tagset);
public createTagset(tagsetData: CreateTagsetInput): ITagset {
return Tagset.create({
...tagsetData,
authorization: new AuthorizationPolicy(),
type: tagsetData.type ?? TagsetType.FREEFORM,
tags: tagsetData?.tags ?? [],
tagsetTemplate: tagsetData.tagsetTemplate,
});
}

async getTagsetOrFail(
Expand Down Expand Up @@ -246,7 +242,7 @@ export class TagsetService {
);
}

return Tagset.create({ ...tagsetData });
return this.createTagset(tagsetData);
}

async save(tagset: ITagset): Promise<ITagset> {
Expand Down
2 changes: 1 addition & 1 deletion src/domain/community/user/user.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export class UserService {
user.lastName
);
}
await this.profileService.addVisualOnProfile(
this.profileService.addVisualOnProfile(
user.profile,
VisualType.AVATAR,
avatarURL
Expand Down
13 changes: 9 additions & 4 deletions src/migrations/1721649196399-innovationPacksAccount.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { safelyDropFK } from './utils/safely-drop-foreignKey';

export class InnovationPacksAccount1721649196399 implements MigrationInterface {
name = 'InnovationPacksAccount1721649196399';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE \`innovation_pack\` DROP FOREIGN KEY \`FK_77777450cf75dc486700ca034c6\``
await safelyDropFK(
queryRunner,
'innovation_pack',
'FK_77777450cf75dc486700ca034c6'
);
await queryRunner.query(
`ALTER TABLE \`library\` DROP FOREIGN KEY \`FK_6664d59c0b805c9c1ecb0070e16\``
await safelyDropFK(
queryRunner,
'library',
'FK_6664d59c0b805c9c1ecb0070e16'
);

await queryRunner.query(
Expand Down
24 changes: 24 additions & 0 deletions src/migrations/utils/safely-drop-foreignKey.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { QueryRunner } from 'typeorm';

export const safelyDropFK = async (
queryRunner: QueryRunner,
tableName: string,
foreignKey: string
) => {
const result = await queryRunner.query(
`
SELECT CONSTRAINT_NAME
FROM information_schema.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = ?
AND CONSTRAINT_NAME = ?
`,
[tableName, foreignKey]
);

if (result && result.length && result.length > 0) {
await queryRunner.query(
`ALTER TABLE \`${tableName}\` DROP FOREIGN KEY \`${foreignKey}\``
);
}
};