@@ -1,6 +1,6 @@
 | 
			
		||||
import { Authorized, Body, Delete, Get, JsonController, OnUndefined, Param, Post, Put, QueryParam } from 'routing-controllers';
 | 
			
		||||
import { OpenAPI, ResponseSchema } from 'routing-controllers-openapi';
 | 
			
		||||
import { getConnection, getConnectionManager, Repository } from 'typeorm';
 | 
			
		||||
import { Repository, getConnection, getConnectionManager } from 'typeorm';
 | 
			
		||||
import { GroupContactIdsNotMatchingError, GroupContactNotFoundError } from '../errors/GroupContactErrors';
 | 
			
		||||
import { RunnerGroupNotFoundError } from '../errors/RunnerGroupErrors';
 | 
			
		||||
import { CreateGroupContact } from '../models/actions/create/CreateGroupContact';
 | 
			
		||||
@@ -26,9 +26,16 @@ export class GroupContactController {
 | 
			
		||||
	@Authorized("CONTACT:GET")
 | 
			
		||||
	@ResponseSchema(ResponseGroupContact, { isArray: true })
 | 
			
		||||
	@OpenAPI({ description: 'Lists all contacts. <br> This includes the contact\'s associated groups.' })
 | 
			
		||||
	async getAll() {
 | 
			
		||||
	async getAll(@QueryParam("page", { required: false }) page: number, @QueryParam("page_size", { required: false }) page_size: number = 100) {
 | 
			
		||||
		let responseContacts: ResponseGroupContact[] = new Array<ResponseGroupContact>();
 | 
			
		||||
		const contacts = await this.contactRepository.find({ relations: ['groups', 'groups.parentGroup'] });
 | 
			
		||||
		let contacts: Array<GroupContact>;
 | 
			
		||||
 | 
			
		||||
		if (page) {
 | 
			
		||||
			contacts = await this.contactRepository.find({ relations: ['groups', 'groups.parentGroup'], skip: page * page_size, take: page_size });
 | 
			
		||||
		} else {
 | 
			
		||||
			contacts = await this.contactRepository.find({ relations: ['groups', 'groups.parentGroup'] });
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		contacts.forEach(contact => {
 | 
			
		||||
			responseContacts.push(contact.toResponse());
 | 
			
		||||
		});
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user