rules

package
v0.0.0-...-9de2c1c Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func C2SAutoCreateActivity

func C2SAutoCreateActivity(ctx context.Context, src ld.Source, actor, stream *models.Entity, activity *as.Activity) error

This rule ensures that the processed activity is indeed an activity, and wraps it as the as:Object in an as:Create event if it's not.

NOTE: This rule is ran before C2SGenerateIDs, do not depend on things having IDs.

ActivityPub §6: Client To Server Interactions

The body of the POST request MUST contain a single Activity (which MAY contain embedded
objects), or a single non-Activity object which will be wrapped in a Create activity
by the server.

ActivityPub §6.2.1: Object creation without a Create Activity

For client to server posting, it is possible to submit an object for creation without a
surrounding activity. The server MUST accept a valid [ActivityStreams] object that isn't
a subtype of Activity in the POST request to the outbox. The server then MUST attach this
object as the object of a Create Activity.
...
 Any to, bto, cc, bcc, and audience properties specified on the object MUST be copied over
 to the new Create activity by the server.

func C2SGenerateIDs

func C2SGenerateIDs(ctx context.Context, src ld.Source, actor, stream *models.Entity, activity *as.Activity) error

This rule generates local IDs for client-to-server submissions.

ActivityPub §6: Client To Server Interactions

If an Activity is submitted with a value in the id property, servers MUST ignore this
and generate a new id for the Activity.

ActivityPub §6.2.1: Object creation without a Create activity

For non-transient objects, the server MUST attach an id to both the wrapping Create and
its wrapped Object.

^ I'm choosing to interpret this as having been placed in the wrong section of the spec

(§6.2.1 rather than §6.2: Create Activity), because it makes no sense for it only to
apply to objects created without Create activities.

func C2SRequiredActivityProperties

func C2SRequiredActivityProperties(ctx context.Context, src ld.Source, actor, stream *models.Entity, activity *as.Activity) (err error)

Ensure that activities have required attributes for their type as dictated by the spec.

TODO: Should this be enforced for federated activities as well as client-submitted ones?

NOTE: This rule is ran before C2SGenerateIDs, do not depend on things having IDs.

ActivityPub §6.1 Client Addressing:

Clients submitting the following activities to an outbox MUST provide the object property
in the activity: Create, Update, Delete, Follow, Add, Remove, Like, Block, Undo.
Additionally, clients submitting the following activities to an outbox MUST also provide
the target property: Add, Remove.

func Copy

func Copy(from, to ld.Entity, prop *meta.Prop)

func IsSameOrigin

func IsSameOrigin(a, b string) bool

Returns whether two IDs are from the same origin.

func RequireActivity

func RequireActivity(ctx context.Context, src ld.Source, actor, stream *models.Entity, activity *as.Activity) (err error)

func Run

func Run(ctx context.Context, rules []Rule, src ld.Source, actor, stream *models.Entity, activity *as.Activity) error

Runs a series of rules on the input.

func Slugify

func Slugify(input string) (string, error)

func ValidateQuacksLike

func ValidateQuacksLike(e ld.Entity, t *meta.Type) error

Types

type Rule

type Rule func(ctx context.Context, src ld.Source, actor, stream *models.Entity, activity *as.Activity) error

A rule can process or reject an activity before it's ingested.

Jump to

Keyboard shortcuts

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