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