orgdirectory

package
v0.0.0-...-46fd052 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DirectoryMetadataKey = "twakeDirectory"
)

Variables

This section is empty.

Functions

func CopyOrgDirectoryFromOrgInstance

func CopyOrgDirectoryFromOrgInstance(ctx context.Context, target *instance.Instance, organizationID string) error

CopyOrgDirectoryFromOrgInstance copies current managed group/contact replicas from the organization instance to a newly created member instance. LDAP/B2B remains authoritative; the organization instance is only a local copy source for late onboarding.

func GroupDocID

func GroupDocID(organizationID, externalID string) string

GroupDocID returns the stable local document ID used for a replicated B2B group. Raw external IDs stay in metadata for traceability.

func IsManagedDirectoryDoc

func IsManagedDirectoryDoc(doc *couchdb.JSONDoc) bool

IsManagedDirectoryDoc reports whether a contact or group document is managed by the B2B organization directory replication.

func IsManagedDirectoryDoctype

func IsManagedDirectoryDoctype(doctype string) bool

IsManagedDirectoryDoctype reports whether a doctype can contain managed organization directory documents.

func SyncGroupCreated

func SyncGroupCreated(ctx context.Context, msg GroupCreatedMessage) error

SyncGroupCreated replicates a B2B group and its initial members to every instance in the organization.

func SyncGroupDeleted

func SyncGroupDeleted(ctx context.Context, msg GroupDeletedMessage) error

SyncGroupDeleted removes a B2B group and first removes its relationship from replicated contacts so existing sharing-group triggers see membership deltas.

func SyncGroupMembersAdded

func SyncGroupMembersAdded(ctx context.Context, msg GroupMembersMessage) error

SyncGroupMembersAdded adds members to a B2B group in every instance in the organization.

func SyncGroupMembersRemoved

func SyncGroupMembersRemoved(ctx context.Context, msg GroupMembersMessage) error

SyncGroupMembersRemoved removes a B2B group relationship from member contacts.

func SyncGroupUpdated

func SyncGroupUpdated(ctx context.Context, msg GroupUpdatedMessage) error

SyncGroupUpdated partially updates a B2B group in every instance in the organization.

func UpsertManagedContact

func UpsertManagedContact(inst *instance.Instance, input ContactPatch) (*contact.Contact, error)

UpsertManagedContact creates or updates a managed organization-directory contact, preserving any existing document ID matched by email or Cozy URL. Callers should pass values already normalized at their input boundary.

Types

type ContactPatch

type ContactPatch struct {
	OrganizationID string
	Username       string
	Email          string
	FirstName      string
	LastName       string
	WorkplaceFQDN  string
	Name           string
	CozyURL        string
	Phone          string
}

ContactPatch describes a B2B contact replica to create or update.

type DirectoryMetadata

type DirectoryMetadata struct {
	Managed        bool   `json:"managed" mapstructure:"managed"`
	Kind           string `json:"kind,omitempty" mapstructure:"kind"`
	OrganizationID string `json:"organizationId,omitempty" mapstructure:"organizationId"`
	ExternalID     string `json:"externalId,omitempty" mapstructure:"externalId"`
	Username       string `json:"username,omitempty" mapstructure:"username"`
	Email          string `json:"email,omitempty" mapstructure:"email"`
	WorkplaceFQDN  string `json:"workplaceFqdn,omitempty" mapstructure:"workplaceFqdn"`
}

DirectoryMetadata describes the B2B organization directory ownership stored on managed contact and group documents.

type GroupCreatedMessage

type GroupCreatedMessage struct {
	Timestamp      time.Time     `json:"timestamp"`
	OrganizationID string        `json:"organizationId"`
	ID             string        `json:"id"`
	Name           string        `json:"name"`
	Description    string        `json:"description"`
	Color          string        `json:"color"`
	CreatedAt      time.Time     `json:"createdAt"`
	Members        []GroupMember `json:"members"`
}

GroupCreatedMessage is the payload for b2b.group.created.

type GroupDeletedMessage

type GroupDeletedMessage struct {
	Timestamp      time.Time `json:"timestamp"`
	OrganizationID string    `json:"organizationId"`
	ID             string    `json:"id"`
}

GroupDeletedMessage is the payload for b2b.group.deleted.

type GroupMember

type GroupMember struct {
	Username      string `json:"username"`
	Email         string `json:"email"`
	FirstName     string `json:"firstName"`
	LastName      string `json:"lastName"`
	WorkplaceFQDN string `json:"workplaceFqdn"`
}

GroupMember describes a B2B user present in a group membership event.

type GroupMembersMessage

type GroupMembersMessage struct {
	Timestamp      time.Time     `json:"timestamp"`
	OrganizationID string        `json:"organizationId"`
	ID             string        `json:"id"`
	Members        []GroupMember `json:"members"`
}

GroupMembersMessage is the payload for b2b.group.member.added and b2b.group.member.removed.

type GroupPatch

type GroupPatch struct {
	OrganizationID string
	ExternalID     string
	Name           *string
	Description    *string
	Color          *string
	CreatedAt      *time.Time
}

GroupPatch describes the local fields to create or update on a replicated organization-directory group.

type GroupUpdatedMessage

type GroupUpdatedMessage struct {
	Timestamp      time.Time `json:"timestamp"`
	OrganizationID string    `json:"organizationId"`
	ID             string    `json:"id"`
	Name           *string   `json:"name,omitempty"`
	Description    *string   `json:"description,omitempty"`
	Color          *string   `json:"color,omitempty"`
}

GroupUpdatedMessage is the payload for b2b.group.updated.

type OrganizationInstances

type OrganizationInstances struct {
	OrganizationID string
	Instances      []*instance.Instance
}

OrganizationInstances is the resolved local instance scope for an organization-directory operation.

func ResolveOrganizationInstances

func ResolveOrganizationInstances(organizationID, organizationDomain string) (OrganizationInstances, error)

ResolveOrganizationInstances retrieves organization instances by ID when it is available, otherwise by organization domain.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL