models

package
v0.0.0-...-e28afbe Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(v vocab.Type) (b []byte, err error)

Marshal takes any ActivityStreams type and serializes it to JSON.

func MustChangeOneRow

func MustChangeOneRow(r sql.Result) error

func MustQueryOneRow

func MustQueryOneRow(r *sql.Rows, fn func(r SingleRow) error) error

func QueryRows

func QueryRows(r *sql.Rows, fn func(r SingleRow) error) error

Types

type ActivityStreams

type ActivityStreams struct {
	vocab.Type
}

ActivityStreams is a wrapper around any ActivityStreams type that also knows how to serialize and deserialize itself for SQL database drivers.

func (ActivityStreams) SanitizeContentSummaryHTML

func (a ActivityStreams) SanitizeContentSummaryHTML()

func (*ActivityStreams) Scan

func (a *ActivityStreams) Scan(src interface{}) error

func (ActivityStreams) Value

func (a ActivityStreams) Value() (driver.Value, error)

type ActivityStreamsApplication

type ActivityStreamsApplication struct {
	vocab.ActivityStreamsApplication
}

ActivityStreamsApplication is a wrapper around the ActivityStreams type that also knows how to serialize and deserialize itself for SQL database drivers.

func (*ActivityStreamsApplication) Scan

func (a *ActivityStreamsApplication) Scan(src interface{}) error

func (ActivityStreamsApplication) Value

type ActivityStreamsCollection

type ActivityStreamsCollection struct {
	vocab.ActivityStreamsCollection
}

ActivityStreamsCollection is a wrapper around the ActivityStreams type that also knows how to serialize and deserialize itself for SQL database drivers.

func (*ActivityStreamsCollection) Scan

func (a *ActivityStreamsCollection) Scan(src interface{}) error

func (ActivityStreamsCollection) Value

type ActivityStreamsCollectionPage

type ActivityStreamsCollectionPage struct {
	vocab.ActivityStreamsCollectionPage
}

ActivityStreamsCollectionPage is a wrapper around the ActivityStreams type that also knows how to serialize and deserialize itself for SQL database drivers.

func (*ActivityStreamsCollectionPage) Scan

func (a *ActivityStreamsCollectionPage) Scan(src interface{}) error

func (ActivityStreamsCollectionPage) Value

type ActivityStreamsFollow

type ActivityStreamsFollow struct {
	vocab.ActivityStreamsFollow
}

ActivityStreamsFollow is a wrapper around the ActivityStreams type that also knows how to serialize and deserialize itself for SQL database drivers.

func (*ActivityStreamsFollow) Scan

func (a *ActivityStreamsFollow) Scan(src interface{}) error

func (ActivityStreamsFollow) Value

func (a ActivityStreamsFollow) Value() (driver.Value, error)

type ActivityStreamsOrderedCollection

type ActivityStreamsOrderedCollection struct {
	vocab.ActivityStreamsOrderedCollection
}

ActivityStreamsOrderedCollection is a wrapper around the ActivityStreams type that also knows how to serialize and deserialize itself for SQL database drivers.

func (*ActivityStreamsOrderedCollection) Scan

func (a *ActivityStreamsOrderedCollection) Scan(src interface{}) error

func (ActivityStreamsOrderedCollection) Value

type ActivityStreamsOrderedCollectionPage

type ActivityStreamsOrderedCollectionPage struct {
	vocab.ActivityStreamsOrderedCollectionPage
}

ActivityStreamsOrderedCollectionPage is a wrapper around the ActivityStreams type that also knows how to serialize and deserialize itself for SQL database drivers.

func (*ActivityStreamsOrderedCollectionPage) Scan

func (a *ActivityStreamsOrderedCollectionPage) Scan(src interface{}) error

func (ActivityStreamsOrderedCollectionPage) Value

type ActivityStreamsPerson

type ActivityStreamsPerson struct {
	vocab.ActivityStreamsPerson
}

ActivityStreamsPerson is a wrapper around the ActivityStreams type that also knows how to serialize and deserialize itself for SQL database drivers.

func (*ActivityStreamsPerson) Scan

func (a *ActivityStreamsPerson) Scan(src interface{}) error

func (ActivityStreamsPerson) Value

func (a ActivityStreamsPerson) Value() (driver.Value, error)

type BinaryMatcher

type BinaryMatcher struct {
	L *UnaryMatcher `json:"left"`
	R *UnaryMatcher `json:"right"`
}

func (BinaryMatcher) Match

func (b BinaryMatcher) Match(res gjson.Result, json []byte, r *Resolution) (lhs, rhs bool, err error)

func (BinaryMatcher) Validate

func (b BinaryMatcher) Validate() error

type ClientInfo

type ClientInfo struct {
	ID     string
	Secret sql.NullString
	Domain string
	UserID string
}

func (*ClientInfo) GetDomain

func (c *ClientInfo) GetDomain() string

func (*ClientInfo) GetID

func (c *ClientInfo) GetID() string

func (*ClientInfo) GetSecret

func (c *ClientInfo) GetSecret() string

func (*ClientInfo) GetUserID

func (c *ClientInfo) GetUserID() string

type ClientInfos

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

ClientInfos is a Model that provides additional database methods for OAuth2 client information.

func (*ClientInfos) Close

func (c *ClientInfos) Close()

func (*ClientInfos) Create

func (c *ClientInfos) Create(ctx util.Context, tx *sql.Tx, info oauth2.ClientInfo) (id string, err error)

Create adds a ClientInfo into the database.

func (*ClientInfos) CreateTable

func (c *ClientInfos) CreateTable(t *sql.Tx, s SqlDialect) error

func (*ClientInfos) GetByID

func (c *ClientInfos) GetByID(ctx util.Context, tx *sql.Tx, id string) (oauth2.ClientInfo, error)

GetByID fetches ClientInfo based on its id.

func (*ClientInfos) Prepare

func (c *ClientInfos) Prepare(db *sql.DB, s SqlDialect) error

type CreatePolicy

type CreatePolicy struct {
	ActorID *url.URL
	Purpose Purpose
	Policy  Policy
}

type CreateResolution

type CreateResolution struct {
	PolicyID string
	IRI      *url.URL
	R        Resolution
}

type CreateUser

type CreateUser struct {
	Email       string
	Hashpass    []byte
	Salt        []byte
	Actor       driver.Valuer
	Privileges  Privileges
	Preferences Preferences
}

type Credentials

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

Credentials is a Model that provides a first-party proxy to OAuth2 tokens for cookies and other first-party storage.

func (*Credentials) Close

func (c *Credentials) Close()

func (*Credentials) Create

func (c *Credentials) Create(ctx util.Context, tx *sql.Tx, userID, tokenID string, expires time.Time) (id string, err error)

Create saves the new first party credential.

func (*Credentials) CreateTable

func (c *Credentials) CreateTable(tx *sql.Tx, s SqlDialect) error

func (*Credentials) Delete

func (c *Credentials) Delete(ctx util.Context, tx *sql.Tx, id string) error

func (*Credentials) DeleteExpired

func (c *Credentials) DeleteExpired(ctx util.Context, tx *sql.Tx) error

func (*Credentials) GetTokenInfo

func (c *Credentials) GetTokenInfo(ctx util.Context, tx *sql.Tx, id string) (oauth2.TokenInfo, error)

func (*Credentials) Prepare

func (c *Credentials) Prepare(db *sql.DB, s SqlDialect) error

func (*Credentials) Update

func (c *Credentials) Update(ctx util.Context, tx *sql.Tx, id string, info oauth2.TokenInfo) error

func (*Credentials) UpdateExpires

func (c *Credentials) UpdateExpires(ctx util.Context, tx *sql.Tx, id string, expires time.Time) error

type DeliveryAttempts

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

DeliveryAttempts is a Model that provides additional database methods for delivery attempts.

func (*DeliveryAttempts) Close

func (d *DeliveryAttempts) Close()

func (*DeliveryAttempts) Create

func (d *DeliveryAttempts) Create(c util.Context, tx *sql.Tx, from string, toActor *url.URL, payload []byte) (id string, err error)

Create a new delivery attempt.

func (*DeliveryAttempts) CreateTable

func (d *DeliveryAttempts) CreateTable(t *sql.Tx, s SqlDialect) error

func (*DeliveryAttempts) FirstPageFailures

func (d *DeliveryAttempts) FirstPageFailures(c util.Context, tx *sql.Tx, fetchTime time.Time, n int) (rf []RetryableFailure, err error)

FirstPageFailures obtains the first page of retryable failures.

func (*DeliveryAttempts) MarkAbandoned

func (d *DeliveryAttempts) MarkAbandoned(c util.Context, tx *sql.Tx, id string) error

MarkAbandoned marks a delivery attempt as abandoned.

func (*DeliveryAttempts) MarkFailed

func (d *DeliveryAttempts) MarkFailed(c util.Context, tx *sql.Tx, id string) error

MarkFailed marks a delivery attempt as failed.

func (*DeliveryAttempts) MarkSuccessful

func (d *DeliveryAttempts) MarkSuccessful(c util.Context, tx *sql.Tx, id string) error

MarkSuccessful marks a delivery attempt as successful.

func (*DeliveryAttempts) NextPageFailures

func (d *DeliveryAttempts) NextPageFailures(c util.Context, tx *sql.Tx, prevID string, fetchTime time.Time, n int) (rf []RetryableFailure, err error)

NextPageFailures obtains the next page of retryable failures.

func (*DeliveryAttempts) Prepare

func (d *DeliveryAttempts) Prepare(db *sql.DB, s SqlDialect) error

type FedData

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

FedData is a Model that provides additional database methods for ActivityStreams data received from federated peers.

func (*FedData) Close

func (f *FedData) Close()

func (*FedData) Create

func (f *FedData) Create(c util.Context, tx *sql.Tx, v ActivityStreams) error

Create inserts the federated data into the table.

func (*FedData) CreateTable

func (f *FedData) CreateTable(t *sql.Tx, s SqlDialect) error

func (*FedData) Delete

func (f *FedData) Delete(c util.Context, tx *sql.Tx, fedIDIRI *url.URL) error

Delete removes the federated data with the specified IRI.

func (*FedData) Exists

func (f *FedData) Exists(c util.Context, tx *sql.Tx, id *url.URL) (exists bool, err error)

Exists determines if the ID is stored in the federated table.

func (*FedData) Get

func (f *FedData) Get(c util.Context, tx *sql.Tx, id *url.URL) (v ActivityStreams, err error)

Get retrieves the ID from the federated table.

func (*FedData) Prepare

func (f *FedData) Prepare(db *sql.DB, s SqlDialect) error

func (*FedData) Update

func (f *FedData) Update(c util.Context, tx *sql.Tx, fedIDIRI *url.URL, v ActivityStreams) error

Update replaces the federated data for the specified IRI.

type Followers

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

Followers is a Model that provides additional database methods for Followers.

func (*Followers) Close

func (i *Followers) Close()

func (*Followers) Contains

func (i *Followers) Contains(c util.Context, tx *sql.Tx, followers, item *url.URL) (b bool, err error)

Contains returns true if the item is in the followers's collection.

func (*Followers) ContainsForActor

func (i *Followers) ContainsForActor(c util.Context, tx *sql.Tx, actor, item *url.URL) (b bool, err error)

ContainsForActor returns true if the item is in the actor's followers's collection.

func (*Followers) Create

func (i *Followers) Create(c util.Context, tx *sql.Tx, actor *url.URL, followers ActivityStreamsCollection) error

Create a new followers for the given actor.

func (*Followers) CreateTable

func (i *Followers) CreateTable(t *sql.Tx, s SqlDialect) error

func (*Followers) DeleteItem

func (i *Followers) DeleteItem(c util.Context, tx *sql.Tx, followers, item *url.URL) error

DeleteItem removes the item from the followers' ordered items list.

func (*Followers) GetAllForActor

func (i *Followers) GetAllForActor(c util.Context, tx *sql.Tx, followers *url.URL) (col ActivityStreamsCollection, err error)

GetAllForActor returns the entire Collection of the Followers.

func (*Followers) GetLastPage

func (i *Followers) GetLastPage(c util.Context, tx *sql.Tx, followers *url.URL, n int) (page ActivityStreamsCollectionPage, startIdx int, err error)

GetLastPage returns the last CollectionPage of the Followers.

func (*Followers) GetPage

func (i *Followers) GetPage(c util.Context, tx *sql.Tx, followers *url.URL, min, max int) (page ActivityStreamsCollectionPage, isEnd bool, err error)

GetPage returns a CollectionPage of the Followers.

The range of elements retrieved are [min, max).

func (*Followers) OpenFollowRequests

func (i *Followers) OpenFollowRequests(c util.Context, tx *sql.Tx, actorIRI *url.URL) (f []ActivityStreamsFollow, err error)

func (*Followers) Prepare

func (i *Followers) Prepare(db *sql.DB, s SqlDialect) error

func (*Followers) PrependItem

func (i *Followers) PrependItem(c util.Context, tx *sql.Tx, followers, item *url.URL) error

PrependItem prepends the item to the followers' ordered items list.

type Following

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

Following is a Model that provides additional database methods for Following.

func (*Following) Close

func (i *Following) Close()

func (*Following) Contains

func (i *Following) Contains(c util.Context, tx *sql.Tx, following, item *url.URL) (b bool, err error)

Contains returns true if the item is in the following's collection.

func (*Following) ContainsForActor

func (i *Following) ContainsForActor(c util.Context, tx *sql.Tx, actor, item *url.URL) (b bool, err error)

ContainsForActor returns true if the item is in the actor's following's collection.

func (*Following) Create

func (i *Following) Create(c util.Context, tx *sql.Tx, actor *url.URL, following ActivityStreamsCollection) error

Create a new following entry for the given actor.

func (*Following) CreateTable

func (i *Following) CreateTable(t *sql.Tx, s SqlDialect) error

func (*Following) DeleteItem

func (i *Following) DeleteItem(c util.Context, tx *sql.Tx, following, item *url.URL) error

DeleteItem removes the item from the following's ordered items list.

func (*Following) GetAllForActor

func (i *Following) GetAllForActor(c util.Context, tx *sql.Tx, following *url.URL) (col ActivityStreamsCollection, err error)

GetAllForActor returns the entire Following Collection.

func (*Following) GetLastPage

func (i *Following) GetLastPage(c util.Context, tx *sql.Tx, following *url.URL, n int) (page ActivityStreamsCollectionPage, startIdx int, err error)

GetLastPage returns the last CollectionPage of the Following collection.

func (*Following) GetPage

func (i *Following) GetPage(c util.Context, tx *sql.Tx, following *url.URL, min, max int) (page ActivityStreamsCollectionPage, isEnd bool, err error)

GetPage returns a CollectionPage of the Following.

The range of elements retrieved are [min, max).

func (*Following) Prepare

func (i *Following) Prepare(db *sql.DB, s SqlDialect) error

func (*Following) PrependItem

func (i *Following) PrependItem(c util.Context, tx *sql.Tx, following, item *url.URL) error

PrependItem prepends the item to the following's ordered items list.

type Inboxes

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

Inboxes is a Model that provides additional database methods for Inboxes.

func (*Inboxes) Close

func (i *Inboxes) Close()

func (*Inboxes) Contains

func (i *Inboxes) Contains(c util.Context, tx *sql.Tx, inbox, item *url.URL) (b bool, err error)

Contains returns true if the item is in the inbox's collection.

func (*Inboxes) ContainsForActor

func (i *Inboxes) ContainsForActor(c util.Context, tx *sql.Tx, actor, item *url.URL) (b bool, err error)

ContainsForActor returns true if the item is in the actor's inbox's collection.

func (*Inboxes) Create

func (i *Inboxes) Create(c util.Context, tx *sql.Tx, actor *url.URL, inbox ActivityStreamsOrderedCollection) error

Create a new inbox for the given actor.

func (*Inboxes) CreateTable

func (i *Inboxes) CreateTable(t *sql.Tx, s SqlDialect) error

func (*Inboxes) DeleteInboxItem

func (i *Inboxes) DeleteInboxItem(c util.Context, tx *sql.Tx, inbox, item *url.URL) error

DeleteInboxItem removes the item from the inbox's ordered items list.

func (*Inboxes) GetLastPage

func (i *Inboxes) GetLastPage(c util.Context, tx *sql.Tx, inbox *url.URL, n int) (page ActivityStreamsOrderedCollectionPage, startIdx int, err error)

GetLastPage returns the last OrderedCollectionPage of the Inbox.

func (*Inboxes) GetPage

func (i *Inboxes) GetPage(c util.Context, tx *sql.Tx, inbox *url.URL, min, max int) (page ActivityStreamsOrderedCollectionPage, isEnd bool, err error)

GetPage returns an OrderedCollectionPage of the Inbox.

The range of elements retrieved are [min, max).

func (*Inboxes) GetPublicLastPage

func (i *Inboxes) GetPublicLastPage(c util.Context, tx *sql.Tx, inbox *url.URL, n int) (page ActivityStreamsOrderedCollectionPage, startIdx int, err error)

GetPublicLastPage returns the last OrderedCollectionPage of inbox items that are public only.

func (*Inboxes) GetPublicPage

func (i *Inboxes) GetPublicPage(c util.Context, tx *sql.Tx, inbox *url.URL, min, max int) (page ActivityStreamsOrderedCollectionPage, isEnd bool, err error)

GetPublicPage returns an OrderedCollectionPage of inbox items that are public only.

The range of elements retrieved are [min, max).

func (*Inboxes) Prepare

func (i *Inboxes) Prepare(db *sql.DB, s SqlDialect) error

func (*Inboxes) PrependInboxItem

func (i *Inboxes) PrependInboxItem(c util.Context, tx *sql.Tx, inbox, item *url.URL) error

PrependInboxItem prepends the item to the inbox's ordered items list.

type InstanceActorPreferences

type InstanceActorPreferences struct {
	// OnFollow indicates default behavior when a Follow request is received
	// by a user.
	OnFollow OnFollowBehavior
	// OpenRegistrations indicates whether registrations are open for this
	// software.
	OpenRegistrations bool
	// ServerBaseURL indicates the "base URL" of this server.
	ServerBaseURL string
	// ServerName contains the name of this particular server.
	ServerName string
	// OrgName contains the name of the wider organization this server
	// belongs to.
	OrgName string
	// OrgContact contains the contact information for the Organization this
	// server belongs to.
	OrgContact string
	// OrgAccount contains the account information representing the
	// Organization this server belongs to.
	OrgAccount string
	// Payload is additional preference information that is app-specific.
	Payload json.RawMessage
}

InstanceActorPreferences are the preferences for an instance actor which are serializable and deserializable into JSON for database storage.

func (*InstanceActorPreferences) Scan

func (p *InstanceActorPreferences) Scan(src interface{}) error

func (InstanceActorPreferences) Value

type KVMatcher

type KVMatcher struct {
	// KeyPathQuery is a GJSON path query
	KeyPathQuery string        `json:"keyPathQuery,omitempty"`
	ValueMatcher *UnaryMatcher `json:"valueMatcher,omitempty"`
}

func (KVMatcher) Resolve

func (k KVMatcher) Resolve(json []byte, r *Resolution) (err error)

func (KVMatcher) Validate

func (k KVMatcher) Validate() error

type Liked

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

Liked is a Model that provides additional database methods for Liked.

func (*Liked) Close

func (i *Liked) Close()

func (*Liked) Contains

func (i *Liked) Contains(c util.Context, tx *sql.Tx, liked, item *url.URL) (b bool, err error)

Contains returns true if the item is in the liked's collection.

func (*Liked) ContainsForActor

func (i *Liked) ContainsForActor(c util.Context, tx *sql.Tx, actor, item *url.URL) (b bool, err error)

ContainsForActor returns true if the item is in the actor's liked's collection.

func (*Liked) Create

func (i *Liked) Create(c util.Context, tx *sql.Tx, actor *url.URL, liked ActivityStreamsCollection) error

Create a new liked entry for the given actor.

func (*Liked) CreateTable

func (i *Liked) CreateTable(t *sql.Tx, s SqlDialect) error

func (*Liked) DeleteItem

func (i *Liked) DeleteItem(c util.Context, tx *sql.Tx, liked, item *url.URL) error

DeleteItem removes the item from the liked's ordered items list.

func (*Liked) GetAllForActor

func (i *Liked) GetAllForActor(c util.Context, tx *sql.Tx, liked *url.URL) (col ActivityStreamsCollection, err error)

GetAllForActor returns the entire Liked Collection.

func (*Liked) GetLastPage

func (i *Liked) GetLastPage(c util.Context, tx *sql.Tx, liked *url.URL, n int) (page ActivityStreamsCollectionPage, startIdx int, err error)

GetLastPage returns the last CollectionPage of the Liked collection.

func (*Liked) GetPage

func (i *Liked) GetPage(c util.Context, tx *sql.Tx, liked *url.URL, min, max int) (page ActivityStreamsCollectionPage, isEnd bool, err error)

GetPage returns a CollectionPage of the Liked.

The range of elements retrieved are [min, max).

func (*Liked) Prepare

func (i *Liked) Prepare(db *sql.DB, s SqlDialect) error

func (*Liked) PrependItem

func (i *Liked) PrependItem(c util.Context, tx *sql.Tx, liked, item *url.URL) error

PrependItem prepends the item to the liked's ordered items list.

type LocalData

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

LocalData is a Model that provides additional database methods for ActivityStreams data generated by this instance.

func (*LocalData) Close

func (f *LocalData) Close()

func (*LocalData) Create

func (f *LocalData) Create(c util.Context, tx *sql.Tx, v ActivityStreams) error

Create inserts the local data into the table.

func (*LocalData) CreateTable

func (f *LocalData) CreateTable(t *sql.Tx, s SqlDialect) error

func (*LocalData) Delete

func (f *LocalData) Delete(c util.Context, tx *sql.Tx, localIDIRI *url.URL) error

Delete removes the local data with the specified IRI.

func (*LocalData) Exists

func (f *LocalData) Exists(c util.Context, tx *sql.Tx, id *url.URL) (exists bool, err error)

Exists determines if the ID is stored in the local table.

func (*LocalData) Get

func (f *LocalData) Get(c util.Context, tx *sql.Tx, id *url.URL) (v ActivityStreams, err error)

Get retrieves the ID from the local table.

func (*LocalData) Prepare

func (f *LocalData) Prepare(db *sql.DB, s SqlDialect) error

func (*LocalData) Stats

func (f *LocalData) Stats(c util.Context, tx *sql.Tx) (la LocalDataActivity, err error)

func (*LocalData) Update

func (f *LocalData) Update(c util.Context, tx *sql.Tx, localIDIRI *url.URL, v ActivityStreams) error

Update replaces the local data for the specified IRI.

type LocalDataActivity

type LocalDataActivity struct {
	NLocalPosts    int
	NLocalComments int
}

type Model

type Model interface {
	Prepare(*sql.DB, SqlDialect) error
	CreateTable(*sql.Tx, SqlDialect) error
	Close()
}

Model handles managing a single database type.

type NullDuration

type NullDuration struct {
	Duration time.Duration
	Valid    bool
}

NullDuration can handle nullable time.Duration values in the database.

func (*NullDuration) Scan

func (n *NullDuration) Scan(src interface{}) error

func (NullDuration) Value

func (n NullDuration) Value() (driver.Value, error)

type OnFollowBehavior

type OnFollowBehavior pub.OnFollowBehavior

OnFollowBehavior is a wrapper around pub.OnFollowBehavior type that also knows how to serialize and deserialize itself for SQL database drivers in a more readable manner.

func (*OnFollowBehavior) Scan

func (o *OnFollowBehavior) Scan(src interface{}) error

func (OnFollowBehavior) Value

func (o OnFollowBehavior) Value() (driver.Value, error)

type Outboxes

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

Outboxes is a Model that provides additional database methods for Outboxes.

func (*Outboxes) Close

func (i *Outboxes) Close()

func (*Outboxes) Contains

func (i *Outboxes) Contains(c util.Context, tx *sql.Tx, inbox, item *url.URL) (b bool, err error)

Contains returns true if the item is in the outbox's collection.

func (*Outboxes) ContainsForActor

func (i *Outboxes) ContainsForActor(c util.Context, tx *sql.Tx, actor, item *url.URL) (b bool, err error)

ContainsForActor returns true if the item is in the actor's outbox's collection.

func (*Outboxes) Create

func (i *Outboxes) Create(c util.Context, tx *sql.Tx, actor *url.URL, outbox ActivityStreamsOrderedCollection) error

Create a new outbox for the given actor.

func (*Outboxes) CreateTable

func (i *Outboxes) CreateTable(t *sql.Tx, s SqlDialect) error

func (*Outboxes) DeleteOutboxItem

func (i *Outboxes) DeleteOutboxItem(c util.Context, tx *sql.Tx, outbox, item *url.URL) error

DeleteOutboxItem removes the item from the outbox's ordered items list.

func (*Outboxes) GetLastPage

func (i *Outboxes) GetLastPage(c util.Context, tx *sql.Tx, outbox *url.URL, n int) (page ActivityStreamsOrderedCollectionPage, startIdx int, err error)

GetLastPage returns the last OrderedCollectionPage of the Outbox.

func (*Outboxes) GetPage

func (i *Outboxes) GetPage(c util.Context, tx *sql.Tx, outbox *url.URL, min, max int) (page ActivityStreamsOrderedCollectionPage, isEnd bool, err error)

GetPage returns an OrderedCollectionPage of the Outbox.

The range of elements retrieved are [min, max).

func (*Outboxes) GetPublicLastPage

func (i *Outboxes) GetPublicLastPage(c util.Context, tx *sql.Tx, outbox *url.URL, n int) (page ActivityStreamsOrderedCollectionPage, startIdx int, err error)

GetPublicLastPage returns the last OrderedCollectionPage of outbox items that are public only.

func (*Outboxes) GetPublicPage

func (i *Outboxes) GetPublicPage(c util.Context, tx *sql.Tx, outbox *url.URL, min, max int) (page ActivityStreamsOrderedCollectionPage, isEnd bool, err error)

GetPublicPage returns an OrderedCollectionPage of outbox items that are public only.

The range of elements retrieved are [min, max).

func (*Outboxes) OutboxForInbox

func (i *Outboxes) OutboxForInbox(c util.Context, tx *sql.Tx, inbox *url.URL) (outbox URL, err error)

OutboxForInbox returns the outbox for the inbox.

func (*Outboxes) Prepare

func (i *Outboxes) Prepare(db *sql.DB, s SqlDialect) error

func (*Outboxes) PrependOutboxItem

func (i *Outboxes) PrependOutboxItem(c util.Context, tx *sql.Tx, outbox, item *url.URL) error

PrependOutboxItem prepends the item to the outbox's ordered items list.

type Policies

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

Policies is a Model that provides additional database methods for the Policy type.

func (*Policies) Close

func (p *Policies) Close()

func (*Policies) Create

func (p *Policies) Create(c util.Context, tx *sql.Tx, cp CreatePolicy) (policyID string, err error)

Create a new Policy

func (*Policies) CreateTable

func (p *Policies) CreateTable(t *sql.Tx, s SqlDialect) error

func (*Policies) GetForActor

func (p *Policies) GetForActor(c util.Context, tx *sql.Tx, actorID *url.URL) (po []PolicyAndPurpose, err error)

GetForActor obtains all policies for an Actor.

func (*Policies) GetForActorAndPurpose

func (p *Policies) GetForActorAndPurpose(c util.Context, tx *sql.Tx, actorID *url.URL, u Purpose) (po []PolicyAndID, err error)

GetForActorAndPurpose obtains all policies for an Actor and Purpose.

func (*Policies) Prepare

func (p *Policies) Prepare(db *sql.DB, s SqlDialect) error

type Policy

type Policy struct {
	Name        string       `json:"name,omitempty"`
	Description string       `json:"description,omitempty"`
	Matchers    []*KVMatcher `json:"matchers,omitempty"`
}

func (Policy) Resolve

func (p Policy) Resolve(json []byte, r *Resolution) error

func (*Policy) Scan

func (p *Policy) Scan(src interface{}) error

func (Policy) Validate

func (p Policy) Validate() error

func (Policy) Value

func (p Policy) Value() (driver.Value, error)

type PolicyAndID

type PolicyAndID struct {
	ID     string
	Policy Policy
}

type PolicyAndPurpose

type PolicyAndPurpose struct {
	ID      string
	Purpose Purpose
	Policy  Policy
}

type Preferences

type Preferences struct {
	// OnFollow indicates default behavior when a Follow request is received
	// by a user.
	OnFollow OnFollowBehavior
	// Payload is additional preference information that is app-specific.
	Payload json.RawMessage
}

Preferences are a user's preferences serializable and deserializable into JSON for database storage.

func (*Preferences) Scan

func (p *Preferences) Scan(src interface{}) error

func (Preferences) Value

func (p Preferences) Value() (driver.Value, error)

type PrivateKeys

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

PrivateKeys is a Model that provides additional database methods for the PrivateKey type.

func (*PrivateKeys) Close

func (p *PrivateKeys) Close()

func (*PrivateKeys) Create

func (p *PrivateKeys) Create(c util.Context, tx *sql.Tx, userID, purpose string, privKey []byte) error

Create a new private key entry in the database.

func (*PrivateKeys) CreateTable

func (p *PrivateKeys) CreateTable(t *sql.Tx, s SqlDialect) error

func (*PrivateKeys) GetByUserID

func (p *PrivateKeys) GetByUserID(c util.Context, tx *sql.Tx, userID, purpose string) (b []byte, err error)

GetByUserID fetches a private key by the userID and purpose of the key.

func (*PrivateKeys) GetInstanceActor

func (p *PrivateKeys) GetInstanceActor(c util.Context, tx *sql.Tx, purpose string) (b []byte, err error)

GetInstanceActor fetches a private key for the single instance actor.

func (*PrivateKeys) Prepare

func (p *PrivateKeys) Prepare(db *sql.DB, s SqlDialect) error

type Privileges

type Privileges struct {
	// Admin indicates whether to treat the user as an administrator by the
	// framework.
	Admin bool
	// InstanceActor indicates whether to treat the user as the instance
	// actor.
	InstanceActor bool
	// Payload is additional privilege information that is app-specific.
	Payload json.RawMessage
}

Privileges are a user's privileges serializable and deserializable into JSON for database storage.

func (*Privileges) Scan

func (p *Privileges) Scan(src interface{}) error

func (Privileges) Value

func (p Privileges) Value() (driver.Value, error)

type Purpose

type Purpose string
const (
	FederatedBlockPurpose Purpose = "federated_block"
)

type Resolution

type Resolution struct {
	Time time.Time `json:"time",omitempty`

	// The following are used by Policies
	Matched  bool     `json:"matched",omitempty`
	MatchLog []string `json:"matchLog",omitempty`
}

func (*Resolution) Log

func (r *Resolution) Log(s string)

func (*Resolution) Logf

func (r *Resolution) Logf(s string, i ...interface{})

type Resolutions

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

Resolutions is a Model that provides additional database methods for the Resolution type.

func (*Resolutions) Close

func (r *Resolutions) Close()

func (*Resolutions) Create

func (r *Resolutions) Create(c util.Context, tx *sql.Tx, cr CreateResolution) error

Create a new Resolution

func (*Resolutions) CreateTable

func (r *Resolutions) CreateTable(t *sql.Tx, s SqlDialect) error

func (*Resolutions) Prepare

func (r *Resolutions) Prepare(db *sql.DB, s SqlDialect) error

type RetryableFailure

type RetryableFailure struct {
	ID          string
	UserID      string
	DeliverTo   URL
	Payload     []byte
	NAttempts   int
	LastAttempt time.Time
}

type SensitiveUser

type SensitiveUser struct {
	ID       string
	Hashpass []byte
	Salt     []byte
}

type SingleRow

type SingleRow interface {
	app.SingleRow
}

SingleRow allows *sql.Rows to be treated as *sql.Row

type SqlDialect

type SqlDialect interface {

	// CreateUsersTable for the User model.
	CreateUsersTable() string
	// CreateFedDataTable for the FedData model.
	CreateFedDataTable() string
	// CreateLocalDataTable for the LocalData model.
	CreateLocalDataTable() string
	// CreateInboxesTable for the Inboxes model.
	CreateInboxesTable() string
	// CreateOutboxesTable for the Outboxes model.
	CreateOutboxesTable() string
	// CreateDeliveryAttemptsTable for the DeliveryAttempts model.
	CreateDeliveryAttemptsTable() string
	// CreatePrivateKeysTable for the PrivateKeys model.
	CreatePrivateKeysTable() string
	// CreateClientInfosTable for the ClientInfos model.
	CreateClientInfosTable() string
	// CreateTokenInfosTable for the TokenInfos model.
	CreateTokenInfosTable() string
	// CreateFollowersTable for the Followers model.
	CreateFollowersTable() string
	// CreateFollowingTable for the Following model.
	CreateFollowingTable() string
	// CreateLikedTable for the Liked model.
	CreateLikedTable() string
	// CreatePoliciesTable for the Policies model.
	CreatePoliciesTable() string
	// CreateResolutionsTable for the Resolutions model.
	CreateResolutionsTable() string
	// CreateFirstPartyCredentialsTable for first party credentials model.
	CreateFirstPartyCredentialsTable() string

	// CreateIndexIDFedDataTable creates an index on the `id` of a federated
	// data payload.
	CreateIndexIDFedDataTable() string
	// CreateIndexIDLocalDataTable creates an index on the `id` of a local
	// data payload.
	CreateIndexIDLocalDataTable() string
	// CreateIndexIDInboxesTable creates an index on the `id` of an inbox.
	CreateIndexIDInboxesTable() string
	// CreateIndexIDOutboxesTable creates an index on the `id` of an outbox.
	CreateIndexIDOutboxesTable() string
	// CreateIndexIDFollowersTable creates an index on the `id` of a
	// followers collection.
	CreateIndexIDFollowersTable() string
	// CreateIndexIDFollowingTable creates an index on the `id` of a
	// following collection.
	CreateIndexIDFollowingTable() string
	// CreateIndexIDLikedTable creates an index on the `id` of a liked
	// collection.
	CreateIndexIDLikedTable() string

	// InsertUser:
	//  Params
	//   Email       string
	//   Hashpass    []byte
	//   Salt        []byte
	//   Actor       []byte
	//   Privileges  []byte
	//   Preferences []byte
	//  Returns
	//   ID          string
	InsertUser() string
	// UpdateUserActor:
	//  Params
	//   ID          string
	//   Actor       []byte
	//  Returns
	UpdateUserActor() string
	// SensitiveUserByEmail:
	//  Params
	//   Email       string
	//  Returns
	//   ID          string
	//   Hashpass    []byte
	//   Salt        []byte
	SensitiveUserByEmail() string
	// UserByID:
	//  Params
	//   ID          string
	//  Returns
	//   ID          string
	//   Email       string
	//   Actor       []byte
	//   Privileges  []byte
	//   Preferences []byte
	UserByID() string
	// UserByPreferredUsername:
	//  Params
	//   Name        string
	//  Returns
	//   ID          string
	//   Email       string
	//   Actor       []byte
	//   Privileges  []byte
	//   Preferences []byte
	UserByPreferredUsername() string
	// ActorIDForOutbox:
	//  Params
	//   OutboxID    string
	//  Returns
	//   ActorID     string
	ActorIDForOutbox() string
	// ActorIDForInbox:
	//  Params
	//   InboxID     string
	//  Returns
	//   ActorID     string
	ActorIDForInbox() string
	// UpdateUserPreferences:
	//  Params
	//   ID          string
	//   Preferences []byte
	//  Returns
	UpdateUserPreferences() string
	// UpdateUserPrivileges:
	//  Params
	//   ID          string
	//   Privileges  []byte
	//  Returns
	UpdateUserPrivileges() string
	// InstanceUser:
	//  Params
	//  Returns
	//   ID          string
	//   Email       string
	//   Actor       []byte
	//   Privileges  []byte
	//   Preferences []byte
	InstanceUser() string
	// GetInstanceActorProfile:
	//  Params
	//  Returns
	//   Prefs          []byte
	GetInstanceActorPreferences() string
	// SetInstanceActorProfile:
	//  Params
	//   Prefs          []byte
	//  Returns
	SetInstanceActorPreferences() string
	// GetUserActivityStats:
	//  Params
	//  Returns
	//   TotalUsers     int
	//   ActiveHalfYear int
	//   ActiveMonth    int
	//   ActiveWeek     int
	GetUserActivityStats() string

	// FedExists:
	//  Params
	//   ID          string
	//  Returns
	//   Exists      bool
	FedExists() string
	// FedGet:
	//  Params
	//   ID          string
	//  Returns
	//   Payload     []byte
	FedGet() string
	// FedCreate:
	//  Params
	//   Payload     []byte
	//  Returns
	FedCreate() string
	// FedUpdate:
	//  Params
	//   ID          string
	//   Payload     []byte
	//  Returns
	FedUpdate() string
	// FedDelete:
	//  Params
	//   ID          string
	//  Returns
	FedDelete() string

	// LocalExists:
	//  Params
	//   ID          string
	//  Returns
	//   Exists      bool
	LocalExists() string
	// LocalGet:
	//  Params
	//   ID          string
	//  Returns
	//   Payload     []byte
	LocalGet() string
	// LocalCreate:
	//  Params
	//   Payload     []byte
	//  Returns
	LocalCreate() string
	// LocalUpdate:
	//  Params
	//   ID          string
	//   Payload     []byte
	//  Returns
	LocalUpdate() string
	// LocalDelete:
	//  Params
	//   ID          string
	//  Returns
	LocalDelete() string
	// LocalStats:
	//  Params
	//  Returns
	//   NLocalPosts    int
	//   NLocalComments int
	LocalStats() string

	// InsertInbox:
	//  Params
	//   ActorID     string
	//   Inbox      []byte
	//  Returns
	InsertInbox() string
	// InboxContainsForActor:
	//  Params
	//   ActorID     string
	//   Item        string
	//  Returns
	//   Contains    bool
	InboxContainsForActor() string
	// InboxContains:
	//  Params
	//   InboxID     string
	//   Item        string
	//  Returns
	//   Contains    bool
	InboxContains() string
	// GetInbox:
	//  Params
	//   Inbox       string
	//   Min         int
	//   Max         int
	//  Returns
	//   Page        []byte
	//   IsEnd       bool
	GetInbox() string
	// GetPublicInbox:
	//  Params
	//   Inbox       string
	//   Min         int
	//   Max         int
	//  Returns
	//   Page        []byte
	//   IsEnd       bool
	GetPublicInbox() string
	// GetInboxLastPage:
	//  Params
	//   Inbox       string
	//   N           int
	//  Returns
	//   Page        []byte
	//   StartIndex  int
	GetInboxLastPage() string
	// GetPublicInboxLastPage:
	//  Params
	//   Inbox       string
	//   N           int
	//  Returns
	//   Page        []byte
	//   StartIndex  int
	GetPublicInboxLastPage() string
	// PrependInboxItem:
	//  Params
	//   Inbox       string
	//   Item        string
	//  Returns
	PrependInboxItem() string
	// DeleteInboxItem:
	//  Params
	//   Inbox       string
	//   Item        string
	//  Returns
	DeleteInboxItem() string

	// InsertOutbox:
	//  Params
	//   ActorID     string
	//   Outbox      []byte
	//  Returns
	InsertOutbox() string
	// OutboxContainsForActor:
	//  Params
	//   ActorID     string
	//   Item        string
	//  Returns
	//   Contains    bool
	OutboxContainsForActor() string
	// OutboxContains:
	//  Params
	//   OutboxID    string
	//   Item        string
	//  Returns
	//   Contains    bool
	OutboxContains() string
	// GetOutbox:
	//  Params
	//   Outbox      string
	//   Min         int
	//   Max         int
	//  Returns
	//   Page        []byte
	//   IsEnd       bool
	GetOutbox() string
	// GetPublicOutbox:
	//  Params
	//   Outbox      string
	//   Min         int
	//   Max         int
	//  Returns
	//   Page        []byte
	//   IsEnd       bool
	GetPublicOutbox() string
	// GetOutboxLastPage:
	//  Params
	//   Outbox      string
	//   N           int
	//  Returns
	//   Page        []byte
	//   StartIndex  int
	GetOutboxLastPage() string
	// GetPublicOutboxLastPage:
	//  Params
	//   Outbox      string
	//   N           int
	//  Returns
	//   Page        []byte
	//   StartIndex  int
	GetPublicOutboxLastPage() string
	// PrependOutboxItem:
	//  Params
	//   Outbox      string
	//   Item        string
	//  Returns
	PrependOutboxItem() string
	// DeleteOutboxItem:
	//  Params
	//   Outbox      string
	//   Item        string
	//  Returns
	DeleteOutboxItem() string
	// OutboxForInbox:
	//  Params
	//   Inbox       string
	//  Returns
	//   Outbox      string
	OutboxForInbox() string

	// InsertAttempt:
	//  Params
	//   FromID      string
	//   ToActor     string
	//   Payload     []byte
	//   State       string
	//  Returns
	//   ID          string
	InsertAttempt() string
	// MarkSuccessfulAttempt:
	//  Params
	//   ID          string
	//  Returns
	MarkSuccessfulAttempt() string
	// MarkFailedAttempt:
	//  Params
	//   ID          string
	//  Returns
	MarkFailedAttempt() string
	// MarkAbandonedAttempt:
	//  Params
	//   ID          string
	//  Returns
	MarkAbandonedAttempt() string
	// FirstPageRetryableFailures:
	//  Params
	//   State       string
	//   FetchTime   time.Time
	//   Limit       int
	//  Returns
	//   ID          string
	//   FromID      string
	//   DeliverTo   string
	//   Payload     []byte
	//   NAttempts   int
	//   LastAttempt time.Time
	FirstPageRetryableFailures() string
	// NextPageRetryableFailures:
	//  Params
	//   State       string
	//   FetchTime   time.Time
	//   Limit       int
	//   PrevID      string
	//  Returns
	//   ID          string
	//   FromID      string
	//   DeliverTo   string
	//   Payload     []byte
	//   NAttempts   int
	//   LastAttempt time.Time
	NextPageRetryableFailures() string

	// CreatePrivateKey:
	//  Params
	//   UserID      string
	//   Purpose     string
	//   PrivKey     []byte
	//  Returns
	CreatePrivateKey() string
	// GetPrivateKeyByUserID:
	//  Params
	//   UserID      string
	//   Purpose     string
	//  Returns
	//   PrivKey     []byte
	GetPrivateKeyByUserID() string
	// GetPrivateKeyForInstanceActor:
	//  Params
	//   Purpose     string
	//  Returns
	//   PrivKey     []byte
	GetPrivateKeyForInstanceActor() string

	// CreateClientInfo:
	//  Params
	//   Secret      string
	//   Domain      string
	//   UserID      string
	//  Returns
	//   ID          string
	CreateClientInfo() string
	// GetClientInfoByID:
	//  Params
	//   ID          string
	//  Returns
	//   ID          string
	//   Secret      string
	//   Domain      string
	//   UserID      string
	GetClientInfoByID() string

	// CreateTokenInfo:
	//  Params
	//   ClientID    string
	//   UserID      string
	//   RedirURI    string
	//   Scope       string
	//   Code        string
	//   CodeCreated time.Time
	//   CodeExpires time.Duration
	//   CodeChal    string
	//   CodeChalMtd string
	//   Access      string
	//   AccessCtd   time.Time
	//   AccessExp   time.Duration
	//   Refresh     string
	//   RefrCreated time.Time
	//   RefrExpires time.Duration
	//  Returns
	//   ID          string
	CreateTokenInfo() string
	// RemoveTokenInfoByCode:
	//  Params
	//   Code        string
	//  Returns
	RemoveTokenInfoByCode() string
	// RemoveTokenInfoByAccess:
	//  Params
	//   Access      string
	//  Returns
	RemoveTokenInfoByAccess() string
	// RemoveTokenInfoByRefresh:
	//  Params
	//   Refresh     string
	//  Returns
	RemoveTokenInfoByRefresh() string
	// GetTokenInfoByCode:
	//  Params
	//   Code        string
	//  Returns
	//   ClientID    string
	//   UserID      string
	//   RedirURI    string
	//   Scope       string
	//   Code        string
	//   CodeCreated time.Time
	//   CodeExpires time.Duration
	//   CodeChal    string
	//   CodeChalMtd string
	//   Access      string
	//   AccessCtd   time.Time
	//   AccessExp   time.Duration
	//   Refresh     string
	//   RefrCreated time.Time
	//   RefrExpires time.Duration
	GetTokenInfoByCode() string
	// GetTokenInfoByAccess:
	//  Params
	//   Access      string
	//  Returns
	//   ClientID    string
	//   UserID      string
	//   RedirURI    string
	//   Scope       string
	//   Code        string
	//   CodeCreated time.Time
	//   CodeExpires time.Duration
	//   CodeChal    string
	//   CodeChalMtd string
	//   Access      string
	//   AccessCtd   time.Time
	//   AccessExp   time.Duration
	//   Refresh     string
	//   RefrCreated time.Time
	//   RefrExpires time.Duration
	GetTokenInfoByAccess() string
	// GetTokenInfoByRefresh:
	//  Params
	//   Refresh     string
	//  Returns
	//   ClientID    string
	//   UserID      string
	//   RedirURI    string
	//   Scope       string
	//   Code        string
	//   CodeCreated time.Time
	//   CodeExpires time.Duration
	//   CodeChal    string
	//   CodeChalMtd string
	//   Access      string
	//   AccessCtd   time.Time
	//   AccessExp   time.Duration
	//   Refresh     string
	//   RefrCreated time.Time
	//   RefrExpires time.Duration
	GetTokenInfoByRefresh() string

	// InsertFollowers:
	//  Params
	//   ActorID     string
	//   Followers   []byte
	//  Returns
	InsertFollowers() string
	// FollowersContainsForActor:
	//  Params
	//   ActorID     string
	//   Item        string
	//  Returns
	//   Contains    bool
	FollowersContainsForActor() string
	// FollowersContains:
	//  Params
	//   Followers   string
	//   Item        string
	//  Returns
	//   Contains    bool
	FollowersContains() string
	// GetFollowers:
	//  Params
	//   Followers   string
	//   Min         int
	//   Max         int
	//  Returns
	//   Page        []byte
	//   IsEnd       bool
	GetFollowers() string
	// GetFollowersLastPage:
	//  Params
	//   Followers   string
	//   N           int
	//  Returns
	//   Page        []byte
	//   StartIndex  int
	GetFollowersLastPage() string
	// PrependFollowersItem:
	//  Params
	//   Followers   string
	//   Item        string
	//  Returns
	PrependFollowersItem() string
	// DeleteFollowersItem:
	//  Params
	//   Followers   string
	//   Item        string
	//  Returns
	DeleteFollowersItem() string
	// GetAllFollowersForActor:
	//  Params
	//   Followers   string
	//  Returns
	//   Followers   []byte
	GetAllFollowersForActor() string

	// InsertFollowing:
	//  Params
	//   ActorID     string
	//   Following   []byte
	//  Returns
	InsertFollowing() string
	// FollowingContainsForActor:
	//  Params
	//   ActorID     string
	//   Item        string
	//  Returns
	//   Contains    bool
	FollowingContainsForActor() string
	// FollowingContains:
	//  Params
	//   Following   string
	//   Item        string
	//  Returns
	//   Contains    bool
	FollowingContains() string
	// GetFollowing:
	//  Params
	//   Following   string
	//   Min         int
	//   Max         int
	//  Returns
	//   Page        []byte
	//   IsEnd       bool
	GetFollowing() string
	// GetFollowingLastPage:
	//  Params
	//   Following   string
	//   N           int
	//  Returns
	//   Page        []byte
	//   StartIndex  int
	GetFollowingLastPage() string
	// PrependFollowingItem:
	//  Params
	//   Following   string
	//   Item        string
	//  Returns
	PrependFollowingItem() string
	// DeleteFollowingItem:
	//  Params
	//   Following   string
	//   Item        string
	//  Returns
	DeleteFollowingItem() string
	// GetAllFollowingForActor:
	//  Params
	//   Following   string
	//  Returns
	//   Following   []byte
	GetAllFollowingForActor() string

	// InsertLiked:
	//  Params
	//   ActorID     string
	//   Liked       []byte
	//  Returns
	InsertLiked() string
	// LikedContainsForActor:
	//  Params
	//   ActorID     string
	//   Item        string
	//  Returns
	//   Contains    bool
	LikedContainsForActor() string
	// LikedContains:
	//  Params
	//   Liked       string
	//   Item        string
	//  Returns
	//   Contains    bool
	LikedContains() string
	// GetLiked:
	//  Params
	//   Liked       string
	//   Min         int
	//   Max         int
	//  Returns
	//   Page        []byte
	//   IsEnd       bool
	GetLiked() string
	// GetLikedLastPage:
	//  Params
	//   Liked       string
	//   N           int
	//  Returns
	//   Page        []byte
	//   StartIndex  int
	GetLikedLastPage() string
	// PrependLikedItem:
	//  Params
	//   Liked       string
	//   Item        string
	//  Returns
	PrependLikedItem() string
	// DeleteLikedItem:
	//  Params
	//   Liked       string
	//   Item        string
	//  Returns
	DeleteLikedItem() string
	// GetAllLikedForActor:
	//  Params
	//   Liked       string
	//  Returns
	//   Liked       []byte
	GetAllLikedForActor() string

	// CreatePolicy:
	//  Params
	//   ActorID     string
	//   Purpose     string
	//   Payload     []byte
	//  Returns
	//   ID          string
	CreatePolicy() string
	// GetPoliciesForActor:
	//  Params
	//   ActorID     string
	//  Returns (Multiple)
	//   ID          string
	//   Purpose     string
	//   Payload     []byte
	GetPoliciesForActor() string
	// GetPoliciesForActorAndPurpose:
	//  Params
	//   ActorID     string
	//   Purpose     string
	//  Returns (Multiple)
	//   ID          string
	//   Payload     []byte
	GetPoliciesForActorAndPurpose() string

	// CreateResolution:
	//  Params
	//   PolicyID    string
	//   DataIRI     string
	//   Payload     []byte
	//  Returns
	CreateResolution() string

	// CreateFirstPartyCredential:
	//  Params
	//   UserID      string
	//   TokenID     string
	//   Expires     time.Time
	//  Returns
	//   ID          string
	CreateFirstPartyCredential() string
	// UpdateFirstPartyCredential:
	//  Params
	//   ID          string
	//   ClientID    string
	//   UserID      string
	//   RedirURI    string
	//   Scope       string
	//   Code        string
	//   CodeCreated time.Time
	//   CodeExpires time.Duration
	//   CodeChal    string
	//   CodeChalMtd string
	//   Access      string
	//   AccessCtd   time.Time
	//   AccessExp   time.Duration
	//   Refresh     string
	//   RefrCreated time.Time
	//   RefrExpires time.Duration
	//  Returns
	UpdateFirstPartyCredential() string
	// UpdateFirstPartyCredentialExpires:
	//  Params
	//   ID          string
	//   Expires     time.Time
	//  Returns
	UpdateFirstPartyCredentialExpires() string
	// RemoveFirstPartyCredential:
	//  Params
	//   ID          string
	//  Returns
	RemoveFirstPartyCredential() string
	// RemoveExpiredFirstPartyCredentials:
	//  Params
	//  Returns
	RemoveExpiredFirstPartyCredentials() string
	// GetTokenInfoForCredentialID:
	//  Params
	//   ID          string
	//  Returns
	//   ClientID    string
	//   UserID      string
	//   RedirURI    string
	//   Scope       string
	//   Code        string
	//   CodeCreated time.Time
	//   CodeExpires time.Duration
	//   CodeChal    string
	//   CodeChalMtd string
	//   Access      string
	//   AccessCtd   time.Time
	//   AccessExp   time.Duration
	//   Refresh     string
	//   RefrCreated time.Time
	//   RefrExpires time.Duration
	GetTokenInfoForCredentialID() string

	// GetOpenFollowRequests
	//  Params
	//   ID          string
	//  Returns (Multiple)
	//   Payload     []byte
	GetOpenFollowRequests() string
}

SqlDialect is a SQL dialect provider.

Note that the order for inputs and outputs listed matter.

type TokenInfo

type TokenInfo struct {
	ClientID            string
	UserID              string
	RedirectURI         string
	Scope               string
	Code                sql.NullString
	CodeCreated         sql.NullTime
	CodeExpires         NullDuration
	CodeChallenge       sql.NullString
	CodeChallengeMethod sql.NullString
	Access              sql.NullString
	AccessCreated       sql.NullTime
	AccessExpires       NullDuration
	Refresh             sql.NullString
	RefreshCreated      sql.NullTime
	RefreshExpires      NullDuration
}

func (*TokenInfo) GetAccess

func (t *TokenInfo) GetAccess() string

func (*TokenInfo) GetAccessCreateAt

func (t *TokenInfo) GetAccessCreateAt() time.Time

func (*TokenInfo) GetAccessExpiresIn

func (t *TokenInfo) GetAccessExpiresIn() time.Duration

func (*TokenInfo) GetClientID

func (t *TokenInfo) GetClientID() string

func (*TokenInfo) GetCode

func (t *TokenInfo) GetCode() string

func (*TokenInfo) GetCodeChallenge

func (t *TokenInfo) GetCodeChallenge() string

func (*TokenInfo) GetCodeChallengeMethod

func (t *TokenInfo) GetCodeChallengeMethod() oauth2.CodeChallengeMethod

func (*TokenInfo) GetCodeCreateAt

func (t *TokenInfo) GetCodeCreateAt() time.Time

func (*TokenInfo) GetCodeExpiresIn

func (t *TokenInfo) GetCodeExpiresIn() time.Duration

func (*TokenInfo) GetRedirectURI

func (t *TokenInfo) GetRedirectURI() string

func (*TokenInfo) GetRefresh

func (t *TokenInfo) GetRefresh() string

func (*TokenInfo) GetRefreshCreateAt

func (t *TokenInfo) GetRefreshCreateAt() time.Time

func (*TokenInfo) GetRefreshExpiresIn

func (t *TokenInfo) GetRefreshExpiresIn() time.Duration

func (*TokenInfo) GetScope

func (t *TokenInfo) GetScope() string

func (*TokenInfo) GetUserID

func (t *TokenInfo) GetUserID() string

func (*TokenInfo) New

func (t *TokenInfo) New() oauth2.TokenInfo

func (*TokenInfo) SetAccess

func (t *TokenInfo) SetAccess(s string)

func (*TokenInfo) SetAccessCreateAt

func (t *TokenInfo) SetAccessCreateAt(s time.Time)

func (*TokenInfo) SetAccessExpiresIn

func (t *TokenInfo) SetAccessExpiresIn(s time.Duration)

func (*TokenInfo) SetClientID

func (t *TokenInfo) SetClientID(s string)

func (*TokenInfo) SetCode

func (t *TokenInfo) SetCode(s string)

func (*TokenInfo) SetCodeChallenge

func (t *TokenInfo) SetCodeChallenge(s string)

func (*TokenInfo) SetCodeChallengeMethod

func (t *TokenInfo) SetCodeChallengeMethod(cm oauth2.CodeChallengeMethod)

func (*TokenInfo) SetCodeCreateAt

func (t *TokenInfo) SetCodeCreateAt(s time.Time)

func (*TokenInfo) SetCodeExpiresIn

func (t *TokenInfo) SetCodeExpiresIn(s time.Duration)

func (*TokenInfo) SetRedirectURI

func (t *TokenInfo) SetRedirectURI(s string)

func (*TokenInfo) SetRefresh

func (t *TokenInfo) SetRefresh(s string)

func (*TokenInfo) SetRefreshCreateAt

func (t *TokenInfo) SetRefreshCreateAt(s time.Time)

func (*TokenInfo) SetRefreshExpiresIn

func (t *TokenInfo) SetRefreshExpiresIn(s time.Duration)

func (*TokenInfo) SetScope

func (t *TokenInfo) SetScope(s string)

func (*TokenInfo) SetUserID

func (t *TokenInfo) SetUserID(s string)

type TokenInfos

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

TokenInfos is a Model that provides additional database methods for OAuth2 token information.

func (*TokenInfos) Close

func (t *TokenInfos) Close()

func (*TokenInfos) Create

func (t *TokenInfos) Create(c util.Context, tx *sql.Tx, info oauth2.TokenInfo) (id string, err error)

Create saves the new token information.

func (*TokenInfos) CreateTable

func (t *TokenInfos) CreateTable(tx *sql.Tx, s SqlDialect) error

func (*TokenInfos) GetByAccess

func (t *TokenInfos) GetByAccess(c util.Context, tx *sql.Tx, access string) (oauth2.TokenInfo, error)

GetByAccess fetches tokens based on the access token.

func (*TokenInfos) GetByCode

func (t *TokenInfos) GetByCode(c util.Context, tx *sql.Tx, code string) (oauth2.TokenInfo, error)

GetByCode fetches tokens based on the authorization code.

func (*TokenInfos) GetByRefresh

func (t *TokenInfos) GetByRefresh(c util.Context, tx *sql.Tx, refresh string) (oauth2.TokenInfo, error)

GetByRefresh fetches tokens based on the refresh token.

func (*TokenInfos) Prepare

func (t *TokenInfos) Prepare(db *sql.DB, s SqlDialect) error

func (*TokenInfos) RemoveByAccess

func (t *TokenInfos) RemoveByAccess(c util.Context, tx *sql.Tx, access string) error

RemoveByAccess deletes the token information based on the access token.

func (*TokenInfos) RemoveByCode

func (t *TokenInfos) RemoveByCode(c util.Context, tx *sql.Tx, code string) error

RemoveByCode deletes the token information based on the authorization code.

func (*TokenInfos) RemoveByRefresh

func (t *TokenInfos) RemoveByRefresh(c util.Context, tx *sql.Tx, refresh string) error

RemoveByRefresh deletes the token information based on the refresh token.

type URL

type URL struct {
	*url.URL
}

URL handles serializing/deserializing *url.URL types into databases.

func (*URL) Scan

func (u *URL) Scan(src interface{}) error

func (URL) Value

func (u URL) Value() (driver.Value, error)

type UnaryMatcher

type UnaryMatcher struct {
	Not   *UnaryMatcher  `json:"not,omitempty"`
	And   *BinaryMatcher `json:"and,omitempty"`
	Or    *BinaryMatcher `json:"or,omitempty"`
	Value *Value         `json:"value,omitempty"`
	Empty bool           `json:"empty,omitempty"`
}

func (UnaryMatcher) Match

func (u UnaryMatcher) Match(res gjson.Result, json []byte, r *Resolution) (bool, error)

func (UnaryMatcher) Validate

func (u UnaryMatcher) Validate() error

type User

type User struct {
	ID          string
	Email       string
	Actor       ActivityStreams
	Privileges  Privileges
	Preferences Preferences
}

type UserActivityStats

type UserActivityStats struct {
	TotalUsers     int
	ActiveHalfYear int
	ActiveMonth    int
	ActiveWeek     int
}

type Users

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

Users is a Model that provides additional database methods for the Users type.

func (*Users) ActivityStats

func (u *Users) ActivityStats(c util.Context, tx *sql.Tx) (uas UserActivityStats, err error)

ActivityStats obtains statistics about the activity of users.

func (*Users) ActorIDForInbox

func (u *Users) ActorIDForInbox(c util.Context, tx *sql.Tx, inbox *url.URL) (actor URL, err error)

ActorIDForOutbox returns the actor associated with the inbox.

func (*Users) ActorIDForOutbox

func (u *Users) ActorIDForOutbox(c util.Context, tx *sql.Tx, outbox *url.URL) (actor URL, err error)

ActorIDForOutbox returns the actor associated with the outbox.

func (*Users) Close

func (u *Users) Close()

func (*Users) Create

func (u *Users) Create(c util.Context, tx *sql.Tx, r *CreateUser) (userID string, err error)

Create a User in the database.

func (*Users) CreateTable

func (u *Users) CreateTable(t *sql.Tx, s SqlDialect) error

func (*Users) InstanceActorPreferences

func (u *Users) InstanceActorPreferences(c util.Context, tx *sql.Tx) (iap InstanceActorPreferences, err error)

InstanceActorPreferences fetches the Server's preferences from the instance actor.

func (*Users) InstanceActorUser

func (u *Users) InstanceActorUser(c util.Context, tx *sql.Tx) (s *User, err error)

InstanceActorUser returns the user representing the instance.

func (*Users) Prepare

func (u *Users) Prepare(db *sql.DB, s SqlDialect) error

func (*Users) SensitiveUserByEmail

func (u *Users) SensitiveUserByEmail(c util.Context, tx *sql.Tx, email string) (s *SensitiveUser, err error)

SensitiveUserByEmail returns the credentials for a given user's email.

func (*Users) SetInstanceActorPreferences

func (u *Users) SetInstanceActorPreferences(c util.Context, tx *sql.Tx, iap InstanceActorPreferences) (err error)

SetInstanceActorPreferences sets the Server's preferences on the instance actor.

func (*Users) UpdateActor

func (u *Users) UpdateActor(c util.Context, tx *sql.Tx, id string, actor ActivityStreams) error

UpdateActor updates the Actor for the userID.

func (*Users) UpdatePreferences

func (u *Users) UpdatePreferences(c util.Context, tx *sql.Tx, id string, p Preferences) error

UpdatePreferences updates the preferences associated with the user.

func (*Users) UpdatePrivileges

func (u *Users) UpdatePrivileges(c util.Context, tx *sql.Tx, id string, p Privileges) error

UpdatePrivileges updates the privileges associated with the user.

func (*Users) UserByID

func (u *Users) UserByID(c util.Context, tx *sql.Tx, id string) (s *User, err error)

UserByID returns the non-sensitive fields for a User for a given ID.

func (*Users) UserByPreferredUsername

func (u *Users) UserByPreferredUsername(c util.Context, tx *sql.Tx, name string) (s *User, err error)

UserByPreferredUsername returns the non-sensitive fields for a User for a given preferredUsername.

type Value

type Value struct {
	JSONPath       string `json:"jsonPath,omitempty"`
	EqualsString   string `json:"equalsString,omitempty"`
	ContainsString string `json:"containsString,omitempty"`
	LenEquals      *int   `json:"lenEquals,omitempty"`
	LenGreater     *int   `json:"lenGreater,omitempty"`
	LenLess        *int   `json:"lenLess,omitempty"`
}

func (Value) Match

func (u Value) Match(res gjson.Result, json []byte, r *Resolution) (bool, error)

func (Value) Validate

func (u Value) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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