Removed useless part from function and updated comments

ref #90
This commit is contained in:
Nicolai Ort 2021-01-15 18:19:26 +01:00
parent ba218c85e0
commit 22e6070e53
1 changed files with 6 additions and 11 deletions

View File

@ -1,6 +1,6 @@
import { IsInt, IsNotEmpty, IsOptional, IsString } from 'class-validator'; import { IsInt, IsNotEmpty, IsOptional, IsString } from 'class-validator';
import { getConnectionManager } from 'typeorm'; import { getConnectionManager } from 'typeorm';
import { GroupContactNotFoundError, GroupContactWrongTypeError } from '../../../errors/GroupContactErrors'; import { GroupContactNotFoundError } from '../../../errors/GroupContactErrors';
import { GroupContact } from '../../entities/GroupContact'; import { GroupContact } from '../../entities/GroupContact';
/** /**
@ -15,7 +15,7 @@ export abstract class CreateRunnerGroup {
name: string; name: string;
/** /**
* The new group's contact. * The new group's contact's id.
* Optional * Optional
*/ */
@IsInt() @IsInt()
@ -26,15 +26,10 @@ export abstract class CreateRunnerGroup {
* Gets the new group's contact by it's id. * Gets the new group's contact by it's id.
*/ */
public async getContact(): Promise<GroupContact> { public async getContact(): Promise<GroupContact> {
if (this.contact === undefined || this.contact === null) { if (!this.contact) { return null; }
return null; let contact = await getConnectionManager().get().getRepository(GroupContact).findOne({ id: this.contact });
} if (!contact) { throw new GroupContactNotFoundError; }
if (!isNaN(this.contact)) { return contact;
let contact = await getConnectionManager().get().getRepository(GroupContact).findOne({ id: this.contact });
if (!contact) { throw new GroupContactNotFoundError; }
return contact;
}
throw new GroupContactWrongTypeError;
} }
} }