graph

package
v1.39.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 23 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package graph is the Microsoft Graph receiving and sending backend (ADR 0037).

Index

Constants

View Source
const BaseURL = "https://graph.microsoft.com/v1.0"

BaseURL is Graph's v1.0 root.

View Source
const SendURL = "https://graph.microsoft.com/v1.0/me/sendMail"

SendURL is Graph's sendMail.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.35.0

type Config struct {
	// URL is the Graph API root, normally BaseURL.
	URL         string
	Credentials backend.CredentialsFunc
	// Wait waits d out, or until ctx is done, when the server asks to back
	// off. Nil waits in real time; tests pass a fake.
	Wait func(ctx context.Context, d time.Duration) error
}

Config is how to reach a Microsoft Graph account.

type Receiver added in v1.35.0

type Receiver struct {
	// contains filtered or unexported fields
}

Receiver is a Microsoft Graph account's receiving backend. A folder's FolderRef is its mailFolder id, a message's ServerID and MessageRef its ImmutableId, and a folder's cursor its messages/delta deltaLink.

func NewReceiver added in v1.35.0

func NewReceiver(cfg Config) *Receiver

NewReceiver is a Receiver for the account cfg names. It connects on first use.

func (*Receiver) Apply added in v1.35.0

func (r *Receiver) Apply(ctx context.Context, op backend.Op) (backend.Result, error)

Apply implements backend.Receiver.

func (*Receiver) Check added in v1.35.0

func (r *Receiver) Check(ctx context.Context) (backend.CheckResult, error)

Check implements backend.Receiver: verifies /me/mailFolders/inbox with the Mail.ReadWrite token and lists the mailbox's folders.

func (*Receiver) Close added in v1.35.0

func (r *Receiver) Close() error

Close implements backend.Receiver.

func (*Receiver) Describe added in v1.35.0

func (r *Receiver) Describe(ctx context.Context) (backend.Description, error)

Describe implements backend.Receiver. Its first call signs in, so refused credentials are ErrAuthFailed here.

func (*Receiver) Fetch added in v1.35.0

Fetch implements backend.Receiver.

func (*Receiver) Find added in v1.35.0

func (r *Receiver) Find(ctx context.Context, folder backend.FolderRef, messageID string, size int64) ([]backend.MessageRef, error)

Find implements backend.Receiver.

func (*Receiver) Headers added in v1.35.0

func (r *Receiver) Headers(ctx context.Context, _ backend.FolderRef, refs []backend.MessageRef, fields []string) (map[backend.MessageRef][]byte, error)

Headers implements backend.Receiver.

func (*Receiver) Sync added in v1.35.0

func (r *Receiver) Sync(ctx context.Context, req backend.SyncRequest, commit func(backend.Page) error) (bool, error)

Sync implements backend.Receiver: folder hierarchy, then each folder's /me/mailFolders/{id}/messages/delta pages from its deltaLink cursor.

func (*Receiver) Watch added in v1.35.0

func (r *Receiver) Watch(context.Context, func([]backend.FolderRef)) error

Watch implements backend.Receiver: desktop clients cannot receive Graph webhooks, so core polls every PollInterval (1 minute).

type ResponseError added in v1.35.0

type ResponseError struct {
	Status  int
	Code    string
	Message string
}

ResponseError is Graph's refusal of a request (4xx other than 401/403/429).

func (*ResponseError) Error added in v1.35.0

func (e *ResponseError) Error() string

type Sender

type Sender struct {
	// contains filtered or unexported fields
}

Sender submits through Graph's sendMail with the Token its credentials give. Graph files the sent copy itself (saveToSentItems).

func New

func New(url string, creds backend.CredentialsFunc) *Sender

New is a Sender posting to url, normally SendURL.

func (*Sender) SavesSent

func (*Sender) SavesSent() bool

func (*Sender) Send

func (s *Sender) Send(ctx context.Context, _ string, rcpts []string, raw []byte) error

Send submits raw to rcpts: ErrUncertain once the whole request went out without an answer, backend.ErrAuthFailed for a refused token, a *backend.RejectedError (5xx) for a refused message. Graph takes recipients from the headers, so rcpts not in To or Cc are added as Bcc to the copy Graph gets (Exchange strips it); from is the mailbox's own.

Jump to

Keyboard shortcuts

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