From 8094e6fdef67ca683afc27208ca578a4422f9b67 Mon Sep 17 00:00:00 2001 From: Juan Font Alonso Date: Sun, 17 Oct 2021 11:59:08 +0200 Subject: [PATCH] Preload the Namespace from SharedMachines --- machine.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machine.go b/machine.go index f97169b2..8986ac92 100644 --- a/machine.go +++ b/machine.go @@ -86,7 +86,7 @@ func (h *Headscale) getShared(m *Machine) (Machines, error) { Msg("Finding shared peers") sharedMachines := []SharedMachine{} - if err := h.db.Preload("Namespace").Preload("Machine").Where("namespace_id = ?", + if err := h.db.Preload("Namespace").Preload("Machine").Preload("Machine.Namespace").Where("namespace_id = ?", m.NamespaceID).Find(&sharedMachines).Error; err != nil { return Machines{}, err } @@ -113,7 +113,7 @@ func (h *Headscale) getSharedTo(m *Machine) (Machines, error) { Msg("Finding peers in namespaces this machine is shared with") sharedMachines := []SharedMachine{} - if err := h.db.Preload("Namespace").Preload("Machine").Where("machine_id = ?", + if err := h.db.Preload("Namespace").Preload("Machine").Preload("Machine.Namespace").Where("machine_id = ?", m.ID).Find(&sharedMachines).Error; err != nil { return Machines{}, err }