parent
6469e3bc97
commit
45c8bb83be
|
@ -28,7 +28,7 @@ export class GroupContactController {
|
|||
@OpenAPI({ description: 'Lists all contacts. <br> This includes the contact\'s associated groups.' })
|
||||
async getAll() {
|
||||
let responseContacts: ResponseGroupContact[] = new Array<ResponseGroupContact>();
|
||||
const contacts = await this.contactRepository.find({ relations: ['groups'] });
|
||||
const contacts = await this.contactRepository.find({ relations: ['groups', 'groups.parentGroup'] });
|
||||
contacts.forEach(contact => {
|
||||
responseContacts.push(contact.toResponse());
|
||||
});
|
||||
|
@ -42,7 +42,7 @@ export class GroupContactController {
|
|||
@OnUndefined(GroupContactNotFoundError)
|
||||
@OpenAPI({ description: 'Lists all information about the contact whose id got provided. <br> This includes the contact\'s associated groups.' })
|
||||
async getOne(@Param('id') id: number) {
|
||||
let contact = await this.contactRepository.findOne({ id: id }, { relations: ['groups'] })
|
||||
let contact = await this.contactRepository.findOne({ id: id }, { relations: ['groups', 'groups.parentGroup'] })
|
||||
if (!contact) { throw new GroupContactNotFoundError(); }
|
||||
return contact.toResponse();
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ export class GroupContactController {
|
|||
}
|
||||
|
||||
contact = await this.contactRepository.save(contact)
|
||||
return (await this.contactRepository.findOne({ id: contact.id }, { relations: ['groups'] })).toResponse();
|
||||
return (await this.contactRepository.findOne({ id: contact.id }, { relations: ['groups', 'groups.parentGroup'] })).toResponse();
|
||||
}
|
||||
|
||||
@Put('/:id')
|
||||
|
@ -83,7 +83,7 @@ export class GroupContactController {
|
|||
}
|
||||
|
||||
await this.contactRepository.save(await contact.update(oldContact));
|
||||
return (await this.contactRepository.findOne({ id: contact.id }, { relations: ['groups'] })).toResponse();
|
||||
return (await this.contactRepository.findOne({ id: contact.id }, { relations: ['groups', 'groups.parentGroup'] })).toResponse();
|
||||
}
|
||||
|
||||
@Delete('/:id')
|
||||
|
@ -95,7 +95,7 @@ export class GroupContactController {
|
|||
async remove(@Param("id") id: number, @QueryParam("force") force: boolean) {
|
||||
let contact = await this.contactRepository.findOne({ id: id });
|
||||
if (!contact) { return null; }
|
||||
const responseContact = await this.contactRepository.findOne(contact, { relations: ['groups'] });
|
||||
const responseContact = await this.contactRepository.findOne(contact, { relations: ['groups', 'groups.parentGroup'] });
|
||||
for (let group of responseContact.groups) {
|
||||
group.contact = null;
|
||||
await getConnection().getRepository(RunnerGroup).save(group);
|
||||
|
|
|
@ -123,7 +123,6 @@ describe('POST /api/contacts working (with group)', () => {
|
|||
"parentGroup": added_org.id
|
||||
}, axios_config);
|
||||
delete res.data.contact;
|
||||
delete res.data.parentGroup;
|
||||
added_team = res.data;
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.headers['content-type']).toContain("application/json")
|
||||
|
|
|
@ -74,7 +74,6 @@ describe('Update contact group after adding (should work)', () => {
|
|||
"parentGroup": added_org.id
|
||||
}, axios_config);
|
||||
delete res.data.contact;
|
||||
delete res.data.parentGroup;
|
||||
added_team = res.data;
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.headers['content-type']).toContain("application/json")
|
||||
|
@ -112,6 +111,7 @@ describe('Update contact group after adding (should work)', () => {
|
|||
"lastname": "last",
|
||||
"groups": added_team.id
|
||||
}, axios_config);
|
||||
console.log(res.data)
|
||||
expect(res.status).toEqual(200);
|
||||
expect(res.headers['content-type']).toContain("application/json");
|
||||
expect(res.data).toEqual({
|
||||
|
|
Loading…
Reference in New Issue