mirror of
				https://github.com/NginxProxyManager/nginx-proxy-manager.git
				synced 2025-11-03 17:13:33 +00:00 
			
		
		
		
	Don't use duplicate relations when eager-loading access list items and clients.
This fixes an Objection warning: 'Duplicate relation "proxy_hosts" in a relation expression. You should use "a.[b, c]" instead of "[a.b, a.c]". This will cause an error in objection 2.0'. It also fixes the access list clients not being properly eager-loaded when building the proxy host nginx configuration files. Closes #434
This commit is contained in:
		@@ -71,7 +71,7 @@ const internalAccessList = {
 | 
			
		||||
				// re-fetch with expansions
 | 
			
		||||
				return internalAccessList.get(access, {
 | 
			
		||||
					id:     data.id,
 | 
			
		||||
					expand: ['owner', 'items', 'clients', 'proxy_hosts.access_list.clients', 'proxy_hosts.access_list.items']
 | 
			
		||||
					expand: ['owner', 'items', 'clients', 'proxy_hosts.access_list.[clients,items]']
 | 
			
		||||
				}, true /* <- skip masking */);
 | 
			
		||||
			})
 | 
			
		||||
			.then((row) => {
 | 
			
		||||
@@ -216,7 +216,7 @@ const internalAccessList = {
 | 
			
		||||
				// re-fetch with expansions
 | 
			
		||||
				return internalAccessList.get(access, {
 | 
			
		||||
					id:     data.id,
 | 
			
		||||
					expand: ['owner', 'items', 'clients', 'proxy_hosts.access_list.clients', 'proxy_hosts.access_list.items']
 | 
			
		||||
					expand: ['owner', 'items', 'clients', 'proxy_hosts.access_list.[clients,items]']
 | 
			
		||||
				}, true /* <- skip masking */);
 | 
			
		||||
			})
 | 
			
		||||
			.then((row) => {
 | 
			
		||||
@@ -254,7 +254,7 @@ const internalAccessList = {
 | 
			
		||||
					.joinRaw('LEFT JOIN `proxy_host` ON `proxy_host`.`access_list_id` = `access_list`.`id` AND `proxy_host`.`is_deleted` = 0')
 | 
			
		||||
					.where('access_list.is_deleted', 0)
 | 
			
		||||
					.andWhere('access_list.id', data.id)
 | 
			
		||||
					.allowEager('[owner,items,clients,proxy_hosts,proxy_hosts.access_list.clients,proxy_hosts.access_list.items]')
 | 
			
		||||
					.allowEager('[owner,items,clients,proxy_hosts.[*, access_list.[clients,items]]]')
 | 
			
		||||
					.omit(['access_list.is_deleted'])
 | 
			
		||||
					.first();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -73,7 +73,7 @@ const internalProxyHost = {
 | 
			
		||||
				// re-fetch with cert
 | 
			
		||||
				return internalProxyHost.get(access, {
 | 
			
		||||
					id:     row.id,
 | 
			
		||||
					expand: ['certificate', 'owner', 'access_list.clients', 'access_list.items']
 | 
			
		||||
					expand: ['certificate', 'owner', 'access_list.[clients,items]']
 | 
			
		||||
				});
 | 
			
		||||
			})
 | 
			
		||||
			.then((row) => {
 | 
			
		||||
@@ -186,7 +186,7 @@ const internalProxyHost = {
 | 
			
		||||
			.then(() => {
 | 
			
		||||
				return internalProxyHost.get(access, {
 | 
			
		||||
					id:     data.id,
 | 
			
		||||
					expand: ['owner', 'certificate', 'access_list.clients', 'access_list.items']
 | 
			
		||||
					expand: ['owner', 'certificate', 'access_list.[clients,items]']
 | 
			
		||||
				})
 | 
			
		||||
					.then((row) => {
 | 
			
		||||
						// Configure nginx
 | 
			
		||||
@@ -219,7 +219,7 @@ const internalProxyHost = {
 | 
			
		||||
					.query()
 | 
			
		||||
					.where('is_deleted', 0)
 | 
			
		||||
					.andWhere('id', data.id)
 | 
			
		||||
					.allowEager('[owner,access_list,access_list.clients,access_list.items,certificate]')
 | 
			
		||||
					.allowEager('[owner,access_list,access_list.[clients,items],certificate]')
 | 
			
		||||
					.first();
 | 
			
		||||
 | 
			
		||||
				if (access_data.permission_visibility !== 'all') {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user