Documentation
¶
Index ¶
- Constants
- Variables
- func CarveTombstone(cadaver map[string]interface{}) (tombstone map[string]interface{})
- func CreateWrap(object map[string]interface{}) (activity map[string]interface{})
- func ExtractCorePropagation(obj map[string]interface{}, sourceActor object.LocalID, host string, ...) (targets []interface{})
- func GlobalizeList(list []interface{}, hostname string, port uint16)
- func GlobalizeLocal(value object.LocalID, hostname string, port uint16) string
- func GlobalizeObject(obj map[string]interface{}, hostname string, port uint16)
- func HasGhostTargets(tx Transaction, activity map[string]interface{}, host string, port uint16, ...) (hasTargets bool)
- func HasGhostTos(activity map[string]interface{}, host string, port uint16) (localTargets []object.LocalID)
- func IsActivity(objType string) (activity bool)
- func IsActor(objType string) (actor bool)
- func IsBlocked(blockList []interface{}, source string) (blocked bool)
- func IsCollection(objType string) (collection bool)
- func MakeNowTimestamp() (datetime string)
- func SlicifyScalar(data interface{}) []interface{}
- func SyncFields(objA map[string]interface{}, objB map[string]interface{}, fieldName string)
- func UpdateActor(actor map[string]interface{}, diff map[string]interface{}) (updated map[string]interface{})
- func UpdateNormalObject(obj map[string]interface{}, diff map[string]interface{}) (updated map[string]interface{})
- type Account
- type Change
- type Core
- func (c *Core) AddActor(actorID object.LocalID, actorType string) (err error)
- func (c *Core) DeleteAccount(user string) (err error)
- func (c *Core) GenerateObjectID(actorID object.LocalID) (objectID object.LocalID)
- func (c *Core) Get(objectID object.LocalID, authActor object.LocalID) (gotObj map[string]interface{}, err error)
- func (c *Core) GetLocal(objectID object.LocalID, authActor object.LocalID) (gotObj map[string]interface{}, err error)
- func (c *Core) InboxAccept(tx Transaction, targetID object.LocalID, activity map[string]interface{}) (err error)
- func (c *Core) InboxLike(tx Transaction, inboxActor object.LocalID, activity map[string]interface{}) (err error)
- func (c *Core) IsSubserver() (issub bool)
- func (c *Core) LoadAccount(user string) (acct Account, err error)
- func (c *Core) NativeObjectOwner(tx Transaction, objectID object.LocalID) (actorID object.LocalID, err error)
- func (c *Core) NewAccount(acct Account) (err error)
- func (c *Core) OutboxAccept(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxAdd(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxBlock(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxCreate(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxDelete(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxFollow(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxLike(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxMove(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxNonSpecialActivity(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxQuestion(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxRemove(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxUndo(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) OutboxUpdate(tx Transaction, actorID object.LocalID, outboxID object.LocalID, ...) (activityID object.LocalID, prop []interface{}, changes []Change, err error)
- func (c *Core) PendingPropagations() (objects map[object.LocalID]map[string]interface{}, ...)
- func (c *Core) PostInboxLocal(inboxID object.LocalID, activity map[string]interface{}) (err error)
- func (c *Core) PostInboxRemote(inboxID object.LocalID, activity map[string]interface{}) (err error)
- func (c *Core) PostOutbox(outboxID object.LocalID, activity map[string]interface{}) (activityIDStr string, err error)
- func (c *Core) SetDatabase(s Storage)
- func (c *Core) UpdateAccount(user string, acct Account) (err error)
- func (c *Core) UpdatePropagation(updates map[object.LocalID][]PropRetryTarget, ...) (err error)
- type DummyStorage
- type PropRetryTarget
- type Storage
- type Transaction
- type UpperLevel
Constants ¶
const ( CSListAppend CSListRemove CSAddField CSUpdateField CSRemoveField CSAddObject CSUpdateObject CSRemoveObject CSColAdd CSColRM CSColSet CSColRMAll )
const RECURSE_MAX = 1
Variables ¶
var Activities = []string{"Accept", "Add", "Announce", "Arrive", "Block",
"Create", "Delete", "Dislike", "Flag", "Follow", "Ignore", "Invite",
"Join", "Leave", "Like", "Listen", "Move", "Offer", "Question", "Reject",
"Read", "Remove", "TentativeReject", "TentativeAccept", "Travel", "Undo",
"Update", "View"}
var ActivityNoTarget = errors.New("Activity does not have a valid target")
var ActorProtectedFields = []string{"outbox", "inbox", "liked", "followers",
"following"}
var BadActorConstruction = errors.New("Actor is borked yo!")
var BadChangeset = errors.New("Invalid changeset action")
var BadPropagationTarget = errors.New("Propagation target does not exist")
var BadQuestion = errors.New("Questions must have either oneOf xor anyOf")
var BlockedActor = errors.New("Source Actor blocked by Target actor")
var ClosedStorage = errors.New("Database closed")
var DuplicateItem = errors.New("Item already exists in this location")
var InvalidDeleteTarget = errors.New("Deletion target is invalid")
var InvalidOutbox = errors.New("Invalid Outbox ID")
var InvalidTargetType = errors.New("Target object is not the correct type")
var InvalidTransaction = errors.New("Invalid transaction")
Errors
var NoChangeset = errors.New("No changeset under that ID")
var ObjectNotInOrigin = errors.New("Object not present in Origin collection")
var ProtectedFields = []string{"@id", "id", "@type", "type", "attributedTo"}
var ProtectedObject = errors.New("Object is protected")
var UnownedTarget = errors.New("Object of Update not owned by Actor")
Functions ¶
func CarveTombstone ¶
Constructs the Tombstone for an object that is being deleted.
func CreateWrap ¶
Wrap a bare object in a Create activity.
func ExtractCorePropagation ¶
func ExtractCorePropagation(obj map[string]interface{}, sourceActor object.LocalID, host string, port uint16) (targets []interface{})
Extracts propagation targets from the standard locations of an object.
func GlobalizeList ¶
Recursively trawls a list and replaces all LocalIDs with globalIDs.
func GlobalizeLocal ¶
Converts a LocalID to a global ID, taking ports or lack therof into account.
func GlobalizeObject ¶
Recursively trawls an object and replaces all LocalIDs with global IDs.
func HasGhostTargets ¶
func HasGhostTargets(tx Transaction, activity map[string]interface{}, host string, port uint16, recursion uint) (hasTargets bool)
Checks if this server owns anything in the target fields.
func HasGhostTos ¶
func HasGhostTos(activity map[string]interface{}, host string, port uint16) (localTargets []object.LocalID)
Checks if this server owns anything that is in the propagation fields.
func IsActivity ¶
func IsCollection ¶
func MakeNowTimestamp ¶
func MakeNowTimestamp() (datetime string)
func SlicifyScalar ¶
func SlicifyScalar(data interface{}) []interface{}
Forces data to be a list. Used to simplify code that wants to deal with lists and may be passed single items.
func SyncFields ¶
Synchronizes a field between two objects.
func UpdateActor ¶
func UpdateActor(actor map[string]interface{}, diff map[string]interface{}) (updated map[string]interface{})
Update non-protected fields of an actor from a diff.
func UpdateNormalObject ¶
func UpdateNormalObject(obj map[string]interface{}, diff map[string]interface{}) (updated map[string]interface{})
Update non-protected fields of an object from a diff.
Types ¶
type Account ¶
type Account struct { User string Salt [16]byte Time uint32 Memory uint32 KeyLen uint32 HashPW []byte ActorID object.LocalID ActorURL string CreationDate string // RFC3339 }
Account data
type Core ¶
type Core struct { Hostname string SubserverName string Port uint16 Prefix string // contains filtered or unexported fields }
server core
func (*Core) DeleteAccount ¶
func (*Core) GenerateObjectID ¶
Generates object IDs for newly created objects and activities that are not special objects.
func (*Core) InboxAccept ¶
func (*Core) IsSubserver ¶
func (*Core) NativeObjectOwner ¶
func (c *Core) NativeObjectOwner(tx Transaction, objectID object.LocalID) (actorID object.LocalID, err error)
Returns the owning actor of a native object.
func (*Core) NewAccount ¶
func (*Core) OutboxAccept ¶
func (*Core) OutboxBlock ¶
func (*Core) OutboxCreate ¶
func (*Core) OutboxDelete ¶
func (*Core) OutboxFollow ¶
func (*Core) OutboxLike ¶
func (*Core) OutboxMove ¶
func (*Core) OutboxNonSpecialActivity ¶
func (*Core) OutboxQuestion ¶
func (*Core) OutboxRemove ¶
func (*Core) OutboxUndo ¶
func (*Core) OutboxUpdate ¶
func (*Core) PendingPropagations ¶
func (*Core) PostInboxLocal ¶
func (*Core) PostInboxRemote ¶
func (*Core) PostOutbox ¶
func (c *Core) PostOutbox(outboxID object.LocalID, activity map[string]interface{}) (activityIDStr string, err error)
PostOutbox handles all of the generally applicable tasks for activities a client posts to an actor's outbox. Tasks specific to an activity are performed by the outbox handlers. PostOutbox handles: * Object sanity checking TODO * Actor / Outbox matching * Create wrapping of non-activity objects * Storing the incoming objects and adding them to the actor's outbox * Distributing replies and propagation
func (*Core) SetDatabase ¶
func (*Core) UpdatePropagation ¶
type DummyStorage ¶
type DummyStorage struct {
// contains filtered or unexported fields
}
func NewDummyStorage ¶
func NewDummyStorage() (d *DummyStorage)
func (*DummyStorage) Close ¶
func (d *DummyStorage) Close() (err error)
func (*DummyStorage) StartTransaction ¶
func (d *DummyStorage) StartTransaction() (t Transaction, err error)
type PropRetryTarget ¶
type PropRetryTarget struct { Url string Cluster bool // Is this a cluster-local propagation? TryCount uint LastTry string // RFC3339 timestamp }
func NewPropRetryCluster ¶
func NewPropRetryCluster(url object.LocalID) (p PropRetryTarget)
func NewPropRetryGlobal ¶
func NewPropRetryGlobal(url string) (p PropRetryTarget)
type Storage ¶
type Storage interface { // Storage utility / management Close() error StartTransaction() (Transaction, error) }
type Transaction ¶
type Transaction interface { RevertTransaction() error EndTransaction(errIn *error) error // Primary object store -- object level StoreObject(obj map[string]interface{}) error LoadObject(objectID object.LocalID) (map[string]interface{}, error) RemoveObject(objectID object.LocalID) error SetProtected(objectID object.LocalID, protected bool) error IsProtected(objectID object.LocalID) (bool, error) BasicObjectData(objectID object.LocalID) (string, object.LocalID, error) Exists(objectID object.LocalID) (bool, error) // Primary object store -- field level LoadObjectField(objectID object.LocalID, fieldName string) (interface{}, error) ListAppend(objectID object.LocalID, fieldName string, data interface{}) error ListRemove(objectID object.LocalID, fieldName string, data interface{}) error AddField(objectID object.LocalID, fieldName string, data interface{}) error UpdateField(objectID object.LocalID, fieldName string, data interface{}) error RemoveField(objectID object.LocalID, fieldName string) error ValueInObject(objectID object.LocalID, fieldName string, data interface{}) (bool, error) // Object ancillary collection handling ObjcolAdd(objectID object.LocalID, fieldName string, value interface{}) error ObjcolRM(objectID object.LocalID, fieldName string, value interface{}) error ObjcolGetAllField(objectID object.LocalID, fieldName string) ([]interface{}, error) ObjcolGetFields(objectID object.LocalID) ([]string, error) ObjcolSet(objectID object.LocalID, data map[string][]interface{}) error ObjcolRMAll(objectID object.LocalID) error ObjcolGetAll(objectID object.LocalID) (map[string][]interface{}, error) // Changeset handling StoreChangeset(changeID string, changeset []Change) error LoadChangeset(changeID string) ([]Change, error) // Cached object store StoreCache(obj map[string]interface{}) error LoadCache(objID string) (map[string]interface{}, error) // Propagation holding StoreProp(obj map[string]interface{}, targets []PropRetryTarget) error GetPropIDs() ([]object.LocalID, error) GetPropObject(objectID object.LocalID) (map[string]interface{}, error) GetPropTargets(objectID object.LocalID) ([]PropRetryTarget, error) UpdatePropTarget(objectID object.LocalID, target PropRetryTarget) error RemovePropTarget(objectID object.LocalID, targetURL string) error // Account data StoreAccount(acct Account) error LoadAccount(user string) (Account, error) UpdateAccount(user string, acct Account) error DeleteAccount(user string) error }
Storage interface
type UpperLevel ¶
Upper system interface This interface is what the server provides to the AP core, so that it can
send data to other servers without needing to know about TLS or other complications.