For now we just set it to the empty contact, which is a bit weird, and wrong until we fix the update logic.
This commit is contained in:
parent
2d4a0347d6
commit
3cafca6cbd
3 changed files with 56 additions and 0 deletions
|
|
@ -3,8 +3,10 @@ package platform
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/Gleipnir-Technology/nidus-sync/db"
|
||||
modelcomms "github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/comms/model"
|
||||
querycomms "github.com/Gleipnir-Technology/nidus-sync/db/query/comms"
|
||||
"github.com/Gleipnir-Technology/nidus-sync/platform/types"
|
||||
)
|
||||
|
|
@ -58,3 +60,17 @@ func ContactsForOrganization(ctx context.Context, org_id int32) (results []types
|
|||
}
|
||||
return results, nil
|
||||
}
|
||||
func ContactEmptyForOrganization(ctx context.Context, txn db.Ex, org_id int32) (modelcomms.Contact, error) {
|
||||
contact, err := querycomms.ContactEmptyForOrganization(ctx, txn, int64(org_id))
|
||||
if err != nil {
|
||||
return modelcomms.Contact{}, fmt.Errorf("querycomms: %w", err)
|
||||
}
|
||||
if contact != nil {
|
||||
return *contact, nil
|
||||
}
|
||||
return querycomms.ContactInsert(ctx, txn, modelcomms.Contact{
|
||||
Created: time.Now(),
|
||||
Name: "",
|
||||
OrganizationID: org_id,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue